Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
sbl::control Namespace Reference

The control stack: scheduler, event queue, merge, CC mapping, calibration. More...

Detailed Description

The control stack: scheduler, event queue, merge, CC mapping, calibration.

Namespaces

namespace  display
 Indicators: RGB LED state and colors.
 
namespace  input
 Inputs: debounce, decoding, smoothing and scaling of raw samples.
 

Classes

struct  Cam
 
struct  CamPitchAxis
 
struct  CcEntry
 One row of a CC map. More...
 
class  CcMapper
 Routes MIDI CCs to app targets through a constexpr table. More...
 
class  Clock
 
class  EventQueue
 Lock-free SPSC event queue from one producing context into the control tick. More...
 
class  Latest
 The last source to move wins. More...
 
struct  LinearFit
 
class  MidiKeys
 
struct  NoCcStore
 
class  PanelReport
 The values of the parameters a panel shows, as #PANEL lines. More...
 
class  ParamBank
 
class  ParamEcho
 
class  Pickup
 A takeover source must reach the held value before it captures it. More...
 
class  PointCalibration
 Capture N reference points, then fit. More...
 
class  Priority
 The highest-priority active source wins. More...
 
class  Scheduler
 Divider slots over one base period, run in a fixed stage order. More...
 
class  Selector
 
class  Snapshot
 Double-buffered struct with a sequence number, for one writer and one reader. More...
 
struct  SystemTimerSource
 
struct  VOctStandard
 1 V per octave: the library's pitch is octaves (CvMapping::VOct) More...
 

Typedefs

using CcCurve = Cam
 
using SubscriberFn = void(*)(void *context, uint32_t elapsed_ticks)
 
using TargetClock = Clock< SystemTimerSource >
 

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 }
 

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 (const float *table, uint16_t size, const float *in, float *out, uint16_t frames)
 
float cam_evaluate (const Cam &cam, float input)
 
void cam_evaluate (const Cam &cam, const float *in, float *out, uint16_t frames)
 
template<size_t N>
float cam_evaluate (const float(&table)[N], float input)
 
template<typename Target , size_t N, size_t COUNT>
 PanelReport (const Target(&)[N], const char *const (&)[COUNT]) -> PanelReport< Target, N >
 
constexpr uint32_t ticks_to_us (uint64_t ticks, uint32_t ticks_per_second)
 
template<typename Output , typename Sched >
void write_scheduler_report (const Sched &scheduler, uint8_t slot, uint32_t ticks_per_second)
 
constexpr uint8_t select (float control, uint8_t positions)
 

Variables

constexpr size_t CAM_GUARD_POINTS = 1
 
constexpr CcCurve CC_LINEAR {}
 
constexpr uint8_t ANY_CHANNEL = 0xFF
 
constexpr uint8_t STAGE_COUNT = 4
 

Typedef Documentation

◆ CcCurve

using sbl::control::CcCurve = typedef Cam

A row's curve: a Cam, or linear when it has no table.

Definition at line 18 of file cc_mapper.hpp.

◆ SubscriberFn

using sbl::control::SubscriberFn = typedef void (*)(void* context, uint32_t elapsed_ticks)

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

Definition at line 25 of file scheduler.hpp.

◆ TargetClock

Definition at line 27 of file target_clock.hpp.

Enumeration Type Documentation

◆ CalState

enum class sbl::control::CalState : uint8_t
strong

Where a PointCalibration is in its routine.

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 116 of file calibration.hpp.

◆ CcFlags

enum class sbl::control::CcFlags : uint8_t
strong

Row flags.

Enumerator
None 

7-bit: cc alone

Paired14 

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

Definition at line 30 of file cc_mapper.hpp.

◆ Stage

enum class sbl::control::Stage : uint8_t
strong

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

Definition at line 15 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 65 of file calibration.hpp.

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

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

◆ cam_evaluate() [1/5]

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 65 of file cam.hpp.

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

◆ cam_evaluate() [2/5]

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

Evaluate a cam table across a buffer.

Definition at line 74 of file cam.hpp.

References cam_evaluate().

◆ cam_evaluate() [3/5]

float sbl::control::cam_evaluate ( const Cam &  cam,
float  input 
)
inline

Evaluate a Cam at a single input position, clamped to [0, 1].

Definition at line 81 of file cam.hpp.

References cam_evaluate().

◆ cam_evaluate() [4/5]

void sbl::control::cam_evaluate ( const Cam &  cam,
const float *  in,
float *  out,
uint16_t  frames 
)
inline

Evaluate a Cam across a buffer.

Definition at line 84 of file cam.hpp.

References cam_evaluate().

◆ cam_evaluate() [5/5]

template<size_t N>
float sbl::control::cam_evaluate ( const float(&)  table[N],
float  input 
)
inline

Evaluate a LUTE table, its size read from the array's type.

Definition at line 90 of file cam.hpp.

References cam_evaluate(), and sbl::control::Cam::of().

◆ ticks_to_us()

constexpr uint32_t sbl::control::ticks_to_us ( uint64_t  ticks,
uint32_t  ticks_per_second 
)
inlineconstexpr

A count of ticks in microseconds, at a tick rate in ticks per second.

Definition at line 25 of file scheduler_report.hpp.

Referenced by write_scheduler_report().

◆ write_scheduler_report()

template<typename Output , typename Sched >
void sbl::control::write_scheduler_report ( const Sched &  scheduler,
uint8_t  slot,
uint32_t  ticks_per_second 
)

Write a slot's late runs, skipped periods and worst delay as a #SYS.SCHED line.

Parameters
ticks_per_secondthe rate of the clock the scheduler runs on

Definition at line 35 of file scheduler_report.hpp.

References sbl::log::TaggedLine< SIZE >::field(), and ticks_to_us().

◆ select()

constexpr uint8_t sbl::control::select ( float  control,
uint8_t  positions 
)
inlineconstexpr

The position, 0 to positions - 1, of a control in [0, 1], by equal shares of its travel. Values outside [0, 1] and NaN land on an end position.

Definition at line 29 of file selector.hpp.

Referenced by sbl::control::Selector< Positions >::update().

Variable Documentation

◆ CAM_GUARD_POINTS

constexpr size_t sbl::control::CAM_GUARD_POINTS = 1
inlineconstexpr

The guard points a cam table carries after its entries (LUTE's guard_points for a cam).

Definition at line 40 of file cam.hpp.

Referenced by sbl::control::Cam::of().

◆ CC_LINEAR

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

A curve with no table: the row's output is its input.

Definition at line 27 of file cc_mapper.hpp.

◆ ANY_CHANNEL

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

Row channel that matches every channel.

Definition at line 36 of file cc_mapper.hpp.

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

◆ STAGE_COUNT

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

number of Stage values

Definition at line 22 of file scheduler.hpp.

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