The OfflineAudioContext()
constructor creates a new OfflineAudioContext
object instance.
var myOfflineAudio = new OfflineAudioContext(numOfChannels,length,sampleRate);
It is important to note that, whereas you can create a new AudioContext
using the new AudioContext()
constructor with no arguments, the OfflineAudioContext()
constructor requires three arguments. This works in exactly the same way as when you create a new AudioBuffer
with the AudioContext.createBuffer
method. For more detail, read Audio buffers: frames, samples and channels from our Basic concepts guide.
Note: Like a regular AudioContext
, an OfflineAudioContext
can be the target of events, therefore it implements the EventTarget
interface.
// define online and offline audio context var audioCtx = new AudioContext(); var offlineCtx = new OfflineAudioContext(2,44100*40,44100); source = offlineCtx.createBufferSource(); // etc...
Note: For a full working example, see our offline-audio-context-promise Github repo (see the source code too.)
Specification | Status | Comment |
---|---|---|
Web Audio API The definition of 'OfflineAudioContext' in that specification. | Working Draft |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support |
(Yes) | (Yes) | No support | (Yes) | No support |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|
Basic support | No support |
(Yes) | (Yes) | No support | (Yes) | No support | (Yes) |
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/OfflineAudioContext/OfflineAudioContext