Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
sbl::dsp::PhaseAccumulator Class Reference

#include <phase.hpp>

Collaboration diagram for sbl::dsp::PhaseAccumulator:

Public Member Functions

void set_increment (uint32_t inc)
 Set the phase increment per sample.
 
void advance ()
 Advance phase by one sample.
 
void advance (uint16_t frames, uint32_t *out)
 Advance and fill a buffer with per-sample phases.
 
uint32_t phase () const
 Current phase value.
 
uint32_t increment () const
 Current phase increment.
 
void reset ()
 Reset phase to zero.
 
void reset (uint32_t phase)
 Reset phase to a specific value (for sync)
 

Static Public Member Functions

static uint32_t freq_to_inc (float freq_hz, float sr=48000.0f)
 Convert frequency in Hz to phase increment.
 

Detailed Description

Definition at line 23 of file phase.hpp.

Member Function Documentation

◆ advance() [1/2]

void sbl::dsp::PhaseAccumulator::advance ( )
inline

Advance phase by one sample.

Definition at line 36 of file phase.hpp.

Referenced by sbl::widgets::mod::Lfo< TableSize >::process(), sbl::widgets::source::ScanningOsc< TableSize, MaxTables >::process(), and sbl::widgets::source::WavetableOsc< TableSize >::process().

Here is the caller graph for this function:

◆ advance() [2/2]

void sbl::dsp::PhaseAccumulator::advance ( uint16_t  frames,
uint32_t *  out 
)
inline

Advance and fill a buffer with per-sample phases.

Each output element is the phase AFTER advancing. Useful for batch wavetable reads.

Definition at line 44 of file phase.hpp.

◆ freq_to_inc()

static uint32_t sbl::dsp::PhaseAccumulator::freq_to_inc ( float  freq_hz,
float  sr = 48000.0f 
)
inlinestatic

Convert frequency in Hz to phase increment.

Parameters
freq_hzFrequency in Hz (e.g., 440.0f)
srSample rate (default 48000)
Returns
Phase increment per sample

Definition at line 70 of file phase.hpp.

Referenced by sbl::widgets::source::ScanningOsc< TableSize, MaxTables >::set_frequency(), sbl::widgets::source::WavetableOsc< TableSize >::set_frequency(), and sbl::widgets::mod::Lfo< TableSize >::set_rate().

Here is the caller graph for this function:

◆ increment()

uint32_t sbl::dsp::PhaseAccumulator::increment ( ) const
inline

Current phase increment.

Definition at line 55 of file phase.hpp.

Referenced by sbl::widgets::mod::Lfo< TableSize >::increment(), sbl::widgets::source::ScanningOsc< TableSize, MaxTables >::increment(), and sbl::widgets::source::WavetableOsc< TableSize >::increment().

Here is the caller graph for this function:

◆ phase()

uint32_t sbl::dsp::PhaseAccumulator::phase ( ) const
inline

◆ reset() [1/2]

void sbl::dsp::PhaseAccumulator::reset ( )
inline

Reset phase to zero.

Definition at line 58 of file phase.hpp.

Referenced by sbl::widgets::mod::Lfo< TableSize >::sync(), sbl::widgets::source::ScanningOsc< TableSize, MaxTables >::sync(), sbl::widgets::source::WavetableOsc< TableSize >::sync(), and sbl::widgets::source::WavetableOsc< TableSize >::sync().

Here is the caller graph for this function:

◆ reset() [2/2]

void sbl::dsp::PhaseAccumulator::reset ( uint32_t  phase)
inline

Reset phase to a specific value (for sync)

Definition at line 61 of file phase.hpp.

References phase().

Here is the call graph for this function:

◆ set_increment()

void sbl::dsp::PhaseAccumulator::set_increment ( uint32_t  inc)
inline

Set the phase increment per sample.

Note
All public methods are ISR-safe — bounded computation, no I/O.

inc = frequency_hz * 2^32 / sample_rate Use freq_to_inc() for Hz input.

Definition at line 33 of file phase.hpp.

Referenced by sbl::widgets::source::ScanningOsc< TableSize, MaxTables >::set_frequency(), sbl::widgets::source::WavetableOsc< TableSize >::set_frequency(), sbl::widgets::mod::Lfo< TableSize >::set_increment(), sbl::widgets::source::ScanningOsc< TableSize, MaxTables >::set_increment(), sbl::widgets::source::WavetableOsc< TableSize >::set_increment(), sbl::widgets::source::ScanningOsc< TableSize, MaxTables >::set_note(), sbl::widgets::source::WavetableOsc< TableSize >::set_note(), and sbl::widgets::mod::Lfo< TableSize >::set_rate().

Here is the caller graph for this function:

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