Trait web_audio_api::render::AudioProcessor
source · pub trait AudioProcessor: Send {
fn process(
&mut self,
inputs: &[AudioRenderQuantum],
outputs: &mut [AudioRenderQuantum],
params: AudioParamValues<'_>,
scope: &RenderScope
) -> bool;
}
Expand description
Interface for audio processing code that runs on the audio rendering thread.
Note that the AudioProcessor is typically constructed together with an
AudioNode
(the user facing object that lives in the control
thread). See BaseAudioContext::register
.
Check the examples/worklet.rs
file for example usage of this trait.
Required Methods§
sourcefn process(
&mut self,
inputs: &[AudioRenderQuantum],
outputs: &mut [AudioRenderQuantum],
params: AudioParamValues<'_>,
scope: &RenderScope
) -> bool
fn process(
&mut self,
inputs: &[AudioRenderQuantum],
outputs: &mut [AudioRenderQuantum],
params: AudioParamValues<'_>,
scope: &RenderScope
) -> bool
Audio processing function
Arguments
- inputs: readonly array of input buffers
- outputs: array of output buffers
- params: available
AudioParam
s for this processor - timestamp: time of the start of this render quantum
- sample_rate: sample rate of this render quantum
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)