# computeSpectrum

**URL:** <https://forum.kirupa.com/t/computespectrum/238703>\
**Category:** flash\
**Created:** [September 14, 2007, 1:57am UTC](https://forum.kirupa.com/t/computespectrum/238703 "2007-09-14T01:57:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rondog](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rondog/32/2478_2.png) [@rondog](https://forum.kirupa.com/u/rondog)\
**Post date:** [September 14, 2007, 1:57am UTC](https://forum.kirupa.com/t/computespectrum/238703/1 "2007-09-14T01:57:51Z")

</div>

Hey guys-  
This is the first AS3 I’ve touched since it came out. I am messing around with the computeSpectrum and now im kind of stuck…

I have it working, but I want to add more to it. For example…I want it to be a gradient…kind of like this one:

> **[computeSpectrum AS3 Example](https://www.kirupa.com/forum/showthread.php?t=260175&highlight=computespectrum)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

I have a little example that ive done here and even added a little blur filter, but other than that I dont know what else i can do…  
[http://ostari.com/ronnie/spectrum/spectrum.swf](http://ostari.com/ronnie/spectrum/spectrum.swf)

```auto

var mySound:Sound = new Sound();
mySound.load(new URLRequest("song.mp3"));
mySound.play();

var myByteArray:ByteArray = new ByteArray();
function readSpectrum(event:Event) {
    SoundMixer.computeSpectrum(myByteArray, false,0);
    graphics.clear();
    for (var i = 0; i<256; i+= 8) {
        drawSpectrum(myByteArray.readFloat(),i);
    }
}

function drawSpectrum(myReadFloat:Number, myIteration:Number) {
    var myNumber:Number = myReadFloat * 500;
    graphics.lineStyle(1, 0x000000);
    graphics.beginFill(0x99ff00);
    ball.rotation = myNumber*-0.1;
    graphics.drawRoundRect((16 * (myIteration / 8)) + 19,250,16,-(myNumber/2),20,20);
    //graphics.drawRect((16 * (myIteration / 8)) + 19, 250,16,-(myNumber / 5));
    //graphics.drawEllipse((16 * (myIteration / 8)) + 19,250,16,-(myNumber / 5));
    //graphics.drawCircle((16 * (myIteration / 8)) + 19,250,-(myNumber / 5));
    var filter:BitmapFilter = new BlurFilter(3,3,BitmapFilterQuality.HIGH);
    //var filter:GlowFilter = new GlowFilter(0x00ccff,5,2,2,50);
    var myFilters:Array = new Array();
    myFilters.push(filter);
    filters = myFilters;
}
this.addEventListener(Event.ENTER_FRAME, readSpectrum);

```

and there is my code…soo any tips on making the bars a gradient like the first example I showed?
