Game Development Community

Sound effects sometimes won't play

by Jack La Corte · in Torque Game Builder · 12/22/2006 (7:32 am) · 6 replies

I've been struggling with a click sound effect that plays when a tile is selected or deselected. The sound file in question is only 7kb and is preloaded. Normally it plays just fine but sometimes when you select a tile there is no sound associated with it. I spent an untold amount of hours looking for a pattern but there doesn't seem to be one. My latest train of thought was that sounds were overlapping on that channel and so it got missed. So I put an alxStop() for that channel right before I play the click sound and at first I thought I fixed it, but the same problem exists. I also tried creating a separate channel just for the click sound and it may be my imagination but the frequency of those occurrences appear to be less. What might be causing this and how can I fix it?

#1
12/22/2006 (12:52 pm)
Offhand, not a clue. Need to see some code
#2
12/22/2006 (7:30 pm)
I used the code from the demo... tdn.garagegames.com/wiki/TGB/ScriptTutorials/MusicTutorial.
The section in my code that I recently tried is...
alxStop ( $effectAudio );
$effectAudio = alxPlay ( buttonClickAudio );
This reduced the occurrence of the missing click, but it still does occur. In the demo it states...
Quote:...remembering that timing is key.
I thought it was in reference to where you play the sounds. Could it be in reference to timing with the sound card? Is it likely the sound card is not ready for the sound when it is sent, so nothing is played?
#3
12/22/2006 (10:07 pm)
I have no clue what he meant by timing, and still can't think up a theory on what might be happening
#4
12/30/2006 (8:01 pm)
I have just started messing with playing some sounds and I recorded my own using Windows Sound Recorder.

I saved my sounds at the lowest quality level(Default) the first time I recorded it.
When I would play it, it would skip and pop and sometimes be cut short..

I then Re-recorded and saved my sounds at a much higher quality and file size.
They seem to play fine now.

It may have something to do with the soundfile itself (Quality, Filesize, etc...)
Hope this helps
#5
01/02/2007 (5:34 am)
My original button click sound file was 80 milliseconds long. Recorded at 44100Hz, stereo, 16-bit. Since the quality was already high I removed dead air at the beginning and end of the file, shrinking it down to 29 milliseconds. The problem is still there, and now it will even occasionally play the sound twice in a row for a single click.
#6
01/02/2007 (4:37 pm)
I have been using this code as well...

if (!alxIsPlaying($CrackSound))
   {
      $CrackSound = alxPlay(CrackAudio);
   }

Just to check and make sure that the sound is not already playing..


Another Question..
What about the code that is calling the sound to play.
Could it possibly be a problem elsewhere in your script??