I know it has something to do with soundTransform, but I’ve been trying to get it working for a few hours now and no luck. Here is my code to start the song. If you cant tell by byte array I am making a spectrum analyzer.
EDIT: I actually have another question. I have two of the same movie clips, playing 2 different songs and what I thought would happen is they would each have their own spectrum, but turns out they sharing the same sound channel. I tried changing each names of the sound channel but didnt work. Here is my code for clip 1:
//BALL1
var s:Sound = new Sound();
var sc:SoundChannel;
var ba:ByteArray = new ByteArray();
var array:Array;
s.load(new URLRequest("mix2.mp3"));
sc = s.play(0,1000);
this.addEventListener(Event.ENTER_FRAME, spectrum);
var a:Number = 0;
function spectrum(event:Event) {
a = 0;
graphics.clear();
SoundMixer.computeSpectrum(ba,true,0);
for (var i=0; i < 256; i=i+8) {
a = ba.readFloat();
var num:Number = a*360;
graphics.lineStyle(num/15,0xccff33|(num << 8),5);
graphics.drawCircle(0,0,i);
}
}
and clip2:
//ball2
var s2:Sound = new Sound();
var sc2:SoundChannel;
var ba2:ByteArray = new ByteArray();
var array:Array;
s2.load(new URLRequest("mix.mp3"));
sc2 = s2.play(0,1000);
this.addEventListener(Event.ENTER_FRAME, spectrum);
var a:Number = 0;
function spectrum(event:Event) {
a = 0;
graphics.clear();
SoundMixer.computeSpectrum(ba2,true,0);
for (var i=0; i < 256; i=i+8) {
a = ba2.readFloat();
var num:Number = a*360;
graphics.lineStyle(num/15,0x00ccff|(num << 8),5);
graphics.drawCircle(0,0,i);
}
}
you can see what im talking about at
http://ostari.com/ronnie/spectrum/leespec.swf
thanks a lot!