pub trait SoundSource {
// Required methods
fn channels(&self) -> u16;
fn sample_rate(&self) -> u32;
fn reset(&mut self);
fn write_samples(&mut self, buffer: &mut [i16]) -> usize;
}
Expand description
A source of sound samples.
Sound samples of each channel must be interleaved.
Required Methods§
Sourcefn sample_rate(&self) -> u32
fn sample_rate(&self) -> u32
Return the sample rate.
Sourcefn write_samples(&mut self, buffer: &mut [i16]) -> usize
fn write_samples(&mut self, buffer: &mut [i16]) -> usize
Write the samples to buffer
.
Return how many samples was written. If it return a value less thand the length of
buffer
, this indicate that the sound ended.
The buffer
length and the returned length should always be a multiple of
self.channels()
.