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::types::Frame< MaxFrames > Struct Template Reference

Detailed Description

template<uint16_t MaxFrames = 48>
struct sbl::dsp::types::Frame< MaxFrames >

Definition at line 40 of file frame.hpp.

#include <frame.hpp>

Public Member Functions

uint16_t begin (uint16_t requested)
 
void end (int32_t *tx, uint16_t n) const
 
void scale (float gain, uint16_t n)
 
void apply (const float *mod, uint16_t n)
 
void mix_mono (const float *src, float gain, uint16_t n)
 
void mix (const Frame &other, float gain, uint16_t n)
 
void mix_stereo (const float *src_l, const float *src_r, float gain, uint16_t n)
 
void tap (float *dst_l, float *dst_r, uint16_t n) const
 
void clear (uint16_t n)
 

Public Attributes

float left [MaxFrames]
 
float right [MaxFrames]
 

Member Function Documentation

◆ begin()

template<uint16_t MaxFrames = 48>
uint16_t sbl::dsp::types::Frame< MaxFrames >::begin ( uint16_t  requested)
inline

Begin a processing block: clamp frame count and zero buffers.

Call this at the top of every audio callback. Returns the actual frame count to use (clamped to MaxFrames).

Parameters
requestedFrame count from DMA callback
Returns
Actual frame count (min of requested and MaxFrames)

Definition at line 51 of file frame.hpp.

References sbl::dsp::types::Frame< MaxFrames >::left, and sbl::dsp::types::Frame< MaxFrames >::right.

◆ end()

template<uint16_t MaxFrames = 48>
void sbl::dsp::types::Frame< MaxFrames >::end ( int32_t *  tx,
uint16_t  n 
) const
inline

Finalize block: float → int32 stereo interleave to DMA tx buffer.

This is the DMA boundary — NaN guard, clamp to [-1.0, 1.0], and 24-bit scaling all happen inside interleave_from_float().

Parameters
txDMA transmit buffer (interleaved stereo int32)
nFrame count

Definition at line 67 of file frame.hpp.

References sbl::dsp::types::interleave_from_float(), sbl::dsp::types::Frame< MaxFrames >::left, and sbl::dsp::types::Frame< MaxFrames >::right.

◆ scale()

template<uint16_t MaxFrames = 48>
void sbl::dsp::types::Frame< MaxFrames >::scale ( float  gain,
uint16_t  n 
)
inline

Scale both channels by a constant gain.

Use for headroom management (e.g., 1/sqrt(N) for N summed voices).

Parameters
gainGain factor
nFrame count

Definition at line 77 of file frame.hpp.

References sbl::dsp::types::Frame< MaxFrames >::left, and sbl::dsp::types::Frame< MaxFrames >::right.

◆ apply()

template<uint16_t MaxFrames = 48>
void sbl::dsp::types::Frame< MaxFrames >::apply ( const float *  mod,
uint16_t  n 
)
inline

Apply per-sample modulation to both channels (stereo VCA).

Multiplies both L and R by a control signal — typically an envelope output [0.0, 1.0].

Parameters
modControl signal buffer (e.g., envelope output)
nFrame count

Definition at line 91 of file frame.hpp.

References sbl::dsp::types::Frame< MaxFrames >::left, and sbl::dsp::types::Frame< MaxFrames >::right.

◆ mix_mono()

template<uint16_t MaxFrames = 48>
void sbl::dsp::types::Frame< MaxFrames >::mix_mono ( const float *  src,
float  gain,
uint16_t  n 
)
inline

Mix a mono source into both channels at a given gain.

Adds src * gain to both L and R. Use for mixing a mono sub-voice into a stereo frame (e.g., bass at -6 dB = gain 0.5).

Parameters
srcMono source buffer
gainMix gain (e.g., 0.5 for -6 dB)
nFrame count

Definition at line 106 of file frame.hpp.

References sbl::dsp::types::Frame< MaxFrames >::left, and sbl::dsp::types::Frame< MaxFrames >::right.

◆ mix()

template<uint16_t MaxFrames = 48>
void sbl::dsp::types::Frame< MaxFrames >::mix ( const Frame< MaxFrames > &  other,
float  gain,
uint16_t  n 
)
inline

Mix another stereo frame into this one at a given gain.

Parameters
otherSource frame
gainMix gain
nFrame count

Definition at line 119 of file frame.hpp.

References sbl::dsp::types::Frame< MaxFrames >::left, and sbl::dsp::types::Frame< MaxFrames >::right.

◆ mix_stereo()

template<uint16_t MaxFrames = 48>
void sbl::dsp::types::Frame< MaxFrames >::mix_stereo ( const float *  src_l,
const float *  src_r,
float  gain,
uint16_t  n 
)
inline

Mix separate stereo buffers into this frame at a given gain.

Parameters
src_lLeft source buffer
src_rRight source buffer
gainMix gain
nFrame count

Definition at line 132 of file frame.hpp.

References sbl::dsp::types::Frame< MaxFrames >::left, and sbl::dsp::types::Frame< MaxFrames >::right.

◆ tap()

template<uint16_t MaxFrames = 48>
void sbl::dsp::types::Frame< MaxFrames >::tap ( float *  dst_l,
float *  dst_r,
uint16_t  n 
) const
inline

Snapshot current buffer state into separate L/R buffers.

Use for explicit feedback paths: tap the signal before effects, then mix the tapped (and possibly processed) signal back in on the next block.

Parameters
dst_lDestination left buffer
dst_rDestination right buffer
nFrame count

Definition at line 149 of file frame.hpp.

References sbl::dsp::types::Frame< MaxFrames >::left, and sbl::dsp::types::Frame< MaxFrames >::right.

◆ clear()

template<uint16_t MaxFrames = 48>
void sbl::dsp::types::Frame< MaxFrames >::clear ( uint16_t  n)
inline

Zero both channels.

Parameters
nFrame count

Definition at line 159 of file frame.hpp.

References sbl::dsp::types::Frame< MaxFrames >::left, and sbl::dsp::types::Frame< MaxFrames >::right.

Member Data Documentation

◆ left

◆ right


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