Skip to main content

EditorBridge

Trait EditorBridge 

Source
pub trait EditorBridge: Send + Sync {
    // Required methods
    fn begin_edit(&self, id: u32);
    fn set_param(&self, id: u32, normalized: f64);
    fn end_edit(&self, id: u32);
    fn request_resize(&self, w: u32, h: u32) -> bool;
    fn get_param(&self, id: u32) -> f64;
    fn get_param_plain(&self, id: u32) -> f64;
    fn format_param(&self, id: u32) -> String;
    fn get_meter(&self, id: u32) -> f32;
    fn get_state(&self) -> Vec<u8> ;
    fn set_state(&self, data: Vec<u8>);
    fn transport(&self) -> Option<TransportInfo>;

    // Provided method
    fn format_param_into(&self, id: u32, out: &mut String) { ... }
}
Expand description

Bridge between the editor and the host / plugin. Format wrappers (CLAP / VST3 / VST2 / AU / AAX / LV2) implement this trait - or build a ClosureBridge from per-method closures - and pass an Arc<dyn EditorBridge> to the editor through PluginContext.

Editors call into the bridge for everything they can’t do directly: starting / ending an automation gesture, reading or writing parameters in normalized or plain form, requesting a window resize, exchanging custom state, sampling the host’s transport. Implementations carry whatever per-format pointers the work needs (clap_host*, AEffect*, an Arc<P> for the param store, etc.).

Send + Sync is required so editors can clone the Arc<dyn EditorBridge> and hand it to UI worker threads or background animation timers without forcing every implementor to rederive thread-safety bounds.

Required Methods§

Source

fn begin_edit(&self, id: u32)

Start an automation gesture for id. Hosts that show “touched” state in the automation lane use this to render the in-progress edit.

Source

fn set_param(&self, id: u32, normalized: f64)

Set parameter id to normalized (clamped to 0.0..=1.0). Format wrappers usually plumb this through both the plugin’s own param store and the host’s automation channel.

Source

fn end_edit(&self, id: u32)

End the automation gesture started by Self::begin_edit.

Source

fn request_resize(&self, w: u32, h: u32) -> bool

Ask the host to resize the editor window to (w, h) logical points. Returns true if the host accepted the request.

Source

fn get_param(&self, id: u32) -> f64

Read the parameter’s current normalized value from the plugin (host→GUI sync path).

Source

fn get_param_plain(&self, id: u32) -> f64

Read the parameter’s current plain (denormalized) value.

Source

fn format_param(&self, id: u32) -> String

Format the parameter’s current value as a display string, applying the plugin’s format_value impl + unit suffix.

Source

fn get_meter(&self, id: u32) -> f32

Read a meter value (0.0–1.0) by meter ID. Returns 0.0 if the meter ID isn’t registered.

Source

fn get_state(&self) -> Vec<u8>

Read the plugin’s custom state (everything outside the parameter system). Returns an empty Vec when the plugin has no custom state.

Source

fn set_state(&self, data: Vec<u8>)

Write custom state back to the plugin (calls load_state()).

Source

fn transport(&self) -> Option<TransportInfo>

Most-recently-reported host transport state, or None if the host does not expose transport to plugin editors or the plugin has not yet received a process block.

Format wrappers populate a shared TransportSlot from their process callback; this method reads from it.

Provided Methods§

Source

fn format_param_into(&self, id: u32, out: &mut String)

Format into a caller-provided buffer instead of returning a fresh String. The default impl calls Self::format_param and copies, so the bridge-internal allocation still happens; the win for the caller is that the out buffer’s capacity is reused across calls (e.g. ParamCache::sync polls one label per changed param per frame and would otherwise drop+reallocate the cached String slot every time). Bridges that produce the formatted string from raw value bytes can override to drop the internal allocation too.

Implementors§