• Status Closed
  • Percent Complete
  • Task Type Patches
  • Category Codecs
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by AdamGashlin - 2006-10-05

FS#6122 - NSF player

Here’s an NSF player, based on NotSo Fatso by Disch.
At the moment it only supports the pAPU, the expansion chip and FDS code is there but I’m working on optimizing the minimal stuff first. Not everything will play real time on my 4g ipod.

Not by any stretch is this “done”, but I figured I should get it out there.

Closed by  pondlife
2007-01-25 18:57
Reason for closing:  Accepted
Additional comments about closing:   Warning: Undefined array key "typography" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 371 Warning: Undefined array key "camelcase" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 407


What’s in the archive?

The archive is the emulation library, libNotSo (from NotSo Fatso), goes in /apps/codecs/. I’d have it in the patch, but I don’t know how to get directories in a patch.

Now full speed for most stuff, sacrificing some accuracy. Wizardry doesn’t work at the moment for reasons to be explored shortly.

Fixed broken mirroring (why SMB3, Wizardry, etc. didn’t work).
Fixed DMC (was all but dead, now try out Journey to Silius!)

Speed improvements, VRC6 support (not full speed for everything, but the first few tracks of Madara run through great).

Cleaned up warnings, removed some unused stuff (might help speed a bit), added FME-07 support.

Added FDS, N106, and VRC7 support (though the latter two are pretty much unusable on my iPod due to them being rather powerful synthesizers in their own right).
Added NSFe loading, track lengths and fade times are read from NSFe. No playlist support yet.
Artist, game name, and company (copyright info) are loaded and displayed as artist, track name, and album, respectively.
I noticed that the loading code is quite endian-dependent (as the files are little endian and the code is written assuming little endian loading of 32 bit integers), this will have to be remedied. Part of this is the reason why there are now warnings shown again.
Oh, and the progress bar will now correctly report the current track as play advances.

Fixed metadata.c reading of number of tracks in NSFe files (had the wrong offset, durr)

Cleaned up endian dependency in the NSFe loading, removed a bunch of stuff related to stereo which isn’t needed (since I only render mono).

I haven’t had this tested on a big endian system, though, if anyone can perform such a test and let me know how it works out I’d very much appreciate it. In fact, it hasn’t been tested on anything but ipods so far. So please give it a go, it is very usable now and could use testing. If anyone is squemish about building the source I can put together a custom build for you.

Fixed a bug, failed to clear out the bank array when loading from an NSFe.

Fixed some more endian issues, haven’t tested this latest version on a big endian target, though.

Backing out some bits that were meant to improve speed but, on further examination, slowed things down. Madara and Gimmick! run full speed again.

0.14 wouldn’t build on coldfire targets due to some bug within gcc, so I changed a number of parameters to const which was probably a good idea to do anyway. Nicer speed and now builds for all targets I’ve tried.
Builds here:

The fellow testing on his H120 for me reported that the last build actually slowed down, so I’ve added some conditional code to disable certain changes I made on coldfire targets. It is still running slower than it should, but he reports it is back up to the performance of 0.13.

A new mode of operation, inspired by a similar setting on the ADX decoder, causes somewhat different behavior when Repeat One is enabled. First, track limits are not enforced (this includes silence detection). Second, since pressing the button to advance to the next track in Repeat One mode has no effect, it is now used to switch to the next song in the NSF, making operation easier than seeking. This is done in a moderately hacky way.
To try to keep things consistent, I’ve named the patch nsf0.17.patch, to show that it comes after the nsf0.16.tar.bz2 (libNoSo). You’ll need the latest numbered version of both the patch and the .tar.bz2 archive to build.

In testing the player, I’ve found it to lock up my H120 while skipping .nsf file (tapping next while not in repeat-1 mode). It was then necessary to reset it using the reset pinhole. The player was unresponsive though the backlight would still brighten and dim with button presses and timeouts.

Do you recall what/how many NSFs you were skipping between? I’ve been unable to reproduce this yet on my ipod, but the architecture is quite a bit different. Does this always happen when skipping?

I cannot easily reproduce it. It seems to be able to happen only on multiple skips so far. If I skip forward, and then skip again before music can start playing (such as seeing that the next NSF file isn’t the one I want) as it seems to take several seconds from skipping into a file before playback starts.

Unfortunately I’m not wholly sure which NSF may have caused the problem. Part of my mind is saying Ninja Gaiden 2, and another part Castlevania 1, but it could easily be neither of those.

