I am loading in a few swfs, each with video embedded on the timeline.
I am trying to use SoundMixer.computeSpectrum to make a visualization but
it isn't getting any values. I can control the loaded swfs volume with
soundTransforms and SoundMixer.areSoundsInaccessible() is reurning false. No
crossdomain/security issues either.
Any ideas? Here is my SoundProcessor class I am working with that has worked
with loaded mp3s in the past.
package {
import flash.display.Sprite;
import flash.media.Sound;
import flash.media.SoundMixer;
import flash.utils.ByteArray;
import flash.utils.Timer;
import flash.events.Event;
import flash.events.TimerEvent;
public class SoundProcessor extends Sprite {
// Settings
private var lineThickness:Number = .5;
public var lineColor:Number = 0xFFFFFF;
private var circleSize:Number = 50;
private var scaleOnBeat:Number = 1.1;
public var reactToBeat:Number = .1;
//
private var music:Sound = new Sound;
private var soundBytes:ByteArray= new ByteArray();
public var timer:Timer;
public var volume:Number;
public var pX:Number;
public var pY:Number;
function SoundProcessor(width:uint=200, height:uint=200) {
this.width = width;
this.height = height;
x = width/2;
y = height/2;
this.addEventListener(Event.ENTER_FRAME, processSound);
}
public function processSound(e:Event):void {
//trace("processSound");
SoundMixer.computeSpectrum(soundBytes, true, 0);
graphics.clear();
graphics.moveTo(0, -circleSize);
graphics.lineStyle(lineThickness, lineColor);
volume = 0;
for (var i:uint = 0; i < 512; i++) {
var lev:Number = soundBytes.readFloat();
if(lev!=0)
{
trace(lev);
}
volume += lev;
var a:uint = i;
if (i < 256)
{
a += 256;
}
if (i == 256)
{
graphics.moveTo(0, -circleSize);
}
pX = -Math.sin(i/256*Math.PI)*circleSize*(lev+1);
pY = Math.cos(a/256*Math.PI)*circleSize*(lev+1);
graphics.lineTo(pX, pY);
}
if (volume > reactToBeat) {
scaleX = scaleY = scaleOnBeat;
} else {
scaleX = scaleY = 1;
}
dispatchEvent(new Event("onProcessSound"));
}
}
}
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders