AudioContext.hx 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /*
  2. * Copyright (C)2005-2017 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. // This file is generated from mozilla\AudioContext.webidl. Do not edit!
  23. package js.html.audio;
  24. /**
  25. An `AudioContext` can be a target of events, therefore it implements the `EventTarget` interface.
  26. Documentation [AudioContext](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext) by [Mozilla Contributors](https://developer.mozilla.org/en-US/docs/Web/API/AudioContext$history), licensed under [CC-BY-SA 2.5](https://creativecommons.org/licenses/by-sa/2.5/).
  27. @see <https://developer.mozilla.org/en-US/docs/Web/API/AudioContext>
  28. **/
  29. @:native("AudioContext")
  30. extern class AudioContext extends js.html.EventTarget
  31. {
  32. /**
  33. Returns an `AudioDestinationNode` representing the final destination of all audio in the context. It can be thought of as the audio-rendering device.
  34. **/
  35. var destination(default,null) : AudioDestinationNode;
  36. /**
  37. Returns a float representing the sample rate (in samples per second) used by all nodes in this context. The sample-rate of an `AudioContext` cannot be changed.
  38. **/
  39. var sampleRate(default,null) : Float;
  40. /**
  41. Returns a double representing an ever-increasing hardware time in seconds used for scheduling. It starts at `0`.
  42. **/
  43. var currentTime(default,null) : Float;
  44. /**
  45. Returns the `AudioListener` object, used for 3D spatialization.
  46. **/
  47. var listener(default,null) : AudioListener;
  48. /**
  49. Returns the current state of the `AudioContext`.
  50. **/
  51. var state(default,null) : js.html.AudioContextState;
  52. /**
  53. An event handler that runs when an event of type `statechange` has fired. This occurs when the `AudioContext`'s state changes, due to the calling of one of the state change methods (`AudioContext.suspend`, `AudioContext.resume`, or `AudioContext.close`).
  54. **/
  55. var onstatechange : haxe.Constraints.Function;
  56. /** @throws DOMError */
  57. @:overload( function() : Void {} )
  58. function new( audioChannelType : js.html.AudioChannel ) : Void;
  59. /** @throws DOMError */
  60. /**
  61. Suspends the progression of time in the audio context, temporarily halting audio hardware access and reducing CPU/battery usage in the process.
  62. **/
  63. function suspend() : Promise<Void>;
  64. /** @throws DOMError */
  65. /**
  66. Resumes the progression of time in an audio context that has previously been suspended.
  67. **/
  68. function resume() : Promise<Void>;
  69. /** @throws DOMError */
  70. /**
  71. Closes the audio context, releasing any system audio resources that it uses.
  72. **/
  73. function close() : Promise<Void>;
  74. /** @throws DOMError */
  75. /**
  76. Creates a new, empty `AudioBuffer` object, which can then be populated by data and played via an `AudioBufferSourceNode`.
  77. **/
  78. function createBuffer( numberOfChannels : Int, length : Int, sampleRate : Float ) : AudioBuffer;
  79. /** @throws DOMError */
  80. /**
  81. Asynchronously decodes audio file data contained in an `ArrayBuffer`. In this case, the ArrayBuffer is usually loaded from an `XMLHttpRequest`'s `response` attribute after setting the `responseType` to `arraybuffer`. This method only works on complete files, not fragments of audio files.
  82. **/
  83. function decodeAudioData( audioData : js.html.ArrayBuffer, ?successCallback : AudioBuffer -> Void, ?errorCallback : Void -> Void ) : Promise<AudioBuffer>;
  84. /** @throws DOMError */
  85. /**
  86. Creates an `AudioBufferSourceNode`, which can be used to play and manipulate audio data contained within an `AudioBuffer` object. `AudioBuffer`s are created using `AudioContext.createBuffer` or returned by `AudioContext.decodeAudioData` when it successfully decodes an audio track.
  87. **/
  88. function createBufferSource() : AudioBufferSourceNode;
  89. /** @throws DOMError */
  90. /**
  91. Creates a `MediaStreamAudioDestinationNode` associated with a `MediaStream` representing an audio stream which may be stored in a local file or sent to another computer.
  92. **/
  93. function createMediaStreamDestination() : MediaStreamAudioDestinationNode;
  94. /** @throws DOMError */
  95. /**
  96. Creates a `ScriptProcessorNode`, which can be used for direct audio processing via JavaScript.
  97. **/
  98. function createScriptProcessor( ?bufferSize : Int = 0, ?numberOfInputChannels : Int = 2, ?numberOfOutputChannels : Int = 2 ) : ScriptProcessorNode;
  99. /** @throws DOMError */
  100. /**
  101. Creates a `StereoPannerNode`, which can be used to apply stereo panning to an audio source.
  102. **/
  103. function createStereoPanner() : StereoPannerNode;
  104. /** @throws DOMError */
  105. /**
  106. Creates an `AnalyserNode`, which can be used to expose audio time and frequency data and for example to create data visualisations.
  107. **/
  108. function createAnalyser() : AnalyserNode;
  109. /** @throws DOMError */
  110. /**
  111. Creates a `MediaElementAudioSourceNode` associated with an `HTMLMediaElement`. This can be used to play and manipulate audio from `video` or `audio` elements.
  112. **/
  113. function createMediaElementSource( mediaElement : js.html.MediaElement ) : MediaElementAudioSourceNode;
  114. /** @throws DOMError */
  115. /**
  116. Creates a `MediaStreamAudioSourceNode` associated with a `MediaStream` representing an audio stream which may come from the local computer microphone or other sources.
  117. **/
  118. function createMediaStreamSource( mediaStream : js.html.MediaStream ) : MediaStreamAudioSourceNode;
  119. /** @throws DOMError */
  120. /**
  121. Creates a `GainNode`, which can be used to control the overall volume of the audio graph.
  122. **/
  123. function createGain() : GainNode;
  124. /** @throws DOMError */
  125. /**
  126. Creates a `DelayNode`, which is used to delay the incoming audio signal by a certain amount. This node is also useful to create feedback loops in a Web Audio API graph.
  127. **/
  128. function createDelay( ?maxDelayTime : Float = 1.0 ) : DelayNode;
  129. /** @throws DOMError */
  130. /**
  131. Creates a `BiquadFilterNode`, which represents a second order filter configurable as several different common filter types: high-pass, low-pass, band-pass, etc.
  132. **/
  133. function createBiquadFilter() : BiquadFilterNode;
  134. /** @throws DOMError */
  135. /**
  136. Creates a `WaveShaperNode`, which is used to implement non-linear distortion effects.
  137. **/
  138. function createWaveShaper() : WaveShaperNode;
  139. /** @throws DOMError */
  140. /**
  141. Creates a `PannerNode`, which is used to spatialise an incoming audio stream in 3D space.
  142. **/
  143. function createPanner() : PannerNode;
  144. /** @throws DOMError */
  145. /**
  146. Creates a `ConvolverNode`, which can be used to apply convolution effects to your audio graph, for example a reverberation effect.
  147. **/
  148. function createConvolver() : ConvolverNode;
  149. /** @throws DOMError */
  150. /**
  151. Creates a `ChannelSplitterNode`, which is used to access the individual channels of an audio stream and process them separately.
  152. **/
  153. function createChannelSplitter( ?numberOfOutputs : Int = 6 ) : ChannelSplitterNode;
  154. /** @throws DOMError */
  155. /**
  156. Creates a `ChannelMergerNode`, which is used to combine channels from multiple audio streams into a single audio stream.
  157. **/
  158. function createChannelMerger( ?numberOfInputs : Int = 6 ) : ChannelMergerNode;
  159. /** @throws DOMError */
  160. /**
  161. Creates a `DynamicsCompressorNode`, which can be used to apply acoustic compression to an audio signal.
  162. **/
  163. function createDynamicsCompressor() : DynamicsCompressorNode;
  164. /** @throws DOMError */
  165. /**
  166. Creates an `OscillatorNode`, a source representing a periodic waveform. It basically generates a tone.
  167. **/
  168. function createOscillator() : OscillatorNode;
  169. /** @throws DOMError */
  170. /**
  171. Creates a `PeriodicWave`, used to define a periodic waveform that can be used to determine the output of an `OscillatorNode`.
  172. **/
  173. function createPeriodicWave( real : js.html.Float32Array, imag : js.html.Float32Array ) : PeriodicWave;
  174. }