Skip to main content

PluginLogic

Trait PluginLogic 

Source
pub trait PluginLogic: Send + 'static {
Show 13 methods // Required methods fn new() -> Self where Self: Sized; fn reset(&mut self, sample_rate: f64, max_block_size: usize); fn process( &mut self, buffer: &mut AudioBuffer<'_>, events: &EventList, context: &mut ProcessContext<'_>, ) -> ProcessStatus; // Provided methods fn params_mut(&mut self) -> Option<&mut dyn Params> { ... } fn render(&self, _backend: &mut dyn RenderBackend) { ... } fn uses_custom_render(&self) -> bool { ... } fn layout(&self) -> GridLayout { ... } fn hit_test( &self, widgets: &[WidgetRegion], x: f32, y: f32, ) -> Option<usize> { ... } fn save_state(&self) -> Vec<u8> { ... } fn load_state(&mut self, _data: &[u8]) { ... } fn latency(&self) -> u32 { ... } fn tail(&self) -> u32 { ... } fn custom_editor(&self) -> Option<Box<dyn Editor>> { ... }
}
Expand description

The trait for hot-reloadable plugin logic.

Implement this in your logic dylib. The shell loads it via Box<dyn PluginLogic> and delegates audio processing and GUI rendering to it.

All methods use safe Rust types. No unsafe, no #[repr(C)], no raw pointers.

Required Methods§

Source

fn new() -> Self
where Self: Sized,

Create a new instance with default state.

Source

fn reset(&mut self, sample_rate: f64, max_block_size: usize)

Reset for a new sample rate / block size.

Source

fn process( &mut self, buffer: &mut AudioBuffer<'_>, events: &EventList, context: &mut ProcessContext<'_>, ) -> ProcessStatus

Process one block of audio.

Provided Methods§

Source

fn params_mut(&mut self) -> Option<&mut dyn Params>

Return a mutable reference to the plugin’s Params, if it owns one.

If this returns Some, the shell automatically syncs parameter values from host automation events and advances smoothers before each process() call. The developer never calls sync manually.

Return None if the plugin reads params via context.param(id) instead.

Source

fn render(&self, _backend: &mut dyn RenderBackend)

Render the GUI into the backend.

Default: no-op. The shell uses BuiltinEditor with the layout from layout() to draw standard widgets automatically. Override only for custom visuals.

Source

fn uses_custom_render(&self) -> bool

Whether this plugin uses a custom render() implementation. If false (default), the shell uses BuiltinEditor with standard widget drawing from layout().

Source

fn layout(&self) -> GridLayout

Return the widget layout.

Use GridLayout::build() for the layout. Widgets auto-flow left-to-right. Use .cols(n) and .rows(n) for spanning.

Source

fn hit_test(&self, widgets: &[WidgetRegion], x: f32, y: f32) -> Option<usize>

Hit test: which widget (if any) is at (x, y)?

Source

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

Serialize plugin-specific state (DSP state, not params).

Source

fn load_state(&mut self, _data: &[u8])

Restore plugin-specific state.

Source

fn latency(&self) -> u32

Report latency in samples.

Source

fn tail(&self) -> u32

Report tail time in samples.

Source

fn custom_editor(&self) -> Option<Box<dyn Editor>>

Provide a custom editor instead of the built-in widget layout.

Return Some(editor) to use a custom Editor implementation (e.g., truce_egui::EguiEditor). The shell calls this first; if it returns None, the shell falls back to creating a BuiltinEditor from layout().

Implementors§