JSPM

start-web-audio

1.4.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q30031F
  • License MIT

chore function for starting web audio in mobile Safari

Package Exports

  • start-web-audio

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 (start-web-audio) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

startWebAudio

NPM Version License

chore function for starting web audio in mobile Safari

Installation

npm install start-web-audio

downloads:

API

  • startWebAudio(audioContext, [ elem, requireUserAction, callback ]): void
    • attach event listeners to elem for starting Web Audio API
    • audioContext: AudioContext
    • elem: EventTarget
      • a target of event listener - default: window
    • requireUserAction: boolean
      • require user action - default: false
      • this option is useful, when want to use the same workflow in all devices.
    • callback: function
      • called when Web Audio API has been started - default: noop

Usage

var audioContext = new AudioContext();

startWebAudio(audioContext, function() {
  console.log("web audio is now available");
});

setInterval(function() {
  var oscillator = audioContext.createOscillator();

  oscillator.start(audioContext.currentTime);
  oscillator.stop(audioContext.currentTime + 0.1);
  oscillator.connect(audioContext.destination);
}, 1000);

License

MIT