|
DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
|
Professional mipmapped wavetable oscillator for bandlimited synthesis. More...
#include <WavetableOscillator.h>
Public Member Functions | |
| 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. | |
Static Public Attributes | |
| static constexpr int | kTableSize = 2048 |
| static constexpr int | kTableMask = kTableSize - 1 |
| static constexpr int | kMaxMipLevels = 12 |
Professional mipmapped wavetable oscillator for bandlimited synthesis.
| T | Sample type (float or double). Must satisfy std::floating_point. |
Definition at line 51 of file WavetableOscillator.h.
|
default |
|
inline |
Builds contiguous mipmapped tables from a harmonic amplitude function.
| HarmonicFunc | Callable signature: T(int harmonic) |
| harmonicFunc | Function returning the amplitude for harmonic N (starts at 1). |
Definition at line 152 of file WavetableOscillator.h.
|
inline |
Builds a bandlimited sawtooth wavetable with mipmaps.
Definition at line 94 of file WavetableOscillator.h.
|
inline |
Builds a pure sine wavetable. Requires only 1 level since it contains only the fundamental.
Definition at line 130 of file WavetableOscillator.h.
|
inline |
Builds a bandlimited square wavetable with mipmaps.
Definition at line 105 of file WavetableOscillator.h.
|
inline |
Builds a bandlimited triangle wavetable with mipmaps.
Definition at line 116 of file WavetableOscillator.h.
|
inlinenoexcept |
Fills every channel of the view with the generated waveform. Satisfies the GeneratorProcessor concept (mono source, all channels equal).
Definition at line 313 of file WavetableOscillator.h.
|
inlinenoexcept |
Returns the current internal frequency.
Definition at line 285 of file WavetableOscillator.h.
|
inlinenoexcept |
Generates the next sample using Hermite interpolation.
Definition at line 292 of file WavetableOscillator.h.
|
inline |
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.
| data | Pointer to wavetable samples. |
| size | Number of samples in the input data. |
Definition at line 201 of file WavetableOscillator.h.
|
inline |
Prepares from AudioSpec (unified API).
| spec | Framework AudioSpec instance containing sample rate. |
Definition at line 83 of file WavetableOscillator.h.
|
inline |
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.
| sampleRate | Sample rate in Hz. Must be > 0 (invalid values, including NaN, are ignored). |
Definition at line 69 of file WavetableOscillator.h.
|
inlinenoexcept |
Generates a block of samples.
| output | Pointer to output buffer. |
| numSamples | Number of samples to process. |
Definition at line 303 of file WavetableOscillator.h.
|
inlinenoexcept |
Hard resets the oscillator phase.
| phase | Initial phase normalized [0.0, 1.0]. |
Definition at line 329 of file WavetableOscillator.h.
|
inlinenoexcept |
Sets the fundamental oscillation frequency.
| frequencyHz | Frequency in Hz. |
Definition at line 271 of file WavetableOscillator.h.
|
staticconstexpr |
Definition at line 56 of file WavetableOscillator.h.
|
staticconstexpr |
Definition at line 55 of file WavetableOscillator.h.
|
staticconstexpr |
Definition at line 54 of file WavetableOscillator.h.