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.
 
 

52 lines
1.1 KiB

#ifndef __PART_H__
#define __PART_H__
#include <unordered_map>
#include <set>
#include "globals.h"
#include "voicemanager.h"
#include "voice.h"
#include "preset.h"
#include "frame.h"
class Channel {
public:
channel_t number;
VoiceManager* voiceManager;
Voice::Settings settings;
Channel() : volume(1), pitchBend(0), modulation(0), lfoPhase(randPhase()) {}
void loadPreset(const Preset* preset);
void noteOn(int note, int vel);
void noteOff(int note);
void control(int cc, int val);
frame tick() {
frame out{0};
float lfo = sin(lfoPhase);
Voice** voices = voiceManager->getChannelVoices(number);
for(Voice** voice = voices; *voice != NULL; ++voice) {
out += (*voice)->tick(pitchBend + settings.lfoPitchMod * lfo, settings.lfoFltMod * lfo);
}
out *= volume;
lfoPhase += settings.lfoStep;
while(lfoPhase >= PIx2) {
lfoPhase -= PIx2;
}
return out;
}
private:
float volume;
float pitchBend;
float modulation;
float lfoPhase;
};
#endif