By Jeff Swartz
Created
14 October 2008
 

Requirements

 
Prerequisite Knowledge

General experience of building applications with Flash is recommended.
 

 
User level

Intermediate
 

 
Required products

 
Sample files

The release of Adobe Flash Player 10 includes new functionality to play dynamically generated sound. Prior to Flash Player 10, all sounds played in Flash Player were based on unmodified data in a loaded MP3 file. Dynamic sound generation allows you to modify the data from a loaded sound (and play the resulting, modified sound). You can also generate sound data without loading an MP3 file, and play a sound based on that generated data.
 
This article describes two sample applications that demonstrate the use of dynamically generated sounds in Flash Player:
 
  • The DynamicSoundSample1 sample application adjusts the pitch (frequency) of a sound. The application reads the sound data as a byte array from a loaded MP3 file, and then adjusts the data of the output sound by removing sound samples, which causes the pitch to shift higher (see Figure 1). To test the DynamicSoundSample1 application, drag the slider control to the desired pitch shift factor (between 100% and 200%). Then click the Play button (make sure your computer speakers are not muted).
This content requires Flash To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player. To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Figure 1. The DynamicSoundSample1 sample application
 

  • The DynamicSoundSample2 sample application generates audio to play text as International Morse Code. The application generates the audio waveform as sound samples stored in a byte array. A sound object uses this byte array data to generate audio (see Figure 2). To test the DynamicSoundSample2 application, enter the text you want to generate in Morse code and then click the Play button. (Again, make sure your computer speakers are not muted.) The application plays the text as Morse code.

This content requires Flash To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player. To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Figure 2. The DynamicSoundSample2 sample application