pub struct OfflineAudioContext { /* private fields */ }
Expand description

The OfflineAudioContext doesn’t render the audio to the device hardware; instead, it generates it, as fast as it can, and outputs the result to an AudioBuffer.

Implementations§

source§

impl OfflineAudioContext

source

pub fn new(number_of_channels: usize, length: usize, sample_rate: f32) -> Self

Creates an OfflineAudioContext instance

Arguments
  • channels - number of output channels to render
  • length - length of the rendering audio buffer
  • sample_rate - output sample rate
source

pub fn start_rendering_sync(self) -> AudioBuffer

Given the current connections and scheduled changes, starts rendering audio.

This function will block the current thread and returns the rendered AudioBuffer synchronously. An async version is currently not implemented.

source

pub fn length(&self) -> usize

get the length of rendering audio buffer

Trait Implementations§

source§

impl BaseAudioContext for OfflineAudioContext

source§

fn base(&self) -> &ConcreteBaseAudioContext

Returns the BaseAudioContext concrete type associated with this AudioContext
source§

fn register<T: AudioNode, F: FnOnce(AudioContextRegistration) -> (T, Box<dyn AudioProcessor>)>(
    &self,
    f: F
) -> T

Construct a new pair of AudioNode and AudioProcessor Read more
source§

fn decode_audio_data_sync<R: Read + Send + Sync + 'static>(
    &self,
    input: R
) -> Result<AudioBuffer, Box<dyn Error + Send + Sync>>

Decode an AudioBuffer from a given input stream. Read more
source§

fn create_buffer(
    &self,
    number_of_channels: usize,
    length: usize,
    sample_rate: f32
) -> AudioBuffer

Create an new “in-memory” AudioBuffer with the given number of channels, length (i.e. number of samples per channel) and sample rate. Read more
source§

fn create_analyser(&self) -> AnalyserNode

Creates a AnalyserNode
source§

fn create_biquad_filter(&self) -> BiquadFilterNode

Creates an BiquadFilterNode which implements a second order filter
source§

fn create_buffer_source(&self) -> AudioBufferSourceNode

Creates an AudioBufferSourceNode
source§

fn create_constant_source(&self) -> ConstantSourceNode

Creates an ConstantSourceNode, a source representing a constant value
source§

fn create_convolver(&self) -> ConvolverNode

Creates an ConvolverNode, a processing node which applies linear convolution
source§

fn create_channel_merger(&self, number_of_inputs: usize) -> ChannelMergerNode

Creates a ChannelMergerNode
source§

fn create_channel_splitter(
    &self,
    number_of_outputs: usize
) -> ChannelSplitterNode

Creates a ChannelSplitterNode
source§

fn create_delay(&self, max_delay_time: f64) -> DelayNode

Creates a DelayNode, delaying the audio signal
source§

fn create_dynamics_compressor(&self) -> DynamicsCompressorNode

Creates a DynamicsCompressorNode, compressing the audio signal
source§

fn create_gain(&self) -> GainNode

Creates an GainNode, to control audio volume
source§

fn create_iir_filter(
    &self,
    feedforward: Vec<f64>,
    feedback: Vec<f64>
) -> IIRFilterNode

Creates an IirFilterNode Read more
source§

fn create_oscillator(&self) -> OscillatorNode

Creates an OscillatorNode, a source representing a periodic waveform.
source§

fn create_panner(&self) -> PannerNode

Creates a PannerNode
source§

fn create_periodic_wave(&self, options: PeriodicWaveOptions) -> PeriodicWave

Creates a periodic wave Read more
source§

fn create_stereo_panner(&self) -> StereoPannerNode

Creates an StereoPannerNode to pan a stereo output
source§

fn create_wave_shaper(&self) -> WaveShaperNode

Creates a WaveShaperNode
source§

fn destination(&self) -> AudioDestinationNode

Returns an AudioDestinationNode representing the final destination of all audio in the context. It can be thought of as the audio-rendering device.
source§

fn listener(&self) -> AudioListener

Returns the AudioListener which is used for 3D spatialization
source§

fn sample_rate(&self) -> f32

The sample rate (in sample-frames per second) at which the AudioContext handles audio.
source§

fn state(&self) -> AudioContextState

Returns state of current context
source§

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.
source§

fn create_audio_param(
    &self,
    opts: AudioParamDescriptor,
    dest: &AudioContextRegistration
) -> (AudioParam, AudioParamId)

Create an AudioParam. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<S> FromSample<S> for S

source§

fn from_sample_(s: S) -> S

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<F, T> IntoSample<T> for Fwhere
    T: FromSample<F>,

§

fn into_sample(self) -> T

source§

impl<T, U> ToSample<U> for Twhere
    U: FromSample<T>,

source§

fn to_sample_(self) -> U

source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<S, T> Duplex<S> for Twhere
    T: FromSample<S> + ToSample<S>,