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?

Sound, or 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 compose 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 300 KB, 44.1 kHz sound file would be 150 KB 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 44.1. Thus, we 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 will go 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 we discuss in Chapter 15, "Adding Sound." 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.

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.

Web Resource 

For more information on down-sampling and conversion, refer to the archived chapter, "Working with Audio Applications," from the Macromedia Flash MX 2004 Bible (Wiley, 2004) at www.flashsupport.com/archive.

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. 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 new 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 us when we say that 16-bit 44 kHz audio will be more than enough quality for average computer-audio devices and speakers.

Refer to 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 wave form 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.

image from book
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

image from book
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

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 will not pay for itself in diminished file size because most compression codecs (especially those used by Flash) won't work with 8-bit sound.

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 3.5, 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.

Web Resource 

For a more detailed description of this process, refer to the Macromedia Flash MX 2004 Bible's (Wiley, 2004) archived chapter, "Working with Audio Applications," available at www.flashsupport.com/archive.




Macromedia Flash 8 Bible
Macromedia Flash8 Bible
ISBN: 0471746762
EAN: 2147483647
Year: 2006
Pages: 395

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net