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 > Sound question

#157910 - mfallon - Sun Jun 01, 2008 7:48 pm

Is there a way to tell when a sound is finished playing? What I need to do is play several different combinations of short sounds (about 1 second each) back to back. Keep in mind I am new to DS programming and don't really know what I'm doing yet. I'm using libnds and I am building both arm9 and arm7 binaries though I'm not really doing anything with arm7 yet except playing around with it.

Thanks,

Matt

#157911 - Maxxie - Sun Jun 01, 2008 8:11 pm

If you are working on the arm9 only, then keeping track of the current time is the only way. Via timers ( http://nocash.emubase.de/gbatek.htm#dstimers ) or regular breaks such as vblank.

If you are on the arm7 you can also poll the status bit in a sound channel's control register ( http://nocash.emubase.de/gbatek.htm#dssound )

There is no callback generated from the sound hardware if a sound has finished playing if this is your question.

#157912 - simonjhall - Sun Jun 01, 2008 8:57 pm

Yeah you've got to do it via timers. However, if you're only playing short sounds you could just put them on the "one-shot" system so that even though you're not sure when it finishes you can be sure that it WILL finish at some point!
_________________
Big thanks to everyone who donated for Quake2

#157916 - mfallon - Sun Jun 01, 2008 9:52 pm

Thanks for the input. The control register solution was what I was looking for however using a timer on the arm9 seems to work well enough without having to use the arm7 making things simpler and I like simpler.

Thanks,

Matt

#158072 - HyperHacker - Wed Jun 04, 2008 5:32 am

I wonder if the sound capture would provide a way to tell about where it is? Fill a buffer with some known value that wouldn't be generated (something invalid, or some transformation of the contents of the input buffer) and read through it looking for that value as you record into it. Might even be a convenient status register or something.
_________________
I'm a PSP hacker now, but I still <3 DS.