Closed mrdoob closed 8 years ago
Definitely a good idea, though I'd need to introduce some sort of viewer callback mechanism from the player. Hmm.
You could use https://github.com/nwjs or https://github.com/atom/electron for the standalone client.
@luckcolors I meant a library that only cares about reproducing the file, without the visualisation part.
Yeah. I'll work on splitting it out. The code needs a bunch of cleanup first, and a unit test suite before that, because it's sort of fragile, since so many mods rely on various corner cases. Trackers didn't have linters back then :/
@mrdoob Ah ok. I will make a separate issue for the native app.
oops, bumped the button. A native app sort of defeats the purpose...
Well it will be just packaged in a differen way. The app will be the same as the one inside the browser.
With 8e114a16da95a5fea14e75a32180d32dcb7d79a3 it's now possible to play without a viewer, though you still need to create a few XMView stubs to do it. I'll have to add a few checks so that isn't necessary.
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 randomlyXMPlayer.playXM()
-> starts playingXMPlayer.pauseXM()
-> obviousXMPlayer.stopXM()
-> obvious; call this before loading a new oneLoading 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 timestampvu
- Float32Array of RMS power (volume) for each channelscopes
- [Float32Array] of oscilloscope data, one array per
channel; XMView.scope_width
contains # of samples to produce heresongpos
- position in the song (# patterns played)pat
- pattern number currently playingrow
- row within patternXMView.pause()
- pause visualizationXMView.stop()
- stop/reset visualizationMay I suggest... XMPlayer.init()
, XMPlayer.load(ArrayBuffer)
, XMPlayer.play()
, XMPlayer.pause()
and XMPlayer.stop()
?
Heh, yeah, now that those functions moved into the namespace, that makes more sense...
What do you think about taking the viewer code out of xm.js into viewer.js so xm.js can be used as standalone player? (You know, for demos and stuff 😉)