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.

Beginners > Direct Sound without using timers?

#111511 - biolizard89 - Thu Dec 07, 2006 4:51 am

I'm attempting to modify the source of a GBA program to use Direct Sound. Unfortunately, I suspect that the program already uses timers for other purposes (I don't know this for a fact, but I'm not the author of the original program, and the source is huge enough that I don't want to look through all of it to see what timers it uses. The author also says that it probably uses timers.). Is there any possible way to play a sound using Direct Sound without using timers?

The program I'm using is running on a Charmed Labs Xport Botball Controller (robotics controller which uses a GBA for processing purposes). The XBC provides a 1-microsecond-resolution timer which is available, but this is only recognized as a volatile variable by the GBA.

I'm guessing there's no way to do what I want with this without rewriting the original program, but I'm asking on the off chance that someone can prove me wrong.

Thanks in advance.

#111517 - tepples - Thu Dec 07, 2006 5:21 am

You need at least one timer (timer 0 or timer 1) to set the sample rate. But you won't really need more than one timer. On the GBA, you can set the rate to 18157 Hz and the buffer size to 304 Hz and then switch buffers based on the vblank interrupt. If you don't want to vgrep through the program to see if timer 0 or timer 1 is already in use, try running the program in VisualBoyAdvance and using the I/O viewer to inspect the timers every so often.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.