Professional mipmapped wavetable oscillator for bandlimited synthesis.
More...
#include <WavetableOscillator.h>
|
| | WavetableOscillator ()=default |
| |
| void | prepare (double sampleRate) |
| | Prepares the oscillator for a given sample rate.
|
| |
| void | prepare (const AudioSpec &spec) |
| | Prepares from AudioSpec (unified API).
|
| |
| void | buildSaw () |
| | Builds a bandlimited sawtooth wavetable with mipmaps.
|
| |
| void | buildSquare () |
| | Builds a bandlimited square wavetable with mipmaps.
|
| |
| void | buildTriangle () |
| | Builds a bandlimited triangle wavetable with mipmaps.
|
| |
| void | buildSine () |
| | Builds a pure sine wavetable. Requires only 1 level since it contains only the fundamental.
|
| |
| template<typename HarmonicFunc > |
| void | buildFromHarmonics (HarmonicFunc harmonicFunc) |
| | Builds contiguous mipmapped tables from a harmonic amplitude function.
|
| |
| void | loadWavetable (const T *data, int size) |
| | Loads and analyzes a custom single-cycle wavetable using DFT.
|
| |
| void | setFrequency (T frequencyHz) noexcept |
| | Sets the fundamental oscillation frequency.
|
| |
| T | getFrequency () const noexcept |
| | Returns the current internal frequency.
|
| |
| T | getSample () noexcept |
| | Generates the next sample using Hermite interpolation.
|
| |
| void | processBlock (T *output, int numSamples) noexcept |
| | Generates a block of samples.
|
| |
| void | generateBlock (AudioBufferView< T > buffer) noexcept |
| | Fills every channel of the view with the generated waveform. Satisfies the GeneratorProcessor concept (mono source, all channels equal).
|
| |
| void | reset (T phase=T(0)) noexcept |
| | Hard resets the oscillator phase.
|
| |
template<FloatType T>
class dspark::WavetableOscillator< T >
Professional mipmapped wavetable oscillator for bandlimited synthesis.
- Template Parameters
-
| T | Sample type (float or double). Must satisfy std::floating_point. |
Definition at line 64 of file WavetableOscillator.h.
◆ WavetableOscillator()
◆ buildFromHarmonics()
template<FloatType T>
template<typename HarmonicFunc >
Builds contiguous mipmapped tables from a harmonic amplitude function.
- Template Parameters
-
| HarmonicFunc | Callable signature: T(int harmonic) |
- Parameters
-
| harmonicFunc | Function returning the amplitude for harmonic N (starts at 1). |
- Note
- Allocates memory. Call only during initialization/preparation.
Definition at line 169 of file WavetableOscillator.h.
◆ buildSaw()
Builds a bandlimited sawtooth wavetable with mipmaps.
- Note
- Allocates memory. Call only during initialization/preparation.
Definition at line 109 of file WavetableOscillator.h.
◆ buildSine()
Builds a pure sine wavetable. Requires only 1 level since it contains only the fundamental.
- Note
- Allocates memory. Call only during initialization/preparation.
Definition at line 145 of file WavetableOscillator.h.
◆ buildSquare()
Builds a bandlimited square wavetable with mipmaps.
- Note
- Allocates memory. Call only during initialization/preparation.
Definition at line 120 of file WavetableOscillator.h.
◆ buildTriangle()
Builds a bandlimited triangle wavetable with mipmaps.
- Note
- Allocates memory. Call only during initialization/preparation.
Definition at line 131 of file WavetableOscillator.h.
◆ generateBlock()
Fills every channel of the view with the generated waveform. Satisfies the GeneratorProcessor concept (mono source, all channels equal).
Definition at line 274 of file WavetableOscillator.h.
◆ getFrequency()
◆ getSample()
Generates the next sample using Hermite interpolation.
- Returns
- Output sample, nominally in [-1.0, 1.0] (tables are peak normalised; interpolation may overshoot slightly between table points).
Definition at line 253 of file WavetableOscillator.h.
◆ loadWavetable()
Loads and analyzes a custom single-cycle wavetable using DFT.
Performs a Discrete Fourier Transform strictly on the original data length to avoid low-pass smearing, then reconstructs bandlimited mipmaps.
- Parameters
-
| data | Pointer to wavetable samples. |
| size | Number of samples in the input data. |
- Note
- Allocates memory. Call only during initialization/preparation.
Definition at line 188 of file WavetableOscillator.h.
◆ prepare() [1/2]
◆ prepare() [2/2]
Prepares the oscillator for a given sample rate.
Re-derives the mip cutoff frequencies for tables that were already built, so a rate change after build*() keeps the anti-aliasing exact.
- Parameters
-
| sampleRate | Sample rate in Hz. Must be > 0 (invalid values, including NaN, are ignored). |
Definition at line 83 of file WavetableOscillator.h.
◆ processBlock()
Generates a block of samples.
- Parameters
-
| output | Pointer to output buffer. |
| numSamples | Number of samples to process. |
Definition at line 264 of file WavetableOscillator.h.
◆ reset()
Hard resets the oscillator phase.
- Parameters
-
| phase | Initial phase normalized [0.0, 1.0]. |
Definition at line 290 of file WavetableOscillator.h.
◆ setFrequency()
Sets the fundamental oscillation frequency.
- Parameters
-
| frequencyHz | Frequency in Hz. |
- Note
- Not inherently thread-safe. Synchronization should be managed externally.
Definition at line 230 of file WavetableOscillator.h.
◆ kMaxMipLevels
Mip levels, half an octave apart (harmonic budgets in kLevelHarmonics).
Definition at line 70 of file WavetableOscillator.h.
◆ kTableMask
◆ kTableSize
The documentation for this class was generated from the following file: