mirror of
https://github.com/Fihdi/Eurorack.git
synced 2026-04-11 23:46:05 +00:00
31 lines
1.3 KiB
C++
31 lines
1.3 KiB
C++
#ifndef SynthClave_Osc_h
|
|
#define SynthClave_Osc_h
|
|
|
|
|
|
//▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
|
|
class Osc {
|
|
private:
|
|
float _head;
|
|
float _speed;
|
|
|
|
public:
|
|
|
|
//▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
|
|
void SetFrequency (float frequency) {
|
|
_speed = frequency / 48000.0f;
|
|
}
|
|
|
|
|
|
//▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
|
|
float Process () {
|
|
_head += _speed;
|
|
if (_head >= 1.0f) _head -= 1.0f;
|
|
float v = _head < 0.5f ? _head * 2.0f : 2.0f * (1.0f - _head);
|
|
return v - 0.5f;
|
|
}
|
|
};
|
|
|
|
|
|
//▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
|
|
#endif // SynthClave_Osc_h
|