Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::signal::SubOscillatorT< SampleType > Class Template Reference

A one- or two-octave divider derived from an explicit parent phase. More...

#include <sub_oscillator.hpp>

Public Member Functions

bool set_octave (int octave) noexcept
 Select one or two octaves below the parent.
int octave () const noexcept
void set_waveform (SubOscillatorWaveform waveform) noexcept
SubOscillatorWaveform waveform () const noexcept
void reset (std::uint32_t completed_parent_cycles=0) noexcept
 Re-anchor the divider to a known completed parent-cycle count.
void on_parent_cycle () noexcept
 Report one completed parent cycle. Call before next(0) on a wrap.
SampleType next (SampleType parent_phase) noexcept
 Render from the parent's current normalized phase in [0, 1).
SampleType next (SampleType parent_phase, bool parent_cycle_edge) noexcept
 Convenience form for a wrap and render in one call.
SampleType phase () const noexcept
 The phase used for the most recently rendered valid sample.

Detailed Description

template<typename SampleType = float>
class pulp::signal::SubOscillatorT< SampleType >

A one- or two-octave divider derived from an explicit parent phase.

This class deliberately owns no free-running clock. The caller supplies the normalized parent phase for every sample and reports each parent-cycle edge. The sub phase is (completed_parent_cycles + parent_phase) / 2^octave, so a parent reset or phase jump cannot leave a second oscillator drifting beside it. Call reset() when the parent cycle count is reset, and call on_parent_cycle() before rendering the first sample after each wrap.

Every operation is fixed-state, allocation-free, lock-free, and noexcept. The output has normalized amplitude, zero latency, and no tail.

Member Function Documentation

◆ next() [1/2]

template<typename SampleType = float>
SampleType pulp::signal::SubOscillatorT< SampleType >::next ( SampleType parent_phase)
inlinenoexcept

Render from the parent's current normalized phase in [0, 1).

Non-finite or out-of-range input is absorbed as silence and re-anchors the divider, preventing invalid arithmetic from poisoning later output.

◆ next() [2/2]

template<typename SampleType = float>
SampleType pulp::signal::SubOscillatorT< SampleType >::next ( SampleType parent_phase,
bool parent_cycle_edge )
inlinenoexcept

Convenience form for a wrap and render in one call.

The edge is applied first, matching the first sample of the new parent cycle.

◆ octave()

template<typename SampleType = float>
int pulp::signal::SubOscillatorT< SampleType >::octave ( ) const
inlinenoexcept

◆ on_parent_cycle()

template<typename SampleType = float>
void pulp::signal::SubOscillatorT< SampleType >::on_parent_cycle ( )
inlinenoexcept

Report one completed parent cycle. Call before next(0) on a wrap.

◆ phase()

template<typename SampleType = float>
SampleType pulp::signal::SubOscillatorT< SampleType >::phase ( ) const
inlinenoexcept

The phase used for the most recently rendered valid sample.

◆ reset()

template<typename SampleType = float>
void pulp::signal::SubOscillatorT< SampleType >::reset ( std::uint32_t completed_parent_cycles = 0)
inlinenoexcept

Re-anchor the divider to a known completed parent-cycle count.

◆ set_octave()

template<typename SampleType = float>
bool pulp::signal::SubOscillatorT< SampleType >::set_octave ( int octave)
inlinenodiscardnoexcept

Select one or two octaves below the parent.

Failure leaves the previous setting and phase relationship unchanged.

◆ set_waveform()

template<typename SampleType = float>
void pulp::signal::SubOscillatorT< SampleType >::set_waveform ( SubOscillatorWaveform waveform)
inlinenoexcept

◆ waveform()

template<typename SampleType = float>
SubOscillatorWaveform pulp::signal::SubOscillatorT< SampleType >::waveform ( ) const
inlinenoexcept

The documentation for this class was generated from the following file: