Trait web_audio_api::context::AsBaseAudioContext [−][src]
pub trait AsBaseAudioContext {
Show 24 methods
fn base(&self) -> &BaseAudioContext;
fn decode_audio_data(&self, file: File) -> AudioBuffer { ... }
fn create_buffer(
&self,
number_of_channels: usize,
length: usize,
sample_rate: SampleRate
) -> AudioBuffer { ... }
fn create_oscillator(&self) -> OscillatorNode { ... }
fn create_stereo_panner(&self) -> StereoPannerNode { ... }
fn create_gain(&self) -> GainNode { ... }
fn create_constant_source(&self) -> ConstantSourceNode { ... }
fn create_iir_filter(
&self,
feedforward: Vec<f64>,
feedback: Vec<f64>
) -> IirFilterNode { ... }
fn create_delay(&self, max_delay_time: f32) -> DelayNode { ... }
fn create_biquad_filter(&self) -> BiquadFilterNode { ... }
fn create_wave_shaper(&self) -> WaveShaperNode { ... }
fn create_channel_splitter(
&self,
number_of_outputs: u32
) -> ChannelSplitterNode { ... }
fn create_channel_merger(&self, number_of_inputs: u32) -> ChannelMergerNode { ... }
fn create_media_stream_source<M: MediaStream>(
&self,
media: M
) -> MediaStreamAudioSourceNode { ... }
fn create_media_element_source(
&self,
media: MediaElement
) -> MediaElementAudioSourceNode { ... }
fn create_buffer_source(&self) -> AudioBufferSourceNode { ... }
fn create_panner(&self) -> PannerNode { ... }
fn create_analyser(&self) -> AnalyserNode { ... }
fn create_periodic_wave(
&self,
options: Option<PeriodicWaveOptions>
) -> PeriodicWave { ... }
fn create_audio_param(
&self,
opts: AudioParamOptions,
dest: &AudioNodeId
) -> (AudioParam, AudioParamId) { ... }
fn destination(&self) -> DestinationNode { ... }
fn listener(&self) -> AudioListener { ... }
fn sample_rate(&self) -> SampleRate { ... }
fn current_time(&self) -> f64 { ... }
}
Expand description
Retrieve the BaseAudioContext
from the concrete AudioContext
Required methods
fn base(&self) -> &BaseAudioContext
fn base(&self) -> &BaseAudioContext
retrieves the BaseAudioContext
associated with the concrete AudioContext
Provided methods
fn decode_audio_data(&self, file: File) -> AudioBuffer
fn decode_audio_data(&self, file: File) -> AudioBuffer
Retrieves an AudioBuffer
from a given std::fs::File
Warning: in the current implementation decode_audio_data
only accepts
.wav
files and do not perform any resampling operation. Be carefull
to use audio files that match the current sample rate or the file will
pitched when played.
fn create_buffer(
&self,
number_of_channels: usize,
length: usize,
sample_rate: SampleRate
) -> AudioBuffer
fn create_buffer(
&self,
number_of_channels: usize,
length: usize,
sample_rate: SampleRate
) -> AudioBuffer
Create an new “in-memory” AudioBuffer
with the given number of channels,
length (i.e. number of samples per channel) and sample rate.
Note: In most cases you will want the sample rate to match the current audio context sample rate.
fn create_oscillator(&self) -> OscillatorNode
fn create_oscillator(&self) -> OscillatorNode
Creates an OscillatorNode
, a source representing a periodic waveform. It basically
generates a tone.
fn create_stereo_panner(&self) -> StereoPannerNode
fn create_stereo_panner(&self) -> StereoPannerNode
Creates an StereoPannerNode
to pan a stereo output
fn create_gain(&self) -> GainNode
fn create_gain(&self) -> GainNode
Creates an GainNode
, to control audio volume
fn create_constant_source(&self) -> ConstantSourceNode
fn create_constant_source(&self) -> ConstantSourceNode
Creates an ConstantSourceNode
, a source representing a constant value
fn create_iir_filter(
&self,
feedforward: Vec<f64>,
feedback: Vec<f64>
) -> IirFilterNode
fn create_iir_filter(
&self,
feedforward: Vec<f64>,
feedback: Vec<f64>
) -> IirFilterNode
Creates an IirFilterNode
Arguments
feedforward
- An array of the feedforward (numerator) coefficients for the transfer function of the IIR filter. The maximum length of this array is 20feedback
- An array of the feedback (denominator) coefficients for the transfer function of the IIR filter. The maximum length of this array is 20
fn create_delay(&self, max_delay_time: f32) -> DelayNode
fn create_delay(&self, max_delay_time: f32) -> DelayNode
Creates a DelayNode
, delaying the audio signal
fn create_biquad_filter(&self) -> BiquadFilterNode
fn create_biquad_filter(&self) -> BiquadFilterNode
Creates an BiquadFilterNode
which implements a second order filter
fn create_wave_shaper(&self) -> WaveShaperNode
fn create_wave_shaper(&self) -> WaveShaperNode
Creates a WaveShaperNode
fn create_channel_splitter(&self, number_of_outputs: u32) -> ChannelSplitterNode
fn create_channel_splitter(&self, number_of_outputs: u32) -> ChannelSplitterNode
Creates a ChannelSplitterNode
fn create_channel_merger(&self, number_of_inputs: u32) -> ChannelMergerNode
fn create_channel_merger(&self, number_of_inputs: u32) -> ChannelMergerNode
Creates a ChannelMergerNode
fn create_media_stream_source<M: MediaStream>(
&self,
media: M
) -> MediaStreamAudioSourceNode
fn create_media_stream_source<M: MediaStream>(
&self,
media: M
) -> MediaStreamAudioSourceNode
Creates a MediaStreamAudioSourceNode
from a MediaElement
fn create_media_element_source(
&self,
media: MediaElement
) -> MediaElementAudioSourceNode
fn create_media_element_source(
&self,
media: MediaElement
) -> MediaElementAudioSourceNode
Creates a MediaElementAudioSourceNode
from a MediaElement
Note: do not forget to start()
the node.
fn create_buffer_source(&self) -> AudioBufferSourceNode
fn create_buffer_source(&self) -> AudioBufferSourceNode
Creates an AudioBufferSourceNode
Note: do not forget to start()
the node.
fn create_panner(&self) -> PannerNode
fn create_panner(&self) -> PannerNode
Creates a PannerNode
fn create_analyser(&self) -> AnalyserNode
fn create_analyser(&self) -> AnalyserNode
Creates a AnalyserNode
fn create_periodic_wave(
&self,
options: Option<PeriodicWaveOptions>
) -> PeriodicWave
fn create_periodic_wave(
&self,
options: Option<PeriodicWaveOptions>
) -> PeriodicWave
Creates a periodic wave
fn create_audio_param(
&self,
opts: AudioParamOptions,
dest: &AudioNodeId
) -> (AudioParam, AudioParamId)
fn create_audio_param(
&self,
opts: AudioParamOptions,
dest: &AudioNodeId
) -> (AudioParam, AudioParamId)
Create an AudioParam
.
Call this inside the register
closure when setting up your AudioNode
fn destination(&self) -> DestinationNode
fn destination(&self) -> DestinationNode
Returns an AudioDestinationNode
representing the final destination of all audio in the
context. It can be thought of as the audio-rendering device.
fn listener(&self) -> AudioListener
fn listener(&self) -> AudioListener
Returns the AudioListener
which is used for 3D spatialization
fn sample_rate(&self) -> SampleRate
fn sample_rate(&self) -> SampleRate
The sample rate (in sample-frames per second) at which the AudioContext
handles audio.
fn current_time(&self) -> f64
fn current_time(&self) -> f64
This is the time in seconds of the sample frame immediately following the last sample-frame in the block of audio most recently processed by the context’s rendering graph.