Home > Articles

  • Print
  • + Share This
This chapter is from the book

Controlling Quality and File Size

Now that you know how to incorporate sound in your movie, it's time to talk about optimizing it for export. A direct relationship exists between quality and file size. If you want the best quality sound, the file size will grow. Conversely, small file size means lower sound quality. This is just a fact. You ultimately need to make a decision as to how you balance this tradeoff. Is a high-quality sound important enough to make your audience sit through an extended download time? Is a speedy download enough to make your audience ignore a low-quality sound? You should be very deliberate in your decision-making process to end up with the best compromise possible.

While exploring this topic further, we'll first cover some digital audio fundamentals and then you'll learn how to apply this knowledge to Flash's compression settings.

Digital Audio Fundamentals

Digital sounds on the computer are not continuous. Similar to how a fluorescent light or your computer monitor flickers, digital audio is a series of discrete bursts called samples. The frequency that these samples occur is so fast that you think you're hearing a continuous sound.

Exactly how fast the samples are occurring is called the frequency rate (also sometimes called sampling rate). Naturally, a higher frequency rate (many bursts per second) sounds better than a low rate. The frequency rate of all audio CDs, for example, is 44,100 hertz, commonly referred to as 44 kilohertz (KHz). Sound-editing software can convert a song to a lower rate but it won't sound as good. Why not always use the highest frequency rate possible? Simple. Each sample takes up disk space and adds to the file size. A sound with a frequency rate of 22,050Hz, for example, is half the size of one at 44,100Hz and may still sound good.

In addition to frequency rate, another important factor is bit depth. Similar to how each pixel on your computer monitor can be one of 256 colors (when the color depth is 8 bit) or one of 16.7 million colors (when the color depth is 32 bit), each sample in an audio track can be one of many sound levels (think of these sound levels as "shades of sound"). A sound with an 8-bit depth means that for every sample, the sound can be one of 256 different levels. A 16-bit sound has the potential of being one of 65,536 different levels. The higher the bit depth, the better the sound quality. (By the way, audio CDs have 16-bit depth.)

Frequency rate and bit depth are independent. One sound could have a high frequency rate (such as 44,100) but a low bit depth (maybe 8 bit). When you increase either factor (to improve quality), file size grows. To make matters worse, a stereo sound is always twice as large as the same sound in mono (because it contains information in two channels). Finally, the length of the sound affects file size directly—a longer sound is larger.

There are ways to calculate the exact size impact of frequency rate and bit depth. The bottom line, however, is that audio takes up a lot of disk space. One minute of CD- quality sound, for example, takes about 9 megabytes! The fact that pure CD-quality sound takes up so much space is why you want to find a better way.

One solution is compression. MP3 compression, for example, analyzes the sound file and finds ways to reduce the file size with minimal sacrifice to quality. Using MP3 compression, that same 9 megabytes of CD quality sound might get reduced to about 1 megabyte! Just like how JPG compression reduces the file size by removing parts of the image you don't notice, MP3 uses a technique to remove the parts of a sound that you're not likely to miss. Exactly how it does this, I don't know. It's magic, I guess. However, Flash can perform MP3 compression based on the level to which you would like your sounds brought down (namely, the bit rate). The best quality MP3 that Flash 5 supports is 160Kbps. A lower number means lower quality (but also means the amount of data per second is lower). One last note: When MP3 reaches 160Kbps (or whatever level you specify), it makes its own decisions regarding the balance between frequency rate and bit depth.

Export Settings

All this theory is interesting, but how do you apply it to your sounds? You have two places in Flash where you can specify quality settings: the Sound Properties dialog box, unique to each imported sound, and the Flash tab of the Publish Settings dialog box.

Global Publish Settings

To set the default sound format for every sound in a Flash movie, select File, Publish Settings.... Make sure under the Formats tab that you've checked Flash (.swf), and then click the Flash tab (see Figure 10.10). You'll see two different sound settings in this dialog box: Audio Stream and Audio Event. Audio Stream affects sound instances using the Stream sync setting, whereas Audio Event affects sounds using the Event sync setting (it also affects sounds set to Start, although it doesn't say so). If you click the Set button, you can see all the options available, as shown in Figure 10.11. The following list provides a description of each option:

Figure 10.10 The Flash tab of the Publish Settings dialog box provides you with a way to set the default sound settings globally for the entire file.

Figure 10.11 You can set the type of compression for all sounds in your movie from Publish Settings.

There's a Set button next to both Stream and Event so you can set the compression for sounds used each way separately. There are five choices for sound compression. With the exception of "Raw" (which is really no compression), you'll need to specify additional options for the compression you choose. For example, you can't just say "compress using MP3"—you have to specify how much MP3 compression. As each option has its own unique characteristics, let's look at each in detail:

  • Disable is pretty simple: It tells Flash not to export any sounds. When you select Disable from the drop-down list, there are no other options to set.

  • ADPCM is almost the same as Raw (below), except it performs a little bit of compression. The options for Sample Rate and Convert Stereo to Mono have the same effects as discussed earlier, but the ADPCM bits specify the level of compression. A higher number means better quality but not as small a file. Pretty much the only reason to use this option rather than MP3 is when you have to deliver your movie to the Flash 3 player (which more people have).

  • MP3 provides great compression. When exporting, always use the Quality setting "Best" because it won't affect the file size but will improve quality. However, while working, you might consider temporarily changing this to "Fast," because every time you test a movie (using Test Movie), it will go quicker. The bit rate is simply how much data per second you're letting the MP3 file take. The higher the number, the better. In theory, a bit rate of 56Kbps will be maintainable on a 56K modem, although reality is sometimes different from theory because other factors can slow the download performance. We'll explore more issues related to downloading in Hour 20, "Optimizing Your Flash Site." You really just have to test this out and keep lowering the bit rate until just before the sound becomes unacceptable. You can judge the result by testing the movie or (as you'll see later in "Individual Export Settings") you can test each sound individually.

  • Speech is a new Flash MX compression setting (which, by the way, requires that your users have the Flash 6 player). This compression setting is optimized for the human voice. In practice, however, you should always compare the quality/filesize effects of Speech compression to MP3 because you'll find the best choice varies case by case.

  • Raw leaves your sounds intact, although you do need to specify a sample rate (frequency rate). Also, if you select Convert Stereo to Mono, any stereo sounds will become half their original size.

