94 |
this->InternalDepth = (InternalDepth / 1200.0f) * this->Max; |
this->InternalDepth = (InternalDepth / 1200.0f) * this->Max; |
95 |
this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * this->Max; |
this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * this->Max; |
96 |
this->ScriptFrequencyFactor = this->ScriptDepthFactor = 1.f; // reset for new voice |
this->ScriptFrequencyFactor = this->ScriptDepthFactor = 1.f; // reset for new voice |
97 |
|
this->pFinalDepth = NULL; |
98 |
|
this->pFinalFrequency = NULL; |
99 |
|
|
100 |
const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF... |
const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF... |
101 |
const float freq = Frequency * this->ScriptFrequencyFactor; |
const float freq = Frequency * this->ScriptFrequencyFactor; |
125 |
c = (int) (intLimit * r); |
c = (int) (intLimit * r); |
126 |
} |
} |
127 |
|
|
128 |
void setScriptDepthFactor(float factor) { |
void setScriptDepthFactor(float factor, bool isFinal) { |
129 |
this->ScriptDepthFactor = factor; |
this->ScriptDepthFactor = factor; |
130 |
|
// set or reset this script depth parameter to be the sole |
131 |
|
// source for the LFO depth |
132 |
|
if (isFinal && !this->pFinalDepth) |
133 |
|
this->pFinalDepth = &this->ScriptDepthFactor; |
134 |
|
else if (!isFinal && this->pFinalDepth == &this->ScriptDepthFactor) |
135 |
|
this->pFinalDepth = NULL; |
136 |
|
// recalculate upon new depth |
137 |
updateByMIDICtrlValue(this->ExtControlValue); |
updateByMIDICtrlValue(this->ExtControlValue); |
138 |
} |
} |
139 |
|
|
140 |
void setScriptFrequencyFactor(float factor, unsigned int SampleRate) { |
void setScriptFrequencyFactor(float factor, unsigned int SampleRate) { |
141 |
this->ScriptFrequencyFactor = factor; |
this->ScriptFrequencyFactor = factor; |
142 |
|
// in case script frequency was set as "final" value before, |
143 |
|
// reset it so that all sources are processed from now on |
144 |
|
if (this->pFinalFrequency == &this->ScriptFrequencyFactor) |
145 |
|
this->pFinalFrequency = NULL; |
146 |
|
// recalculate upon new frequency |
147 |
|
setFrequency(this->Frequency, SampleRate); |
148 |
|
} |
149 |
|
|
150 |
|
void setScriptFrequencyFinal(float hz, unsigned int SampleRate) { |
151 |
|
this->ScriptFrequencyFactor = hz; |
152 |
|
// assign script's given frequency as sole source for the LFO |
153 |
|
// frequency, thus ignore all other sources |
154 |
|
if (!this->pFinalFrequency) |
155 |
|
this->pFinalFrequency = &this->ScriptFrequencyFactor; |
156 |
|
// recalculate upon new frequency |
157 |
setFrequency(this->Frequency, SampleRate); |
setFrequency(this->Frequency, SampleRate); |
158 |
} |
} |
159 |
|
|