31 |
* This is a saw Low Frequency Oscillator which uses pure integer |
* This is a saw Low Frequency Oscillator which uses pure integer |
32 |
* math (without branches) to synthesize the saw wave. |
* math (without branches) to synthesize the saw wave. |
33 |
*/ |
*/ |
34 |
template<range_type_t RANGE, bool SAWUP> |
template<LFO::range_type_t RANGE, bool SAWUP> |
35 |
class SawLFO : public LFOBase<RANGE> { |
class SawLFO : public LFOBase<RANGE> { |
36 |
public: |
public: |
37 |
|
|
52 |
const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF... |
const unsigned int intLimit = (unsigned int) -1; // all 0xFFFF... |
53 |
|
|
54 |
uiLevel += c; |
uiLevel += c; |
55 |
if (RANGE == range_unsigned) |
if (RANGE == LFO::range_unsigned) |
56 |
return normalizer * (float) (SAWUP ? uiLevel : intLimit - uiLevel); |
return normalizer * (float) (SAWUP ? uiLevel : intLimit - uiLevel); |
57 |
else /* signed range */ |
else /* signed range */ |
58 |
return normalizer * (float) (SAWUP ? uiLevel : intLimit - uiLevel) + offset; |
return normalizer * (float) (SAWUP ? uiLevel : intLimit - uiLevel) + offset; |
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) * this->ScriptDepthFactor; |
const float max = (this->InternalDepth + ExtControlValue * this->ExtControlDepthCoeff) * this->ScriptDepthFactor; |
71 |
if (RANGE == range_unsigned) { |
if (RANGE == LFO::range_unsigned) { |
72 |
normalizer = max / (float) intLimit; |
normalizer = max / (float) intLimit; |
73 |
} else { // signed range |
} else { // signed range |
74 |
normalizer = max / (float) intLimit * 2.0f; |
normalizer = max / (float) intLimit * 2.0f; |
89 |
* @param SampleRate - current sample rate of the engines |
* @param SampleRate - current sample rate of the engines |
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, LFO::start_level_t StartLevel, uint16_t InternalDepth, uint16_t ExtControlDepth, bool FlipPhase, unsigned int SampleRate) { |
93 |
this->Frequency = Frequency; |
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; |
165 |
}; |
}; |
166 |
|
|
167 |
|
|
168 |
template<range_type_t RANGE> |
template<LFO::range_type_t RANGE> |
169 |
class SawUpLFO : public SawLFO<RANGE, true> { |
class SawUpLFO : public SawLFO<RANGE, true> { |
170 |
public: |
public: |
171 |
SawUpLFO(float Max) : SawLFO<RANGE, true>::SawLFO(Max) { } |
SawUpLFO(float Max) : SawLFO<RANGE, true>::SawLFO(Max) { } |
172 |
}; |
}; |
173 |
|
|
174 |
template<range_type_t RANGE> |
template<LFO::range_type_t RANGE> |
175 |
class SawDownLFO : public SawLFO<RANGE, false> { |
class SawDownLFO : public SawLFO<RANGE, false> { |
176 |
public: |
public: |
177 |
SawDownLFO(float Max) : SawLFO<RANGE, false>::SawLFO(Max) { } |
SawDownLFO(float Max) : SawLFO<RANGE, false>::SawLFO(Max) { } |