Array

Recording Audio

Must Read

College Funding Through Chase Bank Student Loans

When you're looking for ways to pay for college, you have to research various banks and lenders, and compare...

Home Ownership Readily Accessible For a First Time Buyer Mortgage

With housing prices continuing to fall and credit becoming more widely available to consumers once again, it is an...

How to Handle a Wrongful Arrest or False Arrest

Wrongful arrests are a tricky subject to discuss because there is the legal explanation and then there is the...
Admin
test

When recording, the device buffers the microphone input. Create a ByteArray object to store the audio data. Create a reference to the microphone and add a listener to the SampleDataEvent.SAMPLE_DATA event:

import flash.media.Microphone;
import flash.utils.ByteArray;
import flash.events.SampleDataEvent;
var bytes:ByteArray = new ByteArray();

var microphone:Microphone=Microphone.getMicrophone();
if (microphone!= null) {
microphone.gain = 100;
microphone.rate = 22;
microphone.setSilenceLevel(0, 4000);
microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, recording);
}
function recording(event:SampleDataEvent):void {
while(event.data.bytesAvailable) {
var sample:Number = event.data.readFloat();
bytes.writeFloat(sample);
}
}

To stop the recording, remove the event listener. You can do this in code using a timer:

import flash.utils.Timer;
import flash.events.TimerEvent;
var timer:Timer = new Timer(5000);
timer.addEventListener(TimerEvent.TIMER, stopRecording);
timer.start();
function stopRecording(event:TimerEvent):void {
microphone.removeEventListener(SampleDataEvent.SAMPLE_DATA, recording);
timer.reset();
}

You can also let the user click a button to stop the recording. In this case, be aware of the memory and storage being used. You may want to prompt the user if the recording has been going on for more than a few seconds.

Previous articleThe Microphone
Next articlePlaying Back Audio

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest News

Underlight As Accent, For Power and The Main Light for Photography

Underlighting, in which fill or accent light comes from under the topic, is not widely used technique in the traditional Portraits,...

How To Fix Overexposure As A Creative Tool, The Complete Guide

As an creative tool, overexposure is sort of underrated. What I’m close to propose could be a deliberate and well thought out technique for...

7D Mark II is Canon’s best DSLR cameras without full-frame sensor.

The expected long-awaited Canon EOS 7D Mark II are shipping in November for $ 1,799 without a lens. With a higher price tag, you...

Low key photography and How to isolate your subject.

Low key photography doesn’t depend on underexposure to make its point; the key to low key is that the majority of tones, even correctly...

High Key Lighting Techniques for Professional Photographers

I’ve written many times about high key lighting techniques and how to achieve them. The term “high key” is a bit misleading. As I’ve...

More Articles Like This