views:

297

answers:

2

I hove some sound coming from microphone. i need to add sound filter to it and to play it to the guy which talks into that microphone.

How to do such thing?

A: 

As far as I know this can be done with air: http://www.adobe.com/devnet/air/flex/articles/using_mic_api.html

here is the example code that does what you are asking:

import flash.media.Sound;
import flash.utils.ByteArray;
protected var soundRecording:ByteArray;
protected var soundOutput:Sound;
protected function playbackData():void
{
    soundRecording.position = 0;

    soundOutput = new Sound();
    soundOutput.addEventListener(SampleDataEvent.SAMPLE_DATA, playSound);

    soundOutput.play();
}

private function playSound(soundOutput:SampleDataEvent):void
{
    if (!soundRecording.bytesAvailable > 0)
        return;
    for (var i:int = 0; i < 8192; i++)
    {
        var sample:Number = 0;

        // apply your filter here
        if (soundRecording.bytesAvailable > 0)
            sample = soundRecording.readFloat();
    soundOutput.data.writeFloat(sample); 
    soundOutput.data.writeFloat(sample);  
     }                
}
dome
A: 

Hi Ole,

Take a look at this air application.This can be converted for use in Adobe Flash Player 10.1.

http://download.macromedia.com/pub/developer/air/sample_apps/microphone.zip

It allows you to access the raw data from the microphone in Flash

Now for applying the filter check: http://code.google.com/p/standingwave/

Oliver