-
Notifications
You must be signed in to change notification settings - Fork 24
/
index.html
80 lines (73 loc) · 3.01 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
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
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="modfile.js"></script>
<script type="text/javascript" src="modplayer.js"></script>
<script type="text/javascript" src="dynamicaudio-min.js"></script>
<script type="text/javascript">
var modPlayer;
var dynamicAudio;
function init() {
dynamicAudio = new DynamicAudio({'swf': 'dynamicaudio.swf'});
}
var playing = false;
function play() {
playing = true;
// initially buffer 10 seconds (44100 * 2(stereo) * 10)
dynamicAudio.write(modPlayer.getSamples(882000));
bufferMoreData();
}
function bufferMoreData() {
if (playing) {
dynamicAudio.write(modPlayer.getSamples(88200));
setTimeout(bufferMoreData, 100);
}
}
function stop() {
playing = false;
}
function loadRemote(path) {
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);
}
var binString = ff.join("");
var modFile = new ModFile(binString);
//console.log(modFile);
//var modFile = new ModFile(mod);
modPlayer = new ModPlayer(modFile, 44100);
play();
document.getElementById('status').innerText = '';
}
}
document.getElementById('status').innerText = 'loading...';
fetch.send();
}
</script>
</head>
<body onload="init()">
<h1>JSModPlayer</h1>
<h2>the imaginatively named Javascript .mod player by Gasman</h2>
<ul>
<li><a href="javascript:loadRemote('mods/ambpower.mod')">Ambient Power (Vogue / Triton)</a></li>
<li><a href="javascript:loadRemote('mods/dope.mod')">Dope / Onward Ride (Jugi / Complex)</a></li>
<li><a href="javascript:loadRemote('mods/frust.mod')">Mental Frustration (Nugget / Rebels)</a></li>
<li><a href="javascript:loadRemote('mods/mindkick.mod')">Mindkick (Mindfuck / Mentasm)</a></li>
<li><a href="javascript:loadRemote('mods/sundance.mod')">Sundance (Purple Motion / Future Crew)</a></li>
</ul>
<!-- <button onclick="stop()">stop</button> --><p>(refresh the page to stop audio - no proper playback controls yet...)</p>
<div id="status"></div>
<p>This is a work in progress - not all effects are implemented yet. Sound output is done with Ben Firshman's <a href="http://github.com/bfirsh/dynamicaudio.js">dynamicaudio.js</a> (using Firefox's audio data API, falling back on Flash if not available).</p>
<p><a href="http://github.com/gasman/jsmodplayer">source code, on Github</a></p>
<p><a href="http://twitter.com/westdotcodottt">@westdotcodottt</a> - <a href="http://matt.west.co.tt/">matt.west.co.tt</a> - <a href="mailto:[email protected]">[email protected]</a> - 22 May 2010</p>
</body>
</html>