pub struct Runtime { /* private fields */ }
Expand description
The audio graph processing runtime.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn sample_rate(&self) -> Float
pub fn sample_rate(&self) -> Float
Returns the current sample rate.
Sourcepub fn block_size(&self) -> usize
pub fn block_size(&self) -> usize
Returns the current block size.
Sourcepub fn allocate_for_block_size(
&mut self,
sample_rate: Float,
max_block_size: usize,
)
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.
Sourcepub fn set_block_size(&mut self, block_size: usize) -> RuntimeResult<()>
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.
Sourcepub fn process(&mut self) -> RuntimeResult<()>
pub fn process(&mut self) -> RuntimeResult<()>
Runs the audio graph for one block of samples.
Sourcepub fn get_input_mut(&mut self, input_index: usize) -> Option<&mut SignalBuffer>
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.
Sourcepub fn get_output(&self, output_index: usize) -> Option<&SignalBuffer>
pub fn get_output(&self, output_index: usize) -> Option<&SignalBuffer>
Returns a reference to the runtime’s output buffer for the given output index.
Sourcepub fn param_named(&self, name: &str) -> Option<&Param>
pub fn param_named(&self, name: &str) -> Option<&Param>
Returns a reference to the Param
with the given name.
Sourcepub fn run_offline(
&mut self,
duration: Duration,
sample_rate: Float,
block_size: usize,
) -> RuntimeResult<Box<[Box<[Float]>]>>
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.
Sourcepub fn simulate(
&mut self,
duration: Duration,
sample_rate: Float,
block_size: usize,
) -> RuntimeResult<Box<[Box<[Float]>]>>
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.
Sourcepub fn run_offline_to_file(
&mut self,
file_path: impl AsRef<Path>,
duration: Duration,
sample_rate: Float,
block_size: usize,
) -> RuntimeResult<()>
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.
Sourcepub fn run_for(
&mut self,
duration: Duration,
backend: AudioBackend,
device: AudioDevice,
midi_port: Option<MidiPort>,
) -> RuntimeResult<()>
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.
Sourcepub fn run(
&mut self,
backend: AudioBackend,
device: AudioDevice,
midi_port: Option<MidiPort>,
) -> RuntimeResult<RuntimeHandle>
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§
Auto Trait Implementations§
impl Freeze for Runtime
impl !RefUnwindSafe for Runtime
impl Send for Runtime
impl !Sync for Runtime
impl Unpin for Runtime
impl !UnwindSafe for Runtime
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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