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 > Emulator/HW sound problems..

#26556 - toddy - Sat Sep 18, 2004 3:23 pm

Hey all!

I've got a sound problem with my GBA demo. My sound engine used to work fine when it was developed but now it only works for BoycottAdvance 0.2.8 and VisualboyAdvance v.1.5.1 or earlier. That is, it doesn't work (make any sound) at all with MappyVM, on real hardware or on Visualboy v.1.6a or newer.

The VBA changelog only seem to have two things concerning sound that might seem relevant from 1.5 to 1.6:
- fixed sound envelope bug when set to 0 to mute sound. (Doesn't concern me, I don't use channels 1-4)
- sound problems loading old save states should be gone. (Save states aren't relevant are they..)

I've tried googling for the problem and I've searched through this forum too but I have only found two threads kinda similar but they didn't help. One was concerning volatile registers (check) and the other was solved by 0-ing registers (check).

I use Direct Sound A, Timer0 and DMA1 as the code is built from "Audio Programming on the GameBoy Advance Part 1" by Chris Strickland.
http://www.gamedev.net/reference/articles/article1823.asp

I've been stuck with this crap for quite some time now, I am thankfull for any help!

/toddy

#26557 - Lord Graga - Sat Sep 18, 2004 3:29 pm

It doesn't work on hardware, and that's the only important thing. You should check if you are setting the right registers and following the right procedures.

#26558 - toddy - Sat Sep 18, 2004 3:45 pm

The procedures are:

Code:

 REG_SOUND1CNT_L =0;
 REG_SOUND1CNT_H =0;
 REG_SOUND1CNT_X =0;
 REG_SOUND2CNT_L =0;
 REG_SOUND2CNT_H =0;
 REG_SOUND3CNT_L =0;
 REG_SOUND3CNT_H =0;
 REG_SOUND3CNT_X =0;
 REG_SOUND4CNT_L =0;
 REG_SOUND4CNT_H =0;
 REG_SOUNDCNT_L  =0;
 REG_SOUNDCNT_H  =0;
 REG_SOUNDCNT_X  =0;
 REG_SOUNDBIAS   =0;
 REG_WAVE_RAM0_L =0;
 REG_WAVE_RAM0_H =0;
 REG_WAVE_RAM1_L =0;
 REG_WAVE_RAM1_H =0;
 REG_WAVE_RAM2_L =0;
 REG_WAVE_RAM2_H =0;
 REG_WAVE_RAM3_L =0;
 REG_WAVE_RAM3_H =0;
*(u16*) REG_FIFO_A      =0;
*(u16*) REG_FIFO_A_L    =0;
*(u16*) REG_FIFO_A_H    =0;
*(u16*) REG_FIFO_B      =0;
*(u16*) REG_FIFO_B_L    =0;
*(u16*) REG_FIFO_B_H    =0;

   REG_SOUNDCNT_X = SND_ENABLED;

   REG_SOUNDCNT_L = 0;

   REG_SOUNDCNT_H = SND_OUTPUT_RATIO_100 |
                 DSA_OUTPUT_RATIO_100 |
                 DSA_OUTPUT_TO_BOTH |
                 DSA_TIMER0 |
                 DSA_FIFO_RESET;

   REG_TM0CNT = TIMER_ENABLED;
   REG_TM0D   = TIMER_INTERVAL;

   REG_DMA1SAD = (u32)(SAMPLE_AK47_DATA);
   REG_DMA1DAD = (u32)REG_FIFO_A;
   REG_DMA1CNT = ENABLE_DMA | START_ON_FIFO_EMPTY | WORD_DMA | DMA_REPEAT;

   while (true) {}

#26568 - DekuTree64 - Sun Sep 19, 2004 1:24 am

Hmm, one thing I see in there that you shouldn't be doing is changing the bias register. I think it's set to 512 on startup, and needs to stay that way.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku

#26571 - tepples - Sun Sep 19, 2004 2:21 pm

I agree don't set the bias level to 0. However, the bias register also decides among 32 kHz 9-bit, 64 kHz 8-bit, and 128 kHz 7-bit PCM as well as setting the bias level for the DACs. Most of my sound init routines set up 64 kHz 8-bit sound while preserving the bias level with a read-modify-write sequence.

That said, you don't need to init all the registers.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#26596 - toddy - Mon Sep 20, 2004 9:43 pm

I've tried setting the bias register to 1<<14, 1<<14|512 and 512 (and not setting it at all). Still it doesn't make any sound at all..

Kind of feels like I'm never going to get this stuff working, since not even dekutree knows what's wrong, and he's written a tutorial on gba-sound.. =(

#26599 - DekuTree64 - Mon Sep 20, 2004 10:34 pm

Hmm, I just noticed, you don't have your DMA set to dest fixed. Very bad, copying data to registers all over the place.

And for the bias, just don't touch it at all. It gets set to the right value on startup, and should never need to be changed.

Good luck, hopefully that DMA setting is all that's wrong.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku