Appendix C. Digital Audio Basics

IN THIS APPENDIX

  • Audio sampling and quality basics

  • Production tips

If you plan carefully and pay attention to technical detail, sound can add dimension to your Flash projects. That's because sound introduces another mode of sensory perception. Coordinated with visual form and motion, sound deepens the impact and can even enhance the ease of use of your Flash creation.

Note

For detailed information on adding sound to your Flash productions, refer to Chapter 12, "Adding Sound." Chapter 12 explains how to work with imported sound in Flash CS5, covering topics from codecs and compression to syncing to behaviors.

Understanding the Basics of Sampling and Quality

Before you begin integrating sound with your Flash project, it's important to understand the basics of digital audio. To help you with this, this appendix is dedicated to sampling, bit resolution, and file size.

What is sound?

Hearing is one of our five senses; it's the sense that's produced when vibrations in the air strike the aural receptors located within your ears. When you hear a sound, the volume of the sound is determined by the intensity of the vibrations, or sound waves.

The pitch that you hear — meaning how high (treble) or low (bass) — is determined by the frequency of those vibrations (waves). The frequency of sound is measured in hertz (abbreviated as Hz). Theoretically, most humans have the ability to hear frequencies that range from 20 to 20,000 Hz. The frequency of the sound is a measure of the range of the sound — from the highest high to the lowest low. It's important to note here that, when starting to work with sound, the most common error is confusing the frequency of the sound with the recording sample.

What affects the quality and size of sound files?

When you add sound to a Flash movie, a number of factors affect the final quality of the sound and the size of the sound file. The quality of the sound is important because it determines the aesthetic experience of the sound. The file size is important because it determines how quickly (or slowly) the sound arrives at the end user's computer. The primary factors that determine the quality and size of a sound file are sample rate and bit resolution.

Sample rate

The sample rate, measured in hertz (Hz), describes the number of times an audio signal is sampled when it is recorded digitally. In the late 1940s, Harry Nyquist and Claude Shannon developed a theorem which said that, for optimal sound quality, a sampling rate must be twice the value of the highest frequency of a signal. Thus, the higher the sample rate, the better the audio range. Generally, higher sample rates result in a richer, more complete sound. According to Nyquist and Shannon, in order for the audible range of 20 to 20,000 Hz to be sampled correctly, the audio source needs to be sampled at a frequency no lower than 40,000 Hz, or 40 kHz. This explains why CD audio, which closely resembles the source sound, is sampled at 44.1 kHz.

Note

A sound sample refers to one "analysis" of a recorded sound, whereas a sound file refers to the entire collection of samples recorded, which comprise a digital recording.

The less a sound is sampled, the further the recording will deviate from the original sound. However, this tendency toward loss of the original quality of the sound yields one advantage: When the sample rate of a sound file is decreased, the file size drops proportionately. For example, a 300KB, 44.1 kHz sound file would be 150KB when saved as a 22.05 kHz file. See Table C.1 for more details on how sample rates affect quality.

Table C.1. Audio Sample Rates and Quality

Sample Rate

Quality Level

Possible Uses

48 kHz

Studio quality

Sound or music recorded to a digital medium such as miniDV, DAT, DVCam, and so on

44.1 kHz

CD quality

High-fidelity sound and music

32 kHz

Near-CD quality

Professional/consumer digital camcorders

22.050 kHz

FM radio quality

Short, high-quality music clips

11.025 kHz

Acceptable for music

Longer music clips; high-quality voice; sound effects

5 kHz

Acceptable for speech

"Flat" speech; simple button sounds

Because the native playback rate of most common audio cards is 44.1 kHz, sound that is destined for playback on any computer should be a multiple of 11.025. Thus, I recommend sample rates of 44.1 kHz, 22.05 kHz, and 11.025 kHz for any use on computers. (Although sample rates that deviate from the rule of 44.1 may sound fine on your development platform, and may sound fine on many other computers, some may have problems. This simple rule goes a long way toward reducing complaints of popping and distorted sound.) These standard rates become more important with Flash. When Flash imports sounds that are not multiples of 11.025, the sound file is resampled, which causes the sound to play at a lower or higher pitch than the original recording. This same logic applies to sound export, which I discuss in Chapter 12. Finally, although Flash menus list sample rates as 11, 22, and 44, these are abbreviations for the truly precise sample rates of 11.025, 22.05, and 44.1 kHz.

