Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::format::StateStoreParamPort Class Referencefinal

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.

Detailed Description

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.

Member Typedef Documentation

◆ Listener

using pulp::format::ParamPort::Listener = std::function<void(state::ParamID id, float plain_value)>
inherited

Constructor & Destructor Documentation

◆ StateStoreParamPort() [1/2]

pulp::format::StateStoreParamPort::StateStoreParamPort ( state::StateStore & store)
explicit

◆ ~StateStoreParamPort()

pulp::format::StateStoreParamPort::~StateStoreParamPort ( )
override

◆ StateStoreParamPort() [2/2]

pulp::format::StateStoreParamPort::StateStoreParamPort ( const StateStoreParamPort & )
delete

Member Function Documentation

◆ add_listener()

ParamSubscription pulp::format::StateStoreParamPort::add_listener ( Listener listener)
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.

◆ begin()

void pulp::format::StateStoreParamPort::begin ( state::ParamID id)
overridevirtual

Open a gesture on id.

Implements pulp::format::ParamPort.

◆ connected()

bool pulp::format::StateStoreParamPort::connected ( ) const

False after disconnect().

◆ 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.

◆ end()

void pulp::format::StateStoreParamPort::end ( state::ParamID id)
overridevirtual

Close a gesture this caller opened.

An end without a matching begin is ignored.

Implements pulp::format::ParamPort.

◆ get()

float pulp::format::StateStoreParamPort::get ( state::ParamID id) const
overridevirtual

The current plain value (the host's automation included). Any thread.

Implements pulp::format::ParamPort.

◆ get_normalized()

float pulp::format::ParamPort::get_normalized ( state::ParamID id) const
inlineinherited

get(id) mapped to [0, 1] through the parameter's range (0 for an unknown id).

◆ info()

const state::ParamInfo * pulp::format::StateStoreParamPort::info ( state::ParamID id) const
overridevirtual

One parameter's description, or null for an unknown id. Any thread.

Implements pulp::format::ParamPort.

◆ open_gestures()

int pulp::format::StateStoreParamPort::open_gestures ( state::ParamID id) const

Gestures this port currently holds open on id (0 when none).

◆ operator=()

StateStoreParamPort & pulp::format::StateStoreParamPort::operator= ( const StateStoreParamPort & )
delete

◆ params()

std::span< const state::ParamInfo > pulp::format::StateStoreParamPort::params ( ) const
overridevirtual

Every parameter, in declaration order.

Implements pulp::format::ParamPort.

◆ release_all()

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.

◆ set()

void pulp::format::StateStoreParamPort::set ( state::ParamID id,
float plain_value )
overridevirtual

Write a plain value.

Inside a gesture this is one step of it; outside, a complete one-shot edit.

Implements pulp::format::ParamPort.

◆ set_normalized()

void pulp::format::ParamPort::set_normalized ( state::ParamID id,
float normalized )
inlineinherited

set(id, …) from a [0, 1] value through the parameter's range.

Does nothing for an unknown id.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/format/include/pulp/format/editor_host.hpp