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

Processing node which applies a linear convolution effect given an impulse response.

The current implementation only handles mono-to-mono convolutions. The provided impulse response buffer and the input signal will be downmixed appropriately.

Usage

use std::fs::File;

use web_audio_api::context::{AudioContext, BaseAudioContext};
use web_audio_api::node::{AudioNode, AudioScheduledSourceNode, ConvolverNode, ConvolverOptions};

let context = AudioContext::default();
let file = File::open("samples/vocals-dry.wav").unwrap();
let audio_buffer = context.decode_audio_data_sync(file).unwrap();

let impulse_file = File::open("samples/small-room-response.wav").unwrap();
let impulse_buffer = context.decode_audio_data_sync(impulse_file).unwrap();

let src = context.create_buffer_source();
src.set_buffer(audio_buffer);

let convolve = ConvolverNode::new(&context, ConvolverOptions::default());
convolve.set_buffer(impulse_buffer);

src.connect(&convolve);
convolve.connect(&context.destination());
src.start();
std::thread::sleep(std::time::Duration::from_millis(4_000));

Examples

  • cargo run --release --example convolution

Implementations

returns a ConvolverNode instance

Arguments
  • context - audio context in which the audio node will live.
  • options - convolver options
Panics

Panics when an AudioBuffer is provided via the ConvolverOptions with a sample rate different from the audio context sample rate.

Get the current impulse response buffer

Set or update the impulse response buffer

Panics

Panics when the sample rate of the provided AudioBuffer differs from the audio context sample rate.

Denotes if the response buffer will be scaled with an equal-power normalization

Update the normalize setting. This will only have an effect when set_buffer is called.

Trait Implementations

The number of inputs feeding into the AudioNode. For source nodes, this will be 0.
The number of outputs coming out of the AudioNode.
The BaseAudioContext concrete type which owns this AudioNode. Read more
Connect the output of this AudioNode to the input of another node. Read more
Connect a specific output of this AudioNode to a specific input of another node. Read more
Disconnects all outputs of the AudioNode that go to a specific destination AudioNode.
Disconnects all outgoing connections from the AudioNode.
Represents an enumerated value describing the way channels must be matched between the node’s inputs and outputs. Read more
Update the channel_count_mode attribute
Represents an enumerated value describing the meaning of the channels. This interpretation will define how audio up-mixing and down-mixing will happen. Read more
Update the channel_interpretation attribute
Represents an integer used to determine how many channels are used when up-mixing and down-mixing connections to any inputs to the node. Read more
Update the channel_count attribute

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.