Runtime

Struct Runtime 

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

Instruction types and the runtime wrapper. Safe owner for a native runtime handle.

Implementations§

Source§

impl Runtime

Source

pub fn builder() -> RuntimeConstructBuilder

Starts building a runtime.

Source

pub fn new() -> RuntimeConstructBuilder

Backward-compatible constructor entrypoint used by examples and tests.

Source

pub fn apply_instructions(&self, batch: &InstructionBatch) -> Result<()>

Applies a serialized batch of instructions to the runtime.

Source

pub fn reset(&self)

Resets the runtime state.

Source

pub fn set_current_time_samples(&self, sample_time: i64)

Sets the current runtime time in samples.

Source

pub fn set_current_time_ms(&self, sample_time_ms: f64)

Sets the current runtime time in milliseconds.

Source

pub fn resources(&self) -> Ref<'_, ResourceManager>

Returns the current resource registry.

Source

pub fn add_resource( &self, name: impl AsRef<str>, resource: Resource, ) -> Result<()>

Adds a resource to the registry if the id is unused.

Source

pub fn set_resource( &self, name: impl AsRef<str>, resource: Resource, ) -> Result<Option<Resource>>

Inserts or replaces a resource in the registry.

Source

pub fn replace_resource( &self, name: impl AsRef<str>, resource: Resource, ) -> Result<Resource>

Replaces an existing resource and returns the previous value.

Source

pub fn remove_resource(&self, name: impl AsRef<str>) -> Result<Resource>

Removes a resource from the registry.

Source

pub fn rename_resource( &self, from: impl AsRef<str>, to: impl AsRef<str>, ) -> Result<()>

Renames a resource without changing its value.

Source

pub fn resource(&self, name: impl AsRef<str>) -> Option<Resource>

Returns a cloned resource by name.

Source

pub fn add_shared_resource_f32(&self, name: &str, data: &[f32]) -> Result<()>

Adds a shared f32 resource by name and mirrors it into the Rust registry.

Source

pub fn add_audio_resource(&self, name: &str, buffer: AudioBuffer) -> Result<()>

Adds a decoded mono audio buffer as a shared resource.

Source

pub fn prune_shared_resources(&self)

Prunes native shared resources and releases retired Rust buffers.

Source

pub fn process( &self, num_samples: usize, inputs: &[&[f64]], outputs: &mut [&mut [f64]], ) -> Result<()>

Processes one audio block.

Every input and output channel must have at least num_samples samples.

Source

pub fn gc(&self) -> Vec<NodeId>

Runs garbage collection and returns the collected node identifiers.

Source

pub fn construct(sample_rate: f64, buffer_size: usize) -> Result<Self>

Creates a runtime for the given sample rate and buffer size.

Trait Implementations§

Source§

impl Drop for Runtime

Source§

fn drop(&mut self)

Releases the native runtime handle.

Source§

impl Send for Runtime

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