Sound Byte Libs 29c5ff3
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
sbl::signal::Frame< MaxFrames > Struct Template Reference

#include <frame.hpp>

Collaboration diagram for sbl::signal::Frame< MaxFrames >:

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]
 

Detailed Description

template<uint16_t MaxFrames = 48>
struct sbl::signal::Frame< MaxFrames >

Definition at line 39 of file frame.hpp.

Member Function Documentation

◆ apply()

template<uint16_t MaxFrames = 48>
void sbl::signal::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 90 of file frame.hpp.

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

◆ begin()

template<uint16_t MaxFrames = 48>
uint16_t sbl::signal::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 50 of file frame.hpp.

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

◆ clear()

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

Zero both channels.

Parameters
nFrame count

Definition at line 158 of file frame.hpp.

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

◆ end()

template<uint16_t MaxFrames = 48>
void sbl::signal::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 66 of file frame.hpp.

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

Here is the call graph for this function:

◆ mix()

template<uint16_t MaxFrames = 48>
void sbl::signal::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 118 of file frame.hpp.

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

◆ mix_mono()

template<uint16_t MaxFrames = 48>
void sbl::signal::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 105 of file frame.hpp.

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

◆ mix_stereo()

template<uint16_t MaxFrames = 48>
void sbl::signal::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 131 of file frame.hpp.

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

◆ scale()

template<uint16_t MaxFrames = 48>
void sbl::signal::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 76 of file frame.hpp.

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

◆ tap()

template<uint16_t MaxFrames = 48>
void sbl::signal::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 148 of file frame.hpp.

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

Member Data Documentation

◆ left

template<uint16_t MaxFrames = 48>
float sbl::signal::Frame< MaxFrames >::left[MaxFrames]

◆ right

template<uint16_t MaxFrames = 48>
float sbl::signal::Frame< MaxFrames >::right[MaxFrames]

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