Struct Runtime

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

The audio graph processing runtime.

Implementations§

Source§

impl Runtime

Source

pub fn new(graph: Graph) -> Self

Creates a new runtime from the given graph.

Source

pub fn sample_rate(&self) -> Float

Returns the current sample rate.

Source

pub fn block_size(&self) -> usize

Returns the current block size.

Source

pub fn allocate_for_block_size( &mut self, sample_rate: Float, max_block_size: usize, )

Resets the runtime for the given sample rate and block size.

This will reallocate buffers if necessary.

Source

pub fn set_block_size(&mut self, block_size: usize) -> RuntimeResult<()>

Resets the runtime for the given sample rate and block size.

This is guaranteed to not allocate, assuming all processors are playing nicely. If it would need to allocate, it will return an error.

Source

pub fn graph(&self) -> &Graph

Returns a reference to the audio graph.

Source

pub fn graph_mut(&mut self) -> &mut Graph

Returns a mutable reference to the audio graph.

Source

pub fn process(&mut self) -> RuntimeResult<()>

Runs the audio graph for one block of samples.

Source

pub fn get_input_mut(&mut self, input_index: usize) -> Option<&mut SignalBuffer>

Returns a reference to the runtime’s input buffer for the given input index.

Source

pub fn get_output(&self, output_index: usize) -> Option<&SignalBuffer>

Returns a reference to the runtime’s output buffer for the given output index.

Source

pub fn param_named(&self, name: &str) -> Option<&Param>

Returns a reference to the Param with the given name.

Source

pub fn run_offline( &mut self, duration: Duration, sample_rate: Float, block_size: usize, ) -> RuntimeResult<Box<[Box<[Float]>]>>

Runs the audio graph offline for the given duration and sample rate, returning the output buffers.

Source

pub fn simulate( &mut self, duration: Duration, sample_rate: Float, block_size: usize, ) -> RuntimeResult<Box<[Box<[Float]>]>>

Runs the audio graph offline for the given duration and sample rate, returning the output buffers.

This method will sleep for the duration of each block to simulate real-time processing.

Source

pub fn run_offline_to_file( &mut self, file_path: impl AsRef<Path>, duration: Duration, sample_rate: Float, block_size: usize, ) -> RuntimeResult<()>

Runs the audio graph offline for the given duration and sample rate, writing the output to a file.

Source

pub fn run_for( &mut self, duration: Duration, backend: AudioBackend, device: AudioDevice, midi_port: Option<MidiPort>, ) -> RuntimeResult<()>

Runs the audio graph in real-time for the given duration.

Source

pub fn run( &mut self, backend: AudioBackend, device: AudioDevice, midi_port: Option<MidiPort>, ) -> RuntimeResult<RuntimeHandle>

Starts running the audio graph in real-time. Returns a RuntimeHandle that can be used to stop the runtime.

Trait Implementations§

Source§

impl Clone for Runtime

Source§

fn clone(&self) -> Runtime

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. 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> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,