In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Microphone Test

/**
 * Copyright clouder ( http://wonderfl.net/user/clouder )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/4Gvc
 */

package {
    import flash.display.*;
    import flash.media.*;
    import flash.events.*;
    import flash.utils.*;
    import flash.text.*
    public class MicTest extends Sprite {
        private var mic:Microphone;
        private var canvas:Sprite;
        private var g:Graphics;
        private var timer:Timer;
        private var fld:TextField;
        private var tf:TextFormat;
        public function MicTest() {
        	mic = Microphone.getMicrophone();
        	mic.setLoopBack(true);
        	mic.setUseEchoSuppression(true);
        	mic.gain = 50;
        	mic.rate = 10;
        	mic.setSilenceLevel(5, 1000);
        	
        	tf = new TextFormat();
        	tf.font = "_typewriter";
        	tf.size = 18;
        	tf.color = 0x0000ff;
        	
        	fld = new TextField();
        	fld.defaultTextFormat = tf;
        	fld.x = 10;
        	fld.y = 10;
        	fld.text = "aaaaaaaaaaaa";
        	addChild(fld);
        	
        	timer = new Timer(50);
        	timer.addEventListener(TimerEvent.TIMER, drawLevel);
        	timer.start();
        }
        
        public function drawLevel(evt:TimerEvent):void {
        	fld.text = "level: " + mic.activityLevel;
        }
    }
}