I use computeSpectrum in many CS5.5 Flash applications. I just installed CS6 and when I compile the same file the byte array sent back by computeSpectrum is mostly empty.
Seems to be a bug in the built player 11. I downgraded toi 10.3 and it still doesn't work. Funny, 10.2 is not available in CS6 and that's the highest one I have in CS5.5
Is the built player the problem? Any idea when a fix will be available?
Thanks
Hi klag,
Just using the example code from Adobe on-line help does it.
In CS5.5, as long as there is sound, computeSpectrum returns a byte array with data most times enterFrame updates it. In CS 6 the byte array is most often empty causing the visual to stay flat when it shouldn't.
Here is the code from Adobe as found here : http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fla sh/media/SoundMixer.html#computeSpectrum()
If you run that code in 5.5 then in 6 you'll see a big difference. I use computeSpectrum to mimicate speech and that difference cause the mouth to stay close most of the time.
package {
import flash.display.Sprite;
import flash.display.Graphics;
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import flash.net.URLRequest;
import flash.utils.ByteArray;
import flash.text.TextField;
public class SoundMixer_computeSpectrumExample extends Sprite {
public function SoundMixer_computeSpectrumExample() {
var snd:Sound = new Sound();
var req:URLRequest = new URLRequest("Song1.mp3");
snd.load(req);
var channel:SoundChannel;
channel = snd.play();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
}
private function onEnterFrame(event:Event):void {
var bytes:ByteArray = new ByteArray();
const PLOT_HEIGHT:int = 200;
const CHANNEL_LENGTH:int = 256;
SoundMixer.computeSpectrum(bytes, false, 0);
var g:Graphics = this.graphics;
g.clear();
g.lineStyle(0, 0x6600CC);
g.beginFill(0x6600CC);
g.moveTo(0, PLOT_HEIGHT);
var n:Number = 0;
for (var i:int = 0; i < CHANNEL_LENGTH; i++) {
n = (bytes.readFloat() * PLOT_HEIGHT);
g.lineTo(i * 2, PLOT_HEIGHT - n);
}
g.lineTo(CHANNEL_LENGTH * 2, PLOT_HEIGHT);
g.endFill();
g.lineStyle(0, 0xCC0066);
g.beginFill(0xCC0066, 0.5);
g.moveTo(CHANNEL_LENGTH * 2, PLOT_HEIGHT);
for (i = CHANNEL_LENGTH; i > 0; i--) {
n = (bytes.readFloat() * PLOT_HEIGHT);
g.lineTo(i * 2, PLOT_HEIGHT - n);
}
g.lineTo(0, PLOT_HEIGHT);
g.endFill();
}
private function onPlaybackComplete(event:Event):void {
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}
North America
Europe, Middle East and Africa
Asia Pacific