News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

Could somebody tell me more about SNES Compressed WAVs?

Started by Kitsune_Phoenix, May 27, 2014, 07:10:18 AM

Previous topic - Next topic

Kitsune_Phoenix

*deleted post*

Szandor

You might want to look at this wikipedia article on BRR encoding:

http://en.wikipedia.org/wiki/Bit_Rate_Reduction

Its only been used in compressing SNES sound samples; and it does take a significant hit in quality (it is a lossy compression). It's only designed to take sets of 16 16-bit PCM samples, and reduce the effective bit depth so you get 9-bytes of data out. The format isn't really appropriate for a modern system that isn't limited by storage space as old systems (like the SNES) were, which is why it was mainly used on the SNES (and was an option on the PS1).

Kitsune_Phoenix

#2
*deleted post*

Szandor

The reason you don't hear any compression artifacts is that that its not the same type of lossy compression. Modern lossy audio compression (mp3, ogg, aac, ac3, etc.) essentially work by removing frequency components that you are not likely to be able to hear (or perceive). If you remove too many frequency components, it begins to remove audible sounds too, resulting in the muddled or underwater sounding effects (compression artifacts). If you are familiar with Fourier theory and analysis, they are very closely related.

Bit rate reduction is more like resampling 16-bit audio to 8-bit audio (or less). But it does more, it also defines a set of filters, presumably to cover up some of the inaccuracies that occur in encoding. These appear to be able to be changed from a block to block basis too, to adaptively reduce artifacts.

QuoteOkay, is there a possibility to get a format that sounds better bit is the same relative size? Like Variable Bit Rate or Solid Compression?

Variable bit rate and solid compression are not compression formats. They are techniques used in compression. Most compression formats (lossy and lossless) have many stages that are chained together to maximize the amount of compression that can be achieved. Most of these techniques are computationally expensive to perform, so never made it into the SNES. But, even in a game like Super Metroid, they used baby simple compression for room data, graphics data, and some palette data (I think). I once figured out that the decompressed room data alone would have been as large (or maybe larger) than the rest of the rom. Pretty impressive for inexpensive 1990's technology. (I should dig up my notes for this, it was pretty impressive.)

Also don't forget that in the SNES they are storing samples with the instructions on how to use the samples to recreate music. The SPC700 effectively assembles the audio file on the fly, as needed. Tracker formats do the same thing, thats why they can be much smaller than the resulting music file. These tools may re-use the same sample for multiple notes, pitch correcting them along the way. That alone can cause a huge space savings.

Modern tracker software is used mainly to make music, without needing to worry about space. So people (naturally) want to use the highest quality samples with the least number of pitch corrected samples. I've seen some amazing sounding tracks that are 15-20 MB for a 4-6minute song, which in a good quality mp3 or aac format would be maybe 5MB. (I've also seen the reverse, 500 kb tracks that have 20-30 minutes of music which would otherwise be 50MB in mp3.)

