6#ifndef SBL_CONTROL_CC_MAPPER_HPP_
7#define SBL_CONTROL_CC_MAPPER_HPP_
23 static float cc(uint8_t) {
return 0.0f; }
42template<
typename Target>
84template<
typename Target>
88 using Sink = void (*)(
void* context, Target target,
float value);
98 : table_(table), count_(N), sink_(sink), context_(context) {}
112 template<
typename Store>
113 uint8_t
on_cc(uint8_t channel, uint8_t cc, uint8_t value,
const Store& store)
const {
115 for (
size_t i = 0; i < count_; ++i) {
123 const uint8_t lsb_cc =
static_cast<uint8_t
>(e.
cc + 32);
124 if (cc != e.
cc && cc != lsb_cc) {
129 t =
static_cast<float>((
static_cast<uint16_t
>(msb) << 7) | lsb) * (1.0f / 16383.0f);
134 t =
static_cast<float>(value) * (1.0f / 127.0f);
138 sink_(context_, e.
target, v);
151 uint8_t
on_cc(uint8_t channel, uint8_t cc, uint8_t value)
const {
return on_cc(channel, cc, value,
NoCcStore{}); }
154 size_t size()
const {
return count_; }
Routes MIDI CCs to app targets through a constexpr table.
void(*)(void *context, Target target, float value) Sink
The app's write into the merge layer: the context pointer, the row's target and the curve output.
size_t size() const
Rows in the map.
CcMapper(const CcEntry< Target >(&table)[N], Sink sink, void *context)
Construct over a table.
uint8_t on_cc(uint8_t channel, uint8_t cc, uint8_t value) const
Route one ControlChange event through a map with no 14-bit rows.
const CcEntry< Target > * begin() const
The first row, for a walk over them (an echo of the targets' values, a listing)
const CcEntry< Target > * end() const
One past the last row.
uint8_t on_cc(uint8_t channel, uint8_t cc, uint8_t value, const Store &store) const
Route one ControlChange event.
The control stack: scheduler, event queue, merge, CC mapping, calibration.
constexpr CcCurve CC_LINEAR
float cam_evaluate(const float *table, uint16_t size, float input)
constexpr uint8_t ANY_CHANNEL
constexpr uint8_t to_7bit(float value)
static float cc(uint8_t)
Always 0.