gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Audio > wav faq - step by step

#6818 - Malefactor - Tue Jun 03, 2003 3:21 am

I've been working at playing sound on the GBA for awhile now, specifically a wav file.

I have successfully generate sound via the various tutorials available, but when it comes to making a prog that plays a wav file I always seem to miss something.

To keep it short, I'm looking for step by step instructions; a sort of GBA sound for dummies. I want to do this the easiest way possible, and then I'm sure I could expand on my own from there. I don't need anything fancy like a high bitrate or stereo sound. I just want something that doesn't snap, crackle, pop, hiss, fizz, jump or skip on hardware.

Let's do this in an FAQ format.


1. I'm told told that the best format to use is
tepples wrote:
8-bit PCM with the sign bit flipped, at sample rates in the neighborhood of 21 kHz or below.

is this true?

2. What tool should I use to convert a wav file to that format?
_________________
[Images not permitted - Click here to view it]

#6823 - tepples - Tue Jun 03, 2003 4:40 am

Malefactor wrote:
To keep it short, I'm looking for step by step instructions; a sort of GBA sound for dummies.
[...]
1. I'm told told that the best format to use is
tepples wrote:
8-bit PCM with the sign bit flipped, at sample rates in the neighborhood of 21 kHz or below.

is this true?

Yes. The GBA's native sample format is 8-bit signed PCM (minimum 0x80, neutral 0x00, maximum 0x7f). The low sample rate is to keep your waves from taking up too much cart space.

Quote:
2. What tool should I use to convert a wav file to that format?

For TOD, I wrote my own conversion tool based on the wav specification, but there are probably a few tools in gbadev.org's tools section. I really ought to package my tools separately so that "what tool?" FAQs don't keep popping up all the time.

Now do you want just one or two wav files at once, at fixed volume, or do you want a full mixer?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#6825 - Malefactor - Tue Jun 03, 2003 5:57 am

tepples wrote:
Yes. The GBA's native sample format is 8-bit signed PCM (minimum 0x80, neutral 0x00, maximum 0x7f). The low sample rate is to keep your waves from taking up too much cart space.

Makes sense to me.
tepples wrote:
For TOD, I wrote my own conversion tool based on the wav specification, but there are probably a few tools in gbadev.org's tools section.

I think one of us is misunderstanding my question. First I want to know how to whip a wav file into shape so that I can use one of the tools to convert it to .. lets say a header file .. I've heard that if I used Windows Recorder to record a sound, it won't work.
tepples wrote:
Now do you want just one or two wav files at once, at fixed volume, or do you want a full mixer?

I have very little sound programming experience, and all the talk about mixers just sends me further down The Sprial of Confusion.

The application only requires one sound at a time so that would be fine.
_________________
[Images not permitted - Click here to view it]

#6856 - gb_feedback - Tue Jun 03, 2003 5:19 pm

Save your sound, from whatever app it may be, as a wav file and specify 8 bit mono.

Then your file will contain the bytes you need in sequence, preceded by a header, and maybe followed by some other rubbish. I have often used just a hex editor, extracted the relevant bytes, inverted the msbit of each byte, and saved the result which is the bytes you need in the gba.

To know which bytes to extract it helps to spend half an hour reading a specification of the wav file format, found at say, www.wotsit.org. The only caveat here is that you should read several specs to find the simplest description of the basic wav file. The 'standard' is a real bastard made up of bits and pieces from all kinds of people. But the basic spec is almost trivial.

If the sound capturing app can be made to save in 8 bit mono, and if it uses no fancy compression storage, then the app is fine. I don't know why Windows Recorder (which I haven't used) shouldn't do the job just fine. I'm a great fan of Goldwave myself - well worth the registration if you get on with it.

Finally to write your own tool to locate the right bytes, complement the first bit, and save into another file, is really simple once you know what you need.
_________________
http://www.bookreader.co.uk/

#6927 - Malefactor - Wed Jun 04, 2003 4:58 pm

So are you saying that I need to get rid of the header and footer/trailer before I run it through one of those tools?
_________________
[Images not permitted - Click here to view it]

#6961 - gb_feedback - Thu Jun 05, 2003 9:41 am

I'm saying that 5 minutes with a good hex editor (and a wav file spec) will allow you to extract the data (as binary) without needing any other tools.
This assumes the wav file was saved in mono 8 bit.
A 'tool' would do the same thing but much quicker and would produce the output in the form you wanted. Say, as text for a .h file.
_________________
http://www.bookreader.co.uk/