|How can I get the best sound quality?|
In order to get the best quality sound for the smallest file size and performance hit, you must consider what the content of the sound is. Too often, movies use a blanket 8-bit 22kHz sound format when that may not be appropriate. But first, you must realize what each factor means when recording sound.
First, sound recorded in a computer is digital. This means that a replica of the sound is being recorded as opposed to analog which makes an actul copy of the sound wave. As a developer, you need to be aware of two crucial elements and how they affect your piece.
Bit depth - This is the detail of any particular sample. The higher
the bit depth, the more detail each sample has of the sound. This gives
greater accuracy and, more importantly, less noise.
Nyquist's Theorem says that you need to record your sound at a sampling rate of double that of the dynamic range you are trying to achieve. If you want your sound to have a range of 20 - 20,000kHz, then you need to record it with a sampling rate of at least 40,000Hz. A sampling rate of 44.1kHz is commonly used to achieve a full dynamic range - CD audio quailty.
What it all means
Voice - For voice, a higher bit depth to eliminate hiss and muddiness is preferable to achieve a clean sound. But 16-bit audio files are twice as large as comparable 8-bit sound files. You can usually make the tradeoff in sampling rate, by cutting it down. Recording voice does not require the same frequency range as music. There is no booming bass or higher highs. The human voice is pretty much mid-range. So if you establish that the frequency range does not need to go any higher than 5,000Hz, Nyquist's Theorem says to record the sound with a sampling rate of 11kHz. If your talent has a deeper voice or tends to fluctuate in range, then a range of 11kHz can be achieved by recording at 22kHz. Keep in mind that this will double your file size.
Music - For better sounding music, the bit depth is not as important as the sampling rate. Since music is continuous with no noticeable pauses or gaps similar to what you'd find in voice, hiss and muddiness can often be masked by the nature of the sound. So a lower depth of 8 bit can sound nearly as good as 16 bit, but without the doubled file size. Since most music has a wide dynamic range, then the sound needs to be recorded with this in mind. A lower bit depth such as 11kHz will produce a very flat, undynamic sound, not unlike that coming out of a transistor radio. The highs will be cut off and the bass will be nonexistant or even distorted. 44kHz is CD audio quality and sounds quite good on a good system. But the file size is quadruple that of a sound recorded at 11kHz and most computer systems have small speakers that can't generate the quality you are looiking for. So a happy medium is 22kHz. This is radio quality which is good for applications most of the time.
Things to Consider
Any variation from these sample rates can produce unexpected results
and may not be comptible with Director's import filters.
It used to be that to store such an enormous amount of information, you'd need the long spiral of a vinyl disk (raise your hand if you remember LPs) or miles upon miles of magnetic tape. Such a recording method is called analog, because the LP turns under the needle (or the tape moves past the head) at a rate analogous, or equal to, the sampling rate. If you've ever slowed down or sped up a tape player, you've experienced analog sound out of synch with the sampling rate.
As technology advanced enough to make storing large amounts of data economical, it became practical to record sound digitally. Every sampling of sound is attributed a digital value. If the range from quiet to loud was divvied-up into 16 levels, for instance, you would have 4-bit sound (each sampling would have one of the 16 binary values from 0000 to 1111. Think "walkie-talkie").
As digital data goes, digital sound is very much like digital imagery. Sampling rate is very much like pixel resolution. As a denser array of pixels can increase the clarity of a digital image, so too can a denser sampling rate increase the fidelity of digital sound. Imagine a 300 dots-per-inch (DPI) image and how much more information it provides relative to a 72 DPI image. The same goes for sampling rate. While a music CD reproduces sound with a resolution of 44.1 kHz, the standard computer sound is produced with a density of only one-fourth that (11.025 kHz).
The sophistication, or depth, of each byte of digital information is relevant as well. GIFs possess the 256 values of 8-bit data, but often JPEGs have the color depth of 24-bit data (224 or "millions" of colors). Likewise, digital audio can have the refined tone of 16-bit data or the more bland, "greyscale" tone of 8-bit data. (Human ears, by the way, hear the equivalent of 24-bit sound).
As you may already know, with digital bitmap imagery, more and deeper pixels make for bigger and fatter files. Once again, the same goes for digital sound. Sound, however, has the unique predicament of having to be delivered at a sustained rate because it eventually has to go analog again when it hits the speakers. While a 300 DPI, 24-bit JPEG just takes longer for a computer to buffer and then display to the screen, full-fledged sound taxes the very infrastructure of computer networks with its constant, streaming delivery from disk driveto speaker. If you have ever had occasion to watch the painfully slow draw of a large JPEG, then just imagine if it were an orchestral maneuver.
Note: The compromise of digital quality for file size is as true for
sound as it is for imagery. Sometimes an 8-bit GIF is an acceptable
alternative to a 24-bit JPEG. For the same reason, it just makes sense
to use 8-bit, 11.025 kHz mono sound for a button click. Always determine
the minimum amount of quality acceptable for every instance of sound,
but do yourself a favor: when capturing or altering sound, work at the
maximum resolution and depth possible and then desample to lower rates
on export. Robust original sound data has more latitude and fidelity
and is therefore more tolerant to the ravages of editing and compression.
However, as with digital imagery, it is never necessary to "scale-up"
the data to a higher sampling or bit-depth - the file will be larger
but not better, just laden with more of what you don't have.
|How audio works?|
If you need to capture visual motion for reproduction, you take a lot of pictures with a movie camera and then play them back to see the motion. Sound is motion too, just like the ripples in the water. To capture sound for reproduction, you have to take a lot of little samplings of the motion and then drum them over a speaker to reproduce the sound. The number of samplings captured per second is called the sampling rate and is measured in hertz. These "sound bites" are like the frames of a movie. The sampling rate of pulses per second (Hz) is similar to a movie's frame rate of frames per second (FPS).
Light moves fast — faster than sound. However, when you make a movie, you're not capturing light waves, you are capturing a sequence of static images. The light waves take care of themselves getting from the projector to the screen to our eyes. A process called persistence of vision helps the brain fill in the blanks between all those flickering frames.
To reproduce sound, however, there is no such convenience. Recorded
sound must duplicate the waves themselves, and sound waves can't be
faked with a mere 24 samplings per second. Even a sampling rate of 5564
pulses per second is rather crude - kind of what you'd hear over a walkie-talkie.
To get acceptable results for reproduction, like a good FM radio broadcast,
22050 pulses are produced every single second.
|What are some ways to synch audio in Flash?|
Sound synching strategies
|Optimization techniques for sounds|
Sound is data intensive. The quality of the sound output
and length of playback factor prominently into the amount of data required.
Sounds with higher sample rates (22.5Khz and above) retain a greater
degree of quality, but almost always require too much data to realistically
stream sound to the Flash player on time over a 28.8Kbps modem. Flash
utilizes compression to help reduce the size of the data - but even
the maximum compression allowed in Flash may not be sufficient to deliver
high quality audio over longer periods of time. Here are some tips to
use sound more efficiently:
|To stream or not to stream|
How then do we synchronize animation and sound; two
process operating on such different principles? Unfortunately, we don't
- at least, not really. All we can do is plant sounds where they need
to occur and hope for the best.
|How streaming works|
The term streaming, as it relates to Flash Player, refers to the normal flow of data from a server over a network connection to the client machine that has requested it. The fastest speed at which data moves is limited to the slowest connection through which that data travels.
Often, the slowest point in the connection is a user's modem (running at 28.8Kbps per second or slower). Since all data streams over a connection to the users machine, what makes a Flash Player movie's stream different from a big GIF or JPEG file's stream?
The difference is that the data in a Flash Player movie is stored sequentially
by frame. When the Flash Player (plug-in or ActiveX control) receives
all of the data for a single frame, it may then immediately render it
to the screen without waiting for any more of the data to arrive. A
Flash Player movie will play smoothly only if Flash Player is able to
receive the data over the net connection at about the rate that the
Flash Player movie is set to play in frames per second.
|Streaming and playback performance|
Flash Player movies, just like any other data, always stream. However, how well a Flash Player movie plays when streamed depends on how much data is required for each frame in order for a Flash Player movie to play.
Often, the slowest point in the connection is a user's modem (running
at 28.8Kbps per second or slower).To play smoothly from start to finish,
the following must be given consideration:
If the movie reaches a frame that cannot be rendered because all of
the data hasn't downloaded yet, playback will stop until the needed
data has finished downloading. Therefore, if your movie has complex
items or a large number of items in the first frame, it may take awhile
to download all those items before the first frame can be displayed.
If other frames are also large or complex, your movie may play in spurts
slowing down to wait for data and then speeding up when it has enough
data to play the frames faster.
|Advanced use of streaming sound|
First a little tip about bitrates and Mp3´s:
Instead of embedding the application swf into the html, the application will end up being loaded into a level and run inside another swf file. The swf file embeded in the html is only a small space holder to check the bandwidth. This is done to ensure that there is no collateral bandwidthusage.
The logic order is this:
The next step is to load your application swf into a level and then
set the quality variable in that level according to the check. Now for
the tricky part. The application should have no sound, except for the
seperate swf's encoded at two different mp3 bitrates: soundlo.swf soundhi.swf
as an example.
The real tricky part is creating the preloading processes and setting
up your applicationwith blank targets to load the sound into. The advantage
is having an optimized download time while delivering the best sound
quality as determined by connection speed.
The following tips are general advice for achieving small file sizes and optimum playback performance:
Flash relies on vector based rendering for efficient storage and delivery. Raster (or bitmap) based rendering systems store information about individual pixels to be presented on the screen. The amount of information required to render a raster image is based on the size of the image (or the number of pixels that image contains). Vector based rendering requires far less information, storing only the mathematical data needed to calculate and render the image. For these reasons, raster images can drastically reduce the efficiency of Flash when used excessively.
Here are some tips for using bitmap images effectively:
Use bitmap images sparingly.
Avoid animating bitmap images.
To retain definition and clarity in the original bitmap, disable
smoothing for that image only.
|Improving bitmap image quality in Flash|
There are a few things that can be done to improve the image quality of bitmaps before and after importing them to Flash.
To improve bitmap quality in Flash: Don't scale imported bitmaps within
Flash, which can greatly reduce image quality in published SWFs. Rather,
use an external image editor such as Macromedia Fireworks to scale the
image to the desired pixel dimensions before import.
In the HTML tab of the Publish Settings (File menu > Publish Settings
> HTML tab) set the Quality to Best.
|Naming strategies for Flash|
Although Flash 5 offers flexibility in naming objects
and freedom in coding practices, following some basic naming conventions
will help ensure proper playback. The use of naming conventions when
coding also helps make scripts easier to understand, troubleshoot, and
share with others. This document lists some common naming conventions
when programming in ActionScript and other languages.
Note: For an example list of special characters, refer to the TechNote URL Encoding: Reading special characters from a text file (TechNote 14143).
- Start with a letter. Using a variable or object name that starts
with a number can cause confusion. For example, instead of using the
expression '3frame' to identify a frame label, use 'frame3'. Variable,
function, and object names can contain numerals, however the first character
should be a letter.
Here are some more examples :
- Capitalize the first letter of subsequent words. When using multi-word
names for variables, capitalize the first letter of all words but the
first. Some examples of this are: lastAddress, currentAddress, and lastFrameVisited.
This practice can make code easier to read. If you share code or collaborate
on projects, others will benefit from the readability..
- Avoid reserved words. Words like 'date', 'this', and 'goto' have
special meaning for the Flash Player. Using these words as variables
may cause problems when the script is executed. One way to avoid this
is by using multi-word descriptive names for variables, as suggested
above. For example, use birthDate as the name for a variable holding
a date. In addition to avoiding conflicts with the reserved word 'date',
the result is a more descriptive variable name.
|Optimize your fonts|
Flash stores the outline data for all characters used from a particular font. This technique allows you to use custom fonts in Flash without converting them to outlines in another drawing program or breaking them apart in Flash. If you wish to animate changes to the outline of a font, use the Modify > Break Apart command to convert them to outlines. Here are some tips on using fonts:
Do not break apart fonts unless you really need to edit the
paths of the characters.
Avoid using multiple fonts if possible.