Trait web_audio_api::worklet::AudioWorkletProcessor
source · pub trait AudioWorkletProcessor {
type ProcessorOptions: Send;
// Required methods
fn constructor(opts: Self::ProcessorOptions) -> Self;
fn process<'a, 'b>(
&mut self,
inputs: &'b [&'a [&'a [f32]]],
outputs: &'b mut [&'a mut [&'a mut [f32]]],
params: AudioParamValues<'b>,
scope: &'b RenderScope
) -> bool;
// Provided method
fn parameter_descriptors() -> Vec<AudioParamDescriptor>
where Self: Sized { ... }
}
Expand description
Audio processing code that runs on the audio rendering thread.
Required Associated Types§
sourcetype ProcessorOptions: Send
type ProcessorOptions: Send
Constructor options for the audio processor
This holds any user-defined data that may be used to initialize custom properties in an AudioWorkletProcessor instance that is associated with the AudioWorkletNode.
Required Methods§
sourcefn constructor(opts: Self::ProcessorOptions) -> Self
fn constructor(opts: Self::ProcessorOptions) -> Self
Constructor of the AudioWorkletProcessor
instance (to be executed in the render thread)
sourcefn process<'a, 'b>(
&mut self,
inputs: &'b [&'a [&'a [f32]]],
outputs: &'b mut [&'a mut [&'a mut [f32]]],
params: AudioParamValues<'b>,
scope: &'b RenderScope
) -> bool
fn process<'a, 'b>( &mut self, inputs: &'b [&'a [&'a [f32]]], outputs: &'b mut [&'a mut [&'a mut [f32]]], params: AudioParamValues<'b>, scope: &'b RenderScope ) -> bool
Audio processing function
Arguments
- inputs: readonly array of input buffers
- outputs: array of output buffers
- params: available
AudioParam
values for this processor - scope: AudioWorkletGlobalScope object with current frame, timestamp, sample rate
Return value
The return value (bool) of this callback controls the lifetime of the processor.
- return
false
when the node only transforms their inputs, and as such can be removed when the inputs are disconnected (e.g. GainNode) - return
true
for some time when the node still outputs after the inputs are disconnected (e.g. DelayNode) - return
true
as long as this node is a source of output (e.g. OscillatorNode)
Provided Methods§
sourcefn parameter_descriptors() -> Vec<AudioParamDescriptor>where
Self: Sized,
fn parameter_descriptors() -> Vec<AudioParamDescriptor>where
Self: Sized,
List of AudioParam
s for this audio processor
A default implementation is provided that supplies no parameters.
Object Safety§
This trait is not object safe.