AudioContext.idl 4.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (C) 2010, Google Inc. All rights reserved.
  3. * Copyright (C) 2011 Apple Inc. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
  15. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  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 ANY
  18. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  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 ON
  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
  23. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. [
  26. EnabledBySetting=WebAudio,
  27. Conditional=WEB_AUDIO,
  28. ActiveDOMObject,
  29. CustomConstructor,
  30. EventTarget,
  31. InterfaceName=webkitAudioContext
  32. ] interface AudioContext {
  33. // All rendered audio ultimately connects to destination, which represents the audio hardware.
  34. readonly attribute AudioDestinationNode destination;
  35. // All scheduled times are relative to this time in seconds.
  36. readonly attribute float currentTime;
  37. // All AudioNodes in the context run at this sample-rate (sample-frames per second).
  38. readonly attribute float sampleRate;
  39. // All panning is relative to this listener.
  40. readonly attribute AudioListener listener;
  41. // Number of AudioBufferSourceNodes that are currently playing.
  42. readonly attribute unsigned long activeSourceCount;
  43. [RaisesException] AudioBuffer createBuffer(unsigned long numberOfChannels, unsigned long numberOfFrames, float sampleRate);
  44. [RaisesException] AudioBuffer createBuffer(ArrayBuffer? buffer, boolean mixToMono);
  45. // Asynchronous audio file data decoding.
  46. [RaisesException] void decodeAudioData(ArrayBuffer audioData, AudioBufferCallback successCallback, optional AudioBufferCallback errorCallback);
  47. // Sources
  48. AudioBufferSourceNode createBufferSource();
  49. #if defined(ENABLE_VIDEO) && ENABLE_VIDEO
  50. [RaisesException] MediaElementAudioSourceNode createMediaElementSource(HTMLMediaElement mediaElement);
  51. #endif
  52. #if defined(ENABLE_MEDIA_STREAM) && ENABLE_MEDIA_STREAM
  53. [RaisesException] MediaStreamAudioSourceNode createMediaStreamSource(MediaStream mediaStream);
  54. MediaStreamAudioDestinationNode createMediaStreamDestination();
  55. #endif
  56. // Processing nodes
  57. GainNode createGain();
  58. [RaisesException] DelayNode createDelay(optional double maxDelayTime);
  59. BiquadFilterNode createBiquadFilter();
  60. WaveShaperNode createWaveShaper();
  61. PannerNode createPanner();
  62. ConvolverNode createConvolver();
  63. DynamicsCompressorNode createDynamicsCompressor();
  64. AnalyserNode createAnalyser();
  65. [RaisesException] ScriptProcessorNode createScriptProcessor(unsigned long bufferSize, optional unsigned long numberOfInputChannels, optional unsigned long numberOfOutputChannels);
  66. OscillatorNode createOscillator();
  67. [RaisesException] WaveTable createWaveTable(Float32Array real, Float32Array imag);
  68. // Channel splitting and merging
  69. [RaisesException] ChannelSplitterNode createChannelSplitter(optional unsigned long numberOfOutputs);
  70. [RaisesException] ChannelMergerNode createChannelMerger(optional unsigned long numberOfInputs);
  71. // Offline rendering
  72. // void prepareOfflineBufferRendering(unsigned long numberOfChannels, unsigned long numberOfFrames, float sampleRate);
  73. attribute EventListener oncomplete;
  74. void startRendering();
  75. [Conditional=LEGACY_WEB_AUDIO, ImplementedAs=createGain] GainNode createGainNode();
  76. [Conditional=LEGACY_WEB_AUDIO, ImplementedAs=createDelay, RaisesException] DelayNode createDelayNode(optional double maxDelayTime);
  77. [Conditional=LEGACY_WEB_AUDIO, ImplementedAs=createScriptProcessor, RaisesException] ScriptProcessorNode createJavaScriptNode(unsigned long bufferSize, optional unsigned long numberOfInputChannels, optional unsigned long numberOfOutputChannels);
  78. };