-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVoice.cpp
35 lines (27 loc) · 973 Bytes
/
Voice.cpp
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
#include "Voice.h"
double Voice::nextSample() {
if (!isActive) return 0.0;
double oscillator1Output = mOscillatorMix == 1 ? 0.0 : mOscillator1.nextSample();
double oscillator2Output = mOscillatorMix == 0 ? 0.0 : mOscillator2.nextSample();
double oscillatorSum = ((1 - mOscillatorMix) * oscillator1Output) + (mOscillatorMix * oscillator2Output);
double ampEnvelopeValue = mAmpEnvelope.nextSample();
double filterEnvelopeValue = mFilterEnvelope.nextSample();
oscillatorSum *= mAmpEnvelopeAmount * 0.01;
mFilter.setCutoffMod(filterEnvelopeValue * mFilterEnvelopeAmount); // ignore LFO now.
return mFilter.process(oscillatorSum * ampEnvelopeValue * mVelocity / 127.0);
}
void Voice::setFree() {
isActive = false;
}
// Do reset after every noteoff
void Voice::reset() {
mNoteNumber = -1;
mVelocity = 0;
pbendamount = 0;
//mOscillatorMix = 0;
mOscillator1.reset();
mOscillator2.reset();
mAmpEnvelope.reset();
mFilterEnvelope.reset();
mFilter.reset();
}