Comunidad de diseño web y desarrollo en internet online

microfono para audio visualization flash

Citar            
MensajeEscrito el 05 May 2011 08:52 pm
Hola saludos tengo el siguiente reto

como ago que este código de Audio Visualization en ves de usar un archivo mp3 use la entrada de microfono

import flash.display.Sprite;

//Create the variables and get the audio file to play
// Add the name of your audio file, including the .mp3 extension between the quotation marks


var url:String = "01 Pista 1.mp3";
var request:URLRequest = new URLRequest(url);
var s:Sound = new Sound();
s.addEventListener(Event.COMPLETE, completeHandler);
s.load(request);
var song:SoundChannel = s.play();
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
var ba:ByteArray = new ByteArray();

// The visualization is drawn into a sprite named gr

var gr:Sprite = new Sprite();
gr.x = 20;
gr.y = 200;
addChild(gr);



//The timer is set to fire every 50 milliseconds. Feel free to change the number to see what happens.

var time:Timer = new Timer(50);
time.addEventListener(TimerEvent.TIMER, timerHandler);
time.start();

//What happens when the audio starts

function completeHandler(event:Event):void {
//event.target.play();
};

//The timer is turned off when the end of the audio file is reached

function soundCompleteHandler(event:Event):void {
time.stop();
}

//The bars bounce up and down because the timer fires every 50 milliseconds
// and this function draws the boxes

function timerHandler(event:TimerEvent):void {

// Change the true parameter in computeSpectrum to false to have bouncing bars above and below the line.
//Change the color of the bars by changing the color of the lineStyle and the beginFill methods.
// Make the box bigger by changing the 2 in var w:uint to a larger number

SoundMixer.computeSpectrum(ba, false);
var i:int;
gr.graphics.clear();
gr.graphics.lineStyle(0, 0x0000ff);
gr.graphics.beginFill(0x00f0f);
gr.graphics.moveTo(0, 0);
var w:uint = 20;
for (i=5; i<512; i+=w) {
var t:Number = ba.readFloat();
var n:Number = (t * 400);
gr.graphics.drawRect(i, 0, w, -n);
}
}


aqui tengo un codigo de para la entrada microfono




import flash.events.ActivityEvent;
import flash.events.StatusEvent;
import flash.media.Microphone;

var deviceArray:Array = Microphone.names;
trace("Available sound input devices:");
for (var i:int = 10; i < deviceArray.length; i++)
{
trace(" " + deviceArray[i]);
}

var mic:Microphone = Microphone.getMicrophone();
mic.gain = 1000;
mic.rate = 11;
mic.setUseEchoSuppression(true);
mic.setLoopBack(true);
mic.setSilenceLevel(500, 100);

Por Heteroclito

2 de clabLevel



 

safari
Citar            
MensajeEscrito el 06 May 2011 02:09 pm

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.