The default ParamPort, over a processor's StateStore. More...
#include <editor_host.hpp>
Public Types | |
| using | Listener = std::function<void(state::ParamID id, float plain_value)> |
Public Member Functions | |
| StateStoreParamPort (state::StateStore &store) | |
| ~StateStoreParamPort () override | |
| StateStoreParamPort (const StateStoreParamPort &)=delete | |
| StateStoreParamPort & | operator= (const StateStoreParamPort &)=delete |
| std::span< const state::ParamInfo > | params () const override |
| Every parameter, in declaration order. | |
| const state::ParamInfo * | info (state::ParamID id) const override |
| One parameter's description, or null for an unknown id. Any thread. | |
| float | get (state::ParamID id) const override |
| The current plain value (the host's automation included). Any thread. | |
| void | begin (state::ParamID id) override |
| Open a gesture on id. | |
| void | set (state::ParamID id, float plain_value) override |
| Write a plain value. | |
| void | end (state::ParamID id) override |
| Close a gesture this caller opened. | |
| ParamSubscription | add_listener (Listener listener) override |
| Be told about every change to any parameter, whoever made it (this editor, another editor, host automation, a state restore). | |
| void | release_all () |
| Close every gesture this port still holds, reporting each end to the host. | |
| void | disconnect () |
| Release every gesture, remove every listener this port registered, and let go of the store, which may be destroyed once this returns. | |
| bool | connected () const |
| False after disconnect(). | |
| int | open_gestures (state::ParamID id) const |
| Gestures this port currently holds open on id (0 when none). | |
| float | get_normalized (state::ParamID id) const |
| get(id) mapped to [0, 1] through the parameter's range (0 for an unknown id). | |
| void | set_normalized (state::ParamID id, float normalized) |
| set(id, …) from a [0, 1] value through the parameter's range. | |
The default ParamPort, over a processor's StateStore.
Gestures use the store's shared gesture leases (StateStore::acquire_gesture / release_gesture), so any number of ports and editors over one store open and close the host gesture exactly once per overlapping edit. Writes use StateStore::set_value, the path the format adapters already observe and report to the host as editor edits.
One port may be shared by several editors. Giving each editor its own port over the same store also isolates teardown: destroying a port (or calling release_all()) closes only the gestures that port opened, so closing one window mid-drag never ends another window's gesture.
Main thread only, apart from info(), params(), get() and disconnect(). The store must outlive the port or be disconnected from it first: after disconnect() returns the port holds no reference to the store and calls into it no more, so an editor that outlives the store (its plug-in instance disposed while a host still holds the editor's window) never reaches it. get(), begin(), set(), end() and add_listener() are then refused, and the port's subscriptions are already removed.
params() and info() describe the parameters as they were when the port was made. The span and pointers they return stay valid for the port's lifetime, connected or not, so an editor may keep them.
|
inherited |
|
explicit |
|
override |
|
delete |
|
nodiscardoverridevirtual |
Be told about every change to any parameter, whoever made it (this editor, another editor, host automation, a state restore).
Delivered on the main thread with the plain value; changes from the audio thread are coalesced to the latest value.
Implements pulp::format::ParamPort.
|
overridevirtual |
Open a gesture on id.
Implements pulp::format::ParamPort.
| bool pulp::format::StateStoreParamPort::connected | ( | ) | const |
False after disconnect().
| void pulp::format::StateStoreParamPort::disconnect | ( | ) |
Release every gesture, remove every listener this port registered, and let go of the store, which may be destroyed once this returns.
Waits for a store call already in progress on another thread to finish; the port never calls the store while holding its own lock. Any thread; idempotent; never from inside one of this port's own store callbacks.
Residual risk, accepted: that wait hangs a host that disconnects (for example by disposing of the plug-in) off the main thread while holding a lock its own main-thread parameter callback needs. Not waiting would let that callback reach the departing instance after it is gone. A wait longer than about a second is logged once, so such a hang can be told apart.
|
overridevirtual |
Close a gesture this caller opened.
An end without a matching begin is ignored.
Implements pulp::format::ParamPort.
|
overridevirtual |
The current plain value (the host's automation included). Any thread.
Implements pulp::format::ParamPort.
|
inlineinherited |
get(id) mapped to [0, 1] through the parameter's range (0 for an unknown id).
|
overridevirtual |
One parameter's description, or null for an unknown id. Any thread.
Implements pulp::format::ParamPort.
| int pulp::format::StateStoreParamPort::open_gestures | ( | state::ParamID | id | ) | const |
Gestures this port currently holds open on id (0 when none).
|
delete |
|
overridevirtual |
Every parameter, in declaration order.
Implements pulp::format::ParamPort.
| void pulp::format::StateStoreParamPort::release_all | ( | ) |
Close every gesture this port still holds, reporting each end to the host.
Called by the destructor; a host calls it when the editor using the port goes away mid-gesture.
|
overridevirtual |
Write a plain value.
Inside a gesture this is one step of it; outside, a complete one-shot edit.
Implements pulp::format::ParamPort.
|
inlineinherited |
set(id, …) from a [0, 1] value through the parameter's range.
Does nothing for an unknown id.