Understanding the sound architecture

Your applications can load sound data from five main sources:

  • External sound files loaded at run time

  • Sound resources embedded within a SWF file

  • Sound data from a microphone attached to the user’s system

  • Sound data streamed from a remote media server, such as Flash Media Server

  • Sound data being generated dynamically by using the sampleData event handler

Sound data can be fully loaded before it is played back, or it can be streamed, meaning that it is played back while it is still loading.

Adobe AIR supports sound files that are stored in the mp3 format. They cannot directly load or play sound files in other formats like WAV or AIFF. (However, AIR can also load and play AAC audio files using the NetStream class.)

The AIR sound architecture includes the following classes:

Class

Description

Sound

The Sound class handles the loading of sound, manages basic sound properties, and starts a sound playing.

SoundChannel

When an application plays a Sound object, a new SoundChannel object is created to control the playback. The SoundChannel object controls the volume of both the left and right playback channels of the sound. Each sound that plays has its own SoundChannel object.

SoundLoaderContext

The SoundLoaderContext class specifies how many seconds of buffering to use when loading a sound, and whether the runtime looks for a cross-domain policy file from the server when loading a file. A SoundLoaderContext object is used as a parameter to the Sound.load() method.

SoundMixer

The SoundMixer class controls playback and security properties that pertain to all sounds in an application. In effect, multiple sound channels are mixed through a common SoundMixer object. Property values in the SoundMixer object affect all SoundChannel objects that are currently playing.

SoundTransform

The SoundTransform class contains values that control sound volume and panning. A SoundTransform object can be applied to an individual SoundChannel object, to the global SoundMixer object, or to a Microphone object, among others.

ID3Info

An ID3Info object contains properties that represent ID3 metadata information that is often stored in MP3 sound files.

Microphone

The Microphone class represents a microphone or other sound input device attached to the user’s computer. Audio input from a microphone can be routed to local speakers or sent to a remote server. The Microphone object controls the gain, sampling rate, and other characteristics of its own sound stream.

Each sound that is loaded and played needs its own instance of the Sound class and the SoundChannel class. During playback, the SoundMixer class mixes the output from multiple SoundChannel instances.

The Sound, SoundChannel, and SoundMixer classes are not used for sound data obtained from a microphone or from a streaming media server like Flash Media Server.

// Ethnio survey code removed