none
Noise from Click Sound RRS feed

  • General discussion

  • I have just tried the Pong program listed in the thread "Why can't I see the shapes?". It uses the Click sound, Sound.PlayClick(), whenever the ball hits a bat or the walls. Sometimes, instead of just a click I get a burst of noise (or a click immediately followed by a burst of noise). It sounds like it may be the click sound being rapidly repeated. I have noticed it before, but I have never been able to make it easily repeatable. You just have to wait for it to happen. I have not had the same problem with other sounds.
    Has anybody else noticed this problem?
    Friday, April 10, 2009 11:12 AM

All replies

  • I had a similar problem with the Chimes().  Try uninstalling SB and then re-installing.  This worked for me.  Also make sure the 3.5 .net framework has been installed correctly...
    F
    Saturday, April 11, 2009 3:20 AM
  • Didn't have problem with Chimes(). Re-installed both SB and .net framework 3.5 as you suggested and it made no difference.
    Sunday, April 12, 2009 6:31 AM
  • I guess you should ask Vijae what could be going on... Do other sound files play ok on your pc?  I use winamp for a lot of my mp3, wav, and ogg files.. this may be a driver issue.  Check in your control panel under sounds and audio devices\hardware\properties  that all of the drivers are installed correctly..
    Frank
    Wednesday, April 15, 2009 4:39 PM
  • I had a similar problem and came to the conclusion that it occurs when a second call to the sound is made before the first has completed as could happen if there are two ball collisions close together.  If you use the PlayClickAndWait() it will work but introduce a delay to the game play.  I didn't find a good solution other than to prevent the calls to the PlayClick() too close together, for example by only allowing the call if at least 1 second elapsed since the last call.

    For example the following crashes for me

    While ("true")
      Sound.PlayClick()
      Program.Delay(1)
    EndWhile

    But these work

    While ("true")
      Sound.PlayClick()
      Program.Delay(100)
    EndWhile

    OR

    While ("true")
      Sound.PlayClickAndWait()
      Program.Delay(1)
    EndWhile

    OR

    seclast = -1
    While ("true")
      sec = Clock.Second
      If (sec <> seclast) Then
        Sound.PlayClick()
        seclast = sec
      EndIf
      Program.Delay(1)
    EndWhile


    Wednesday, April 15, 2009 6:38 PM
    Moderator
  • At first I thought, "That's it, the sound is being repeated because the ball is still passing the test to play the sound until it has moved out of the test region". There are two problems with this. The first is that the ball only moves by 1 in the x or y directions (hence it always moves at 45° but that's another matter) and the direction is immediately reversed on detecting a collision so that the test cannot be passed on two consecutive sub calls. The second is that before I realised this, I had modified the sound calls to use a flag. The idea being that the flag (collision) is set when the sound is played and not cleared until the test to play the sound is false. The sound can then only be played if the ball has previously moved away from the area that causes the sound to be played.

    ...
        If (y < 0 Or y > 500 - BALLSIZE) Then   
          deltaY = -deltaY  
          If collision = 0 Then  
            Sound.PlayClick()
            collision = 1
          endif
        else
            collision = 0
        endif  
       
        If (x < PADDLEWIDTH Or x > 800 - PADDLEWIDTH - BALLSIZE) Then   
          deltaX = -deltaX
          If collision = 0 Then  
            Sound.PlayClick()
            collision = 1
          endif
        else
          collision = 0
        endif  
       
    ...

    The trouble is the problem is still there. I was going to say that to hear the noise I'm talking about, run the following code,

    For i = 1 To 10
      Sound.PlayClick()
    EndFor

    But if I run this on its own I hear nothing! If I bury it in the start of the mouse move routine so that it must get called frequently the program crashes (Some sort of stack overflow?)

    Thursday, April 16, 2009 6:16 PM