function func(a:Number) {
return num * Math.sin(a);
}
function drawFunction(func:Function, thickness:Number, color:Number) {
graphics.lineStyle(thickness, color, 100);
graphics.moveTo(30, stage.stageHeight / 2 - func((30 + t) / 20) * 20);
for (var i = 30; i <= stage.stageWidth - 30; i++) {
var fi = stage.stageHeight / 2 - func((i + t++) / 20) * 20;
graphics.lineTo(i, fi);
}
}
function spectrum(event:Event) {
graphics.clear();
SoundMixer.computeSpectrum(ba, true, 0);
num = ba.readFloat() * 10;
drawFunction(func, 1, 0x0066cc);
}
var sound:Sound = new Sound();
var sound_channel:SoundChannel;
var ba:ByteArray = new ByteArray();
var num:Number;
var t:Number = 0;
sound.load(new URLRequest("test.mp3"));
sound_channel = sound.play();
this.addEventListener(Event.ENTER_FRAME, spectrum);