Skip to main content

Crate truce_plugin

Crate truce_plugin 

Source
Expand description

User-facing plugin traits + internal bridge.

This crate is the plugin author’s entry point. The single impl PluginLogic for MyPlugin { ... } block covers both audio-thread DSP and main-thread GUI, with sample precision routed through the prelude (see truce::prelude / truce::prelude64).

truce-plugin depends on truce-gui-types (light: layout, render trait, widget regions) - not the full truce-gui. Plugin authors who supply a custom editor (egui, iced, slint, raw window handle) end up with truce-plugin in their dep tree but not the built-in editor’s tiny-skia + baseview + truce-font stack.

§Three traits, one source of truth

  • PluginLogic - what plugin authors implement for f32-buffer plugins.
  • PluginLogic64 - what plugin authors implement for f64-buffer plugins.
  • PluginLogicCore - generic-over-S trait the format wrappers consume.

The two leaf traits are stamped from one plugin_logic_leaf_trait! macro_rules! definition (further down this file) so their method surfaces stay in lock-step. Each leaf gets a blanket impl that forwards every method to PluginLogicCore<S> with the matching S. Wrappers (StaticShell, HotShell, the format crates) bind on PluginLogicCore<S> and don’t care which leaf the user impl’d.

§What this buys

Plugin authors writing impl PluginLogic for Synth { ... } never name a precision. The truce::prelude64 re-export aliases PluginLogic64 as PluginLogic in the user’s scope, so the same impl header reads the same regardless of which prelude is in use. The <S> token that used to live on the impl header is gone - the prelude carries the precision choice.

Traits§

PluginLogic
The f32-buffer user-facing plugin trait.
PluginLogic64
The f64-buffer user-facing plugin trait. Same surface as PluginLogic but with the audio buffer pinned to f64.
PluginLogicCore
Wrapper-facing plugin trait, generic over the audio sample type.

Functions§

default_hit_test
Default hit test: circular for knobs, rectangular for everything else, skip meters. Used by the leaf traits’ hit_test defaults.