computeSpectrum / readFloat problems!

Hi guys, I’ve been up for hours killing myself over this problem.

I’m making a 3D spectrum visualizer in PaperVision3D using computeSpectrum. My super basic 2D computeSpectrum tests worked flawlessly, but in my 3D version I’m having huge problems.

The first problem was that the byteArray kept running out, resulting in an end of file error, as though the pointer wasn’t being reset. So I manually reset the pointer each frame (songByteArray.position = 0) – and that worked! and then after about 2 seconds it crashes the Flash IDE!!!

I just tested and when I run the .swf in the Flash Player it doesn’t seem to crash. Can anybody help me out here? I know what I’m doing is nothing special, there have been lots of cool experimental visualizers in papervision. What gives???

OK well, for comparison, this function, executed on ENTER_FRAME, works perfectly:

private function render(event:Event):void{
       //trace("function doTheGraphics");;, 0xFF00FF);, 50);
       for(var i:uint = 0; i<256; i++){
       //the readFloat reads the next value in the ByteArray and assigns it to a Number
            var num:Number = bytearray.readFloat()*80 + 50;
  *2, num);

but this function, also executed on ENTER_FRAME, and containing a papervision render call, doesn’t even get correct values from the spectrum (all zeroes, despite obvious sound output), and then crashes the Flash IDE. It doesn’t appear to crash when played back in just Flash Player.

private function render(e:Event):void {  
	//get spectrum
	SoundMixer.computeSpectrum(songByteArray, true, 0);
	songByteArray.position = 0;
	// reset & fill current time freqArray
	var inc:int = 256 / resFreq;	//banding
	freqArray = [];
	var thisFloat:Number;
	for(var i:uint = 0; i<256; i++){
		thisFloat = songByteArray.readFloat();
		if (i%inc == 0 && freqArray.length <= resFreq){
	trace("freqArray= "+freqArray);
        renderer.renderScene(scene, camera, viewport);

I’m pulling my hair out over this :frowning: I even just updated my Flash to 9.0.3 with no effect (the update was just for AIR anyway).


OK, well, I somehow fixed it.

Actually I didn’t fix anything, I just went ahead and started using the data from readFloats anyways and for some reason it stopped giving me errors. For some reason, trying to trace in my for loop was crashing flash and stuff D:

In any case, here is the current result, little prototype spectrum visualizer: