Skip to content

Commit

Permalink
Amp amount works now.
Browse files Browse the repository at this point in the history
  • Loading branch information
BLumia committed Aug 22, 2016
1 parent a8205ad commit 4c12a09
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Synthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ void Synthesis::OnParamChange(int paramIdx)
case mOscillatorMix:
voiceManager.setOscillatorMixForEachVoice(GetParam(paramIdx)->Value());
break;
case mAmpAmount:
voiceManager.setAmpAmountForEachVoice(GetParam(paramIdx)->Value());
break;
case mAttack:
case mDecay:
case mSustain:
Expand Down
2 changes: 2 additions & 0 deletions Voice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ double Voice::nextSample() {
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);
Expand Down
3 changes: 3 additions & 0 deletions Voice.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ class Voice {
EnvelopeGenerator mFilterEnvelope;
// Component Attribute
double mFilterEnvelopeAmount;
double mAmpEnvelopeAmount;
public:
friend class VoiceManager;
Voice() :
mNoteNumber(-1),
mVelocity(0),
mFilterEnvelopeAmount(0.0),
mAmpEnvelopeAmount(1.0),
mOscillatorMix(0.0),
isActive(false) {
// Set myself free everytime my volume envelope has fully faded out of RELEASE stage:
mAmpEnvelope.finishedEnvelopeCycle.Connect(this, &Voice::setFree);
}
// Setters
inline void setFilterEnvelopeAmount(double amount) { mFilterEnvelopeAmount = amount; }
inline void setAmpEnvelopeAmount(double amount) { mAmpEnvelopeAmount = amount; }
inline void setOscillatorMix(double mix) { mOscillatorMix = mix; }
inline void setNoteNumber(int noteNumber) {
mNoteNumber = noteNumber;
Expand Down
6 changes: 6 additions & 0 deletions VoiceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,10 @@ void VoiceManager::setFilterAmountForEachVoice(double amount) {
for (int i = 0; i < NumberOfVoices; i++) {
voices[i].mFilterEnvelopeAmount = amount;
}
}

void VoiceManager::setAmpAmountForEachVoice(double amount) {
for (int i = 0; i < NumberOfVoices; i++) {
voices[i].mAmpEnvelopeAmount = amount;
}
}
1 change: 1 addition & 0 deletions VoiceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ class VoiceManager {
void setAmpEnvStageValueForEachVoice(EnvelopeGenerator::EnvelopeStage stage, double value);
void setFilterEnvStageValueForEachVoice(EnvelopeGenerator::EnvelopeStage stage, double value);
void setFilterAmountForEachVoice(double amount);
void setAmpAmountForEachVoice(double amount);
};

0 comments on commit 4c12a09

Please sign in to comment.