Now you've learned how you can set the default sound settings for both Stream and Event sounds from the Publish Settings dialog box. Also note the Override Sound Settings check box. This will cause the settings you apply here to be imposed on all sounds in your movie, regardless of their individual export settings. You're about to see how to specify sound settings individually per sound. Override can be useful when you want to publish a single copy for a special purpose. Say you want a copy to demonstrate from your hard drive—download time isn't an issue, so you could make all the sounds play at their highest quality (Raw).

Individual Export Settings

In addition to a movie's globally specified sound settings, each sound item in the Library can have its own individual settings, which apply to every instance of that sound. Just double-click a sound in the Library (or from the Options menu, select Properties...), and you'll see the Sound Properties dialog box, as shown in Figure 10.12.

Figure 10.12 The Sound Properties dialog box provides individual control of exactly how a sound will be exported (regardless of the default publish settings).

This dialog box is similar to the Bitmap Properties dialog box you studied in Hour 3. In the same way that individual imported bitmaps can have their own set of compression settings, so, too, can imported audio. The choice of settings is practically identical to the settings under Publish Settings. However, in this dialog box, for each change you make, you're given details of the effect on file size and quality. Down at the bottom you'll see how much the file compresses for each change. If you click the Test button, not only will Flash perform the compression you specified, but the sound starts playing and you can hear how it sounds (similar to the Test button for bitmaps, although with bitmaps you judge the visual effect). This gives you all the information you need to decide what settings to use. You can listen to the sound while assessing the effect on file size.

The Sound Properties dialog box has a couple other items you should note. The Default option will use whatever settings you specify in the Publish Settings. Also, you have the same ability to replace sounds as you do for replacing bitmaps. For instance, if you've edited a sound in a sound editor and you want to import the replacement sound, just click the Update button (if the file has moved, you'll be asked to point to the new location). Additionally, if you want to replace a sound (without taking the trouble of reassigning every keyframe where you've already used the sound), just click Import and select the new file when prompted.

Tricks for Efficiency

Obviously the best way to reduce file size (in respect to audio) is to avoid using audio. Although this may sound facetious, it's worth consideration. You should force yourself to consider each sound you use, and if it's not adding something to your file, it's most certainly distracting because it's adding to the file size (and that's a distraction during download). Gratuitous sound effects are worse than gratuitous visual effects because sounds add significantly to the file size. Just be extra critical when asking yourself whether a particular sound is really necessary.

After you've decided that a sound is, indeed, necessary, you still have ways to reduce the sound's impact on the file size. The best way is to trim any "silence" at the beginning or end of the audio. Silence still adds to the file size. Ideally, you should do this before importing the audio into Flash, but you can also do it for each instance through the Edit Envelope dialog box shown earlier. Another great way to reduce file size is to use a short looping sound instead of a long linear sound. Of course, there's a possibility of selecting a loop that can become monotonous, but you might be surprised how much "mileage" you can get from one simple loop. Sprinkle a few incidental Event sounds independent of the loop, and it can often sound very interesting.

Probably the most subjective question is "Which level of compression is appropriate?" First of all, it makes the most sense to always start with the best quality sound possible and then selectively reduce the file size and quality as appropriate. (The only exception is an MP3 file that you believe already has the best possible compression—in which case you wouldn't want to recompress it.) If you start with a bad sound, it's never going to get any better. You always want to start with top-quality sounds.

Determining which level of compression is appropriate is really a subjective decision, but that doesn't mean I can't make a few suggestions. First of all, there's a common misconception that audio containing voice can withstand the most compression, whereas music can't. This is just plain false! A better generalization would be to say that sounds of natural items (acoustic instruments and voices, for example) are best kept at a high quality, whereas sounds of synthetic items (such as a distorted electric guitar and synthesized keyboards) will likely be perfectly acceptable at a lower quality. This is true because any sound on the computer is fake—you're trying to make the user believe the sound is one thing or another when, in fact, it's just electronic data. When you attempt to simulate something natural, such as a voice or acoustic instrument, your audience has a good recollection of what that sound is supposed to sound like, and they'll notice if it doesn't sound right. On the other hand, sounds from an electric guitar, for example, can be distorted and still sound perfect. Ultimately, you'll still need to test each compression setting to hear how it sounds, but just remember it's easier to notice that something's wrong when a natural sound gets distorted.

One other fact: If everything else is kept equal, a mono sound will appear "cleaner" than a stereo sound. This doesn't mean that you shouldn't use stereo. Instead, simply realize that in order to maintain quality in a stereo sound, you usually can't compress as much (and add to this the fact that stereo sounds are twice as big as mono sounds). Therefore, just be absolutely sure you need stereo sound (and remember you can still pan the left and right channels without a stereo sound).

  • + Share This
  • 🔖 Save To Your Account