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
chore function for starting web audio in mobile Safari
Installation
npm install start-web-audiodownloads:
API
startWebAudio(audioContext, [ elem, requireUserAction, callback ]): void- attach event listeners to
elemfor starting Web Audio API audioContext: AudioContextelem: 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
- attach event listeners to
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