One of the most fundamental things a developer would want to be able to do with audio sample data gathered from an Android microphone, would be to capture the data and use it in some way within an application. This recipe will demonstrate how to preserve and play back captured microphone audio sample data.
We will employ an event listener to respond to sample data reported through the Microphone
API by writing captured audio data to a ByteArray
and then playing it back internally through the Sound
object:
1. First, import the following classes into your project:
import flash.display.Sprite; import flash.display.Stage; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.SampleDataEvent; import flash.events.TouchEvent; import flash.media.Microphone; import flash.media.Sound; import flash.media.SoundChannel; import flash.utils.ByteArray; import flash.ui.Multitouch; import flash.ui.MultitouchInputMode;...