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 audio tones for your application

Packing a lot of sound files into an application is one method of including audio. Another method is the runtime generation of sound data. We'll produce some simple sine tones in this recipe, which vary based upon detected touch pressure.

How to do it…

We will examine how to generate audio sample byte data based upon user touch pressure and feed this into a Sound object to generate a variety of tones:

  1. First, import the following classes into your project:
    import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.events.SampleDataEvent; import flash.events.TouchEvent; import flash.media.Sound; import flash.media.SoundChannel; import flash.ui.Multitouch; ...

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