1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2005 - 2017 Christian Schoenebeck * |
* Copyright (C) 2005 - 2019 Christian Schoenebeck * |
4 |
* * |
* * |
5 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
100 |
const float harmonicCompensation = 1.0f + fabsf(AMP2); // to compensate the 2nd harmonic's amplitude overhead |
const float harmonicCompensation = 1.0f + fabsf(AMP2); // to compensate the 2nd harmonic's amplitude overhead |
101 |
this->InternalDepth = (InternalDepth / 1200.0f) * this->Max / harmonicCompensation; |
this->InternalDepth = (InternalDepth / 1200.0f) * this->Max / harmonicCompensation; |
102 |
this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * this->Max / harmonicCompensation; |
this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * this->Max / harmonicCompensation; |
103 |
|
this->pFinalDepth = NULL; |
104 |
|
this->pFinalFrequency = NULL; |
105 |
|
|
106 |
const float freq = Frequency * this->ScriptFrequencyFactor; |
const float freq = Frequency * this->ScriptFrequencyFactor; |
107 |
c1 = 2.0f * M_PI * freq / (float) SampleRate; |
c1 = 2.0f * M_PI * freq / (float) SampleRate; |
147 |
c2 = 2.0f * M_PI * freq / (float) SampleRate * 3.0f; |
c2 = 2.0f * M_PI * freq / (float) SampleRate * 3.0f; |
148 |
} |
} |
149 |
|
|
150 |
void setScriptDepthFactor(float factor) { |
void setScriptDepthFactor(float factor, bool isFinal) { |
151 |
this->ScriptDepthFactor = factor; |
this->ScriptDepthFactor = factor; |
152 |
|
// set or reset this script depth parameter to be the sole |
153 |
|
// source for the LFO depth |
154 |
|
if (isFinal && !this->pFinalDepth) |
155 |
|
this->pFinalDepth = &this->ScriptDepthFactor; |
156 |
|
else if (!isFinal && this->pFinalDepth == &this->ScriptDepthFactor) |
157 |
|
this->pFinalDepth = NULL; |
158 |
|
// recalculate upon new depth |
159 |
updateByMIDICtrlValue(this->ExtControlValue); |
updateByMIDICtrlValue(this->ExtControlValue); |
160 |
} |
} |
161 |
|
|
162 |
void setScriptFrequencyFactor(float factor, unsigned int SampleRate) { |
void setScriptFrequencyFactor(float factor, unsigned int SampleRate) { |
163 |
this->ScriptFrequencyFactor = factor; |
this->ScriptFrequencyFactor = factor; |
164 |
|
// in case script frequency was set as "final" value before, |
165 |
|
// reset it so that all sources are processed from now on |
166 |
|
if (this->pFinalFrequency == &this->ScriptFrequencyFactor) |
167 |
|
this->pFinalFrequency = NULL; |
168 |
|
// recalculate upon new frequency |
169 |
|
setFrequency(this->Frequency, SampleRate); |
170 |
|
} |
171 |
|
|
172 |
|
void setScriptFrequencyFinal(float hz, unsigned int SampleRate) { |
173 |
|
this->ScriptFrequencyFactor = hz; |
174 |
|
// assign script's given frequency as sole source for the LFO |
175 |
|
// frequency, thus ignore all other sources |
176 |
|
if (!this->pFinalFrequency) |
177 |
|
this->pFinalFrequency = &this->ScriptFrequencyFactor; |
178 |
|
// recalculate upon new frequency |
179 |
setFrequency(this->Frequency, SampleRate); |
setFrequency(this->Frequency, SampleRate); |
180 |
} |
} |
181 |
|
|