63 |
* |
* |
64 |
* @param ExtControlValue - new external controller value |
* @param ExtControlValue - new external controller value |
65 |
*/ |
*/ |
66 |
inline void update(const uint16_t& ExtControlValue) { |
inline void updateByMIDICtrlValue(const uint16_t& ExtControlValue) { |
67 |
|
this->ExtControlValue = ExtControlValue; |
68 |
|
|
69 |
const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF... |
const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF... |
70 |
const float max = this->InternalDepth + ExtControlValue * this->ExtControlDepthCoeff; |
const float max = (this->InternalDepth + ExtControlValue * this->ExtControlDepthCoeff) * this->ScriptDepthFactor; |
71 |
if (RANGE == range_unsigned) { |
if (RANGE == range_unsigned) { |
72 |
normalizer = max / (float) intLimit; |
normalizer = max / (float) intLimit; |
73 |
} else { // signed range |
} else { // signed range |
90 |
* audio output signal |
* audio output signal |
91 |
*/ |
*/ |
92 |
virtual void trigger(float Frequency, start_level_t StartLevel, uint16_t InternalDepth, uint16_t ExtControlDepth, bool FlipPhase, unsigned int SampleRate) { |
virtual void trigger(float Frequency, start_level_t StartLevel, uint16_t InternalDepth, uint16_t ExtControlDepth, bool FlipPhase, unsigned int SampleRate) { |
93 |
|
this->Frequency = Frequency; |
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 |
97 |
|
|
98 |
const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF... |
const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF... |
99 |
const float r = Frequency / (float) SampleRate; // frequency alteration quotient |
const float freq = Frequency * this->ScriptFrequencyFactor; |
100 |
|
const float r = freq / (float) SampleRate; // frequency alteration quotient |
101 |
c = (int) (intLimit * r); |
c = (int) (intLimit * r); |
102 |
|
|
103 |
uiLevel = 0; |
uiLevel = 0; |
116 |
} |
} |
117 |
|
|
118 |
void setFrequency(float Frequency, unsigned int SampleRate) { |
void setFrequency(float Frequency, unsigned int SampleRate) { |
119 |
|
this->Frequency = Frequency; |
120 |
|
const float freq = Frequency * this->ScriptFrequencyFactor; |
121 |
const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF... |
const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF... |
122 |
float r = Frequency / (float) SampleRate; // frequency alteration quotient |
float r = freq / (float) SampleRate; // frequency alteration quotient |
123 |
c = (int) (intLimit * r); |
c = (int) (intLimit * r); |
124 |
} |
} |
125 |
|
|
126 |
|
void setScriptDepthFactor(float factor) { |
127 |
|
this->ScriptDepthFactor = factor; |
128 |
|
updateByMIDICtrlValue(this->ExtControlValue); |
129 |
|
} |
130 |
|
|
131 |
|
void setScriptFrequencyFactor(float factor, unsigned int SampleRate) { |
132 |
|
this->ScriptFrequencyFactor = factor; |
133 |
|
setFrequency(this->Frequency, SampleRate); |
134 |
|
} |
135 |
|
|
136 |
protected: |
protected: |
137 |
unsigned int uiLevel; |
unsigned int uiLevel; |
138 |
int c; |
int c; |