pub struct DelayNode { /* private fields */ }
Expand description
Node that delays the incoming audio signal by a certain amount
The current implementation does not allow for zero delay. The minimum delay is one render quantum (e.g. ~2.9ms at 44.1kHz).
- MDN documentation: https://developer.mozilla.org/en-US/docs/Web/API/DelayNode
- specification: https://webaudio.github.io/web-audio-api/#DelayNode
- see also:
BaseAudioContext::create_delay
§Usage
use std::fs::File;
use web_audio_api::context::{BaseAudioContext, AudioContext};
use web_audio_api::node::{AudioNode, AudioScheduledSourceNode};
// create an `AudioContext` and load a sound file
let context = AudioContext::default();
let file = File::open("samples/sample.wav").unwrap();
let audio_buffer = context.decode_audio_data_sync(file).unwrap();
// create a delay of 0.5s
let delay = context.create_delay(1.);
delay.delay_time().set_value(0.5);
delay.connect(&context.destination());
let mut src = context.create_buffer_source();
src.set_buffer(audio_buffer);
// connect to both delay and destination
src.connect(&delay);
src.connect(&context.destination());
src.start();
§Examples
cargo run --release --example simple_delay
cargo run --release --example feedback_delay
Implementations§
Source§impl DelayNode
impl DelayNode
Sourcepub fn new<C: BaseAudioContext>(context: &C, options: DelayOptions) -> Self
pub fn new<C: BaseAudioContext>(context: &C, options: DelayOptions) -> Self
Create a new DelayNode
§Panics
Panics when the max delay value is smaller than zero or langer than three minutes.
Sourcepub fn delay_time(&self) -> &AudioParam
pub fn delay_time(&self) -> &AudioParam
A-rate AudioParam
representing the amount of delay (in seconds) to apply.
Trait Implementations§
Source§impl AudioNode for DelayNode
impl AudioNode for DelayNode
Source§fn connect_from_output_to_input<'a>(
&self,
dest: &'a dyn AudioNode,
output: usize,
input: usize,
) -> &'a dyn AudioNode
fn connect_from_output_to_input<'a>( &self, dest: &'a dyn AudioNode, output: usize, input: usize, ) -> &'a dyn AudioNode
Connect a specific output of this AudioNode to a specific input of another node.
Source§fn disconnect(&self)
fn disconnect(&self)
Disconnects all outgoing connections from the AudioNode.
Source§fn disconnect_dest(&self, dest: &dyn AudioNode)
fn disconnect_dest(&self, dest: &dyn AudioNode)
Disconnects all outputs of the AudioNode that go to a specific destination AudioNode.
§Panics
This function will panic when
- the AudioContext of the source and destination does not match
- the source node was not connected to the destination node
Source§fn disconnect_output(&self, output: usize)
fn disconnect_output(&self, output: usize)
Disconnects all outgoing connections at the given output port from the AudioNode.
§Panics
This function will panic when
- if the output port is out of bounds for this node
Source§fn disconnect_dest_from_output(&self, dest: &dyn AudioNode, output: usize)
fn disconnect_dest_from_output(&self, dest: &dyn AudioNode, output: usize)
Disconnects a specific output of the AudioNode to a specific destination AudioNode
§Panics
This function will panic when
- the AudioContext of the source and destination does not match
- if the output port is out of bounds for the source node
- the source node was not connected to the destination node
Source§fn disconnect_dest_from_output_to_input(
&self,
dest: &dyn AudioNode,
output: usize,
input: usize,
)
fn disconnect_dest_from_output_to_input( &self, dest: &dyn AudioNode, output: usize, input: usize, )
Disconnects a specific output of the AudioNode to a specific input of some destination AudioNode
§Panics
This function will panic when
- the AudioContext of the source and destination does not match
- if the input port is out of bounds for the destination node
- if the output port is out of bounds for the source node
- the source node was not connected to the destination node
Source§fn registration(&self) -> &AudioContextRegistration
fn registration(&self) -> &AudioContextRegistration
BaseAudioContext
. Read moreSource§fn channel_config(&self) -> &ChannelConfig
fn channel_config(&self) -> &ChannelConfig
Source§fn number_of_inputs(&self) -> usize
fn number_of_inputs(&self) -> usize
Source§fn number_of_outputs(&self) -> usize
fn number_of_outputs(&self) -> usize
Source§fn context(&self) -> &ConcreteBaseAudioContext
fn context(&self) -> &ConcreteBaseAudioContext
BaseAudioContext
concrete type which owns this
AudioNode.Source§fn connect<'a>(&self, dest: &'a dyn AudioNode) -> &'a dyn AudioNode
fn connect<'a>(&self, dest: &'a dyn AudioNode) -> &'a dyn AudioNode
Source§fn channel_count_mode(&self) -> ChannelCountMode
fn channel_count_mode(&self) -> ChannelCountMode
Source§fn set_channel_count_mode(&self, v: ChannelCountMode)
fn set_channel_count_mode(&self, v: ChannelCountMode)
channel_count_mode
attributeSource§fn channel_interpretation(&self) -> ChannelInterpretation
fn channel_interpretation(&self) -> ChannelInterpretation
Source§fn set_channel_interpretation(&self, v: ChannelInterpretation)
fn set_channel_interpretation(&self, v: ChannelInterpretation)
channel_interpretation
attributeSource§fn channel_count(&self) -> usize
fn channel_count(&self) -> usize
Source§fn set_channel_count(&self, v: usize)
fn set_channel_count(&self, v: usize)
channel_count
attribute