forked from gasman/jasmid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
44 lines (43 loc) · 1.25 KB
/
index.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
<!DOCTYPE HTML>
<html>
<head>
<script src="stream.js"></script>
<script src="midifile.js"></script>
<script src="replayer.js"></script>
<script src="synth.js"></script>
<script src="audio.js"></script>
<script>
function loadRemote(path, callback) {
var fetch = new XMLHttpRequest();
fetch.open('GET', path);
fetch.overrideMimeType("text/plain; charset=x-user-defined");
fetch.onreadystatechange = function() {
if(this.readyState == 4 && this.status == 200) {
/* munge response into a binary string */
var t = this.responseText || "" ;
var ff = [];
var mx = t.length;
var scc= String.fromCharCode;
for (var z = 0; z < mx; z++) {
ff[z] = scc(t.charCodeAt(z) & 255);
}
callback(ff.join(""));
}
}
fetch.send();
}
function play(file) {
loadRemote(file, function(data) {
midiFile = MidiFile(data);
synth = Synth(44100);
replayer = Replayer(midiFile, synth);
audio = AudioPlayer(replayer);
})
}
</script>
</head>
<body>
<a href="javascript:void(play('minute_waltz.mid'))">Chopin - Waltz Op.61 (Minute Waltz)</a> |
<a href="javascript:void(play('rachmaninov3.mid'))">Rachmaninov - Piano Concerto No.3 (First movement)</a>
</body>
</html>