Package Exports
- standardized-audio-context
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (standardized-audio-context) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
standardized-audio-context
A patched AudioContext which imitates the current API in current browsers.
This is a hopelessly naive attempt to patch the current implementation of the Web Audio API's
AudioContext in current browsers. The
goal is to make them all behave as promised by the
Specification.
There are of course some things which cannot be faked in a reasonable way. The most obvious amongst
those is the AudioWorkerNode
which is currently not implemented by any browser. Therefore the corresponding
createAudioWorker() method is missing here, too. All implemented methods are covered by unit
tests.
That said, there are a lot of other functions which are currently not implemented for no specific
reason besides a lack of time: createAudioWorker(), createConvolver(),
createDelay(), createDynamicsCompressor(), createMediaElementSource(),
createMediaStreamDestination(), createMediaStreamSource(), createPanner(),
createPeriodicWave(), createScriptProcessor(), createStereoPanner(), createWaveShaper(),
resume() and suspend(). The listener property is also missing for now.
This module also provides an
OfflineAudioContext which does
only expose the destination, length and sampleRate attributes as well as the createGain()
and decodeAudioData() methods up to now.
Usage
The standardized-audio-context is available on
npm and can be installed as usual.
npm install standardized-audio-contextYou can then import the AudioContext and OfflineAudioContext into your module like this:
import { AudioContext, OfflineAudioContext } from 'standardized-audio-context';In addition to that the standardized-audio-context also exports a promise named isSupported
which resolves to a boolean which indicates support within the currently used browser.
import { isSupported } from 'standardized-audio-context';
isSupported
.then((isSupported) => {
if (isSupported) {
// yeah everything should work
} else {
// oh no this browser seems to be outdated
}
});Tests
Many thanks to BrowserStack and Sauce Labs for allowing this module to be tested with their services.