17#ifndef SBL_DSP_PRIMITIVES_PHASE_ACCUMULATOR_HPP_
18#define SBL_DSP_PRIMITIVES_PHASE_ACCUMULATOR_HPP_
51 void advance(uint16_t frames, uint32_t* out) {
52 for (uint16_t i = 0; i < frames; ++i) {
59 uint32_t
phase()
const {
return phase_; }
78 return static_cast<uint32_t
>((freq_hz / sr) * PHASE_ACCUMULATOR_RANGE);
83 uint32_t increment_ = 0;
void reset(uint32_t phase)
Reset phase to a specific value (for sync)
void set_increment(uint32_t inc)
Set the phase increment per sample.
static uint32_t freq_to_inc(float freq_hz, float sr=types::SAMPLE_RATE_F)
Convert frequency in Hz to phase increment.
void reset()
Reset phase to zero.
uint32_t phase() const
Current phase value.
void advance(uint16_t frames, uint32_t *out)
Advance and fill a buffer with per-sample phases.
uint32_t increment() const
Current phase increment.
void advance()
Advance phase by one sample.
The numbers every layer reaches for.
Fixed-point constants and audio sample types.
constexpr float PHASE_ACCUMULATOR_RANGE
The phase accumulator's full range: uint32_t [0, 2^32) is one cycle.
Stateful, single-concern building blocks.