MDN wants to learn about developers like you:


The OfflineAudioContext() constructor creates a new OfflineAudioContext object instance.


var myOfflineAudio = new OfflineAudioContext(numOfChannels,length,sampleRate);


An integer representing the number of channels this buffer should have. Implementations must support a minimum 32 channels.
An integer representing the size of the buffer in sample-frames.
The sample-rate of the linear audio data in sample-frames per second. An implementation must support sample-rates in at least the range 22050 to 96000, with 44100 being the most commonly used.

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  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes)
(Yes) No support


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)

Document Tags and Contributors

 Contributors to this page: jpmedley, chrisdavidmills
 Last updated by: jpmedley,