-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandpan3note.html
197 lines (149 loc) · 4.9 KB
/
handpan3note.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<!doctype html>
<html>
<head>
<title>3 notes based on Scirra test (v3)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<style>
button { width: 90px;
height: 90px;
background-color: #81a2eb;
margin: 10px 40px 10px;
display: block;
float: left;
}
p { display: block;
float: left;
width: 90px;
height: 90px;
margin: 10px 40px 10px;
}
</style>
<script src="jquery-2.1.4.js"></script>
<script>
(function () {
var context = null;
var buffer1 = null, buffer2 = null, buffer3 = null;
function addStatus1(msg) {
jQuery("#status1").append("<br/>" + msg);
};
function addStatus2(msg) {
jQuery("#status2").append("<br/>" + msg);
};
function addStatus3(msg) {
jQuery("#status3").append("<br/>" + msg);
};
window.onerror = function(errorMsg, url, lineNumber) {
addStatus1("JAVASCRIPT ERROR: " + errorMsg + " (" + url + ", line " + lineNumber + ")");
};
// window.onerror2 = function(errorMsg, url, lineNumber) {
// addStatus2("JAVASCRIPT ERROR: " + errorMsg + " (" + url + ", line " + lineNumber + ")");
// };
function decodeError1() {
addStatus1("Error in decodeAudioData");
};
function decodeError2() {
addStatus2("Error in decodeAudioData");
};
function decodeError3() {
addStatus3("Error in decodeAudioData");
};
function playSound1(when_) {
if (!buffer1)
return;
var source = context.createBufferSource();
source.buffer = buffer1;
source.connect(context.destination);
source.noteOn(when_);
};
function playSound2(when_) {
if (!buffer2)
return;
var source = context.createBufferSource();
source.buffer = buffer2;
source.connect(context.destination);
source.noteOn(when_);
};
function playSound3(when_) {
if (!buffer3)
return;
var source = context.createBufferSource();
source.buffer = buffer3;
source.connect(context.destination);
source.noteOn(when_);
};
jQuery(document).ready(function () {
context = new webkitAudioContext();
addStatus1("Created AudioContext");
//
// if (typeof AudioContext !== "undefined")
// {
// context = new AudioContext();
// addStatus1("Created AudioContext");
// }
// else if (typeof webkitAudioContext !== "undefined")
// {
// context = new webkitAudioContext();
// addStatus1("Created webkitAudioContext");
// }
// else
// {
// addStatus1("Web Audio API does not appear to be supported");
// return;
// }
// AJAX request sound
var request1 = new XMLHttpRequest();
request1.open("GET", "8notesDiatoAmV4A3.mp3", true);
request1.responseType = "arraybuffer";
request1.onload = function () {
addStatus1("A3.mp3 loaded, decoding...");
context.decodeAudioData(request1.response, function (buffer_) {
addStatus1("Finished decoding audio");
buffer1 = buffer_;
}, decodeError1);
};
request1.send();
var request2 = new XMLHttpRequest();
request2.open("GET", "8notesDiatoAmV4B3.mp3", true);
request2.responseType = "arraybuffer";
request2.onload = function () {
addStatus2("B3.mp3 loaded, decoding...");
context.decodeAudioData(request2.response, function (buffer_) {
addStatus2("Finished decoding audio");
buffer2 = buffer_;
}, decodeError2);
};
request2.send();
var request3 = new XMLHttpRequest();
request3.open("GET", "8notesDiatoAmV4A4.mp3", true);
request3.responseType = "arraybuffer";
request3.onload = function () {
addStatus3("A4.mp3 loaded, decoding...");
context.decodeAudioData(request3.response, function (buffer_) {
addStatus3("Finished decoding audio");
buffer3 = buffer_;
}, decodeError3);
};
request3.send();
jQuery("#play1").on("touchstart", function() {
playSound1(0);
});
jQuery("#play2").on("touchstart",function() {
playSound2(0);
});
jQuery("#play3").on("touchstart",function() {
playSound3(0);
});
});
})();
</script>
</head>
<body>
<button id="play1" data-sound="8notesDiatoAmV4A3.mp3">A3</button>
<button id="play2" data-sound="8notesDiatoAmV4B3.mp3">B3</button>
<button id="play3" data-sound="8notesDiatoAmV4A4.mp3">A4</button>
<p id="status1">Status:</p>
<p id="status2">Status:</p>
<p id="status3">Status:</p>
<header>test 8</header>
</body>
</html>