Ok here is a really odd one. I can't find where the error is.
I have an mp3 which is 10,728 seconds long exactly. I do a computespectrum on it using the code shown below. It is supposed to run every 50ms.... and when it does trigger, it sends the values to an array in javascript. So i was expecting that my array would have 214 values but lo and behold it has only 195. not only that,, but when i play the mp3, i am hearing an echo.... what the?
What am i missing here?
Code:
var url:String = "mysong.php";
var requestt:URLRequest = new URLRequest(url);
var s:Sound = new Sound();
s.addEventListener(Event.COMPLETE, completeHandler);
s.load(requestt);
var song:SoundChannel = s.play();
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
var ba:ByteArray = new ByteArray();
var time:Timer = new Timer(50);
time.addEventListener(TimerEvent.TIMER, timerHandler);
time.start();
function completeHandler(event:Event):void
{event.target.play();}
function soundCompleteHandler(event:Event):void
{time.stop();}
function timerHandler(event:TimerEvent):void {
SoundMixer.computeSpectrum(ba, true);
var a:int=ba[100];
ExternalInterface.call("addtoarray", a);
}