You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

45 lines
992 B

#ifndef __SYNTH_H__
#define __SYNTH_H__
#include "voicemanager.h"
#include "channel.h"
#include "dsp/frame.h"
#include "dsp/reverb.h"
class Synth {
public:
Synth() {
for(VoiceManager::channel_t i = 0; i < 16; ++i) {
channels[i].number = i;
channels[i].voiceManager = &voiceManager;
channels[i].loadPreset(&DEFAULT_PRESET);
}
}
void noteOn(int ch, int note, int vel);
void noteOff(int ch, int note);
void control(int ch, int cc, int val);
inline frame tick() {
frame out{};
frame reverbBus{};
for(auto& channel : channels) {
frame channelOut = channel.tick();
out += channelOut;
reverbBus += channel.settings.reverb * channelOut;
}
out += reverb.tick(reverbBus);
out *= 0.125f;
return out;
}
private:
VoiceManager voiceManager{};
Channel channels[16];
Reverb reverb;
};
#endif