31 |
* This is a pulse Low Frequency Oscillator which uses pure integer |
* This is a pulse Low Frequency Oscillator which uses pure integer |
32 |
* math (without branches) to synthesize the pulse wave. |
* math (without branches) to synthesize the pulse wave. |
33 |
*/ |
*/ |
34 |
template<range_type_t RANGE, int WIDTH /* in permilles */> |
template<LFO::range_type_t RANGE, int WIDTH /* in permilles */> |
35 |
class PulseLFO : public LFOBase<RANGE> { |
class PulseLFO : public LFOBase<RANGE> { |
36 |
public: |
public: |
37 |
|
|
50 |
*/ |
*/ |
51 |
inline float render() { |
inline float render() { |
52 |
uiLevel += c; |
uiLevel += c; |
53 |
if (RANGE == range_unsigned) |
if (RANGE == LFO::range_unsigned) |
54 |
return uiLevel <= width ? normalizer : 0; |
return uiLevel <= width ? normalizer : 0; |
55 |
else /* signed range */ |
else /* signed range */ |
56 |
return uiLevel <= width ? normalizer : -normalizer; |
return uiLevel <= width ? normalizer : -normalizer; |
99 |
uiLevel = 0; |
uiLevel = 0; |
100 |
} |
} |
101 |
|
|
102 |
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) { |
103 |
trigger(Frequency, InternalDepth, ExtControlDepth, WIDTH / 10.0f, SampleRate); |
trigger(Frequency, InternalDepth, ExtControlDepth, WIDTH / 10.0f, SampleRate); |
104 |
} |
} |
105 |
|
|
162 |
float normalizer; |
float normalizer; |
163 |
}; |
}; |
164 |
|
|
165 |
template<range_type_t RANGE> |
template<LFO::range_type_t RANGE> |
166 |
class SquareLFO : public PulseLFO<RANGE, 500> { |
class SquareLFO : public PulseLFO<RANGE, 500> { |
167 |
public: |
public: |
168 |
SquareLFO(float Max) : PulseLFO<RANGE, 500>::PulseLFO(Max) { } |
SquareLFO(float Max) : PulseLFO<RANGE, 500>::PulseLFO(Max) { } |