Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone player #3

Closed
mrdoob opened this issue Nov 10, 2015 · 11 comments
Closed

Standalone player #3

mrdoob opened this issue Nov 10, 2015 · 11 comments

Comments

@mrdoob
Copy link

mrdoob commented Nov 10, 2015

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 😉)

@a1k0n
Copy link
Owner

a1k0n commented Nov 10, 2015

Definitely a good idea, though I'd need to introduce some sort of viewer callback mechanism from the player. Hmm.

@luckcolors
Copy link
Contributor

You could use https://github.com/nwjs or https://github.com/atom/electron for the standalone client.

@mrdoob
Copy link
Author

mrdoob commented Nov 11, 2015

@luckcolors I meant a library that only cares about reproducing the file, without the visualisation part.

@a1k0n
Copy link
Owner

a1k0n commented Nov 11, 2015

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 :/

@luckcolors
Copy link
Contributor

@mrdoob Ah ok. I will make a separate issue for the native app.

@a1k0n a1k0n closed this as completed Nov 11, 2015
@a1k0n a1k0n reopened this Nov 11, 2015
@a1k0n
Copy link
Owner

a1k0n commented Nov 11, 2015

oops, bumped the button. A native app sort of defeats the purpose...

@luckcolors
Copy link
Contributor

Well it will be just packaged in a differen way.
The app will be the same as the one inside the browser.

@a1k0n
Copy link
Owner

a1k0n commented Nov 12, 2015

With 8e114a1 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.

@a1k0n a1k0n closed this as completed in 8c37c8d Nov 12, 2015
@a1k0n
Copy link
Owner

a1k0n commented Nov 12, 2015

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

@mrdoob
Copy link
Author

mrdoob commented Nov 12, 2015

May I suggest... XMPlayer.init(), XMPlayer.load(ArrayBuffer), XMPlayer.play(), XMPlayer.pause() and XMPlayer.stop()?

@a1k0n
Copy link
Owner

a1k0n commented Nov 12, 2015

Heh, yeah, now that those functions moved into the namespace, that makes more sense...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants