7 Replies Latest reply on Jan 22, 2013 8:20 AM by kglad

    computeSpectrum not working in CS6

    ygd123

      I use computeSpectrum in many CS5.5 Flash applications. I just installed CS6 and when I compile the same file the byte array sent back by computeSpectrum is mostly empty.

       

      Seems to be a bug in the built player 11. I downgraded toi 10.3 and it still doesn't work. Funny, 10.2 is not available in CS6 and that's the highest one I have in CS5.5

       

      Is the built player the problem? Any idea when a fix will be available?

       

      Thanks

        • 1. Re: computeSpectrum not working in CS6
          kglad Adobe Community Professional & MVP

          i've never had that problem with cs6.

           

          copy and paste the simplest code that shows the problem.

          • 2. Re: computeSpectrum not working in CS6
            ygd123 Level 1

            Hi klag,

             

            Just using the example code from Adobe on-line help does it.

             

            In CS5.5, as long as there is sound, computeSpectrum returns a byte array with data most times enterFrame updates it. In CS 6 the byte array is most often empty causing the visual to stay flat when it shouldn't.

             

            Here is the code from Adobe as found here : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/SoundMixer. html#computeSpectrum()

             

            If you run that code in 5.5 then in 6 you'll see a big difference. I use computeSpectrum to mimicate speech and that difference cause the mouth to stay close most of the time.

             

            package {

                import flash.display.Sprite;

                import flash.display.Graphics;

                import flash.events.Event;

                import flash.media.Sound;

                import flash.media.SoundChannel;

                import flash.media.SoundMixer;

                import flash.net.URLRequest;

                import flash.utils.ByteArray;

                import flash.text.TextField;

             

                public class SoundMixer_computeSpectrumExample extends Sprite {

             

                    public function SoundMixer_computeSpectrumExample() {

                        var snd:Sound = new Sound();

                        var req:URLRequest = new URLRequest("Song1.mp3");

                        snd.load(req);

                       

                        var channel:SoundChannel;

                        channel = snd.play();

                        addEventListener(Event.ENTER_FRAME, onEnterFrame);

                        channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);

                    }

             

                    private function onEnterFrame(event:Event):void {

                        var bytes:ByteArray = new ByteArray();

                        const PLOT_HEIGHT:int = 200;

                        const CHANNEL_LENGTH:int = 256;

             

                        SoundMixer.computeSpectrum(bytes, false, 0);

                       

                        var g:Graphics = this.graphics;

                       

                        g.clear();

                  

                        g.lineStyle(0, 0x6600CC);

                        g.beginFill(0x6600CC);

                        g.moveTo(0, PLOT_HEIGHT);

                       

                        var n:Number = 0;

                       

                        for (var i:int = 0; i < CHANNEL_LENGTH; i++) {

                            n = (bytes.readFloat() * PLOT_HEIGHT);

                            g.lineTo(i * 2, PLOT_HEIGHT - n);

                        }

             

                        g.lineTo(CHANNEL_LENGTH * 2, PLOT_HEIGHT);

                        g.endFill();

             

                        g.lineStyle(0, 0xCC0066);

                        g.beginFill(0xCC0066, 0.5);

                        g.moveTo(CHANNEL_LENGTH * 2, PLOT_HEIGHT);

                       

                        for (i = CHANNEL_LENGTH; i > 0; i--) {

                            n = (bytes.readFloat() * PLOT_HEIGHT);

                            g.lineTo(i * 2, PLOT_HEIGHT - n);

                        }

             

                        g.lineTo(0, PLOT_HEIGHT);

                        g.endFill();

                    }

                   

                    private function onPlaybackComplete(event:Event):void {

                        removeEventListener(Event.ENTER_FRAME, onEnterFrame);

                    }

                }

            }

            • 3. Re: computeSpectrum not working in CS6
              kglad Adobe Community Professional & MVP

              publishing for flash player 9 fixes the problem.

               

              i'm still checking on the exact cause of the problem.

              • 4. Re: computeSpectrum not working in CS6
                ygd123 Level 1

                Thanks klad.

                 

                Unfortunatly FP9 is not an option because of unsupported features.

                 

                In CS5.5 I was publishing in 10.2 and 10.2 is not available in CS6 only 10.3 which doen't solve the problem

                • 5. Re: computeSpectrum not working in CS6
                  kglad Adobe Community Professional & MVP

                  this is a known flash player bug:  forums.adobe.com/thread/1136942?tstart=0

                   

                  i see it in the flash ide but not in my browser ff or in the stand-alone player when publishing for fp 11.4

                   

                  test in your target browsers/players to see if there's a problem for you.

                  • 6. Re: computeSpectrum not working in CS6
                    ygd123 Level 1

                    Thanks a lot for your input klad.

                     

                    You are correct, it is working in the browser even though in the IDE it doesn't.

                     

                    Would be nice to see it work in the IDE too though but it is not a show stopper.

                     

                    Thanks again.

                    • 7. Re: computeSpectrum not working in CS6
                      kglad Adobe Community Professional & MVP

                      you're welcome.