OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010, Google Inc. All rights reserved. | 2 * Copyright (C) 2010, Google Inc. All rights reserved. |
3 * Copyright (C) 2011 Apple Inc. All rights reserved. | 3 * Copyright (C) 2011 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
13 * | 13 * |
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y | 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN
Y |
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
17 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y | 17 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN
Y |
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N | 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O
N |
21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
| 26 enum AudioContextState { |
| 27 "suspended", |
| 28 "running", |
| 29 "closed" |
| 30 }; |
| 31 |
26 [ | 32 [ |
27 GarbageCollected, | 33 GarbageCollected, |
28 ActiveDOMObject, | 34 ActiveDOMObject, |
29 Conditional=WEB_AUDIO, | 35 Conditional=WEB_AUDIO, |
30 Constructor, | 36 Constructor, |
31 ConstructorCallWith=Document, | 37 ConstructorCallWith=Document, |
32 NoInterfaceObject, | 38 NoInterfaceObject, |
33 RaisesException=Constructor, | 39 RaisesException=Constructor, |
34 ] interface AudioContext : EventTarget { | 40 ] interface AudioContext : EventTarget { |
35 // All rendered audio ultimately connects to destination, which represents t
he audio hardware. | 41 // All rendered audio ultimately connects to destination, which represents t
he audio hardware. |
36 readonly attribute AudioDestinationNode destination; | 42 readonly attribute AudioDestinationNode destination; |
37 | 43 |
38 // All scheduled times are relative to this time in seconds. | 44 // All scheduled times are relative to this time in seconds. |
39 readonly attribute double currentTime; | 45 readonly attribute double currentTime; |
40 | 46 |
41 // All AudioNodes in the context run at this sample-rate (sample-frames per
second). | 47 // All AudioNodes in the context run at this sample-rate (sample-frames per
second). |
42 readonly attribute float sampleRate; | 48 readonly attribute float sampleRate; |
43 | 49 |
44 // All panning is relative to this listener. | 50 // All panning is relative to this listener. |
45 readonly attribute AudioListener listener; | 51 readonly attribute AudioListener listener; |
46 | 52 |
| 53 // Current state of the AudioContext |
| 54 readonly attribute AudioContextState state; |
| 55 |
47 [RaisesException] AudioBuffer createBuffer(unsigned long numberOfChannels, u
nsigned long numberOfFrames, float sampleRate); | 56 [RaisesException] AudioBuffer createBuffer(unsigned long numberOfChannels, u
nsigned long numberOfFrames, float sampleRate); |
48 | 57 |
49 // Asynchronous audio file data decoding. | 58 // Asynchronous audio file data decoding. |
50 [RaisesException] void decodeAudioData(ArrayBuffer audioData, AudioBufferCal
lback successCallback, optional AudioBufferCallback errorCallback); | 59 [RaisesException] void decodeAudioData(ArrayBuffer audioData, AudioBufferCal
lback successCallback, optional AudioBufferCallback errorCallback); |
51 | 60 |
52 // Sources | 61 // Sources |
53 AudioBufferSourceNode createBufferSource(); | 62 AudioBufferSourceNode createBufferSource(); |
54 | 63 |
55 [RaisesException] MediaElementAudioSourceNode createMediaElementSource(HTMLM
ediaElement mediaElement); | 64 [RaisesException] MediaElementAudioSourceNode createMediaElementSource(HTMLM
ediaElement mediaElement); |
56 | 65 |
57 [RaisesException] MediaStreamAudioSourceNode createMediaStreamSource(MediaSt
ream mediaStream); | 66 [RaisesException] MediaStreamAudioSourceNode createMediaStreamSource(MediaSt
ream mediaStream); |
58 MediaStreamAudioDestinationNode createMediaStreamDestination(); | 67 MediaStreamAudioDestinationNode createMediaStreamDestination(); |
59 | 68 |
60 // Processing nodes | 69 // Processing nodes |
61 GainNode createGain(); | 70 GainNode createGain(); |
62 [RaisesException] DelayNode createDelay(optional double maxDelayTime); | 71 [RaisesException] DelayNode createDelay(optional double maxDelayTime); |
63 BiquadFilterNode createBiquadFilter(); | 72 BiquadFilterNode createBiquadFilter(); |
64 WaveShaperNode createWaveShaper(); | 73 WaveShaperNode createWaveShaper(); |
65 PannerNode createPanner(); | 74 PannerNode createPanner(); |
66 ConvolverNode createConvolver(); | 75 ConvolverNode createConvolver(); |
67 DynamicsCompressorNode createDynamicsCompressor(); | 76 DynamicsCompressorNode createDynamicsCompressor(); |
68 AnalyserNode createAnalyser(); | 77 AnalyserNode createAnalyser(); |
69 [RaisesException] ScriptProcessorNode createScriptProcessor(optional unsigne
d long bufferSize, optional unsigned long numberOfInputChannels, optional unsign
ed long numberOfOutputChannels); | 78 [RaisesException] ScriptProcessorNode createScriptProcessor(optional unsigne
d long bufferSize, optional unsigned long numberOfInputChannels, optional unsign
ed long numberOfOutputChannels); |
70 OscillatorNode createOscillator(); | 79 OscillatorNode createOscillator(); |
71 [RaisesException] PeriodicWave createPeriodicWave(Float32Array real, Float32
Array imag); | 80 [RaisesException] PeriodicWave createPeriodicWave(Float32Array real, Float32
Array imag); |
72 | 81 |
73 // Channel splitting and merging | 82 // Channel splitting and merging |
74 [RaisesException] ChannelSplitterNode createChannelSplitter(optional unsigne
d long numberOfOutputs); | 83 [RaisesException] ChannelSplitterNode createChannelSplitter(optional unsigne
d long numberOfOutputs); |
75 [RaisesException] ChannelMergerNode createChannelMerger(optional unsigned lo
ng numberOfInputs); | 84 [RaisesException] ChannelMergerNode createChannelMerger(optional unsigned lo
ng numberOfInputs); |
| 85 |
| 86 // Pause/resume |
| 87 [CallWith=ScriptState, ImplementedAs=suspendContext] Promise suspend(); |
| 88 [CallWith=ScriptState, ImplementedAs=resumeContext] Promise resume(); |
76 }; | 89 }; |
OLD | NEW |