[go: up one dir, main page]

Menu

[r39]: / Source / LFOModulated.cpp  Maximize  Restore  History

Download this file

88 lines (68 with data), 2.7 kB

 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**************************************************************************
Copyright (C) 2019 Arnaud Champenois arthelion@free.fr
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#include "LFOModulated.h"
void LFOModulated::init(double sampleRate)
{
mLFO.init(sampleRate);
}
void LFOModulated::noteOn(int note)
{
ControllerResponsive::noteOn(note);
mLFO.noteOn();
}
void LFOModulated::updateInternalValues(int controller)
{
if (controller != 0 && controller != mPLFO.mControlNumber->getCtrl() &&
controller != AftrTouchCtrl &&
controller != PitchWheelCtrl &&
controller != ModWheelCtrl)
return;
double controllerDepth = float(*mPLFO.mModWheelDepth) * mModWheel +
float(*mPLFO.mPitchWheelDepth) * mPitchWheel +
float(*mPLFO.mAfterTouchDepth) * mAfterTouch +
float(*mPLFO.mControlDepth)*mController[mPLFO.mControlNumber->getCtrl()];
mLFODepthValue =
float(*mPLFO.mDepth) +
float(*mPLFO.mVeloDepth) * mVelocity +
controllerDepth;
mLFOFreqValue = float(*mPLFO.mFrequency) +
float(*mPLFO.mModWheelFreq) * mModWheel +
float(*mPLFO.mPitchWheelFreq) * mPitchWheel +
float(*mPLFO.mAfterTouchFreq) * mAfterTouch +
float(*mPLFO.mVeloFreq) * mVelocity +
float(*mPLFO.mControlFreq) * mController[mPLFO.mControlNumber->getCtrl()];
if (bool(*mPLFO.mTempoSync) && mPLFO.mTempo>0) {
mLFOFreqValue *= mPLFO.mTempo/60.0;
}
if (mLFOFreqValue < 0.0)
mLFOFreqValue = 0.0;
if (mLFODepthValue > 1.0)
mLFODepthValue = 1.0;
else if (mLFODepthValue < -1.0)
mLFODepthValue = -1.0;
double lfoDelay;
if (controllerDepth != 0.0)
lfoDelay = 0.0f;
else {
lfoDelay = float(*mPLFO.mDelay) +
float(*mPLFO.mPitchWheelDelay) * mPitchWheel +
float(*mPLFO.mModWheelDelay) * mModWheel +
float(*mPLFO.mVeloDelay) * mVelocity +
float(*mPLFO.mControlDelay) * mController[mPLFO.mControlNumber->getCtrl()];
if (lfoDelay < 0.0)
lfoDelay = 0.0;
}
mLFO.setDelay(lfoDelay);
mIsLFOBypassed = (mLFODepthValue == 0.0f || mLFOFreqValue == 0.0f);
}