2026-02-22 12:39:27 +01:00
|
|
|
#ifndef __BREAKOR_AUDIO_APP_HPP__
|
|
|
|
|
#define __BREAKOR_AUDIO_APP_HPP__
|
|
|
|
|
|
|
|
|
|
#include "../../src/memllib/audio/AudioAppBase.hpp"
|
|
|
|
|
#include "../../src/memllib/synth/maximilian.h"
|
2026-02-22 13:41:09 +01:00
|
|
|
#include "../../src/memllib/interface/MIDIInOut.hpp"
|
|
|
|
|
|
2026-02-22 12:39:27 +01:00
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <memory> // Added for std::shared_ptr
|
|
|
|
|
|
2026-02-22 13:41:09 +01:00
|
|
|
#include "../../src/memllib/interface/InterfaceBase.hpp"
|
2026-02-22 12:39:27 +01:00
|
|
|
|
|
|
|
|
#include <span>
|
|
|
|
|
|
|
|
|
|
#include "../../voicespaces/VoiceSpaces.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<size_t NPARAMS=33>
|
|
|
|
|
|
|
|
|
|
class BreakOrAudioApp : public AudioAppBase<NPARAMS>
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
static constexpr size_t kN_Params = NPARAMS;
|
|
|
|
|
static constexpr size_t nVoiceSpaces=0;
|
|
|
|
|
|
2026-02-22 13:41:09 +01:00
|
|
|
std::shared_ptr<MIDIInOut> midiIO;
|
|
|
|
|
|
2026-02-22 12:39:27 +01:00
|
|
|
std::array<VoiceSpace<NPARAMS>, nVoiceSpaces> voiceSpaces;
|
|
|
|
|
|
|
|
|
|
VoiceSpaceFn<NPARAMS> currentVoiceSpace;
|
|
|
|
|
|
|
|
|
|
std::array<String, nVoiceSpaces> getVoiceSpaceNames() {
|
|
|
|
|
std::array<String, nVoiceSpaces> names;
|
|
|
|
|
for(size_t i=0; i < voiceSpaces.size(); i++) {
|
|
|
|
|
names[i] = voiceSpaces[i].name;
|
|
|
|
|
}
|
|
|
|
|
return names;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setVoiceSpace(size_t i) {
|
|
|
|
|
if (i < voiceSpaces.size()) {
|
|
|
|
|
currentVoiceSpace = voiceSpaces[i].mappingFunction;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BreakOrAudioApp() : AudioAppBase<NPARAMS>() {
|
|
|
|
|
// currentVoiceSpace = voiceSpaces[0].mappingFunction;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool __force_inline euclidean(float phase, const size_t n, const size_t k, const size_t offset, const float pulseWidth)
|
|
|
|
|
{
|
|
|
|
|
// Euclidean function
|
|
|
|
|
const float fi = phase * n;
|
|
|
|
|
int i = static_cast<int>(fi);
|
|
|
|
|
const float rem = fi - i;
|
|
|
|
|
if (i == n)
|
|
|
|
|
{
|
|
|
|
|
i--;
|
|
|
|
|
}
|
|
|
|
|
const int idx = ((i + n - offset) * k) % n;
|
|
|
|
|
return (idx < k && rem < pulseWidth) ? 1 : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stereosample_t __force_inline Process(const stereosample_t x) override
|
|
|
|
|
{
|
2026-02-22 13:41:09 +01:00
|
|
|
phasor0 += 1.f;
|
|
|
|
|
if (phasor0>=48000.f) {
|
|
|
|
|
phasor0-=48000.f;
|
|
|
|
|
midiIO->queueNoteOn(36, 127);
|
|
|
|
|
midiIO->flushQueue();
|
|
|
|
|
}
|
2026-02-22 12:39:27 +01:00
|
|
|
stereosample_t ret { 0.f,0.f };
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Setup(float sample_rate, std::shared_ptr<InterfaceBase> interface) override
|
|
|
|
|
{
|
|
|
|
|
AudioAppBase<NPARAMS>::Setup(sample_rate, interface);
|
|
|
|
|
maxiSettings::sampleRate = sample_rate;
|
|
|
|
|
sampleRatef = static_cast<float>(sample_rate);
|
|
|
|
|
}
|
2026-02-22 13:41:09 +01:00
|
|
|
void setupMIDI(std::shared_ptr<MIDIInOut> new_midi_interf) {
|
|
|
|
|
midiIO = new_midi_interf;
|
|
|
|
|
}
|
2026-02-22 12:39:27 +01:00
|
|
|
|
|
|
|
|
void loop() override {
|
|
|
|
|
AudioAppBase<NPARAMS>::loop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProcessParams(const std::array<float, NPARAMS>& params)
|
|
|
|
|
{
|
|
|
|
|
firstParamsReceived = true;
|
|
|
|
|
// currentVoiceSpace(params);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
|
|
float sampleRatef;
|
|
|
|
|
bool firstParamsReceived = false;
|
2026-02-22 13:41:09 +01:00
|
|
|
|
|
|
|
|
float phasor0=0.f;
|
2026-02-22 12:39:27 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // __BREAKOR_AUDIO_APP_HPP__
|
|
|
|
|
|