Original Post
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):
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
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