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.

DS development > Some questions about sounds

#108408 - Lupi - Wed Nov 08, 2006 3:49 pm

I am doing a musical game, but the 4 MB of RAM isn't enough for loading a entire song into the game.
I also need some info about the shyncronization between ARM7 and ARM9

1. If I load a song at a given time, and I count 60 VBlanks in ARM9, is that equal to one second of song played, or the two processors are independant each other?
2. How many data is equivalent to one second of sound, so I can load it via the libfat with read() {like read(song,sizeof(u16)*n)} being n what I'm searching?

Thanks for the help

#108410 - Lick - Wed Nov 08, 2006 4:02 pm

1. You can choose from using (1) the FIFO queue (2) some random spot in the Main RAM. The FIFO queue is really designed for this kind of interprocessor communication, but I think the Main RAM is easier to implement.
2. Depends on your sound file. You'll need to know that beforehand, or load from the sound file's header. For example, if it's a WAV file, you'll have to load the WAVE-fileheader that contains more information about the sound.
_________________
http://licklick.wordpress.com

#108463 - tepples - Thu Nov 09, 2006 4:04 am

Lupi wrote:
I am doing a musical game, but the 4 MB of RAM isn't enough for loading a entire song into the game.

Keysounded or not keysounded? Parappa, Beatmania, Frequency, Amplitude, and Guitar Hero are keysounded. DDR is not.

Quote:
1. If I load a song at a given time, and I count 60 VBlanks in ARM9, is that equal to one second of song played, or the two processors are independant each other?

The frame rate is not 60 Hz. It's specified as 33554432/560190 Hz, where 560190 is the exact number of ARM7 CPU cycles per vblank. But yes, both CPUs reach vblank at the same time.

Quote:
2. How many data is equivalent to one second of sound

Most apps seem to use 16384 Hz or 32768 Hz, which are sample rates that mesh nicely with the DS's DAC. There are two major differences between the sample rate situation on the GBA and that on the DS:
  • On the GBA, it's common to switch buffers during the vertical blanking, as there are plenty of factors of 280896 cycles per frame. I even made a tool in JavaScript to find these rates. The DS, on the other hand, has 560190 cycles, which has a lot of large prime factors. This means that fewer nice, round rates exist, as you can see by replacing 280896 with 560190 in the form.
  • The GBA's PWM DAC can be set to 32.8 kHz, 65.5 kHz, 131 kHz, or 262 kHz, with a reduction in bit depth. A lot of games used 65.5 kHz and 8 bits, which gave more tolerance for the jitter that the common 18.2 kHz and 21.0 kHz sample rates introduced. The DS's PWM DAC, on the other hand, always runs at 32768 Hz and 10 bits, and using oddball sample rates will make aliasing more apparent.

You're also going to want to use some sort of compression on the audio. If you're streaming something longer than RAM, I would recommend against using the built-in ADPCM compression because ADPCM is stateful, and it's hard to link one ADPCM segment to the next. Instead, stream compressed data encoded with something like my 8ad codec, and decode it on the ARM7 or ARM9.

As for FIFO, the "right" way to do this is to send commands through the FIFO, where these commands include pointers into the 4 MiB EWRAM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#108966 - Lupi - Mon Nov 13, 2006 5:18 pm

Sorry for my delay in answering

Well, I want to do a Elite Beat Agents/Osu Takatae Ouendan type of game.

I want people to put their own files in it, so for example I have a file.sng wich includes the beats (the circles in the song) and then the data of the song.

My idea was, using FAT libraries, load all the beats in memory and then load the song second by second by storing data in a buffer from FAT, So th songs starts, I load one second of music into memory, second finished, quickly load one more second, and so on...

That's why I was asking for the size of a second of song. I have also planed to put songs into RAW format (16 bit unsigned), mostly because I have no idea of audio compression and how to decompress and play it via the DS hardware.