Sound Byte Libs 0.5.1-121-g3358a44
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::dsp::primitives::PhaseAccumulator Class Reference

Detailed Description

Definition at line 30 of file phase_accumulator.hpp.

#include <phase_accumulator.hpp>

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=types::SAMPLE_RATE_F)
 Convert frequency in Hz to phase increment.
 

Member Function Documentation

◆ set_increment()

void sbl::dsp::primitives::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 40 of file phase_accumulator.hpp.

Referenced by sbl::dsp::comp::Lfo< TableSize >::set_increment().

◆ advance() [1/2]

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

Advance phase by one sample.

Definition at line 43 of file phase_accumulator.hpp.

Referenced by sbl::dsp::modules::TapeDelay::process(), and sbl::dsp::comp::Lfo< TableSize >::process().

◆ advance() [2/2]

void sbl::dsp::primitives::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 51 of file phase_accumulator.hpp.

◆ phase()

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

◆ increment()

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

Current phase increment.

Definition at line 62 of file phase_accumulator.hpp.

Referenced by sbl::dsp::comp::Lfo< TableSize >::increment().

◆ reset() [1/2]

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

Reset phase to zero.

Definition at line 65 of file phase_accumulator.hpp.

Referenced by sbl::dsp::modules::TapeDelay::reset(), and sbl::dsp::comp::Lfo< TableSize >::sync().

◆ reset() [2/2]

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

Reset phase to a specific value (for sync)

Definition at line 68 of file phase_accumulator.hpp.

References phase().

◆ freq_to_inc()

static uint32_t sbl::dsp::primitives::PhaseAccumulator::freq_to_inc ( float  freq_hz,
float  sr = types::SAMPLE_RATE_F 
)
inlinestatic

Convert frequency in Hz to phase increment.

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

Definition at line 77 of file phase_accumulator.hpp.


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