FORUMS: list search recent posts

AS3 ByteArray and Record Voice

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Giang Nguyen
AS3 ByteArray and Record Voice
on Nov 3, 2011 at 9:03:11 am

Hi all guys,
I am new in flash, and i am trying to make a spectrum when we record the sound. But i have a trouble, i think someone can help me.
This is my code :

var mic:Microphone = Microphone.getMicrophone();
mic.addEventListener(SampleDataEvent.SAMPLE_DATA, micSampleDataHandler);
var soundBytes:ByteArray = new ByteArray();
var sample:Number;

function micSampleDataHandler(e:SampleDataEvent):void{
if(e.data.bytesAvailable){
sample = e.data.readFloat();
soundBytes.writeFloat(sample);
trace(soundBytes.readFloat());
mic.removeEventListener(SampleDataEvent.SAMPLE_DATA, micSampleDataHandler);
}


}

var mc:MC;
addEventListener(Event.ENTER_FRAME, loop);

function loop(e:Event):void
{
//trace(mic.activityLevel); equalizer
while(mcSpectrum.mcMask.numChildren>0){
mcSpectrum.mcMask.removeChildAt(0);
}

SoundMixer.computeSpectrum(soundBytes);
for(var i:uint=0; i<256; i++)
{
mc = new MC();
mcSpectrum.mcMask.addChild(mc);
mc.y = 95;
mc.x = i;
mc.scaleY = soundBytes.readFloat()*2;


}

}


I attach my source file also, please help me.
http://f1.creativecow.net/3174/3174


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]