Skip to content

Web version of vgmPlay

Technical discussion about the VGM format, and all the software you need to handle VGM files.

Moderator: Staff

Post by vampirefrog »

I think I found a possible bug. Sometimes p.getPlaybackPosition() is bigger than p.getMaxPlaybackPosition(), especially during fade-outs. So maybe getMaxPlaybackPosition() isn't adding the fade-out seconds? I noticed this when i was making the progress slider, it went out of the page until I made it hide overflow. If you look at the project2612 pages, you'll see that songs that loop stay on 100% while they're fading out. Try http://project2612.org/details.php?id=61 track 02.

Also, regarding the Tag functions above, are these already implemented? Can I already access them from JS? I don't want to compile it myself, I fear it would take a while to get it to work.

Is there a way to avoid getting a message box if WebAudio is not supported? In the case of project2612, I just want the player buttons and progress bars to appear if playback is possible. Otherwise I want it to pretend there is no player. Maybe I can just call the verification function myself before initializing the player, and use the player ready callback to show the player controls (I do the latter part anyway).
  • tinyrsid Offline
  • Posts: 35
  • Joined: 2015-05-19, 22:03:39

Post by tinyrsid »

I am currently using neither FadeTime nor PauseTime (whatever that might be..) so I should probably add those..

The above mentioned tags are implemented and you'd access them on the JavaScript side using the keys: title, author, desc, player, program. (any additional tags would first need to be implemented)

Post by vampirefrog »

Thanks, I'll implement those once I figure out how to integrate them with the player design without cluttering the page.

I have another idea now, which would add a lot of visual value to the pages using the VGM player. If you look here you'll see my AS3 VGM player. It supports a few chips, and out of those, YM2612, SN76489 and YM2413 can output note information, so if you play for example, Green Hill Zone, you will be able to see all the notes. To do this, I implemented a callback for each chip, which gets called whenever there's a Note On or Note Off event, which the chip decides when that happens, depending on its input commands. I implemented this only in the AS3 version, but it can be implemented in the C version as well, so I'm thinking of doing that, at least for the YM2612 and SN76489, and somehow displaying them in the page. To display them, I can write a separate JS library that can display keyboards and piano rolls, but the note events have to get to it somehow. Sometimes it can be tens of events per second, so do you think this would be an issue with bridging the emscripten app with JS? Would there be a lot of overhead to this? Maybe there's a way to lower the overhead somehow, what do you think?

If we can manage to implement something like this, it would make the player so awesome and it would increase the site popularity gosh wow!

I can try to just implement the note events in one of the chips, like ym2612, and figure out a way to call a JS callback for every event. All the chips would call the exact same callback btw, which can look like this: void noteFunc(uint8_t chipId, uint8_t channelId, uint8_t noteNum, bool onOff); As you can see, the parameters can be condensed into a 32-bit unsigned int. The onOff parameter can even be the sign of the int. This might help optimize the bridge between the emscripten code and normal JS, so we can use that if it helps.

What do you think?

Another idea I have is to name the instruments. For example, in Green Hill Zone, there is a bass, some drums, a sort of flute, some pad keys, and other instruments, which we can list in some sort of metadata that can be an associative array of the instrument CRC32 values and the instrument names. That way we can quickly find the instrument when the chip registers correspond. It would require extra work to input the instrument names, but it would be a cool feature. We can also autodetect the instrument names from their timbres. Maybe there is a tool for that, or we could write some heuristic that does that.
  • Lupinzar Offline
  • Posts: 11
  • Joined: 2015-05-11, 20:23:18

Post by Lupinzar »

I only have some familiarly with the VGM format, not the playback source, so sorry if this sound stupid. But, is there any reason why you'd have a callback for each note command instead of one callback for all the commands between wait periods? Is it just too difficult to utilize Javascript objects in emscripten?
  • tinyrsid Offline
  • Posts: 35
  • Joined: 2015-05-19, 22:03:39

Post by tinyrsid »

@vampirefrog: "tens of events per second" does not seem to be much.. I'd suggest you just try it. Here is what you need to do:

1) In the C code where you want to call the JavaScript code you just declare the function:

void noteFunc(int a, int b, int c);

2) to the Emscripten built command you add: --js-library callback.js

3) and you create a callback.js with the following content:

mergeInto(LibraryManager.library, {
noteFunc: function(a, b, c) {
return window['someGlobalNoteFunc'](a, b, c);
}
});

This will ensure that the Emscripten build will setup the necessary wiring without it needing to know about your specific logic. You can later just define you "someGlobalNoteFunc" JavaScript function and do with the params whatever you want ..

Have fun :-)

Post by vampirefrog »

Lupinzar, the only time note events can happen IS between wait periods, since that's when the chip commands are issued. So there you go. However, I can also queue the note commands and make a callback when the buffer is filled, and that would be an optimization. I could also send the note events along with the buffer data, I'm not sure how the code works right now. And then just use the queued notes in JS.

tinyrsid, thanks, I guess this means I'll have to attempt to compile it.
  • tinyrsid Offline
  • Posts: 35
  • Joined: 2015-05-19, 22:03:39

Post by tinyrsid »

@vampirefrog: I recommend you install one of the all-included sdk https://kripken.github.io/emscripten-si ... loads.html Compiling should then be no problem.
  • Lupinzar Offline
  • Posts: 11
  • Joined: 2015-05-11, 20:23:18

Post by Lupinzar »

vampirefrog wrote:However, I can also queue the note commands and make a callback when the buffer is filled, and that would be an optimization. I could also send the note events along with the buffer data, I'm not sure how the code works right now. And then just use the queued notes in JS.
Ok, that's kind of what I had in mind.

Post by vampirefrog »

Ok, I managed to compile it, though you should create the directory 'built' from the makeEmscripten.bat, I had to create it manually
  • tinyrsid Offline
  • Posts: 35
  • Joined: 2015-05-19, 22:03:39

Post by tinyrsid »

seems git does not check in empty folders...
  • User avatar
  • MaliceX Offline
  • Posts: 226
  • Joined: 2012-09-29, 11:45:48
  • Location: Australia
  • Contact:

Post by MaliceX »

Indeed. That's why many open source projects have a "delete.me" file of sorts to address that. :P
-dj.tuBIG/MaliceX

Post by vampirefrog »

MaliceX wrote:Indeed. That's why many open source projects have a "delete.me" file of sorts to address that. :P
Sorry, let me translate what MaliceX said, since I know it's hard to understand through his thick aussie accent. He said that's why many open source projects have a "delete.me" file which addresses the empty folder problem. Good day, Bruce!
  • tinyrsid Offline
  • Posts: 35
  • Joined: 2015-05-19, 22:03:39

Post by tinyrsid »

g'day mate, 'ow yer goin? no worries, look at it as an intentional entry test for those trying to use the lib :-)
  • ctr Offline
  • Posts: 492
  • Joined: 2013-07-17, 23:32:39

Post by ctr »

Are you going to update the web player to the latest VGMPlay version? Would be nice to see it support the newly implemented chips.
  • tinyrsid Offline
  • Posts: 35
  • Joined: 2015-05-19, 22:03:39

Post by tinyrsid »

if somebody tells me where to find the latest stable version...
Post Reply