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