1.4.0 • Published 8 years ago

start-web-audio v1.4.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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

1.4.0

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago