A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: sound format affecting final .swf size?

  1. #1
    Junior Member
    Join Date
    Mar 2002
    Posts
    16

    Arrow

    I was wondering, does the initial sound formats have an influence on the resulting total swf file? For exemple, will mp3s produce smaller swf than wavs? Or does Flash compress the sounds in its own way anyways?
    I'm trying to use mp3 instead of wav but the result does not sound as it did in wav format, even for small sound fx files.

    -corv-

  2. #2
    Senior Moderator ®
    FK´s Banning Machine ™
    GMF ™'s Avatar
    Join Date
    Feb 2000
    Location
    Oslo, Norway
    Posts
    5,697
    Mp3 is compressed and can only make the file bigger if you set the bitrate higher than the orginal, but you wont get better quality.

    Importing was are makeing the file smaller if you set the rate/exportsettings to default . This depaneds on the orig. filesize though .

    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:

    Use the lowest bit-depth and sample rate acceptable to achieve the smallest data size.
    Sound quality deteriorates as the sample rate declines, so you may find lower sample rates yield more even playback but also poorer quality audio. Try to find a happy medium between quality and data size.

    Keep sounds short.
    Flash doesn't have the same type of compression capabilities as Shockwave streaming audio, so it is ill suited as a means to deliver longer audio programs. You may use smaller sounds looped to achieve longer audio playback because a smaller amount of sound data is downloaded once and used repeatedly.

    Watch the size report closely for clogging of data near keyframes.
    The Event synch option delivers the sound data all at once when needed for playback; Stream synch delivers the sound data over the specified series of frames. Watch the size report closely for clogging of data near keyframes and use the "preloading" techniques to trim down the amount of data needed per frame or per second.

    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.
    Sampling rate - The number is measured in kHz, but is actually the number of times per second that the sound is sampled. At each of those intervals, that particular place in the sound is recorded. A sample is taken
    So a sound recorded at 16 bits and 44.1 kHz is actually a sound that has been sampled 44,100 times per second and each sample has a bit depth of 16 bits.

    Bit Depth

    Bit depth is the detail of the sound samples. The higher bit depth, the more detail and less room for noise or muddiness. Sounds recorded at 8 bit typically have more noise (hiss) than sounds recorded at 16 bit. If you are recording voice alone, there will be gaps and pauses between words and sentences which can accentuate any noise in your sound. Generally, a higher bit depth is recommended for voice in order to keep your sound "clean".

    Sampling Rate

    Sampling rate is a bit more complex. You need to consider what your needs are. Keep in mind that the human ear can hear things in a range of approximately 20-20,000Hz. Anything above 20,000kHz cannot be heard by humans (while sounds below 20Hz cannot be heard per se, they can be felt assuming that your sound system can output at that frequency). A range of 20 - 20,000Hz is the general rule of thumb although this can vary somewhat among individuals.

    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

    Now that you've had a crash course in digital audio, you need to apply it to your piece. File size and quality are important. While it is easy to assign a blanket bit depth and sampling rate to all of your sounds, your sound quality might not benefit from this strategy. Instead, weigh the differences each provides.

    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.

    Summary

    For voice, focus on bit depth to reduce noise, hiss, and muddiness. Sampling rate is usually a secondary concern. For music, focus on sampling rate since the nature of music can mask the degradation of a lower bit depth.

    Things to Consider

    File size is always halved if you cut the bit depth or sampling rate in half. In other words, you won't get a smaller file by cutting the bit depth in half than you would if you cut the sampling rate in half. You will get the half the size of the original regardless of which one you cut.
    An 8-bit 44.1kHz sound is the same size as a 16-bit 22.050kHz sound.
    A 16-bit 11.025 kHz sound is the same size as an 8-bit 44.1kHz sound
    Most people don't have sound systems on their computers that can pump out a 16-bit 44kHz sound the way you want them to hear it. Unless you know your target audience has this capability, there is no sense in doing it.
    File size is not the only thing to consider when chopping sounds. Performance is also affected by bit depth and sampling rate. As expected, higher bit depths and sampling rates require more system resources to process, possibly degrading the performance of other elements in the piece. So if your animation speed is crucial at that moment, consider dropping the sound quality.
    Director for windows has one sound channel. We employ macromix.dll to mix Director's 8 sound channels into one. But if you try to mix sounds of different bit depths, two performance hits can result:
    The sounds will be resampled to match each other. A 44kHz sound may suddenly have the same range as the 11kHx sound you are trying to play at the same time.
    Due to the time it takes to mix the sounds, there can be a noticeable delay bertween the time the command to play the sound is issued and when it actually begins to play.
    For more information specifically regarding this issue, please see TechNote 3191, Windows and Multichannel Sound.
    For purposes of simplicity, sampling rates in this techNote are referred to in their simplest values such as 44kHz. This is not entirely accurate and to keep things standard for the widest compatibility across different sound cards, you should limit yourself to the following sample rates:
    44.1kHz
    22.050kHz
    11.025kHz
    Any variation from these sample rates can produce unexpected results and may not be comptible with Director's import filters.

  3. #3
    Junior Member
    Join Date
    Mar 2002
    Posts
    16

    Lightbulb

    Wow that's what i call thourough info! Thanks a bunch for your help, it's very much appreciated

    -corv-

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center