Page 1 of 1

Extracting .SPC files from .RSN files

Posted: Sun May 23, 2010 1:36 pm
by Lance Boyle
Just in case anybody wants to know, here's how you do it:

1. Rename the file to have a .rar extension (example: rename the file "swiv.rsn" to "swiv.rar"
2. Extract the file with WinRAR or any program like that

Originally I was going to ask how you could do it, but then I found out

Posted: Sun May 23, 2010 9:23 pm
by tepples
I can use this opportunity to explain the rationale behind RSN.

Solid archives
Often, SPC files will only differ by a few KB, with the rest bit-identical. For example, several songs might all use the same playback code and set of samples, with only the module data (or even just the playback pointer) differing between songs. But because PKZIP always compresses each file as a separate object, it can't take advantage of similarities between files. Even tar.gz, which combines the files before compressing them into a "solid archive", could only reference data from the past 32768 bytes. RAR was the first widely used general data compression program that used a window bigger than a single SPC file, so SPC sets were often distributed as RAR files.

Why specifically RAR
The one disadvantage of RAR is that it is not free software due to a license term prohibiting reverse-engineering the format to create a description of the compression method. 7-Zip and tar.bz2 are free alternatives to RAR, but RAR had the first mover advantage, and music archives that already deal in non-free music have seen no need to repack in a free format.

Why the rename to RSN
The file manager included with Windows is incredibly primitive. Instead of inspecting each file when the user opens it to see what application is best suited for it, it guesses based on the part of the filename after the last period character. That's why various file formats based on PKZIP archives have different extensions: .zip for general data, .jar for Java applications, .smzip for StepMania, .cbz for sequences of JPEG or PNG images ("comic book zip"), .odt for OASIS text documents, .ods for OASIS spreadsheets, etc. Likewise, RAR has .rar for general data, .cbr for image sequences, and .rsn (RAR Super Nintendo) for sets of SPC files.

Feel free to copy this to any wiki you want, as long as I am credited. What is the most popular wiki for Super NES development info anyway?

Posted: Mon May 24, 2010 12:46 am
by kode54
More reasoning behind renaming archives to RSN
The first player to support RSN files was Winamp, which does not support playing files from archives in general without hacks. (Hacks being an input that pretends to support the archives, then unpacks their contents to a temporary folder and opens the resulting files with the correct inputs.)

Players such as foobar2000 do not require the RSN hack since the player itself can support RAR files directly. Of course, you probably don't want to associate RAR files with the audio player, but you can still drag the archives onto the player, as well as open them within the player, and they can contain more than just SPC files. Although most general purpose audio formats are already compressed, so they don't really benefit from being stuffed into other archive formats.

Posted: Mon May 24, 2010 3:16 am
by blargg
Years ago I even wrote a free alternative to .rsn, which put common data into a new file, and had the .spc files reference it. It kept .spc files the same format as currently, except it replaced the 64K RAM with the compressed data/references, then .gz'd them. This way any metadata utilities would continue to work without changes; only players needed to be modified. You could then take this set of .spc and .shared files and put them in an archive, or keep them loose in a directory on your drive. The decompressor was a very short affair. One disadvantage is that you couldn't do as the original poster here did, simply rename the file and use one of several utilities to decompress to normal .spc files.

Posted: Mon May 24, 2010 7:03 am
by tepples
blargg wrote:Years ago I even wrote a free alternative to .rsn, which put common data into a new file, and had the .spc files reference it.
That reminds me of minipsf/psflib.

Posted: Mon May 24, 2010 8:22 am
by kode54
Yes, but this also came with a tool to automate the compression. So far, minixsf and xsflib sets are all manually generated. Except for 2SF. At least I think that's how it's worked out.

Posted: Mon May 24, 2010 8:30 am
by MatthewCallis
tepples wrote:Feel free to copy this to any wiki you want, as long as I am credited. What is the most popular wiki for Super NES development info anyway?
I'll add this to the list of things I need to add to the wiki unless someone beats me to it:

Updated:
Added: http://wiki.superfamicom.org/snes/show/ ... ile+Format

Posted: Mon May 24, 2010 9:34 am
by blargg
kode54 wrote:Yes, but this also came with a tool to automate the compression.
And didn't require 4-40 MB of RAM to decompress a track, making it suitable for portable devices. But RAR wins for general use, and is easily converted to a more specialized format for other uses.

I'm surprised the original poster had to change the file extension. I'd have figured most decompression programs would be able to open and identify a file even if its extension were unknown or wrong, by examining the file header or other signature data.

Posted: Mon May 24, 2010 12:07 pm
by tepples
I can think of a few reasons:
  • Some users might not be aware that one open an archive by opening the compression program itself first. They typically open archives by double-clicking them from the file manager, and they create archives by right-clicking a folder or a set of files and choosing Compress.
  • Other users can open an archive from within the compression program, but they don't know how to change the Open File dialog's filter from "All Archives (*.rar, *.zip, *.jar, *.7z, *.lzma, *.Z, *.gz, *.bz2, *.tar, *.tgz, *.tbz)" to "All Files (*.*)", so they have to rename the file first.
  • Most PC GUIs have made the idiotic design mistake of not starting the Open File and Save As dialog boxes in the frontmost folder in the file manager. Users don't want to re-navigate to a file through a complicated folder structure within the Open File dialog box if they have already navigated to it in Windows Explorer.

Posted: Tue May 25, 2010 1:07 pm
by Lance Boyle
tepples wrote:[...]and .rsn (RAR Super Nintendo) for sets of SPC files.
Oh, so that's what .rsn means! Thanks, man