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 »

ValleyBell is your man. Just ask a more specific question, he says he can't help you from what you've said so far. Maybe isolate a test case.

Post by vampirefrog »

also, to save CPU cycles, you do know that vgmplay has its own resampler, and you can set the output frequency from vgmplay.ini. so you don't have to use your own resampler. One feature of the VGM format is that it's oriented around the 44100 sample rate. Most chips can comply to that rate, only some of them need to be resampled. But if you play at 44100Hz, the CPU usage will be the lowest.

So two things you can do are:

1. Set the default sample rate to 44100 in vgmplay.ini (I don't expect a huge performance increase from this)
2. Use vgmplay's internal resampler (worth a test)

Post by vampirefrog »

I've setup a copy here: http://chiptune.ninja/tools/vgmplay-0.4 ... en/htdocs/

I don't know when I'll have the time to implement it into the packs pages, but I guess it will improve over time. I really just need it to be very simple, like:

var vgm = new VGMPlayer({ /* options */ });
vgm.load('path/to/file.vgz');
/* OR */
vgm.load(buffer);

Do you think you can make it work in a separate Worker thread? Might give better performance, less skipping. The only downside of using Workers is that data is serialized before being transmitted between the Worker and the main thread. It might work well enough though.

Also, if you're curious, here are our previous efforts:

There is NeoLogiX' VGM web player: http://vgmrips.net/forum/viewtopic.php?f=3&t=1601
Then there is my AS3 VGM player: http://chiptune.ninja/dev/chiptune/as3/ ... e/main.php
And there is my JS VGM player: http://chiptune.ninja/dev/vgm/

Each of these has down sides and up sides.

NeoLogiX' player works, but I haven't seen him around, so I guess he's not working on it anymore.
the AS3 and VGM players can be developed and they can work great (the AS3 player even has key display for some of the chips), but again, it's very time consuming.
Your player is almost fully functional but it eats up a lot of CPU. Pretty sure there are still some optimizations that can be made to get it to work really well.

BTW ValleyBell is working on libvgm, which will, as far as I know, separate the components of vgmplay and make them reusable, so maybe you can work with him to figure out a way to make libvgm easily usable with emscripten and ready for web playback.
  • tinyrsid Offline
  • Posts: 35
  • Joined: 2015-05-19, 22:03:39

Post by tinyrsid »

tinyrsid wrote:
vampirefrog wrote:I might know a guy.
cool.. maybe he can drop me a PM or email..
so that should be fixed now.. plz let me know if you still find other bugs

Post by vampirefrog »

if you're curious, I had a C++ -> JS and AS3 converter working here: http://chiptune.ninja/dev/chiptune/clang/test.php

I used it to roughly convert the per-chip code, and then hand fix stuff until it worked properly. It's written with clang.
  • User avatar
  • MaliceX Offline
  • Posts: 226
  • Joined: 2012-09-29, 11:45:48
  • Location: Australia
  • Contact:

Post by MaliceX »

tinyrsid wrote:
tinyrsid wrote:
vampirefrog wrote:I might know a guy.
cool.. maybe he can drop me a PM or email..
so that should be fixed now.. plz let me know if you still find other bugs
Stuff looks good on this end. Perhaps now might be a good opportunity to get it building for v0.40.6!
-dj.tuBIG/MaliceX

Post by vampirefrog »

You should work with ValleyBell so that you can add your #ifdefs to the base code via github.

Post by vampirefrog »

Can you make a stripped down version of vgmplay that only supports YM2612, SN76489, 32X PWM and RF5C164?
  • tinyrsid Offline
  • Posts: 35
  • Joined: 2015-05-19, 22:03:39

Post by tinyrsid »

vampirefrog wrote:Can you make a stripped down version of vgmplay that only supports YM2612, SN76489, 32X PWM and RF5C164?
did you try it yet?

PS: The code needed to play one file would look like this (it shouldn't be difficult to add a little wrapper that is customized to your needs.. just make sure to use the proper callbacks so that the stuff that depends on async file loading is properly setup before you are trying to use it..):

function doOnTrackEnd(){ /* whatever you want to do when the played track ends */}
function doOnTrackReadyToPlay(){ ScriptNodePlayer.getInstance().play(); }
function doOnPlayerReady() {
/* once the player is ready you can start loading song files..*/
var p= ScriptNodePlayer.getInstance();
var options= {};
options.boostVolume= 0; // turn up to play louder

p.loadMusicFromURL('music/whatever.vgz', options,
(function(filename){ /* whatever you want to do when the file has been loaded */}),
(function(){ /* whatever you want to do on 'fail' */}),
(function(total, loaded){ /* whatever you want to do on 'load progress' */}));
}

ScriptNodePlayer.createInstance(new VgmBackendAdapter(), '', ["VGMPlay.ini", "yrw801.rom"], true,
doOnPlayerReady, doOnTrackReadyToPlay, doOnTrackEnd);

vampi edit: http://www.wothke.ch/download/backend_vgm.js

Post by vampirefrog »

That looks very nice. I'll give it a try.

Post by vampirefrog »

I've set it up here but I'm having trouble getting the 32X PWM songs to make any sound. Perhaps it's the same bug as before, when we couldn't hear 32X streaming? Some of the songs work, some don't. Perhaps it's the same fix as before?

A particular case is Popful Mail Opening, which starts with some drums, then the FM kicks in. In the reduced player there are no drums, but in the full one it works fine: http://chiptune.ninja/tools/vgmplay-0.4 ... /index.php

Also, is there a way to get a playing progress callback, and a way to seek? Is ScriptNodePlayer documented anywhere?
  • tinyrsid Offline
  • Posts: 35
  • Joined: 2015-05-19, 22:03:39

Post by tinyrsid »

If something is not working in the stripped version then it's probably due to me just having stripped too much.. (why don't you just use the full version?) There is no real documentation yet.. for seeking you'd use:
var p= ScriptNodePlayer.getInstance();
p.seekPlaybackPosition(Math.round(p.getMaxPlaybackPosition()*relPos));

you'd get the current position using:
p.getPlaybackPosition()

Admin edit: fullquote removed

Post by vampirefrog »

tinyrsid wrote: why don't you just use the full version?
This one is half the size, and we're so close...
tinyrsid wrote: There is no real documentation yet.. for seeking you'd use:
var p= ScriptNodePlayer.getInstance();
p.seekPlaybackPosition(Math.round(p.getMaxPlaybackPosition()*relPos));

you'd get the current position using:
p.getPlaybackPosition()
[/quote]
Thanks.
  • tinyrsid Offline
  • Posts: 35
  • Joined: 2015-05-19, 22:03:39

Post by tinyrsid »

vampirefrog wrote:
tinyrsid wrote: why don't you just use the full version?
This one is half the size, and we're so close...
Here is "my" source code: http://www.wothke.ch/download/vgmplay-0.40.5.zip

When you search for "STRIPPED_VGM" ifdefs you'll find all the places where I am stripping
stuff off. I think it's most efficient if someone familiar with vgmPlay (e.g. ValleyBell) has a quick look - I guess for him it will be obvious if some of the stripped parts are actually needed.

Post by vampirefrog »

Good thinking!
Post Reply