Play NSF files in Flash 10

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Play NSF files in Flash 10
by on (#61429)
Hello all, I'm new here, but have been hanging out some on the IRC channel.

I just wanted to share a little project I've been working on: Flash 10 playback of NSF files.

It's still really rudimentary and I can't take all the credit, because it uses Blargg's excellent band-limited playback c-libs. I used Adobe Alchemy and some AS3 glue to get what you can see here:

http://p1xl.com/fun/flashnsf/

I'm working on expanding it, so stay tuned.

P.S. check out our website at http://p1xl.com/ and, buy our game if you own an iPhone ;)

by on (#61431)
Nice! I guess that there is no excuse anymore for emulators in Flash not to feature sound, right?

by on (#61435)
tokumaru wrote:
Nice! I guess that there is no excuse anymore for emulators in Flash not to feature sound, right?

How many GHz does NES audio emulation in Flash need? A lot of us are cheapskates with low-end laptops.

And how's the latency? An NSF player can get away with buffering a second of decoded audio because it need not respond to input immediately; an NES emulator cannot.

by on (#61436)
I'm not sure of the flash's latency, but it uses one 6K buffer in the C code. Maybe you can try it out on your system and let us know? My CPU meter shows a 2% usage. I have a 2.5Ghz laptop. Blargg's code is pretty tight.

by on (#61514)
Ok, so some updates. The track select buttons are now limited to the number of tracks. It also displays the Title of the song, read from the .nsf.

http://p1xl.com/fun/flashnsf/

Any feature requests?

by on (#61552)
Nice work, it sounds pretty good.

by on (#61555)
You already know my thoughts about potential NSFE support from the chipmusic forum. :D Great work!

Chipmusic also implemented the current version of the player for uploads-
http://chipmusic.org/bucky/music/the-ex ... l-area-bgm

^There's an upload of mine. Sounds pretty good!

Unfortunately a track with VRC7 isn't working right-
http://chipmusic.org/saskrotch/music/3- ... s-vrc7-nsf

by on (#61564)
Ok, I'm confused.. I thought the foo_gep plugin for foobar2000 used Blargg's libs. It says so on his site. But now that I've read pretty thoroughly through the GME code base, I see that there's *no* VRC7 or MM5 support. Yet, foo_gep seems to play both expansion chips just fine.

In the code base, the chip emulators are called, for instance, Nes_Vrc6_Apu

The strange thing is that if I google Nes_Vrc7_Apu, I get a japanese site showing a patch to get it working, or maybe it's a tweak, I can't tell, but no original file.

Does a Nes_Vrc7_Apu patch exist? How about Nes_MMC5_Apu? I've googled a bunch and can't find anything.

In other news, I've got NSFE's loading, but not reading track info yet. Stay tuned.

by on (#61569)
p1xl wrote:
In other news, I've got NSFE's loading, but not reading track info yet. Stay tuned.


<3

Does it play FDS audio?

by on (#61570)
It has VRC6, N106, and FME-7, didn't see anything about FDS

by on (#61645)
Ok, big look-n-feel update. Colors and buttons sizes are now configurable. Also NSFE display of track names, and playlists are included, but the player doesn't yet honor the NSFE play/fade times (still loops each track forever).

Still no time for documentation yet, but you can see the new params if you view source.

http://p1xl.com/fun/flashnsf/

by on (#61860)
Just dropping in to say nice work!

by on (#61882)
Thanks :) And thanks to Blargg, it now supports the other expansion chips. woot!

by on (#61921)
This is looking really good p1xl! I've been thinking about adding an NSF section on my database site, this would be a really cool way of allowing live playback.

by on (#62059)
Let us know when you're planning on releasing the player. I'd be interested in using it as well.

by on (#62061)
Thanks! Feel free to use it on your site, chipmusic.org already has. I am constantly expanding tho. I suppose it will reach a "stable release" at some point, probably when I finally get around to documenting the config options. For now, you need to "view source" on the demo page.

New Update. There's now a volume control and it remembers your preferred volume level between visits.

http://p1xl.com/fun/flashnsf/

by on (#62064)
A great feature would be if you could switch tunes in the player.

by on (#62073)
This has either been done, or is planned, depending on what you mean. :) You currently can switch between the different tracks in a single NSF/NSFE, and automatically moving to the next track is supported.

However, if you mean having a playlist of several NSF's that you can switch between, that's on the todo list. Watch for updates :)

by on (#62085)
Actually, I think I was tired when I was messing around with it before. Yes, you can switch the tunes. My mistake.

by on (#62148)
Doesn't even open my sound output device under Linux, using the 64-bit beta Flash plug-in, version 10.0.45.2. The track skip controls do update the track title display, but the play and pause buttons don't seem to do anything.

by on (#62149)
That's strange. I supposedly don't have to do any initializations since Flash does it for you. Do any other dynamic sound projects work for you? Like this one: http://www.adobe.com/devnet/flash/artic ... index.html

by on (#62150)
Yes, as does the dynamic sound segment on this page: http://www.adobe.com/products/flashplayer/features/

EDIT: Okay, now that I've installed the latest Flash plug-in 10.1 RC6 using nspluginwrapper, it works. Although I had problems with nspluginwrapper failing after a while under Ubuntu, I'm using Fedora now, and I'll see how it goes.

by on (#63328)
Thanks so much for the flash based NSF player. I've put 4 of my Famitracker covers on my site using the player.

by on (#63329)
Cool :) Glad to hear it's being used, and I really like your cover of Hymn To Aurora. Very nice!

by on (#63336)
I just hate that Firefox makes things hard to test. It disables javascript running from file:// urls.

by on (#63349)
Toss the whole lot of files into the same directory and use relative paths? It shouldn't disable that.

by on (#63350)
Is setting security.fileuri.strict_origin_policy to false in about:config enough?

by on (#64260)
First of all, let me thank you (and blargg) for this. I was so desperate of having a Flash NSF player that I was about to try and make myself, but I certainly wouldn't have done as well as you have. So, thanks, and congrats! :)

Now, I have just a quick question - apparently, the player doesn't like ampersands (&) in NSF filenames. Is there any way around this other than just renaming the file?

by on (#64261)
Seems this is a long standing issue with swfobject. See here: http://code.google.com/p/swfobject/issues/detail?id=66

I'm not sure how you're using FlashNSF, but if you are just typing in filenames, you can work around this by using %26 instead of &. For instance, say you have this&that.nsf, use this%26that.nsf in your file param. Or, if you are using dynamic code like PHP you could do a urlencode() on the filename: echo urlencode('this&that.nsf')

This is the kind of thing you'd need to do anyways if you choose not to use swfobject, and it's up to the swfobject maintainers to fix it, and it looks like they are being a bit stubborn about it.

I tested FlashNSF with the above recommendation and it works fine on files with &'s in them.

Hope that helps

by on (#64271)
I am using PHP, and yes, your recommendation works magnificiently! Sorry for asking, I should have thought about this.

Thank you very much! :D

by on (#64523)
I was wondering if FlashNSF features an option to autoplay a file once it's loaded. I couldn't find it among the other configuration possibilities, so I figured asking here would be my best bet.

by on (#64604)
Sorry for the triple post, but there's something I can't figure out and could possibly be a bug...

I have taken a NSFE file, set the playlist so that there's only one track on it, and reset every track's length and fade to 0 except for the one left in the playlist. NotSo Fatso plays it fine, but FlashNSF skips every track.

Here is an example of such a file.

by on (#64672)
Hi juef, seems like that is a bug, and I've added it to my list, but wouldn't it be more proper to write a new playlist (plst) chunk instead of zeroing out the lengths of the songs?

by on (#64710)
Thanks for the reply! I actually had written a new playlist, but I figured I'd still "initialize" the lengths and fades of tracks that weren't included in it. I have no idea why I thought 0 would be a nice value... :? So yeah, I'll give non-zero lengths to my tracks and create a playlist without problem - it's definitely more proper! I just wanted to report this since this since the NSFE specification allows it. :)

Also, I just wanted to make sure you didn't miss it - have you read my 2nd previous post?

Thanks a bunch! I'm really grateful for FlashNSF and for your help! :D

by on (#64989)
I've added autoplay to my todo list. :)

by on (#65003)
Thanks! :D

I guess I should let you know what I'm doing with FlashNSF!

First of all, I'm conducting a kind of survey on another forum, where the ultimate goal is to make a "Top 100 NSF tracks" list. People have nominated about ~1700 tracks, which would make it impossible for most people to rate each track individually. So basically, I have modified NotSo Fatso so that it can batch-make NSFEs with single-track playlists for each of these tracks, which play randomly and must be rated by the listener.

Somebody suggested I leave the thing online when the rating process is done, so I'm probably just gonna tweak it a little and make it some sort of NSF radio (hence the interest in the autoplay feature :)).

by on (#65008)
Neat! What's the link?

by on (#65017)
Until the rating process is done, I'd rather not post it on another forum; the community participating in this has musical tastes I'd very much like to see reflected in the results.

See your PM's, though!