pub trait SampleResourceF32 {
// Required methods
fn info(&self) -> SampleResourceInfo;
fn channel(&self, i: usize) -> Option<&[f32]>;
}Expand description
An immutable resource of audio samples which has its data stored in de-interleaved
f32 format, and which has all of its data loaded into memory.
§Implementation example
struct MyResource {
data: Vec<Vec<f32>>,
frames: usize,
sample_rate: Option<f64>,
}
impl SampleResourceF32 for MyResource {
fn info(&self) -> SampleResourceInfo {
SampleResourceInfo {
num_channels: self.data.len(),
len_frames: self.frames as u64,
sample_rate: self.sample_rate,
}
}
fn channel(&self, i: usize) -> Option<&[f32]> {
self.data.get(i).map(|ch| ch.as_slice())
}
}§Realtime Safety
3rd party libraries that implement this trait should expect that all methods in this trait may be called in a realtime thread. For more information, see: http://www.rossbencina.com/code/real-time-audio-programming-101-time-waits-for-nothing
Required Methods§
Sourcefn info(&self) -> SampleResourceInfo
fn info(&self) -> SampleResourceInfo
Retrieve information about this sample resource. This information is not allowed to change for the lifetime of this sample resource.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".