@@ -5,33 +5,36 @@ use super::{
5
5
AudioNode , ChannelConfig , ChannelConfigOptions , ChannelCountMode , ChannelInterpretation ,
6
6
} ;
7
7
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
+ ///
9
33
pub struct AudioDestinationNode {
10
34
registration : AudioContextRegistration ,
11
35
channel_config : ChannelConfig ,
12
36
}
13
37
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
-
35
38
impl AudioNode for AudioDestinationNode {
36
39
fn registration ( & self ) -> & AudioContextRegistration {
37
40
& self . registration
@@ -109,3 +112,24 @@ impl AudioDestinationNode {
109
112
self . registration . context ( ) . base ( ) . max_channel_count ( )
110
113
}
111
114
}
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