Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::osc::OscParameterMap Class Reference

#include <osc_parameter_map.hpp>

Public Member Functions

bool set_mapping (std::string_view pattern, pulp::state::ParamID id)
 Bind pattern → parameter over the full normalized range, treating the surface as sending 0..1.
bool set_mapping (std::string_view pattern, pulp::state::ParamID id, OscMapScale scale)
 Bind pattern → parameter through scale.
void arm_learn (pulp::state::ParamID id)
 Arm learn: the next incoming address binds to id over the full range.
void arm_learn (pulp::state::ParamID id, OscMapScale scale)
 Arm learn: the next incoming address binds to id through scale.
void clear (pulp::state::ParamID id)
 Remove every mapping that targets id.
void pump ()
 Drain queued UI commands. Call before dispatching a batch of messages.
template<typename Apply>
void route (std::string_view address, float value, Apply &&apply)
 Route one address / value pair to a caller-supplied sink.
void handle_value (pulp::state::StateStore &store, std::string_view address, float value)
 Route one address / value pair into store from a control thread.
void handle_message (pulp::state::StateStore &store, const Message &msg)
 Route one OSC message, taking its first numeric argument as the value.
bool learn_armed () const
 True while an armed learn is still waiting for an address.
std::size_t mapping_count () const
 Number of installed mappings, up to kMaxMappings; further bindings are dropped.

Static Public Member Functions

static bool pattern_fits (std::string_view pattern)
 True if pattern can be held verbatim in a mapping's fixed-capacity, NUL-terminated storage.
static bool is_wildcard (std::string_view pattern)
 True if pattern uses OSC wildcard syntax and must therefore be matched with address_matches rather than a byte compare.

Static Public Attributes

static constexpr std::size_t kMaxMappings = 64
 Largest number of simultaneous bindings.

Member Function Documentation

◆ arm_learn() [1/2]

void pulp::osc::OscParameterMap::arm_learn ( pulp::state::ParamID id)
inline

Arm learn: the next incoming address binds to id over the full range.

◆ arm_learn() [2/2]

void pulp::osc::OscParameterMap::arm_learn ( pulp::state::ParamID id,
OscMapScale scale )
inline

Arm learn: the next incoming address binds to id through scale.

◆ clear()

void pulp::osc::OscParameterMap::clear ( pulp::state::ParamID id)
inline

Remove every mapping that targets id.

◆ handle_message()

void pulp::osc::OscParameterMap::handle_message ( pulp::state::StateStore & store,
const Message & msg )
inline

Route one OSC message, taking its first numeric argument as the value.

int32 arguments are widened to float; a message whose first argument is missing or non-numeric carries no control value and is ignored entirely — it neither applies a mapping nor consumes an armed learn.

◆ handle_value()

void pulp::osc::OscParameterMap::handle_value ( pulp::state::StateStore & store,
std::string_view address,
float value )
inline

Route one address / value pair into store from a control thread.

◆ is_wildcard()

bool pulp::osc::OscParameterMap::is_wildcard ( std::string_view pattern)
inlinestatic

True if pattern uses OSC wildcard syntax and must therefore be matched with address_matches rather than a byte compare.

◆ learn_armed()

bool pulp::osc::OscParameterMap::learn_armed ( ) const
inline

True while an armed learn is still waiting for an address.

Read on the dispatching thread — arming from the UI is queued, so a UI-thread reader would see the state before pump() applied its own command.

◆ mapping_count()

std::size_t pulp::osc::OscParameterMap::mapping_count ( ) const
inline

Number of installed mappings, up to kMaxMappings; further bindings are dropped.

Visible on the dispatching thread after pump().

◆ pattern_fits()

bool pulp::osc::OscParameterMap::pattern_fits ( std::string_view pattern)
inlinestatic

True if pattern can be held verbatim in a mapping's fixed-capacity, NUL-terminated storage.

set_mapping rejects anything else, and an armed learn ignores an incoming address that does not fit rather than binding a truncated one — a shortened pattern would silently match the wrong addresses. An embedded NUL is rejected for the same reason; a wire-format OSC address cannot contain one.

◆ pump()

void pulp::osc::OscParameterMap::pump ( )
inline

Drain queued UI commands. Call before dispatching a batch of messages.

◆ route()

template<typename Apply>
void pulp::osc::OscParameterMap::route ( std::string_view address,
float value,
Apply && apply )
inline

Route one address / value pair to a caller-supplied sink.

Binds the address if learn is armed, then invokes apply(ParamID, normalized) once per matching mapping, with the value already through that mapping's scale. This is the seam for applying on the audio thread: a processor draining its own OSC queue inside process() passes a sink that calls set_normalized_rt. Routing itself allocates nothing for literal addresses; wildcard patterns go through address_matches, which does not carry that guarantee.

◆ set_mapping() [1/2]

bool pulp::osc::OscParameterMap::set_mapping ( std::string_view pattern,
pulp::state::ParamID id )
inline

Bind pattern → parameter over the full normalized range, treating the surface as sending 0..1.

Returns false if the pattern does not fit.

◆ set_mapping() [2/2]

bool pulp::osc::OscParameterMap::set_mapping ( std::string_view pattern,
pulp::state::ParamID id,
OscMapScale scale )
inline

Bind pattern → parameter through scale.

Returns false if the pattern does not fit (nothing is queued) or if the command queue is full, so a caller can tell a rejected binding from an accepted one.

Member Data Documentation

◆ kMaxMappings

std::size_t pulp::osc::OscParameterMap::kMaxMappings = 64
staticconstexpr

Largest number of simultaneous bindings.


The documentation for this class was generated from the following file: