Trait SoundSource

Source
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§

Source

fn channels(&self) -> u16

Return the number of channels.

Source

fn sample_rate(&self) -> u32

Return the sample rate.

Source

fn reset(&mut self)

Start the sound from the begining.

Source

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().

Implementations on Foreign Types§

Source§

impl<T: SoundSource + ?Sized> SoundSource for Box<T>

Source§

fn channels(&self) -> u16

Source§

fn sample_rate(&self) -> u32

Source§

fn reset(&mut self)

Source§

fn write_samples(&mut self, buffer: &mut [i16]) -> usize

Source§

impl<T: SoundSource + ?Sized> SoundSource for Arc<Mutex<T>>

Source§

fn channels(&self) -> u16

Source§

fn sample_rate(&self) -> u32

Source§

fn reset(&mut self)

Source§

fn write_samples(&mut self, buffer: &mut [i16]) -> usize

Implementors§