From 8c37c8d96bd3ca4f2ec65ab4118bfc9089bf06dd Mon Sep 17 00:00:00 2001 From: Andy Sloane Date: Wed, 11 Nov 2015 21:09:58 -0800 Subject: [PATCH] Separate html "shell" javascript; player now standalone Closes #3. The code which defines what the buttons do and downloads songs and so forth are now completely separated from the player, which has the following API: - `XMPlayer.initAudio` -> starts up audio context; it's available as `XMPlayer.audioctx` - `XMPlayer.loadXM(ArrayBuffer)` -> returns `true` if loaded, otherwise barfs randomly - `XMPlayer.playXM()` -> starts playing - `XMPlayer.pauseXM()` -> obvious - `XMPlayer.stopXM()` -> obvious; call this before loading a new one Loading trackview.js is now optional; without it, the player won't do any visualizations. Or, you can override the following to get callbacks: - `XMView.pushEvent(e)` -> push an audio event onto the queue. Called once per tick (about 50Hz, controlled by song). `e` contains fields: - `t` - audio timestamp - `vu` - Float32Array of RMS power (volume) for each channel - `scopes` - [Float32Array] of oscilloscope data, one array per channel; `XMView.scope_width` contains # of samples to produce here - `songpos` - position in the song (# patterns played) - `pat` - pattern number currently playing - `row` - row within pattern - `XMView.pause()` - pause visualization - `XMView.stop()` - stop/reset visualization --- index.html | 1 + shell.js | 111 +++++++++++++++++++++++++++++++++ trackview.js | 26 ++++---- xm.js | 170 +++++++++++---------------------------------------- 4 files changed, 164 insertions(+), 144 deletions(-) create mode 100644 shell.js diff --git a/index.html b/index.html index 1370a34..0dfe25d 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,7 @@ +