2

I am using tweenlite to fade out sound, the fade out effect itself is working well, but it seems that everytime soundTransform is applied to soundChannel with tweenlite some noise like a crackle appears.

You can test it here here

And here is the code:

package  {

    import flash.display.Sprite;

    import flash.events.Event;  
    import flash.events.MouseEvent; 

    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.media.SoundTransform;

    import com.greensock.*;     
    import com.greensock.plugins.*;
    TweenPlugin.activate([VolumePlugin]);


    public class SoundFade extends Sprite {

        public var keySound:Sound; 
        public var keySoundChannel:SoundChannel;
        public var keySoundTransform:SoundTransform;


        public function SoundFade():void {

            keySound = new MySound();
            keySoundChannel = new SoundChannel();

            btn.addEventListener(MouseEvent.CLICK, onClick);

        }


        private function onClick(e:MouseEvent):void {

            keySoundChannel = keySound.play();

            TweenLite.to(keySoundChannel, 0.5, {
                volume: 0
            }); 

        }

    }

}

Does anyone have an idea how to work around this issue?

I believe you guys can help me with the problem. Thanks in advance.

  • I didn't hear a crackle. I'm using Flash Player 11.2 on a Mac. I wonder if this is hardware specific. Also, the sound plays so fast I can't really tell if it's fading out :) – Sunil D. Jul 04 '12 at 11:04
  • It is hard to hear the crackle if the sound is played in speakers. It can be heard when the sound is played in your headphones. I don't think this is hardware specific as the crackle can be heard on iPad as well. – user1500682 Jul 04 '12 at 11:25
  • Okay, random question, please don't get mad...have you tried different headphones? I'm asking because I've had similar issues before. Headphones can create crackling where there is none. – CodeMouse92 May 27 '13 at 18:27

1 Answers1

0

I couldn't listen as the link doesn't work but from what I know the crackles appear when changing from a high(or low) volume to a low(or high) volume very fast. This happens because you modify the waveform on the fly and so it becomes discontinuous.

I see that you use TweenLite and this is a good start. I believe that if you increase the tween duration the crackles will disappear.

Mind that the TweenLite's default ease, according to the documentation, is Quad.easeOut, so the fading is not linear and so the crackles might appear where the transition is faster! Changing the ease to "Linear.easeNone" might help as well.

Oliver
  • 487
  • 2
  • 9