Made “repeat one” work a bit more reasonably.
All code is now in a single file (no libNotSo, and now there’s a single patch), tidied up a bit.
Enabled processing of undocumented opcodes (Loopz now works).
Speed seems to have taken a slight hit, much work to be done along those lines.

Oh, something I failed to remember when writing the last comment: VRC7 support is removed, as only one game uses it, it takes up a whole lot of space, and it will likely never run full speed.

I’ve put some profiling code in (disabled by default), helped me find a lot of things to speed up. Mostly at the cost of approximation, though, so if anything sounds off let me know (I haven’t been able to hear the difference). Speed is very much better.

Okay, tried patch 21. On a clean build of Rockbox I applied JUST that .patch file, compile, .nsf files are recognized as music (have the notes next to them) but when I play them it goes to the WPS and says “No File.”

Was I supposed to apply 21 over 20 or anything? (Tested with an H120, just to clarify)

sorry, I’m getting that when cleanly applying the patch too, must’ve screwed up while making it

There were sufficient changes to metadata.c that the patch didn’t go in, and I was only testing rebuilding the codec itself, so I didn’t notice. This new one should work.

Just wanted to follow up to confirm that it’s working here as well. Though, it feels like playback is a good deal slower than it was with 17. I’m not 100% sure, but at the very least on H120 the first song of the metroid .nsf is halting quite a bit, it’s not realtime, and I *think* that I played it succesfully with 17, but I’m honestly not absolutely positive.

Fixed an issue with the triangle wave running even when silenced, causes unpleasant clicks when it comes back on, esp noticable in Zelda 2 track 2.
Speaking of track numbers, is zero-based ok for everyone?

I don’t know what to say about your speed issues… everything is running much faster on ARM. I’d like you to run the profiled version (uncomment #define NSF_PROFILE) so I can get an idea where the problem is, but it uses the portalplayer’s USEC_TIMER, and I don’t know of an equivalent mechanism on the coldfile. Could you try removing the whole #if CONFIG_CPU==etc. block at the beginning? One tester was reporting those helped with speed, but that was several versions back.

NSFE playlists supported (as long as repeat != one, this is assumed to be fully manual mode)

Force reinit of nsf core on track change, changed some related variable names around to make things more clear.

Fixed an issue with repeat one mode, wasn’t behaving properly when selecting a new file.
Moved a lot of stuff into IRAM, helped speed a lot for someone on an H120.
Cleaned up a bunch of code related to mixing that isn’t needed now (since every channel is played at full volume).

Quick fix, I broke the third FME07 channel when moving the mix tables around. Should be good now.

Fixed to compile with current CVS (dithering is no longer controlled by the codec). No other changes.

Sync’d to CVS again.

Sync’d to CVS again.

Problems with IRAM fixed, and more stuff moved into IRAM for additional speediness.

Project Manager

One question: how much have you changed in the original source code?

The reason I am asking is because nsf.c breaks just about every rule we have regarding source code formatting, e.g mixed case identifiers, TAB characters and // comments.

We allow this kind of formatting if it helps us maintain the code, for example patches from the main project, but if you have rewritten large portions of it anyway, we certainly prefer having the code follow our guidelines.

True to form I got some stuff backwards, VRC6 should work correctly now.

It has been substantially rewritten, so I’m going to need to clean it up.

Project Manager

Apart from the formatting, how ready for CVS do you feel it is?

It’s working reliably on several targets (ipods and h120s), the biggest thing holding it back for me is the use of floating point in some inconvenient places. It’d be nice to have some more information in the metadata prefetch, as well, but I don’t think that is critical.

Did some formatting, no tabs and 80 characters per line, got rid of the #define this stuff, removed a bunch of commented code and moved every comment to /* */ format. I specifically didn’t change the capitalization of many variable names, because I think they are most readable in their current form, and the #defines in the CPU emulator are still mixed case.
If this is in good enough shape I’d like it to be considered for CVS.

FDS now implemented with fixed point math. Metadata loading cleaned up. More formatting fixes.

Whoops, typo broke builds with ICODE.

Just some feedback for you from a coldfire user (H320). I queued two NSF files, The Legend of Zelda and Super Mario Bros., let them play and went to the audio debug screen. After letting it play for a while, I got a boost ratio of 10% or so. Nice job, keep it up.


Available keyboard shortcuts


Task Details

Task Editing