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§
Sourcefn reset(&mut self, sample_rate: f64, max_block_size: usize)
fn reset(&mut self, sample_rate: f64, max_block_size: usize)
Reset for a new sample rate / block size.
Sourcefn process(
&mut self,
buffer: &mut AudioBuffer<'_>,
events: &EventList,
context: &mut ProcessContext<'_>,
) -> ProcessStatus
fn process( &mut self, buffer: &mut AudioBuffer<'_>, events: &EventList, context: &mut ProcessContext<'_>, ) -> ProcessStatus
Process one block of audio.
Provided Methods§
Sourcefn params_mut(&mut self) -> Option<&mut dyn Params>
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.
Sourcefn render(&self, _backend: &mut dyn RenderBackend)
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.
Sourcefn uses_custom_render(&self) -> bool
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().
Sourcefn layout(&self) -> GridLayout
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.
Sourcefn hit_test(&self, widgets: &[WidgetRegion], x: f32, y: f32) -> Option<usize>
fn hit_test(&self, widgets: &[WidgetRegion], x: f32, y: f32) -> Option<usize>
Hit test: which widget (if any) is at (x, y)?
Sourcefn save_state(&self) -> Vec<u8> ⓘ
fn save_state(&self) -> Vec<u8> ⓘ
Serialize plugin-specific state (DSP state, not params).
Sourcefn load_state(&mut self, _data: &[u8])
fn load_state(&mut self, _data: &[u8])
Restore plugin-specific state.
Sourcefn custom_editor(&self) -> Option<Box<dyn Editor>>
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().