OLD | NEW |
1 /** | 1 /** |
2 * High-fidelity audio programming in the browser. | 2 * High-fidelity audio programming in the browser. |
3 */ | 3 */ |
4 library dart.dom.web_audio; | 4 library dart.dom.web_audio; |
5 | 5 |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 import 'dart:_collection-dev' hide deprecated; | 8 import 'dart:_collection-dev' hide deprecated; |
9 import 'dart:html'; | 9 import 'dart:html'; |
10 import 'dart:html_common'; | 10 import 'dart:html_common'; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 void stop(num when) { | 147 void stop(num when) { |
148 if (JS('bool', '!!#.stop', this)) { | 148 if (JS('bool', '!!#.stop', this)) { |
149 JS('void', '#.stop(#)', this, when); | 149 JS('void', '#.stop(#)', this, when); |
150 } else { | 150 } else { |
151 JS('void', '#.noteOff(#)', this, when); | 151 JS('void', '#.noteOff(#)', this, when); |
152 } | 152 } |
153 } | 153 } |
154 // To suppress missing implicit constructor warnings. | 154 // To suppress missing implicit constructor warnings. |
155 factory AudioBufferSourceNode._() { throw new UnsupportedError("Not supported"
); } | 155 factory AudioBufferSourceNode._() { throw new UnsupportedError("Not supported"
); } |
156 | 156 |
| 157 /** |
| 158 * Static factory designed to expose `ended` events to event |
| 159 * handlers that are not necessarily instances of [AudioBufferSourceNode]. |
| 160 * |
| 161 * See [EventStreamProvider] for usage information. |
| 162 */ |
157 @DomName('AudioBufferSourceNode.endedEvent') | 163 @DomName('AudioBufferSourceNode.endedEvent') |
158 @DocsEditable() | 164 @DocsEditable() |
159 @Experimental() // untriaged | 165 @Experimental() // untriaged |
160 static const EventStreamProvider<Event> endedEvent = const EventStreamProvider
<Event>('ended'); | 166 static const EventStreamProvider<Event> endedEvent = const EventStreamProvider
<Event>('ended'); |
161 | 167 |
162 @DomName('AudioBufferSourceNode.FINISHED_STATE') | 168 @DomName('AudioBufferSourceNode.FINISHED_STATE') |
163 @DocsEditable() | 169 @DocsEditable() |
164 static const int FINISHED_STATE = 3; | 170 static const int FINISHED_STATE = 3; |
165 | 171 |
166 @DomName('AudioBufferSourceNode.PLAYING_STATE') | 172 @DomName('AudioBufferSourceNode.PLAYING_STATE') |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 void noteGrainOn(num when, num grainOffset, num grainDuration) native; | 214 void noteGrainOn(num when, num grainOffset, num grainDuration) native; |
209 | 215 |
210 @DomName('AudioBufferSourceNode.noteOff') | 216 @DomName('AudioBufferSourceNode.noteOff') |
211 @DocsEditable() | 217 @DocsEditable() |
212 void noteOff(num when) native; | 218 void noteOff(num when) native; |
213 | 219 |
214 @DomName('AudioBufferSourceNode.noteOn') | 220 @DomName('AudioBufferSourceNode.noteOn') |
215 @DocsEditable() | 221 @DocsEditable() |
216 void noteOn(num when) native; | 222 void noteOn(num when) native; |
217 | 223 |
| 224 /// Stream of `ended` events handled by this [AudioBufferSourceNode]. |
218 @DomName('AudioBufferSourceNode.onended') | 225 @DomName('AudioBufferSourceNode.onended') |
219 @DocsEditable() | 226 @DocsEditable() |
220 @Experimental() // untriaged | 227 @Experimental() // untriaged |
221 Stream<Event> get onEnded => endedEvent.forTarget(this); | 228 Stream<Event> get onEnded => endedEvent.forTarget(this); |
222 | 229 |
223 } | 230 } |
224 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 231 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
225 // for details. All rights reserved. Use of this source code is governed by a | 232 // for details. All rights reserved. Use of this source code is governed by a |
226 // BSD-style license that can be found in the LICENSE file. | 233 // BSD-style license that can be found in the LICENSE file. |
227 | 234 |
228 | 235 |
229 @DomName('AudioContext') | 236 @DomName('AudioContext') |
230 // https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AudioCo
ntext-section | 237 // https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#AudioCo
ntext-section |
231 @Experimental() | 238 @Experimental() |
232 class AudioContext extends EventTarget native "AudioContext,webkitAudioContext"
{ | 239 class AudioContext extends EventTarget native "AudioContext,webkitAudioContext"
{ |
233 // To suppress missing implicit constructor warnings. | 240 // To suppress missing implicit constructor warnings. |
234 factory AudioContext._() { throw new UnsupportedError("Not supported"); } | 241 factory AudioContext._() { throw new UnsupportedError("Not supported"); } |
235 | 242 |
| 243 /** |
| 244 * Static factory designed to expose `complete` events to event |
| 245 * handlers that are not necessarily instances of [AudioContext]. |
| 246 * |
| 247 * See [EventStreamProvider] for usage information. |
| 248 */ |
236 @DomName('AudioContext.completeEvent') | 249 @DomName('AudioContext.completeEvent') |
237 @DocsEditable() | 250 @DocsEditable() |
238 static const EventStreamProvider<Event> completeEvent = const EventStreamProvi
der<Event>('complete'); | 251 static const EventStreamProvider<Event> completeEvent = const EventStreamProvi
der<Event>('complete'); |
239 | 252 |
240 /// Checks if this type is supported on the current platform. | 253 /// Checks if this type is supported on the current platform. |
241 static bool get supported => JS('bool', '!!(window.AudioContext || window.webk
itAudioContext)'); | 254 static bool get supported => JS('bool', '!!(window.AudioContext || window.webk
itAudioContext)'); |
242 | 255 |
243 @DomName('AudioContext.activeSourceCount') | 256 @DomName('AudioContext.activeSourceCount') |
244 @DocsEditable() | 257 @DocsEditable() |
245 final int activeSourceCount; | 258 final int activeSourceCount; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 _decodeAudioData(audioData, | 368 _decodeAudioData(audioData, |
356 (value) { completer.complete(value); }, | 369 (value) { completer.complete(value); }, |
357 (error) { completer.completeError(error); }); | 370 (error) { completer.completeError(error); }); |
358 return completer.future; | 371 return completer.future; |
359 } | 372 } |
360 | 373 |
361 @DomName('AudioContext.startRendering') | 374 @DomName('AudioContext.startRendering') |
362 @DocsEditable() | 375 @DocsEditable() |
363 void startRendering() native; | 376 void startRendering() native; |
364 | 377 |
| 378 /// Stream of `complete` events handled by this [AudioContext]. |
365 @DomName('AudioContext.oncomplete') | 379 @DomName('AudioContext.oncomplete') |
366 @DocsEditable() | 380 @DocsEditable() |
367 Stream<Event> get onComplete => completeEvent.forTarget(this); | 381 Stream<Event> get onComplete => completeEvent.forTarget(this); |
368 | 382 |
369 factory AudioContext() => JS('AudioContext', | 383 factory AudioContext() => JS('AudioContext', |
370 'new (window.AudioContext || window.webkitAudioContext)()'); | 384 'new (window.AudioContext || window.webkitAudioContext)()'); |
371 | 385 |
372 GainNode createGain() { | 386 GainNode createGain() { |
373 if (JS('bool', '#.createGain !== undefined', this)) { | 387 if (JS('bool', '#.createGain !== undefined', this)) { |
374 return JS('GainNode', '#.createGain()', this); | 388 return JS('GainNode', '#.createGain()', this); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 | 891 |
878 | 892 |
879 @DocsEditable() | 893 @DocsEditable() |
880 @DomName('OscillatorNode') | 894 @DomName('OscillatorNode') |
881 // https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#dfn-Osc
illatorNode | 895 // https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#dfn-Osc
illatorNode |
882 @Experimental() | 896 @Experimental() |
883 class OscillatorNode extends AudioSourceNode native "OscillatorNode,Oscillator"
{ | 897 class OscillatorNode extends AudioSourceNode native "OscillatorNode,Oscillator"
{ |
884 // To suppress missing implicit constructor warnings. | 898 // To suppress missing implicit constructor warnings. |
885 factory OscillatorNode._() { throw new UnsupportedError("Not supported"); } | 899 factory OscillatorNode._() { throw new UnsupportedError("Not supported"); } |
886 | 900 |
| 901 /** |
| 902 * Static factory designed to expose `ended` events to event |
| 903 * handlers that are not necessarily instances of [OscillatorNode]. |
| 904 * |
| 905 * See [EventStreamProvider] for usage information. |
| 906 */ |
887 @DomName('OscillatorNode.endedEvent') | 907 @DomName('OscillatorNode.endedEvent') |
888 @DocsEditable() | 908 @DocsEditable() |
889 @Experimental() // untriaged | 909 @Experimental() // untriaged |
890 static const EventStreamProvider<Event> endedEvent = const EventStreamProvider
<Event>('ended'); | 910 static const EventStreamProvider<Event> endedEvent = const EventStreamProvider
<Event>('ended'); |
891 | 911 |
892 @DomName('OscillatorNode.FINISHED_STATE') | 912 @DomName('OscillatorNode.FINISHED_STATE') |
893 @DocsEditable() | 913 @DocsEditable() |
894 static const int FINISHED_STATE = 3; | 914 static const int FINISHED_STATE = 3; |
895 | 915 |
896 @DomName('OscillatorNode.PLAYING_STATE') | 916 @DomName('OscillatorNode.PLAYING_STATE') |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
935 void setPeriodicWave(PeriodicWave periodicWave) native; | 955 void setPeriodicWave(PeriodicWave periodicWave) native; |
936 | 956 |
937 @DomName('OscillatorNode.start') | 957 @DomName('OscillatorNode.start') |
938 @DocsEditable() | 958 @DocsEditable() |
939 void start(num when) native; | 959 void start(num when) native; |
940 | 960 |
941 @DomName('OscillatorNode.stop') | 961 @DomName('OscillatorNode.stop') |
942 @DocsEditable() | 962 @DocsEditable() |
943 void stop(num when) native; | 963 void stop(num when) native; |
944 | 964 |
| 965 /// Stream of `ended` events handled by this [OscillatorNode]. |
945 @DomName('OscillatorNode.onended') | 966 @DomName('OscillatorNode.onended') |
946 @DocsEditable() | 967 @DocsEditable() |
947 @Experimental() // untriaged | 968 @Experimental() // untriaged |
948 Stream<Event> get onEnded => endedEvent.forTarget(this); | 969 Stream<Event> get onEnded => endedEvent.forTarget(this); |
949 } | 970 } |
950 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 971 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
951 // for details. All rights reserved. Use of this source code is governed by a | 972 // for details. All rights reserved. Use of this source code is governed by a |
952 // BSD-style license that can be found in the LICENSE file. | 973 // BSD-style license that can be found in the LICENSE file. |
953 | 974 |
954 | 975 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 | 1043 |
1023 | 1044 |
1024 @DocsEditable() | 1045 @DocsEditable() |
1025 @DomName('ScriptProcessorNode') | 1046 @DomName('ScriptProcessorNode') |
1026 // https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#ScriptP
rocessorNode | 1047 // https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#ScriptP
rocessorNode |
1027 @Experimental() | 1048 @Experimental() |
1028 class ScriptProcessorNode extends AudioNode native "ScriptProcessorNode,JavaScri
ptAudioNode" { | 1049 class ScriptProcessorNode extends AudioNode native "ScriptProcessorNode,JavaScri
ptAudioNode" { |
1029 // To suppress missing implicit constructor warnings. | 1050 // To suppress missing implicit constructor warnings. |
1030 factory ScriptProcessorNode._() { throw new UnsupportedError("Not supported");
} | 1051 factory ScriptProcessorNode._() { throw new UnsupportedError("Not supported");
} |
1031 | 1052 |
| 1053 /** |
| 1054 * Static factory designed to expose `audioprocess` events to event |
| 1055 * handlers that are not necessarily instances of [ScriptProcessorNode]. |
| 1056 * |
| 1057 * See [EventStreamProvider] for usage information. |
| 1058 */ |
1032 @DomName('ScriptProcessorNode.audioprocessEvent') | 1059 @DomName('ScriptProcessorNode.audioprocessEvent') |
1033 @DocsEditable() | 1060 @DocsEditable() |
1034 @Experimental() // untriaged | 1061 @Experimental() // untriaged |
1035 static const EventStreamProvider<AudioProcessingEvent> audioProcessEvent = con
st EventStreamProvider<AudioProcessingEvent>('audioprocess'); | 1062 static const EventStreamProvider<AudioProcessingEvent> audioProcessEvent = con
st EventStreamProvider<AudioProcessingEvent>('audioprocess'); |
1036 | 1063 |
1037 @DomName('ScriptProcessorNode.bufferSize') | 1064 @DomName('ScriptProcessorNode.bufferSize') |
1038 @DocsEditable() | 1065 @DocsEditable() |
1039 final int bufferSize; | 1066 final int bufferSize; |
1040 | 1067 |
1041 /** | 1068 /// Stream of `audioprocess` events handled by this [ScriptProcessorNode]. |
| 1069 /** |
1042 * Get a Stream that fires events when AudioProcessingEvents occur. | 1070 * Get a Stream that fires events when AudioProcessingEvents occur. |
1043 * This particular stream is special in that it only allows one listener to a | 1071 * This particular stream is special in that it only allows one listener to a |
1044 * given stream. Converting the returned Stream [asBroadcast] will likely ruin | 1072 * given stream. Converting the returned Stream [asBroadcast] will likely ruin |
1045 * the soft-real-time properties which which these events are fired and can | 1073 * the soft-real-time properties which which these events are fired and can |
1046 * be processed. | 1074 * be processed. |
1047 */ | 1075 */ |
1048 @DomName('ScriptProcessorNode.onaudioprocess') | 1076 @DomName('ScriptProcessorNode.onaudioprocess') |
1049 @DocsEditable() | 1077 @DocsEditable() |
1050 @Experimental() // untriaged | 1078 @Experimental() // untriaged |
1051 Stream<AudioProcessingEvent> get onAudioProcess => audioProcessEvent.forTarget
(this); | 1079 Stream<AudioProcessingEvent> get onAudioProcess => audioProcessEvent.forTarget
(this); |
(...skipping 12 matching lines...) Expand all Loading... |
1064 factory WaveShaperNode._() { throw new UnsupportedError("Not supported"); } | 1092 factory WaveShaperNode._() { throw new UnsupportedError("Not supported"); } |
1065 | 1093 |
1066 @DomName('WaveShaperNode.curve') | 1094 @DomName('WaveShaperNode.curve') |
1067 @DocsEditable() | 1095 @DocsEditable() |
1068 Float32List curve; | 1096 Float32List curve; |
1069 | 1097 |
1070 @DomName('WaveShaperNode.oversample') | 1098 @DomName('WaveShaperNode.oversample') |
1071 @DocsEditable() | 1099 @DocsEditable() |
1072 String oversample; | 1100 String oversample; |
1073 } | 1101 } |
OLD | NEW |