-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudio.js
More file actions
19 lines (19 loc) · 575 Bytes
/
Audio.js
File metadata and controls
19 lines (19 loc) · 575 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var Audio = {
gainNode: undefined,
bufferList: undefined,
audioContext: new (window.AudioContext ||
window.webkitAudioContext)(),
init: function(bufferList) {
this.bufferList = bufferList;
this.gainNode = this.audioContext.createGain();
this.gainNode.gain.value = 1;
this.gainNode.connect(this.audioContext.destination);
},
play: function(i) {
var sound = this.audioContext.createBufferSource();
sound.connect(this.gainNode);
sound.buffer = this.bufferList[i];
sound.start(0);
sound.stop(this.audioContext.currentTime + 18);
}
};