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::control Namespace Reference

Control Stack v2: scheduler, event queue, merge, CC mapping, calibration, presets. More...

Detailed Description

Control Stack v2: scheduler, event queue, merge, CC mapping, calibration, presets.

Classes

struct  CcCurve
 A LUTE cam table (size + 1 entries, guard point included), or linear when table is null. More...
 
struct  CcEntry
 
class  CcMapper
 
class  EventQueue
 
class  Latest
 The last source to move wins. More...
 
struct  LinearFit
 measured su → corrected su. Identity until a fit is computed or loaded. More...
 
class  Pickup
 A takeover source must reach the held value before it captures it. More...
 
class  PointCalibration
 Capture N reference points, then fit. More...
 
struct  Preset
 A named set of controller values, selected by MIDI program number. More...
 
struct  PresetCc
 One controller value in a preset. More...
 
class  Priority
 The highest-priority active source wins. More...
 
class  Scheduler
 
struct  VOctStandard
 1 V per octave in SBL pitch su (1.0 su spans 8 octaves) More...
 

Typedefs

using TickFn = void(*)(void *context, uint32_t elapsed_samples)
 Subscriber callback: context pointer and samples elapsed since its slot last ran.
 

Enumerations

enum class  CalState : uint8_t { Idle , Capturing , Done , Failed }
 
enum class  CcFlags : uint8_t { None = 0 , Paired14 = 1 << 0 }
 
enum class  Stage : uint8_t { Drain , Update , Merge , Publish }
 Intra-tick order. Every due subscriber of a stage runs before any of the next. More...
 

Functions

bool fit_points (const float *measured, const float *expected, uint8_t n, LinearFit &out)
 Least-squares line through captured points.
 
float cam_evaluate (const float *table, uint16_t size, float input)
 
void cam_evaluate_block (const float *table, uint16_t size, const float *in, float *out, uint16_t n)
 Evaluate a cam table across a buffer.
 
const Preset * find_preset (const Preset *presets, uint8_t count, uint8_t program)
 The preset a program selects, or nullptr if the table has none.
 
template<typename Sink >
void apply_preset (const Preset &preset, Sink &&sink)
 Send a preset's values wherever a controller's would go.
 

Variables

constexpr CcCurve kCcLinear {}
 
constexpr uint8_t kAnyChannel = 0xFF
 Row channel that matches every channel.
 
constexpr uint8_t kStageCount = 4
 

Typedef Documentation

◆ TickFn

Subscriber callback: context pointer and samples elapsed since its slot last ran.

Definition at line 52 of file scheduler.hpp.

Enumeration Type Documentation

◆ CalState

Enumerator
Idle 

not calibrating; fit() is whatever was loaded or measured

Capturing 

waiting for the next reference point

Done 

a fit was computed; accept() or cancel()

Failed 

the points were degenerate; cancel() to restore

Definition at line 96 of file calibration.hpp.

◆ CcFlags

Enumerator
None 
Paired14 

14-bit: cc is the MSB (0–31), cc + 32 the LSB

Definition at line 46 of file cc_mapper.hpp.

◆ Stage

Intra-tick order. Every due subscriber of a stage runs before any of the next.

Enumerator
Drain 
Update 
Merge 
Publish 

Definition at line 42 of file scheduler.hpp.

Function Documentation

◆ fit_points()

bool sbl::control::fit_points ( const float *  measured,
const float *  expected,
uint8_t  n,
LinearFit &  out 
)
inline

Least-squares line through captured points.

Parameters
measuredwhat the source read at each reference
expectedwhat it should have read (the standard's answer)
n2 or more
outthe fit, untouched when the points are degenerate
Returns
false if n < 2 or every measurement is the same value

Definition at line 55 of file calibration.hpp.

References sbl::control::LinearFit::offset, and sbl::control::LinearFit::scale.

Referenced by sbl::control::PointCalibration< N, Standard >::capture().

◆ cam_evaluate()

float sbl::control::cam_evaluate ( const float *  table,
uint16_t  size,
float  input 
)
inline

Evaluate a cam table at a single input position. Input clamped to [0, 1]. Returns linearly interpolated table value. Table must have at least 1 guard point (size + 1 entries).

Definition at line 27 of file cam.hpp.

Referenced by cam_evaluate_block(), and sbl::control::CcMapper< Target >::on_cc().

◆ cam_evaluate_block()

void sbl::control::cam_evaluate_block ( const float *  table,
uint16_t  size,
const float *  in,
float *  out,
uint16_t  n 
)
inline

Evaluate a cam table across a buffer.

Definition at line 36 of file cam.hpp.

References cam_evaluate().

◆ find_preset()

const Preset * sbl::control::find_preset ( const Preset *  presets,
uint8_t  count,
uint8_t  program 
)
inline

The preset a program selects, or nullptr if the table has none.

Definition at line 48 of file preset.hpp.

◆ apply_preset()

template<typename Sink >
void sbl::control::apply_preset ( const Preset &  preset,
Sink &&  sink 
)
inline

Send a preset's values wherever a controller's would go.

Definition at line 58 of file preset.hpp.

References sbl::control::CcEntry< Target >::cc.

Variable Documentation

◆ kCcLinear

constexpr CcCurve sbl::control::kCcLinear {}
inlineconstexpr

Definition at line 44 of file cc_mapper.hpp.

◆ kAnyChannel

constexpr uint8_t sbl::control::kAnyChannel = 0xFF
inlineconstexpr

Row channel that matches every channel.

Definition at line 52 of file cc_mapper.hpp.

Referenced by sbl::control::CcMapper< Target >::on_cc().

◆ kStageCount

constexpr uint8_t sbl::control::kStageCount = 4
inlineconstexpr

Definition at line 49 of file scheduler.hpp.

Referenced by sbl::control::Scheduler< Slots, Capacity >::run().