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
calibration.hpp File Reference

Source calibration: fit, standard, routine. More...

Detailed Description

Source calibration: fit, standard, routine.

A source reads a little off, for example from a divider's tolerance or an op-amp's offset. Calibration measures the source against known references and stores the correction as a line - scale and offset - that the app applies to every later reading.

  • LinearFit: the correction, apply(measured) = measured * scale + offset.
  • fit_points(): least squares over 2..N captured points.
  • VOctStandard: what a reference means in octaves (1 V per octave).
  • PointCalibration: the routine: begin, capture, capture, done.

One shape drives every calibration an app runs - a button calls advance(), another cancel(), and the UI slot polls state() for the LED. The library holds no storage: fit() is POD, and the app writes it wherever it keeps its calibration.

Usage - two-point V/Oct on a 1 V and 3 V reference:

constexpr float REFS[] = {1.0f, 3.0f}; // volts
cal.begin(); // button: start
cal.capture(jack.value()); // button: patch 1 V, capture
cal.capture(jack.value()); // button: patch 3 V, capture -> Done
float pitch = cal.apply(jack.value()); // corrected, from now on
Capture N reference points, then fit.

Loading a stored fit skips the routine entirely: cal.set_fit(saved).

Definition in file calibration.hpp.

#include <cstdint>

Go to the source code of this file.

Classes

struct  sbl::control::LinearFit
 
struct  sbl::control::VOctStandard
 1 V per octave: the library's pitch is octaves (CvMapping::VOct) More...
 
class  sbl::control::PointCalibration< N, Standard >
 Capture N reference points, then fit. More...
 

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs code.
 
namespace  sbl::control
 The control stack: scheduler, event queue, merge, CC mapping, calibration.
 

Enumerations

enum class  sbl::control::CalState : uint8_t { sbl::control::Idle , sbl::control::Capturing , sbl::control::Done , sbl::control::Failed }
 

Functions

bool sbl::control::fit_points (const float *measured, const float *expected, uint8_t n, LinearFit &out)
 Least-squares line through captured points.