Jump to content

  • Log In with Google      Sign In   
  • Create Account

Help on SDL sound


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 svnstrk   Members   -  Reputation: 133

Like
0Likes
Like

Posted 17 March 2012 - 06:23 AM

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

Sponsor:

#2 JustinDaniel   Members   -  Reputation: 137

Like
0Likes
Like

Posted 17 March 2012 - 10:47 AM

You should probably give a try to
Mix_PlayChannelTimed(0, mixChunkArr[index], 0, int milliseconds);
Try and see if it works, Not sure.

#3 svnstrk   Members   -  Reputation: 133

Like
0Likes
Like

Posted 19 March 2012 - 05:27 AM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS