DEPRECATION NOTICE
Since AudioContext depends on particular web-audio engine, it cannot be used as solid base for other audio components.
Besides:
- There's no necessarily common API between OfflineContext and AudioContext;
- Chrome requires interaction to enable AudioContext;
- spec fluctuates;
Better use WebAudioAPI, web-audio-api, web-audio-js or other engine directly in your app.
If you need just a convention for your component, implement simple context chache defaulting to {sampleRate: 44100}.
Creates a WebAudio context singleton with the given options. Returns null if not supported.
var audioCtx = require('audio-context')()You can also create an OfflineAudioContext in case you would like to process (faster) without any rendering.
var offlineContext = require('audio-context')({offline: true})Returns a singleton audio context for the given sampleRate.
The options:
sampleRate- if specified, will set the context sampleRate.latencyHint- if specified, will control latency. One of'balanced','playback','interaction'(default) or number.offline- if specified, will create OfflineAudioContext.length- if specified, will set number of frames for offline context.channels- if specified, will set number of channels for offline context.{...contextAttributes}any other options for the context.
Handles vendor prefixing for audio contexts. Returns null if we are not in a browser, or if the context is not available, or if there was an error creating the context.
# Run tests in tape-run's default browser
npm test
# Run in a specified browser.
# See https://github.com/juliangruber/tape-run#runopts for options
npm test -- --browser firefoxMIT
