Trait Sound
pub trait Sound: Send {
// Required methods
fn process(&mut self, out: &mut [Frame], dt: f64, info: &Info<'_>);
fn finished(&self) -> bool;
// Provided methods
fn on_start_processing(&mut self) { ... }
fn process_one(&mut self, dt: f64, info: &Info<'_>) -> Frame { ... }
}
Available on crate feature
dep_kira
only.Expand description
An actively playing sound.
For performance reasons, the methods of this trait should not allocate or deallocate memory.
Required Methods§
Provided Methods§
fn on_start_processing(&mut self)
fn on_start_processing(&mut self)
Called whenever a new batch of audio samples is requested by the backend.
This is a good place to put code that needs to run fairly frequently, but not for every single audio sample.
fn process_one(&mut self, dt: f64, info: &Info<'_>) -> Frame
fn process_one(&mut self, dt: f64, info: &Info<'_>) -> Frame
Processes a single Frame
. Mostly useful for testing.
dt
is the time elapsed since the previous frame (in seconds).