Note

Although the Flash Player can play a wide range of sampling rates with runtime assets, the Flash Player resamples all audio to 44.1 kHz during playback. You may want to make sure that all external assets that you intend to play at runtime use 44.1 kHz for consistency.

Bit resolution

The second key factor that influences audio quality is bit resolution (or bit depth). Bit resolution describes the number of bits used to record each audio sample. Bit resolution is increased exponentially, meaning that an 8-bit sound sample has a range of 28, or 256, levels, whereas a 16-bit sound sample has a range of 216, or 65,536, levels. Thus, a 16-bit sound is recorded with far more information than an 8-bit sound of equal length. The result of this additional information in a 16-bit sound is that background hiss is minimized, while the sound itself is clearer. The same sound recorded at 8-bits will be noisy and washed out.

A 16-bit sound file is twice the size of the same file saved at 8-bit quality. This is due to the increase in the amount of information taken to record the higher-quality file. So, if your sound is too big, what can you do? Well, a sound that's been recorded at a higher bit resolution can be converted to a lower bit resolution, and a sound with a high sample rate can be converted to a lower sample rate. Although a professional studio might perform such conversions with hardware, you can do either of these conversions with software.

Tip

If you're having difficulty understanding the significance of bit depths, yet are familiar with the intricacies of scanning photographic images, consider the difference between an 8-bit grayscale image and a 24-bit color image of equivalent dimensions. The file size for the 8-bit grayscale image (such as a black-and-white photograph) is much smaller than the 24-bit color image (such as a color photograph). The grayscale image doesn't have as much tonal information — only 256 levels of gray — yet the 24-bit color image records a range of 16.7 million colors. Unlike photographs, sound samples don't require anything close to a range of 16.7 million values. Also, 16-bit sound samples deliver a dynamic range of over 64,000 values, which is more than the human ear can detect.

Table C.2 lists the various bit depths of sound along with their quality levels and possible uses.

Table C.2. Audio Bit Resolution and Quality

Bit Depth

Quality Level

Possible Uses

16-bit

CD quality

High-fidelity sound and music

12-bit

Near-CD quality

Professional/consumer digital camcorder audio

8-bit

FM radio quality

Short, high-quality music clips

4-bit

Acceptable for music

Longer music clips; high-quality voice; sound effects

Note

As hardware technology improves, we're seeing even better audio bit resolution beyond the 16-bit and 44 kHz range. The DVD-Audio format, for example, offers audio bit resolutions of 16, 20, or 24, and sampling rates of 48, 96, or 192 kHz. Obviously, these extraordinarily high fidelity recordings are appreciated by extreme audiophiles who have superior playback devices and speakers. Don't worry if your multimedia presentations don't use such extremes — trust me when I say that 16-bit 44 kHz audio is more than enough quality for average computer-audio devices and speakers.

See Figures C.1 and C.2 for a comparison of the differences between sounds at different sample rates and bit depths. Both figures show a waveform derived from the same original sound file, differing only in their sample rates and bit depths. The waveform of the 16-bit 44.1 kHz sound has twice as many points — or samples of information — as the 8-bit 11.025 kHz sound. Because the 16-bit 44.1 kHz sound has more samples, the gap between each sample isn't as large as the gaps of the 8-bit 11.025 kHz sound. More samples result in a much smoother, cleaner sound.

Tip

A common mistake novices make with sound is the assumption that 8-bit audio is acceptable, especially because it ought to result in a much smaller file than 16-bit sound. This is wrong for at least two reasons. First, 8-bit is unacceptable because it sounds far worse than 16-bit sound. Second, the horrible sound does not pay for itself in diminished file size because most audio compression codecs (especially those used by Flash) won't work with 8-bit sound.

A waveform of a sound sampled at 44.100 kHz with a 16-bit resolution, as displayed in a high-end sound application

