Skip to content

Commit 9ce5fef

Browse files
committed
docs: harmonize AudioDestination doc
1 parent 4bb48b7 commit 9ce5fef

File tree

1 file changed

+46
-22
lines changed

1 file changed

+46
-22
lines changed

src/node/destination.rs

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,36 @@ use super::{
55
AudioNode, ChannelConfig, ChannelConfigOptions, ChannelCountMode, ChannelInterpretation,
66
};
77

8-
/// Representing the final audio destination and is what the user will ultimately hear.
8+
/// The AudioDestinationNode interface represents the terminal node of an audio
9+
/// graph in a given context. usually the speakers of your device, or the node that
10+
/// will "record" the audio data with an OfflineAudioContext.
11+
///
12+
/// AudioDestinationNode has no output (no AudioNode can be linked after it in the
13+
/// audio graph) and one input. The number of channels of its input must be between
14+
/// 0 and the maxChannelCount value.
15+
///
16+
/// - MDN documentation: <https://developer.mozilla.org/en-US/docs/Web/API/AudioDestinationNode>
17+
/// - specification: <https://webaudio.github.io/web-audio-api/#AudioDestinationNode>
18+
/// - see also: [`BaseAudioContext::destination`](crate::context::BaseAudioContext::destination)
19+
///
20+
/// # Usage
21+
///
22+
/// ```no_run
23+
/// use web_audio_api::context::{BaseAudioContext, AudioContext};
24+
/// use web_audio_api::node::{AudioNode, AudioScheduledSourceNode};
25+
///
26+
/// let context = AudioContext::default();
27+
///
28+
/// let osc = context.create_oscillator();
29+
/// osc.connect(&context.destination());
30+
/// osc.start();
31+
/// ```
32+
///
933
pub struct AudioDestinationNode {
1034
registration: AudioContextRegistration,
1135
channel_config: ChannelConfig,
1236
}
1337

14-
struct DestinationRenderer {}
15-
16-
impl AudioProcessor for DestinationRenderer {
17-
fn process(
18-
&mut self,
19-
inputs: &[AudioRenderQuantum],
20-
outputs: &mut [AudioRenderQuantum],
21-
_params: AudioParamValues<'_>,
22-
_scope: &RenderScope,
23-
) -> bool {
24-
// single input/output node
25-
let input = &inputs[0];
26-
let output = &mut outputs[0];
27-
28-
// just move input to output
29-
*output = input.clone();
30-
31-
true
32-
}
33-
}
34-
3538
impl AudioNode for AudioDestinationNode {
3639
fn registration(&self) -> &AudioContextRegistration {
3740
&self.registration
@@ -109,3 +112,24 @@ impl AudioDestinationNode {
109112
self.registration.context().base().max_channel_count()
110113
}
111114
}
115+
116+
struct DestinationRenderer {}
117+
118+
impl AudioProcessor for DestinationRenderer {
119+
fn process(
120+
&mut self,
121+
inputs: &[AudioRenderQuantum],
122+
outputs: &mut [AudioRenderQuantum],
123+
_params: AudioParamValues<'_>,
124+
_scope: &RenderScope,
125+
) -> bool {
126+
// single input/output node
127+
let input = &inputs[0];
128+
let output = &mut outputs[0];
129+
130+
// just move input to output
131+
*output = input.clone();
132+
133+
true
134+
}
135+
}

0 commit comments

Comments
 (0)