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§
fn stream_state(&self) -> &StreamState
fn stream_state_mut(&mut self) -> &mut StreamState
Sourcefn pull_samples<'a>(
&mut self,
scratch_space: &mut [f32],
audio_pcm: PCMSlice<'a, f32>,
) -> PullInfo
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_timecursor that ALL streams must have - the samples that the stream pulls internally and writes to
audio_pcmMUST be in the same format as specified by PCMSlice.
For exmaple, if the stream is 4 channels interleaved internally butaudio_pcmis 2 channels interleaved then this function must convert the internal stream to 2 channels before writing toaudio_pcm.- Use
scratch_spaceto do the conversion - note: the mixer WILL break if the channel conversion doesn’t happen
- Use
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 interval_mut(&mut self) -> &mut Interval
Sourcefn calculate_samples_needed(&self, dt: u32) -> u32
fn calculate_samples_needed(&self, dt: u32) -> u32
given a time interval dt(in milliseconds) returns number of samples needed to represent the interval