|
| void | prepare (double sampleRate) noexcept |
| | Prepares the phasor for a given sample rate.
|
| |
| void | prepare (const AudioSpec &spec) noexcept |
| | Prepares from AudioSpec (unified API).
|
| |
| void | setFrequency (T frequencyHz) noexcept |
| | Sets the baseline oscillation frequency.
|
| |
| T | getFrequency () const noexcept |
| | Returns the baseline frequency.
|
| |
| T | advance () noexcept |
| | Returns the phase for the current sample, then advances the accumulator (post-increment semantics).
|
| |
| T | advanceWithFM (T fmHz) noexcept |
| | Advances the phase with per-sample frequency modulation.
|
| |
| T | getPhase () const noexcept |
| | Returns the current phase without advancing the accumulator.
|
| |
| void | setPhase (T newPhase) noexcept |
| | Forcibly overwrites the current phase.
|
| |
| void | hardSync (T fractionalOffset=T(0)) noexcept |
| | Hard syncs the oscillator, optionally with a sub-sample offset.
|
| |
| void | softSync (T threshold=T(0.5)) noexcept |
| | Soft syncs the oscillator conditionally.
|
| |
| void | reset (T startPhase=T(0)) noexcept |
| | Resets the phasor to a specific initial state (default 0).
|
| |
| T | getIncrement () const noexcept |
| | Returns the calculated phase increment per sample.
|
| |
template<FloatType T>
class dspark::Phasor< T >
Phase accumulator generating a [0, 1) ramp for oscillators and modulation.
Scalar recursive accumulator with a fast in-range wrap (one compare in the common case) that also handles arbitrarily large excursions (extreme FM, frequencies far above the sample rate) without unbounded loops. Supports fractional phase offsets on hard sync for PolyBLEP/MinBLEP-style anti-aliased oscillators.
- Note
- This class is not internally thread-safe. Parameter updates (e.g., setFrequency) should be synchronized or smoothed by the caller prior to block processing.
- Template Parameters
-
| T | Sample type (must satisfy FloatType concept). |
Definition at line 49 of file Phasor.h.
Advances the phase with per-sample frequency modulation.
The instantaneous increment is computed in double, and the wrap safely handles arbitrarily large FM indices without unbounded loops. A NaN excursion cannot poison the accumulator permanently (the wrap resets it to 0), but the caller should keep fmHz finite.
- Parameters
-
| fmHz | Instantaneous frequency deviation in Hz. |
- Returns
- Current phase value in [0, 1).
Definition at line 116 of file Phasor.h.