pub trait AudioPipe {
// Required methods
fn stream_params(&self) -> &AudioStreamParams;
fn read_samples_unchecked(&mut self, to: &mut [f32]);
// Provided method
fn read_samples(&mut self, to: &mut [f32]) { ... }
}Expand description
An object to read audio samples from.
Required Methods§
Sourcefn stream_params(&self) -> &AudioStreamParams
fn stream_params(&self) -> &AudioStreamParams
The audio stream parameters of the audio pipe.
Sourcefn read_samples_unchecked(&mut self, to: &mut [f32])
fn read_samples_unchecked(&mut self, to: &mut [f32])
Reads samples from the pipe without checking the channel count of the output.
Provided Methods§
Sourcefn read_samples(&mut self, to: &mut [f32])
fn read_samples(&mut self, to: &mut [f32])
Reads samples from the pipe.
When using in a MIDI synthesizer, the amount of samples determines the time of the current active MIDI events. For example if we send a note on event and read 44100 samples (with a 44.1kHz sample rate), then the note will be audible for 1 second. If after reading those samples we send a note off event for the same key, then on the next read the key will be released. If we don’t, then the note will keep playing.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".