|
| | Binding ()=default |
| | Binding (StateStore &store, ParamID param_id) |
| | Bind to a specific parameter in a store.
|
| float | get () const |
| | Read the parameter's current value.
|
| void | set (float value) |
| | Write a new value. Fires change callbacks if the value actually changed.
|
| float | get_normalized () const |
| | Read the parameter's value mapped to [0, 1].
|
| void | set_normalized (float normalized) |
| | Write from a normalized [0, 1] value. Fires change callbacks if changed.
|
| void | begin_gesture () |
| | Notify the host that a user gesture (e.g., mouse drag) has begun.
|
| void | end_gesture () |
| | Notify the host that the current gesture has ended.
|
| void | set_from_background (float value) |
| | Perform a complete parameter gesture (begin → set → end) from ANY thread — the thread-safe entry point for background writers such as a MIDI-learn engine driving a mapped parameter from a timer thread.
|
| void | set_edit_history (state::EditHistory *h) |
| | Attach an EditHistory for undo support. Optional — null by default.
|
| state::EditHistory * | edit_history () const |
| const ParamInfo * | info () const |
| | Get the immutable metadata for the bound parameter.
|
| ParamID | id () const |
| | The ID of the bound parameter.
|
| void | on_change (ChangeCallback callback) |
| | Register a callback that fires when the value changes via set() or poll().
|
| bool | poll () |
| | Check whether the parameter was changed externally (e.g., host automation).
|
| void | reset () |
| | Reset the parameter to its default value and fire change callbacks.
|
| bool | is_bound () const |
| | True if this Binding is associated with a StateStore.
|
Reactive binding between a UI widget and a StateStore parameter.
Binding wraps a single parameter with value access, gesture tracking, and change notification. The typical usage in a UI widget:
Binding gain_binding(store, kGainParamID);
gain_binding.on_change([&](float v) { knob.repaint(); });
gain_binding.begin_gesture();
gain_binding.set_normalized(knob_position);
gain_binding.end_gesture();
gain_binding.poll();
- Note
- Thread safety: get/set/get_normalized/set_normalized go through StateStore's atomics and are safe to call from any thread; change callbacks fire on the thread that calls set() or poll(). The GESTURE entry points (begin_gesture/end_gesture) and the EditHistory they drive are main-thread only — they forward to the host's undo-grouping calls (VST3 beginEdit / AU parameter-change gesture / CLAP gesture events) and mutate this Binding's non-atomic gesture state. A background writer (e.g. a MIDI-learn engine on a timer thread) must NOT call them directly; use
set_from_background(), which marshals a full begin→set→end gesture onto the host main thread.