chore function for starting web audio in mobile Safari
npm install start-web-audio> chore function for starting web audio in mobile Safari
```
npm install start-web-audio
downloads:
- start-web-audio.js
- start-web-audio.min.js
- 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
`js
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);
``MIT