Jump to content
  • Advertisement
Sign in to follow this  
svnstrk

Help on SDL sound

This topic is 2341 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi,

Im trying to create a machine gun sound. So I have a gunshot.wav (about 1 second) that contains the gun sound and the echo. now since its a machine gun, i want to repeat the gunshot.wav every 0.5 second so the echo only heard at the last shot.

I've tried it with SDL but its not working. So I use one channel only (for test):


void SoundManager::playSound(int index) {
if (index != 0) {
return;
}

Mix_HaltChannel(0);
Mix_PlayChannel(0, mixChunkArr[index], 0);

}


each time the machine gun fire (2 shot per second) it call the playSound method, sending the same mixChunk index and playing at the same channel 0. But apparently this is not working properly. The sound only played when the previous song is finished. So its like hearing 1 shot per second machine gun rather than 2 shot per second.

How can I do this in SDL? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
You should probably give a try to

Mix_PlayChannelTimed(0, mixChunkArr[index], 0, int milliseconds);

Try and see if it works, Not sure.

Share this post


Link to post
Share on other sites
nope its not working.

anyone?

also i can't seem to post on libsdl forum. i already registered and activate my account, but i can't post anything. Anyone here on libsdl forum? How can I contact the admin?


thanks in advance

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!