audio-context

A WebAudio Context singleton

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
audio-context
3141.0.35 years ago9 years agoMinified + gzip package size for audio-context in KB

Readme

audio-context Build Status unstable Greenkeeper badge npm license
Creates a WebAudio context singleton with the given options. Returns null if not supported.

Example

```js var audioCtx = require('audio-context')() ``` You can also create an OfflineAudioContext in case you would like to process (faster) without any rendering. ```js var offlineContext = require('audio-context')({offline: true}) ```

Usage

npm install audio-context

ctx = createContext(options|sampleRate)

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.
  • 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.

Running tests

```sh
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 firefox ```

License

MIT