-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSynthesis.h
57 lines (52 loc) · 1.96 KB
/
Synthesis.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef __SYNTHESIS__
#define __SYNTHESIS__
#include "IPlug_include_in_plug_hdr.h"
#include "Oscillator.h"
#include "MIDIReceiver.h"
#include "EnvelopeGenerator.h"
#include "ADSRVisualizationControl.h"
#include "Filter.h"
class Synthesis : public IPlug
{
public:
Synthesis(IPlugInstanceInfo instanceInfo);
~Synthesis();
void Reset();
void OnParamChange(int paramIdx);
void ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames);
// to receive MIDI messages:
void ProcessMidiMsg(IMidiMsg* pMsg);
// Needed for the GUI keyboard:
// Should return non-zero if one or more keys are playing.
inline int GetNumKeys() const { return mMIDIReceiver.getNumKeys(); };
// Should return true if the specified key is playing.
inline bool GetKeyStatus(int key) const { return mMIDIReceiver.getKeyStatus(key); };
static const int virtualKeyboardMinimumNoteNumber = 0;
int lastVirtualKeyboardNoteNumber;
private:
double mFrequency;
void CreatePresets();
Filter mFilter;
Oscillator mOscillator;
MIDIReceiver mMIDIReceiver;
IControl* mVirtualKeyboard;
EnvelopeGenerator mEnvelopeGenerator;
IKnobMultiControl* ampAdsrKnobs[4];
EnvelopeGenerator mFilterEnvelopeGenerator;
IKnobMultiControl* filterAdsrKnobs[4];
double filterEnvelopeAmount;
ADSRVisualizationControl* ampAdsrVisualization;
ADSRVisualizationControl* filterEnvAdsrVisualization;
void processVirtualKeyboard();
inline void onNoteOn(const int noteNumber, const int velocity) {
mEnvelopeGenerator.enterStage(EnvelopeGenerator::ENVELOPE_STAGE_ATTACK);
mFilterEnvelopeGenerator.enterStage(EnvelopeGenerator::ENVELOPE_STAGE_ATTACK);
};
inline void onNoteOff(const int noteNumber, const int velocity) {
mEnvelopeGenerator.enterStage(EnvelopeGenerator::ENVELOPE_STAGE_RELEASE);
mFilterEnvelopeGenerator.enterStage(EnvelopeGenerator::ENVELOPE_STAGE_RELEASE);
};
inline void onBeganEnvelopeCycle() { mOscillator.setMuted(false); }
inline void onFinishedEnvelopeCycle() { mOscillator.setMuted(true); }
};
#endif