JSPM

standardized-audio-context

11.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 221397
  • Score
    100M100P100Q179437F
  • License MIT

A patched AudioContext which imitates the current API in current browsers.

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.

tests dependencies version

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-context

You 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 which can be accessed by calling isSupported(). This promise resolves to a boolean which indicates if the functionality is supported 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.