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.

C/C++ > Sound problems ! N00b question

#5538 - Quedex - Wed Apr 30, 2003 11:23 pm

Hi people

I just want to play a sound when the fire button is pressed i can get it to work with the tutorial off of......

http://www.gamedev.net/reference/articles/article1823.asp

but of course this uses vblanks as a timer not very good for a game anyone got any source which will not interupt my game whilst playing i have tried but im pulling my hair out now any info is much appreciated

also whats the best proggy for converting wav files to c/c++ code ?

thanks

#5540 - darkcloud - Thu May 01, 2003 12:34 am

Quedex wrote:
but of course this uses vblanks as a timer not very good for a game


Um.... why would vblanks as a timer not be good for a game?

If you don't want to use vblanks you can use another timer to stop the sound at a certain point. Just wait until the timer gets to the length of the sound and then stop the sound.
_________________
Maybe in order to understand mankind, we have to look at the word itself: "Mankind". Basically, it's made up of two separate words - "mank" and "ind". What do these words mean ? It's a mystery, and that's why so is mankind.

#5541 - Quedex - Thu May 01, 2003 12:46 am

Well in that tutorial the game stops while the sample is playing thats what i meant about not being good for a game, it stops for like 3 seconds then carries on till you press the button again sorry for not being clear about that "8)

i've just been messing with the sound for a day or two now and it's driving me nuts i know it's not difficult but to a n00b it's like chewing through steel

Me "8)

#5542 - darkcloud - Thu May 01, 2003 12:59 am

Ohhhh yes, I think I know what you're talking about. I remember when I first did this tutorial (or a variation on it or something) and tried to figure out how to get the game not to stop.

It's not because you are using vblanks as a timer. Are you looping to wait for the sample to stop? If you're doing something like
Code:

while (vblank < sample_Length)
{
     //do something
}


That will make everything stop until the while() loop ends.

If this is what you are doing, you should not put in the loop and instead, during your main game loop, just check the value of your timer every frame until it gets to the end of the sample, then stop the sample.

I think this is what I had to do when I was trying to get sound to work.

If you're still having problems, I could send you the sound functions that work for me.

The GBA sound system is tricky, especially when there are not so many resources devoted to it.
_________________
Maybe in order to understand mankind, we have to look at the word itself: "Mankind". Basically, it's made up of two separate words - "mank" and "ind". What do these words mean ? It's a mystery, and that's why so is mankind.

#5543 - Quedex - Thu May 01, 2003 2:46 am

Yup you got it !

if you could send me yours that would be great !

maybe i'll have hair left by the end of the week lol

thanks again

Me "8)

#5544 - darkcloud - Thu May 01, 2003 2:52 am

Alright, glad to have helped. I'll send you my files so you can check them out.
_________________
Maybe in order to understand mankind, we have to look at the word itself: "Mankind". Basically, it's made up of two separate words - "mank" and "ind". What do these words mean ? It's a mystery, and that's why so is mankind.