24#ifndef SBL_HW_COMPONENTS_CV_INPUT_HPP_
25#define SBL_HW_COMPONENTS_CV_INPUT_HPP_
99 : filter_(static_cast<uint8_t>(config.smoothing)), raw_(0) {}
102 : filter_(static_cast<uint8_t>(smoothing)), raw_(0) {}
116 void update_dma(
const uint16_t* buffer, uint8_t channel_index) {
117 update(
static_cast<const volatile uint16_t*
>(buffer)[channel_index]);
121 uint16_t
raw()
const {
return raw_; }
138 filter_.
set_shift(
static_cast<uint8_t
>(smoothing));
148 float map(uint16_t counts)
const {
149 float c =
static_cast<float>(counts);
154 return (t < 0.0f) ? 0.0f : (t > 1.0f) ? 1.0f : t;
159 return (b < -1.0f) ? -1.0f : (b > 1.0f) ? 1.0f : b;
171 primitives::math::Ewma filter_;
174 CvConditioning cond_{};
uint16_t update(uint16_t raw)
Feed a new sample and return the smoothed value.
uint16_t value() const
Return current smoothed value without updating.
void set_shift(uint8_t shift)
Change smoothing exponent without resetting filter state.
void reset()
Reset filter state (next update will re-seed)
Electrical description of an analog port — the jack-to-converter circuit.
Exponentially Weighted Moving Average filter.
Smoothing
Smoothing presets for the raw-domain EWMA filter.
@ None
Raw passthrough (no filtering)
@ Medium
alpha=1/8, settles in ~24 samples (pots, knobs)
@ Light
alpha=1/2, settles in ~4 samples (pitch, fast CV)
@ Heavy
alpha=1/32, settles in ~96 samples (noisy sources)
CvMapping
Musical interpretation of the jack — a structural parameter.
@ Unipolar
[0, 1] — full ADC span (default)
@ Bipolar
[-1, 1] — around the conditioned midpoint
@ VOct
su pitch offset — 1 V/oct, 8 octaves per 1.0 su, unclamped
Root namespace for all Sound Byte Libs code.
Conditioning constants — one code-owned home (ADR-011 D2)
float counts_per_volt
Counts per volt (16-bit over ±5 V)
static constexpr CvConditioning from(const sbl::hal::adc::Electrical &e)
float midpoint
Count at 0 V (bipolar conditioning)
bool inverted
Conditioning op-amp inverts (+V → lower count)
float counts_max
Full-scale ADC count.
constexpr float counts_max() const
constexpr uint16_t midpoint() const
Code that reads as 0 V — the bipolar midpoint. Clamps if 0 V is out of range.
bool inverted
+V at the jack reads as a lower code
constexpr float counts_per_volt() const