Spectrum Graph : SoundMixer : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » SoundMixer »

 

Spectrum Graph


 
package{
   import flash.display.*;
   import flash.events.*;
   import flash.utils.*;
   import flash.ui.*;
   import flash.geom.*;
   import flash.filters.*;
   import flash.media.*;
    public class Main extends Sprite {
        private var _spectrumBMP:BitmapData;
        
        public function Main(  )
        {
             _spectrumBMP = new BitmapData(25630, true, 0x00000000);
            var bitmap:Bitmap = new Bitmap(_spectrumBMP);
            bitmap.filters = [new DropShadowFilter(3450132.33)];
            addChild(bitmap);
        }
        
        public function update(  ):void
        {
            // Get spectrum data
            var spectrum:ByteArray = new ByteArray(  );
            SoundMixer.computeSpectrum(spectrum);
            
            // Draw to bitmap
            _spectrumBMP.fillRect(_spectrumBMP.rect, 0xff666666);
            _spectrumBMP.fillRect(new Rectangle(1125428),
                                 0x00000000);
            for(var i:int=0;i<256;i++) {
                _spectrumBMP.setPixel32(i, 
                                       10 + spectrum.readFloat(  ) 10,
                                       0xff000000);
            }
            for(var i:int=0;i<256;i++) {
                _spectrumBMP.setPixel32(i, 
                                       20 + spectrum.readFloat(  ) 10,
                                       0xff000000);
            }
        }
    }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Development
» SoundMixer