Skip to main content

PluginDriver

Struct PluginDriver 

Source
pub struct PluginDriver<P>
where P: PluginExport,
{ /* private fields */ }

Implementations§

Source§

impl<P> PluginDriver<P>
where P: PluginExport,

Source

pub fn new() -> PluginDriver<P>

Source

pub fn sample_rate(self, sr: f64) -> PluginDriver<P>

Source

pub fn channels(self, n: usize) -> PluginDriver<P>

Source

pub fn block_size(self, n: usize) -> PluginDriver<P>

Source

pub fn duration(self, d: Duration) -> PluginDriver<P>

Source

pub fn transport(self, t: TransportSpec) -> PluginDriver<P>

Source

pub fn bpm(self, bpm: f64) -> PluginDriver<P>

Source

pub fn playing(self, playing: bool) -> PluginDriver<P>

Source

pub fn input(self, source: InputSource) -> PluginDriver<P>

Source

pub fn script(self, f: impl FnOnce(&mut Script)) -> PluginDriver<P>

Build a script via a closure. Each set_param / note_on / etc. lands at the cursor’s current sample offset; wait_ms advances the cursor.

Source

pub fn set_param(self, id: impl Into<u32>, normalized: f64) -> PluginDriver<P>

Set a parameter to a normalized [0, 1] value before the run starts. Equivalent to a setup(|p| p.params().set_normalized(id, v)) closure but written as one builder call. Multiple .set_param calls compose; they run in declaration order, before the .setup closure (if any).

For automation during a run, use .script(|s| s.set_param(...)), which emits a sample-accurate ParamChange event the plugin processes inline.

Source

pub fn manifest_dir(self, dir: impl Into<PathBuf>) -> PluginDriver<P>

Anchor for state_file relative paths. Defaults to the process CWD; callers from truce-test override it with the test crate’s CARGO_MANIFEST_DIR via the screenshot!-style macro pattern (see truce-test’s wrapping macro).

Source

pub fn setup<F>(self, f: F) -> PluginDriver<P>
where F: FnOnce(&mut P, &SetupContext) + 'static,

Mutate the plugin between init/reset+state-load and the first process block. Use when the test needs more than param tweaks - load arbitrary fields, drive a warmup process() call to populate meters / lookahead, etc.

Composes with state_file (state loads first) and set_param (shortcuts apply first); the closure runs last.

The closure receives a SetupContext with the resolved channel count, sample rate, and block size - exactly what the upcoming process loop will use. Channel resolution happens before setup runs, so a closure that allocates per-channel scratch can size correctly without re-querying P::bus_layouts.

Source

pub fn state_blob(self, bytes: Vec<u8>) -> PluginDriver<P>

Apply an in-memory .pluginstate blob via plugin.load_state(&bytes) at the same lifecycle point as Self::state_file (after init/reset, before set_param shortcuts and setup). Use when the test already has the bytes in hand and doesn’t want a temp file round-trip.

Source

pub fn state_file(self, path: impl Into<PathBuf>) -> PluginDriver<P>

Read a .pluginstate file (the standalone host’s Cmd+S save format) and apply it via plugin.load_state(&bytes) after init/reset and before any set_param overrides / setup closure. Path is resolved relative to manifest_dir, or used as-is if absolute.

I/O is deferred to .run(). The builder records the path; a missing or unreadable file panics at run time with the resolved path in the message, alongside other run-time failures, rather than from inside this method.

Source

pub fn capture_audio(self, on: bool) -> PluginDriver<P>

Source

pub fn capture_meters(self, m: MeterCapture) -> PluginDriver<P>

Source

pub fn capture_output_events(self, on: bool) -> PluginDriver<P>

Source

pub fn capture_block_snapshots(self, on: bool) -> PluginDriver<P>

Source

pub fn run(self) -> DriverResult<P>

Drive the plugin and return the captured result.

§Panics

Panics if a state_file(...) path cannot be read. Plugin init / reset / process / restore_values panics propagate unchanged so the underlying failure surfaces with its original stack rather than being wrapped.

Trait Implementations§

Source§

impl<P> Default for PluginDriver<P>
where P: PluginExport,

Source§

fn default() -> PluginDriver<P>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<P> Freeze for PluginDriver<P>

§

impl<P> !RefUnwindSafe for PluginDriver<P>

§

impl<P> !Send for PluginDriver<P>

§

impl<P> !Sync for PluginDriver<P>

§

impl<P> Unpin for PluginDriver<P>

§

impl<P> UnsafeUnpin for PluginDriver<P>

§

impl<P> !UnwindSafe for PluginDriver<P>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.