Figure C.1. A waveform of a sound sampled at 44.100 kHz with a 16-bit resolution, as displayed in a high-end sound application

The same sound that is shown in Figure C.1, but it's down-sampled to 11.025 kHz with an 8-bit resolution

Figure C.2. The same sound that is shown in Figure C.1, but it's down-sampled to 11.025 kHz with an 8-bit resolution

Channels

Audio files are either mono (single channel) or stereo (dual channel: left and right). Stereo files are twice the size of mono files because they have twice the information. Most audio-editing applications offer the option to mix the two stereo channels together and either save or export a stereo sound to a one-channel mono sound. Most audio applications also have the capability to save the right or left channel of a stereo sound separately as a .wav or .aif file.

With the more robust, multitrack-editing applications such as Deck, ProTools, Sound Forge, or Cool Edit Pro, it's not unusual to work with eight or more audio tracks — limited only by your system configuration. As you may imagine, these applications give the sound artist greater control over the final sound mix. For use in Flash, these multitrack audio project files need to be "bounced" or mixed down to a stereo or mono file in order to be saved as .wav or .aif files.

Getting Tips on Production

The primary goal of sound optimization for limited delivery networks (such as the Internet) is to deliver an acceptable quality without a large file-size "cost." You should be concerned about the file size of your audio clips for several reasons:

  • Sound files require a large amount of drive space.

  • Managing large sound files and importing them into Flash can be cumbersome and slow.

  • Download times for large, elaborate sound clips (even when heavily compressed upon export from Flash) can be detrimental to the appreciation of your Flash project (even if your target audience has what may be considered a high-speed Internet connection).

When you're working with audio clips, it's important to create the shortest audio clips possible. That means trimming off any excess sound that you don't need, especially any blank lead-in or lead-out handles (also called in and out points) at either the beginning or the end of a clip.

Note

I discuss trimming excess sound briefly in Chapter 12, with reference to Flash's sound tools.

If you plan to have a background music track in your Flash project, it's a good idea to use a small audio clip that can be looped.

Note

I describe looping audio clips in Chapter 12.

Here is a simple formula to determine the file size, in bytes, of a given audio clip:

Seconds of audio × sample rate × # of channels × (bit depth ÷ 8) = file size

Note

In the preceding formula, the sample rate is expressed in Hz (hertz), not kHz (kilohertz). The bit depth is divided by 8 because there are 8 bits per byte.

Thus, a 20-second stereo audio loop at 8 bits, 11 kHz would be calculated like this:

20-sec × 11,025 Hz × 2 channels × (8 bits ÷ 8 bits/byte) = 441,000 bytes = 430KB

There are two schools of thought regarding the ideal quality of sound files for import into Flash. These schools are pretty much divided into those who have high-end sound-editing tools and those who don't. In an effort to delineate the best path for each group, we've noted the following:

  • If you don't have high-end sound tools available, you may be among those who always prefer to start with audio source files of the highest possible quality (16-bit, 44.1 kHz is ideal), and then use the Flash sound settings to obtain optimal compression upon export.

    Note

    See Chapter 12 for detailed information on the sound export settings for Flash movies.

  • If you do have high-end sound tools available, you may prefer to compose most of your clients' music from scratch and may very rarely work with the MP3 format before importing into Flash. You may also disagree with those who advise you to bring sound into Flash at the highest quality before optimizing. This workflow difference may be attributable to the plethora of options available to those with high-end sound tools. I know of one sound engineer who converts all of his audio to 16-bit, 22.1 kHz mono files, "with major bass reduction," before importing into Flash.

You should always keep in mind that Flash can retain imported MP3 compression settings only with those MP3 files that will be used for non-Stream sync options. Anytime you set a sound to use Stream sync on a timeline, Flash needs to recompress the file with the Stream export settings found in the Publish Settings dialog box.

Finally, all linked sounds, or those set to export from the Library and played back via ActionScript, are treated as non-Stream sounds. If you use linked sounds, you may find it useful to import precompressed MP3 files at your preferred bit rate. Flash does not recompress the MP3 file upon export to a .swf file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset