O'Reilly logo

Flash Development for Android Cookbook by Joseph Labrecque

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Generating an audio spectrum visualizer

The ability to generate some sort of visual feedback when playing audio is very useful to the user, as they will be able to see that playback occurs even if the device volume has been muted or turned down. Generating visuals from audio is also useful in certain games, or in monitoring audio input levels.

How to do it…

We will load a MP3 file into a Sound object. By employing the SoundMixer. computeSpectrum() method, we can access the actual bytes being played back and construct visualizations with this data using the Sprite graphics API:

  1. First, import the following classes into your project:
    import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.TimerEvent; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required