[snippit] – generating a faux waveform in AS3

Working on a Flash project. I had to use the microphone to record some audio and generate a simple waveform so the user has some feedback that they are being heard. While not a true waveform, you can use the microphone activity level to generate something that works pretty well.

[kml_flashembed publishmethod=”static” fversion=”9.0.0″ movie=”http://www.wirelust.com/examples/waveform/bin-debug/waveform.swf” width=”500″ height=”250″ targetclass=”flashmovie”]

Get Adobe Flash player

[/kml_flashembed]

Here is the code to generate the above sample:

span style="color: #808080; font-style: italic;">// loopback is required so we can get the activity level and create the waveform. - so stupid
// turn off the volume for the loopback
 

And for the Waform class:

span style="color: #808080; font-style: italic;">// trim the levels so we don't keep eating up memory
// autoscale will find the highest volume and scale all lines in the display accordingly.
 

Files

 Download source code