Split up NSF music

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Split up NSF music
by on (#99804)
Hi there. I did some Googling but couldn't really find what I wanted, so I figured I'd ask here.
Since I stopped using my iPod, I recently dug up Winamp and started redownloading all my NSF game music and other tracked files. And now I'm wondering if anyone has ever endeavored towards splitting up NSF files so that instead of them being packed into one file, you can actually have a playlist. Does that exist? I couldn't find it.
Or maybe there's a specific NSF plugin for Winamp that is able to show the multiple songs inside one file as multiple items in a playlist. That would be neat. :)
Re: Split up NSF music
by on (#99809)
NSFPlug can read M3U playlists that reference NSFs. See its readme file for details. NEZPlug had the same feature.
Re: Split up NSF music
by on (#99812)
Michiel wrote:
Hi there. I did some Googling but couldn't really find what I wanted, so I figured I'd ask here.
Since I stopped using my iPod, I recently dug up Winamp and started redownloading all my NSF game music and other tracked files. And now I'm wondering if anyone has ever endeavored towards splitting up NSF files so that instead of them being packed into one file, you can actually have a playlist. Does that exist? I couldn't find it.
Or maybe there's a specific NSF plugin for Winamp that is able to show the multiple songs inside one file as multiple items in a playlist. That would be neat. :)
It is easy to split up NSFs containing multiple songs into multiple files of single songs each. Just make multiple copies of the single .NSF and patch it to load the A register at the beginning the INIT routine (if there is any unused space in the file). Of course this will waste disk space since you need multiple copies of a file. Using playlists is probably a better choice if you are able to do this.
Re: Split up NSF music
by on (#99827)
zzo38 wrote:
Michiel wrote:
Hi there. I did some Googling but couldn't really find what I wanted, so I figured I'd ask here.
Since I stopped using my iPod, I recently dug up Winamp and started redownloading all my NSF game music and other tracked files. And now I'm wondering if anyone has ever endeavored towards splitting up NSF files so that instead of them being packed into one file, you can actually have a playlist. Does that exist? I couldn't find it.
Or maybe there's a specific NSF plugin for Winamp that is able to show the multiple songs inside one file as multiple items in a playlist. That would be neat. :)
It is easy to split up NSFs containing multiple songs into multiple files of single songs each. Just make multiple copies of the single .NSF and patch it to load the A register at the beginning the INIT routine (if there is any unused space in the file). Of course this will waste disk space since you need multiple copies of a file. Using playlists is probably a better choice if you are able to do this.


Maybe I should have a look to see if I can find a brief specification of the file format so that I can write a splitter program. That way a split file will contain only one of the songs. It doesn't sound like it's the most complicated file format, right?
I'll give that a try a bit later.

edit: ah, interesting! viewtopic.php?t=5480
I might actually do it this way, just make a little script that duplicates the files with a different LDA #xx at the start. It'll waste some space, but NSF files are so tiny to begin with it doesn't really matter.
Re: Split up NSF music
by on (#99847)
Michiel wrote:
It doesn't sound like it's the most complicated file format, right?

It's fairly complicated if you consider that an NSF is basically the game code stripped of anything that's not related to the music, and that each game handles music differently. The NSF specification just "wraps" that code in a way that makes it easier to interface with it.

Quote:
just make a little script that duplicates the files with a different LDA #xx at the start. It'll waste some space, but NSF files are so tiny to begin with it doesn't really matter.

That's exactly what zzo38 suggested above.
Re: Split up NSF music
by on (#99889)
Quote:
just make a little script that duplicates the files with a different LDA #xx at the start.


There is a simpler way. Just adjust the starting and ending song in the header. That's not a good idea to write in LDA #$xx unless you know how to rewrite the code accordingly. Also, there is init code at the beginning of many NSFs and so can't be overwritten unless you want to screw up the NSF.

LDA #$xx
JMP INIT

LDA #$xx
JSR INIT
RTS

LDA #$xx
STA $xx
RTS

ETC.

These are just very basic code examples before you go to the main init. Even those won't work for a lot of NSFs. Especially the ones that require a complicated init routine.

It's better to use a playlist like others suggested. You can also use NSFE which has a lot more information than the standard NSF.

If you decide to split them anyways. Please, don't release them, only for personal use.
Re: Split up NSF music
by on (#99987)
Gil-Galad wrote:
Quote:
just make a little script that duplicates the files with a different LDA #xx at the start.


There is a simpler way. Just adjust the starting and ending song in the header. That's not a good idea to write in LDA #$xx unless you know how to rewrite the code accordingly. Also, there is init code at the beginning of many NSFs and so can't be overwritten unless you want to screw up the NSF.
You have to find an unused area of ROM to do this; you cannot simply put always at beginning or whatever else.

Quote:
LDA #$xx
JMP INIT
Yes, a code like this is what I meant.

Quote:
If you decide to split them anyways. Please, don't release them, only for personal use.
Agreed; anyone can split them by themself.