-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsoundtest.html
44 lines (37 loc) · 1.09 KB
/
soundtest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<html>
<body>
<script>
window.onload = init;
var context;
var bufferLoader;
function init() {
// Fix up prefixing
window.AudioContext = window.AudioContext || window.webkitAudioContext;
context = new AudioContext();
// Load buffer asynchronously
var request = new XMLHttpRequest();
request.open("GET", 'http://guelphsonification.github.io/Files/ding.wav', true);
request.responseType = "arraybuffer";
request.onload = function() {
// Asynchronously decode the audio file data in request.response
context.decodeAudioData(
request.response,
function(buffer) {
var source1 = context.createBufferSource();
source1.buffer = buffer;
source1.connect(context.destination);
source1.start(0);
},
function(error) {
console.error('decodeAudioData error', error);
}
);
}
request.onerror = function() {
alert('BufferLoader: XHR error');
}
request.send();
}
</script>
</body>
</html>