Band-limited oscillator featuring PolyBLEP anti-aliasing and analog-modeled integration.
More...
|
| void | prepare (double sampleRate) noexcept |
| | Prepares the oscillator with the system sample rate.
|
| |
| void | prepare (const AudioSpec &spec) noexcept |
| | Prepares the oscillator from an AudioSpec configuration.
|
| |
| void | setFrequency (T freq) noexcept |
| | Sets the oscillator's fundamental frequency.
|
| |
| void | setWaveform (Waveform w) noexcept |
| | Changes the active waveform.
|
| |
| void | setSyncRatio (T ratio) noexcept |
| | Enables band-limited hard sync.
|
| |
| void | setPhase (T phase) noexcept |
| | Forces the oscillator phase to a specific value.
|
| |
| void | reset () noexcept |
| | Hard-resets the oscillator phase and integrator state.
|
| |
| T | getNextSample () noexcept |
| | Computes and returns the next single audio sample.
|
| |
| void | processBlock (T *buffer, size_t numSamples) noexcept |
| | Fills a buffer with generated samples.
|
| |
| T | getSample () noexcept |
| | Generator contract alias for getNextSample() (GeneratorProcessor).
|
| |
| void | generateBlock (AudioBufferView< T > buffer) noexcept |
| | Fills every channel of the view with the generated waveform. Satisfies the GeneratorProcessor concept. The oscillator is mono, so all channels receive the same signal (channel 0 is generated, the rest copy it).
|
| |
| T | getPhase () const noexcept |
| |
| T | getFrequency () const noexcept |
| |
| Waveform | getWaveform () const noexcept |
| |
| T | getSyncRatio () const noexcept |
| |
template<typename T>
class dspark::Oscillator< T >
Band-limited oscillator featuring PolyBLEP anti-aliasing and analog-modeled integration.
This oscillator provides high-quality waveform generation suitable for both audio-rate synthesis and low-frequency modulation (LFO). It utilizes PolyBLEP (Polynomial Band-Limited Step) to drastically reduce aliasing artifacts in discontinuous waveforms (Saw, Square). The Triangle wave is generated via a leaky integrator driven by a PolyBLEP square, providing an analog-style curve. Under hard sync (setSyncRatio) every discontinuity is instead corrected with a table minBLEP (MinBlepTable) – a causal minimum-phase kernel whose alias rejection (~-90 dB measured) survives the arbitrary jump amplitudes sync creates. Exception: a hard-synced Sine has no value discontinuity, only a derivative kink at the reset, which the minBLEP does not address; its residual alias floor is ~-64 dB (a minBLAMP table is the future direction).
- Note
- This class is not internally thread-safe: apply parameter changes (e.g. setFrequency) from the audio thread between process calls, publishing values from other threads via atomics, as the framework effects do.
- Template Parameters
-
| T | Sample type (must be float or double). |
Definition at line 63 of file Oscillator.h.
Enables band-limited hard sync.
The oscillator's frequency becomes the sync MASTER; an internal slave runs at ratio times that frequency and is phase-reset every master cycle – the classic ripping sync timbre. Every discontinuity (the slave's own edges and the reset jump, scaled to its actual amplitude) is corrected with a table minBLEP (see MinBlepTable): a minimum-phase band-limited step whose correction is fully causal, pushing aliasing to the windowed-sinc stopband instead of the ~-40 dB envelope of a 2-point polynomial kernel.
- Note
- A band-limited (brickwall) rendition of the synced waveform legitimately overshoots the naive one: peaks may reach ~1.5x full scale (Gibbs), unlike the sync-off waveforms which stay within [-1, 1]. Leave headroom or follow with a gain stage.
- Parameters
-
| ratio | Slave/master frequency ratio. Values <= 1 disable sync (a small guard band just above 1 also disables it – a 1:1 slave adds nothing but correction noise). |
Definition at line 141 of file Oscillator.h.