NSF player for Java or Flash?

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
NSF player for Java or Flash?
by on (#59108)
I am curious about this as I may want to showcase some on my website. I heard about someone wanting to port an NSF player to Actionscript 3 but not knowing how to (there was someone suggesting a C->actionscript wrapper or something)

But anyway I'm just curious if there is one. If not, no biggie :)

by on (#59113)
Java has NES emulator applets. Can you try converting the NSF to an NES ROM and playing it in one of those?

by on (#59164)
I ported my NSF, GBS, SPC, and VGM players to Java a while back. I'll see if I can finally release it.

by on (#59187)
Here's a test page for the player: GME Java test

Click on a song to start it. Previously played songs can be gone to via the Prev button. Click Stop to pause/unpause. If you check Playlist, when you click on a song it adds it to the list without stopping the current song.

The GUI is crap, because I don't use Java and my development machine is inadequate for Java development. The underlying library is clean, so I'm hoping someone can write a better front-end. Contact me and we can work on this.

Internally, it supports uncompressed files, gzipped files, and zip archives. It caches the file at the URL of the current playing song, so for example playing several tracks from the same NSF or from the same zip archive is fast and doesn't involve any re-downloading.

Please don't share the URL, as it probably has problems and I don't want massive bandwidth usage. Please let me know how you like it, what it needs, whatever. I need someone who uses Java regularly to take over the front-end and make it non-crappy.

by on (#59188)
Is Lavos's theme correct? It sounds a little distorted at the beginning.

by on (#59189)
Probably not, as I may have ported the old OpenSPC-based DSP. But the focus here is on the Java portion, not fine accuracy. Let's get the front-end working well first.

by on (#59191)
Nice little player. The sound accuracy is good. It's the first time in a while that it was worth to use java in my browser ;)

by on (#59212)
tepples wrote:
Java has NES emulator applets. Can you try converting the NSF to an NES ROM and playing it in one of those?


I probably should have mentioned that I explored that option, but the forum post I read stated that that emulator only plays actual ROMs, and my Mega Man 10 NSF is way too large to fit in a regular NES file.

Blargg, that emulated sound engine is pretty awesome, GUI be damned (I favour sound quality over how good something looks anyawy, that was always the old MikMod motto, anyways).. Is it okay to try and salvage the applet and use it on my website? Or should I wait for you to release it? :)

It's a GBS player too? Awesome, I can finally release the Infinity Game Boy Color soundtrack without linking to my host's low quality MP3s! ;) ..That is, if I get the OK from you :)

by on (#59216)
Blarg is a nice guy, I would be surprised that he would say no. If that was the case, he would have not give the link here in the first place.

by on (#59217)
Yes, please give it a try. My main goal is to find someone to maintain it, including cleaning up/redoing the GUI front-end. I will of course be releasing the full source code. I want to avoid something half-done getting out there in general use.

I buried a readme.txt on the test page, BTW, and it describes (I hope) all the features it currently supports. As the test page shows, it supports NSF, GBS, SPC, VGM/VGZ (including Sega Genesis).

by on (#59219)
I managed to get it to work here:

http://tssf.gamemusic.ca/nsf.html

It seems the square channels are louder than the triangle/noise channel tho, I don't suppose there's a way to lower Square 1 and 2's amplitude so that they're not drowning out the triangle/noise, is there? :) (I suppsoe I could do it in-NSF tho by modifying the instruments)

by on (#59348)
That page tssf has posted, has moved to http://tssf.gamemusic.ca/emuplay.html, linked from the Credits section of his web site.

by on (#59376)
I always thought it'd be nice if there was something like this for NES music-
http://www.lemon64.com/music/

by on (#59388)
OK, I posted the complete source code: Game_Music_Emu_Java.zip

I also fixed the NSF relative APU volumes and updated gme.jar on the site and in the above archive. It was quite off before.

I looked and the SPC DSP code is actually port of my latest fast DSP. I played the Lavos intro squeal and it sounds fine to me, as compared to the accurate DSP.

by on (#59395)
Awesome, I'll update gme.jar when I get home. This will make things sound great! Blargg, you seem to be the reason why sound in the emulation world is so great, so thank you for that. :)

by on (#59398)
For me, he's the "sound god" :P

by on (#59412)
Blargg, Lavos sounds fine.

http://tssf.gamemusic.ca/Remakes/ZeroLavo.mp3 <- an MP3 of a Lavos remix I did back in the day, and it had a (albeit processed with reverb) sampled Lavos scream straight from Square's OSV.. (Can't get any more accurate than that)

.. It could be much worse though. You could have a scream that sounds like the Playstation/Nintendo DS version:
http://www.youtube.com/watch?v=zRyQf-R6xKM&fmt=21#t=5m41s

by on (#59461)
As I remember, getting that sound correct meant figuring exactly how the pitch modulation worked, and finding how the BRR decoder behaved when pushed to decode more than 4 samples for each output sample. It's nice that even the fast DSP (which the Java version is based on) still plays it correctly.

by on (#59530)
blargg wrote:
Here's a test page for the player: GME Java test

Click on a song to start it. Previously played songs can be gone to via the Prev button. Click Stop to pause/unpause. If you check Playlist, when you click on a song it adds it to the list without stopping the current song.

The GUI is crap, because I don't use Java and my development machine is inadequate for Java development. The underlying library is clean, so I'm hoping someone can write a better front-end. Contact me and we can work on this.

Internally, it supports uncompressed files, gzipped files, and zip archives. It caches the file at the URL of the current playing song, so for example playing several tracks from the same NSF or from the same zip archive is fast and doesn't involve any re-downloading.

Please don't share the URL, as it probably has problems and I don't want massive bandwidth usage. Please let me know how you like it, what it needs, whatever. I need someone who uses Java regularly to take over the front-end and make it non-crappy.

by on (#59532)
Weird...tssf's site works fine, but blargg's is silent. Doesn't look like the files ever actually start playing, since the counter is missing. :\

Firefox 3.6.3 here, dunno what version of Java (fairly recent I'm sure).

by on (#59539)
Argh, forgot to update URLs on page when I moved it to a different server. Works now on my machine here. Thanks for notifying me of the problem.

by on (#59549)
The only problem I've had is the fact that I can't make files that aren't archived play. Like, if I linked to MegaMan9.nsf, it would ignore it and not play anything.

Also, is there a way for it to generate a playlist without having to "add" the file to the playlist? (Kind of like a "play all tracks" function?)

This java player is extremely accurate and very awesome indeed, I hope it evolves into something very great :)

by on (#59556)
Uncompressed files work for me. For example, <a href="javascript:gme.playFile('http://example.com/Blaster_Master.nsf','',3)">Blaster Master - Underground</a>. What HTML were you using to link a file?

There aren't any meta functions for playlists or track names embedded in files. My idea was that you'd build the appropriate JavaScript to add all the files from an album, using some database or other program. This gives you complete control over presentation and track length, without the need for a complex interface in the applet for selecting what to play.

I do need to add an addFile() function that doesn't play the track immediately (basically acts like Playlist checkbox is checked, regardless of whether it really is). I also noticed that the automatic next track code is commented out (and of course this doesn't do any automatic end-of-track silence detection, as I assume you specify an appropriate song length already). I had lots of problems with the front-end on my old iMac running a really old version of OS X (which is the newest computer I have, sadly). We need to find a Java programmer to work on the front-end.

It would be cool if someone provided a 7z and/or RAR reader for Java, then this applet could play NSF music from all the archives out there. I cringe at the thought of a RAR reader in Java, allocating 40MB or more just to access a file.

by on (#59559)
RAR is non-free. As for 7-Zip, check out LZMA SDK.

by on (#59650)
blargg wrote:
Uncompressed files work for me. For example, <a href="javascript:gme.playFile('http://example.com/Blaster_Master.nsf','',3)">Blaster Master - Underground</a>. What HTML were you using to link a file?

There aren't any meta functions for playlists or track names embedded in files. My idea was that you'd build the appropriate JavaScript to add all the files from an album, using some database or other program. This gives you complete control over presentation and track length, without the need for a complex interface in the applet for selecting what to play.

I do need to add an addFile() function that doesn't play the track immediately (basically acts like Playlist checkbox is checked, regardless of whether it really is). I also noticed that the automatic next track code is commented out (and of course this doesn't do any automatic end-of-track silence detection, as I assume you specify an appropriate song length already). I had lots of problems with the front-end on my old iMac running a really old version of OS X (which is the newest computer I have, sadly). We need to find a Java programmer to work on the front-end.

It would be cool if someone provided a 7z and/or RAR reader for Java, then this applet could play NSF music from all the archives out there. I cringe at the thought of a RAR reader in Java, allocating 40MB or more just to access a file.


Oddly enough I linked it the same way your example states. It's not a big deal, I mean archiving the NSF files speeds up the playing delay time due to download speed (I'm capped) anyway.

I was wondering if it had RAR support, I never did try..but it's not a big deal.. if it can save space and just have ZIP support, that should work just as well.

Any thoughts on adding a PSF loader to your library? Hehe. Kidding of course. That's probably way too much, and to think some PSFs use libraries, you'd have to definitely load the instrumentation file before anything would play..which I guess wouldn't be too hard, you'd just have to add an extra string.

Anyway great work. I'm hoping for a better GUI in the future, but a lot of people need to get wind of this app before it will probably get the support it needs.. perhaps make an announcement on zophar or something?

by on (#59653)
I actually found a port of unrar for Java, but none of my computers have a new enough Java runtime to even run it, so I can't test it. I didn't see any Java versions of 7-zip, just the low-level LZMA SDK, so no easy way to support that.

I really need to find someone who can take over this project, at least everything except the emulation code. I don't have what it takes to move this much farther forward. I've been sitting on it for almost two years now, so at least it's seen the light of day.

by on (#90197)
Doesn't work for me.

I extracted Game_Music_Emu_Java.zip to a folder, then created "test.html" in the folder. I've experimented with files both extracted and not, with various parameters, but I never hear a peep from the player.

Here's the contents of my test.html:
Code:
<html>
<head>
<title>GME Player</title>
</head>
<body>
<div id="divgmeplayer">
   <APPLET archive="gme.jar" code="gme" name="gme" width=400 height=100>
      <PARAM NAME="BACKGROUND" VALUE="1">
   </APPLET><br>
   <a href="javascript:gme.playFile('batman.nsf','',1)">Batman Stage 1</a><br>
</div>
</body>
</html>


How can I make it play the damn NSF file?

Thanks, Blargg!

[edit]
Note: I couldn't get tsst's site to play either, but then it suddenly started working. Mine still doesn't work.

by on (#90254)
...and now, mine has started working.

I can't figure out why only the first two TMNT4 SPC tracks will play.

http://dl.dropbox.com/u/19038986/Game_M ... /test.html

Let me know if it works for you. I have to click a track and then click "Prev" to make it work.