Skip to main content

Script

Struct Script 

Source
pub struct Script { /* private fields */ }
Expand description

Sample-accurate sequence of events fed to the plugin during a run. Cursor advances via wait_ms / wait_samples; events land at the current cursor position.

Implementations§

Source§

impl Script

Source

pub fn note_on(&mut self, note: u8, velocity: f32)

Source

pub fn note_off(&mut self, note: u8)

Source

pub fn cc(&mut self, cc: u8, value: f32)

Source

pub fn pitch_bend(&mut self, normalized: f32)

Source

pub fn channel_pressure(&mut self, value: f32)

Source

pub fn set_param(&mut self, id: impl Into<u32>, normalized: f64)

Set a parameter to a normalized [0.0, 1.0] value, sample- accurate at the cursor’s offset. The plugin sees a ParamChange event in its event list - same delivery path CLAP / VST3 / AU automation lanes use.

Source

pub fn raw(&mut self, body: EventBody)

Push an arbitrary EventBody at the current cursor - escape hatch for events Script doesn’t have a typed helper for.

Source

pub fn wait_ms(&mut self, ms: u64)

Advance the cursor by ms milliseconds at the run’s sample rate. Resolves correctly only after Script::sample_rate is filled in by PluginDriver::run - call sites can rely on the driver wiring it before scanning the script.

wait_ms(0) is almost always a copy-paste artifact and trips a debug_assert in dev builds. If you genuinely want “schedule the next event at the current cursor”, that’s the implicit default - drop the call. If you want a typed no-op for clarity (e.g. mirroring a user-supplied delay variable that can be zero), use wait_samples(0) which doesn’t trip the assertion.

Source

pub fn wait_samples(&mut self, n: usize)

Advance the cursor by n samples.

Trait Implementations§

Source§

impl Clone for Script

Source§

fn clone(&self) -> Script

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Script

Source§

fn default() -> Script

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.