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 > Playing a wave file on GBA ? Background noise problem? help

#1189 - notron - Wed Jan 15, 2003 5:07 pm

Anybody out there know some details about the direct sound channels on the GBA. I have stripped the 8 bit samples out of a mono wave file and have set them up to feed directly into Sound Channel A on the GBA using the DMA technique with two timers. ( Timer 0 controls samples per second and timer 1 controls # of samples.) Everything is working just fine and the sound is starting and stopping perfectly. However, there is some kind of really bad background noise in the playback. The data is just 8 bit samples 0-255 with midpoint at 0x80. The samples play perfectly in a wav player with no background noise, but not on the GBA ( using VBOY emulator). There must be something I am missing about the what the GBA sound channel is doing with the 8 bit sound samples.

I have searched all the links/sites on GBA sound and they all seem to indicate that direct feed of the 8 bit signed samples should work.

Any help or information will be much appreciated.
_________________
MysticX is The Defender

#1199 - Splam - Wed Jan 15, 2003 6:09 pm

Make sure they're signed samples, I know you say "midpoint 0x80" but that doesn't always mean the same thing. Also vboy doesn't perfectly emulate the directsound, it actually gives you a bit more leeway with doing things wrong (hard to explain here what, nothing to do with timing, cycles or dma so don't worry abou those) so I'd say it must be the samples aren't signed properly and it certainly would sound like it's playing but with noise (due to the lack of sign the frequency modulation would be almost right but not going in the correct direction) I've had that problem b4 and it was signs.

#1216 - grumpycat - Wed Jan 15, 2003 7:20 pm

Splam wrote:
Make sure they're signed samples, I know you say "midpoint 0x80" but that doesn't always mean the same thing. Also vboy doesn't perfectly emulate the directsound, it actually gives you a bit more leeway with doing things wrong (hard to explain here what, nothing to do with timing, cycles or dma so don't worry abou those) so I'd say it must be the samples aren't signed properly and it certainly would sound like it's playing but with noise (due to the lack of sign the frequency modulation would be almost right but not going in the correct direction) I've had that problem b4 and it was signs.


"midpoint at 0x80" sounds like he's using unsigned samples. Signed samples have a midpoint of 0x00.

If your samples are unsigned +0 to +255 (midpoint 128 (0x80)), then you could write a simple program to subtract 128 (0x80) from each one and write the data out - giving you signed samples -128 to +127 (midpoint of 0).

grumpy.

#1220 - Splam - Wed Jan 15, 2003 7:34 pm

True, depends what wav converter you're using though ;) I hate audio apps they're always displaying things the wrong way round hehe but yep, makes it sound even more like it's unsigned data.

#1222 - notron - Wed Jan 15, 2003 7:50 pm

Yep, the problem was that wav data, even though it is 0x80 midpoint PCM data, it NOT signed 8 bit.

All I did was invert the first bit of every sample, i.e. subtracted 128 (0x80) from it and PRESTO, background static was gone. Perfect reproduction!

Thanks again guys! I knew I was missing something but didn't know what!
_________________
MysticX is The Defender