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

BiquadFilterNode is an AudioNode processor implementing very common low-order IIR filters.

Low-order filters are the building blocks of basic tone controls (bass, mid, treble), graphic equalizers, and more advanced filters. Multiple BiquadFilterNode filters can be combined to form more complex filters.

Usage

use std::fs::File;
use web_audio_api::context::{AudioContext, BaseAudioContext};
use web_audio_api::node::{AudioNode, AudioScheduledSourceNode};

let context = AudioContext::default();

let file = File::open("samples/think-stereo-48000.wav").unwrap();
let buffer = context.decode_audio_data_sync(file).unwrap();

// create a lowpass filter (default) and open frequency parameter over time
let biquad = context.create_biquad_filter();
biquad.connect(&context.destination());
biquad.frequency().set_value(10.);
biquad
    .frequency()
    .exponential_ramp_to_value_at_time(10000., context.current_time() + 10.);

// pipe the audio buffer source into the lowpass filter
let src = context.create_buffer_source();
src.connect(&biquad);
src.set_buffer(buffer);
src.set_loop(true);
src.start();

Examples

  • cargo run --release --example biquad

Implementations

returns a BiquadFilterNode instance

Arguments
  • context - audio context in which the audio node will live.
  • options - biquad filter options

Returns the gain audio paramter

Returns the frequency audio paramter

Returns the detune audio paramter

Returns the Q audio paramter

Returns the biquad filter type

biquad filter type setter

Arguments
  • type_ - the biquad filter type (lowpass, highpass,…)

Returns the frequency response for the specified frequencies

Arguments
  • frequency_hz - frequencies for which frequency response of the filter should be calculated
  • mag_response - magnitude of the frequency response of the filter
  • phase_response - phase of the frequency response of the filter
Panics

This function will panic if arguments’ lengths don’t match

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

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

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

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.