HasAudioStream

Trait HasAudioStream 

Source
pub trait HasAudioStream: Send + Debug {
Show 14 methods // Required methods fn stream_state(&self) -> &StreamState; fn stream_state_mut(&mut self) -> &mut StreamState; fn pull_samples<'a>( &mut self, scratch_space: &mut [f32], audio_pcm: PCMSlice<'a, f32>, ) -> PullInfo; fn seek(&mut self, global_time: SampleTime); // Provided methods fn interval(&self) -> &Interval { ... } fn gain(&self) -> f32 { ... } fn set_gain(&mut self, new_gain: f32) { ... } fn frequency(&self) -> u32 { ... } fn interval_mut(&mut self) -> &mut Interval { ... } fn calculate_samples_needed(&self, dt: u32) -> u32 { ... } fn calculate_samples_needed_per_channel_fp(&self, dt: FP64) -> FP64 { ... } fn calculate_samples_needed_per_channel_f32(&self, dt: f32) -> f32 { ... } fn time_remaining_in_ms(&self) -> FP64 { ... } fn is_dead(&self) -> bool { ... }
}

Required Methods§

Source

fn stream_state(&self) -> &StreamState

Source

fn stream_state_mut(&mut self) -> &mut StreamState

Source

fn pull_samples<'a>( &mut self, scratch_space: &mut [f32], audio_pcm: PCMSlice<'a, f32>, ) -> PullInfo

§Description

Pulls samples and write to audio_pcm \

§Returns

info about how much data was written, the elapsed time that the written audio would take to pay it, etc

§Comments
  • will advance the local_time cursor that ALL streams must have
  • the samples that the stream pulls internally and writes to audio_pcm MUST be in the same format as specified by PCMSlice.
    For exmaple, if the stream is 4 channels interleaved internally but audio_pcm is 2 channels interleaved then this function must convert the internal stream to 2 channels before writing to audio_pcm.
    • Use scratch_space to do the conversion
    • note: the mixer WILL break if the channel conversion doesn’t happen
Source

fn seek(&mut self, global_time: SampleTime)

Provided Methods§

Source

fn interval(&self) -> &Interval

Source

fn gain(&self) -> f32

Source

fn set_gain(&mut self, new_gain: f32)

Source

fn frequency(&self) -> u32

in samples per second

Source

fn interval_mut(&mut self) -> &mut Interval

Source

fn calculate_samples_needed(&self, dt: u32) -> u32

given a time interval dt(in milliseconds) returns number of samples needed to represent the interval

Source

fn calculate_samples_needed_per_channel_fp(&self, dt: FP64) -> FP64

Source

fn calculate_samples_needed_per_channel_f32(&self, dt: f32) -> f32

Source

fn time_remaining_in_ms(&self) -> FP64

Source

fn is_dead(&self) -> bool

Implementors§