So what I'm getting at is you need to pick a format where you weigh your options. From what I've seen, many computer games store music and sound effects in a compressed format (like ogg, frequently used since you don't need to pay royalties for the decoder), or sometimes in straight WAV files so their engine does not need to worry about the overhead of decoding. I'm sure console games probably use what ever format the console audio hardware supports. Without knowing what you are trying to achieve, I'm not sure what else I can say.

I rambled on a bit there, hope I was of some help.

Kitsune_Phoenix

#4
*deleted post*

Szandor

D'oh! Sorry I misinterpreted your post.

Since you're going to use tracker music in Unreal Engine, I'm guessing it has support for tracker formats (or some extension module that does)? Honestly, the easiest thing to do is convert the samples to whatever format the tracker playback module supports. Since you're going to package them in RAR archives, and RAR actually compresses uncompressed wav's fairly well, so that might be simplest and most effective method to implement. It might even get close to the SNES BRR compression which is about 3.5x.

The other possibility is leaving it in the SNES format and write code that at run time converts the samples to raw PCM samples for the tracker, but that's probably more work with little gain.

Good luck on the project though! Sounds interesting!

Kitsune_Phoenix

#6
*deleted post*

Szandor

QuoteThe SPC sequencer format is incompatible with trackers, though.

Not surprised. I could possibly see someone designing a converter, but since every SPC programmer undoubtedly had their own programming style, the only possible way I could see this done is basically by emulating the SPC and then periodically output the state. This would be a cool project, but I could see it being a bit tricky. That and you would need to understand all the internals of the SPC and a tracker format beforehand. Sounds painful to me.

QuoteI plan to re-add tracker support in Unreal Engine 4 though

Very cool. I wonder if there are any libraries out there that would save you lots of work. Maybe there is a library thats mainly used on Linux/Unix that has a Windows port that would help.

I've always been very impressed with tracker formats. I remember my first exposure to them back in 8th or 9th grade (like maybe 1996) and playing around with some awesome DOS music player programs. That and the old demoscene programs that had psychedelic visuals with like 20 minutes of music in like 100kb. Back when SNES emulation was a dos program called ESNES that could only play games at like 1/3 speed. Oh the good old days...

Kitsune_Phoenix

#8
*deleted post*

Crashtour99

That's because SPCs come with their own sound samples while .midi files use the samples that come packaged with your PCs OS (if it has software for sound emulation / synthesizer stuff like Windows uses for .midi).

Or you could do something like I did.
https://dl.dropboxusercontent.com/u/9394977/SM-Phendrana%20complete.mp3
https://dl.dropboxusercontent.com/u/9394977/sektor4.mp3
https://dl.dropboxusercontent.com/u/9394977/Quadraxis.mp3
https://dl.dropboxusercontent.com/u/9394977/Flaahgra-theme.mp3

These are exported .mp3s from FLStudio-11 using a custom Super Metroid soundfont I created from samples exported from the ROM.  Everything including the soundfont is still a WIP, but it's a good way to lay out the music and see what it sounds like before starting to code it.
If you want your .midi to use custom samples instead of the default OS ones you'll have to make sure it loads a .sf2 / soundfont using the samples you want.

Hawntah

Quote from: Crashtour99 on June 09, 2014, 05:37:08 AM
Or you could do something like I did.
https://dl.dropboxusercontent.com/u/9394977/SM-Phendrana%20complete.mp3
https://dl.dropboxusercontent.com/u/9394977/sektor4.mp3
https://dl.dropboxusercontent.com/u/9394977/Quadraxis.mp3
https://dl.dropboxusercontent.com/u/9394977/Flaahgra-theme.mp3
Did you make the MIDIs for these? Because they're.. well.. not very true to the original songs, to say the least. :neutral:

Anyway, how would one go about making a soundfont, and how hard/time-consuming is it to make one? Because a Zero Mission soundfont would make my life (or at least inserting decent-sounding songs into ZM hacks) quite a bit easier. I found a program that extracts the sounds from GBA ROMs and converts them into a soundfont, but, apparently, the GBA Metroid games use a slightly modified version of the engine used in most GBA games, so they aren't compatible..

Crashtour99

Well, like I said they're still work in progress.  But I was going more for remixed kinda stuff instead of direct ports.  Some of them I got the notation for from sites like vgmusic.com and the like.  Others I had to do by ear.

As far as making a soundfont, once you have the .wav files for the samples you can use a couple of different programs to make it.  I used a couple free ones called Viena and Polyphone.  Viena I used for in depth editing the .wav files and finding loop points / ASDR settings, and Polyphone for actual creation of the .sf2.

Kitsune_Phoenix

#12
*deleted post*

Quietus

* Kitsune_Phoenix mentions 'tracker' in a reply.
* Quietus quietly leaves.

Szandor

Unfortunately ImpulseTracker's source hasn't been released yet. The author said "later this year." I assume he might be trying to work out some bugs or maybe remove some swearing from the source files (I know I have a few code files that I'd never want another person to look at :P).

Other than that, its a cool idea. But, it is something like 230k lines of x86 (probably 386) ASM, made for DOS. It might be tricky to add stuff to it.

Kitsune_Phoenix

#15
*deleted post*

Quietus

Quote from: Kitsune_Phoenix on June 09, 2014, 10:47:17 PMSo does that mean you are one of those people who thinks anybody who writes Tracker music is not a real musician?
Not at all.  It just felt like every time I read one of your replies over the last week or so, that word was in there somewhere. :heheh:

Zhs2

Modules are amazing. Trying to jam them into Super Metroid isn't. Not to mention that the concept of "Super Famitracker" is kind of silly - if the intent is to output SPCs, that's fair, but what could you actually do with them afterward? The note data is what's most important as the game defines the rest of the samples - could just get that from writing MIDI music. General use? Nah - can do exactly the same thing with ImpulseTracker modules, and more! Maybe that last one is just me, though; why sacrifice functionality for nostalgia?

Kitsune_Phoenix

#18
*deleted post*

Zhs2

Could just rip all of the samples and pass the sample packs around for people who wanted to compose music in that style. Hell, could use the stuff with composers like Fruity Loops that way too. Might catch hell from the original game owners but you can't win 'em all.

The stone wall here is decoding the SPC assembly instructions - yes, SPCs are effectively emulated; writing out the instructions on demand from a tracker would be the headache and a half for anyone who dared to attempt it, and that speaks nothing about all of the various items the processor supported to be considered for writing out to file. (I know nothing, I can't offer any examples.) I hate to be throwing equally as many darts at the wall here for the sake of technical discussion, but I should wonder if SPC has some major killers going for it that modern modules don't need to deal with: limitation of two banks in size, including samples... the aforementioned instruction set... arbitrarily-developed tag spaces that aren't necessarily the same between any two player devs...

Kitsune_Phoenix

I don't mean ripping the game's samples specifically, but making a modern format or piece of software that uses the BRR codec (or an improved variation thereof.)

Crashtour99

The thing to remember about SPCs is that the sound engines aren't all necessarily the same between games.  ChronoTrigger's sound engine caters primarily to music, while SuperMetroid relies heavily on sound fx.  As a result, the engines may be the same basic SPC format, but they are coded very differently.  I remember reading an IRC log where MathOnNapkins mentioned that even the instruction set (which the engine is coded in) may not be the same between games.  It all depends on how the entire thing was designed by the game devs.  They're about as far from universal as you can get while still being the same format.

Kitsune Phoenix, just what precisely IS your goal?  From what I can tell, whatever it is you're going after could be accomplished far easier and better with modern techniques and resources.  The NSPC-700 is a 20 year old relic.  Trying to integrate it into something modern is beyond silly.

Kitsune_Phoenix

#22
*deleted post*