Accessibility

Table of Contents

The KILL THE SILENCE® Technique: Optimizing Digital Audio for Flash Lite

The Layered Sound Files

To begin, download and expand the layering_audio.zip archive that accompanies this tutorial. In it you will find one FLA file, two SWF files, and a file called silent.wav.

Open the C0064.fla file and look inside. You will see on the Stage the image shown in Figure 1. The file contains four parts of a composition—violin, brass, strings, and piano. If you go into the Library, you can listen to each part individually. You can find all four parts in the folder called Musical Elements. In this tutorial, you will produce a Flash Lite SWF movie to run on the Nokia 6600 mobile phone.

Note: You can obtain the most current pre-configured templates for various mobile devices from David Mannl's Flash Lite site. These templates are already set to the proper screen size.

 The C0064.fla file contains four parts of a composition.

Figure 1: The C0064.fla file contains four parts of a composition.

Each part of this composition was recorded and optimized separately and imported as an individual sound file into Flash. In order for the sounds to loop properly in their own layers and mix with each other, all sound files (as well as any sound files using this technique), must be either equal in length or proportional (in milliseconds or better yet exact number of samples) to each other. In this example, all four parts are of equal length. The colored blocks represent instances on the Timeline where the parts play. If you run the movie in the Flash application, you can listen and follow along with the music as each part plays out.

Figure 2 shows the Flash Timeline. Each part has its own layer and begins at the same keyframe (16) with the exception of the silent layer, which I will discuss in a moment. It is very important that all of the elements of the music begin on the same keyframe. I will explain this part in more detail below.

 On the Timeline each part has its own layer and begins at the same keyframe.

Figure 2: On the Timeline each part has its own layer and begins at the same keyframe.

When exporting for Flash Lite, it is best not to start the sounds right away but to provide many empty frames to buffer the data. I found that some devices, with slower processors, take a second or so to begin displaying the content; therefore, if you start the audio too soon, the beginning portion of it may be cut off.

Setting and Editing the Sound Envelope Points

Now go to the strings - event layer and click Frame 16 where the sound is embedded. In the Frame Properties window, you can see that the attached sound is called C0064strings.wav and that it has been set to repeat 10 times. Click the Edit button to open the Edit Envelope window. Click the Frames button (lower right) to convert the timeline scale to show frames rather than seconds. Zoom out all the way (using the zoom buttons at the bottom of that window) to see the six envelope points that have been applied to this part (see Figure 3).

You can apply envelope points, the little squares, to manipulate the volume of the sound.

Figure 3: You can apply envelope points, the little squares, to manipulate the volume of the sound.

The envelope points, which appear as little squares in the sound window, are volume points. You can click and drag those points to create volume effects. You can adjust the volume levels appropriately for each sound layer in order to get the right mix of volume. The two windows within the sound window represent the right and left channels. You will want to make sure that you mirror your actions in both windows, unless you want to create some effect such as panning.

You can see that, after two instances or loops of C0064strings.wav, there is a quick but gradual fade out using the envelope points. This part then stays muted until the beginning of the fifth instance or loop. Zoom in to the maximum on that particular point where the fifth instance begins (see Figure 4). This should be at about Frame 399. Remember you can toggle between sample view and time view (the two buttons to the right of the zoom buttons at the bottom of the window). The envelope point is set exactly at the start of the fifth instance or loop. You need to be this exact when using this technique to ensure a smooth mix.

 Zoom in at the maximum level to accurately manipulate the envelope points.

Figure 4: Zoom in at the maximum level to accurately manipulate the envelope points.

Now, take a look at the other layers and the way in which envelope points have been applied to them. For example, notice that the envelope points for the violin part are not set to maximum, because you don't want the violin to overpower the entire mix. This mix is only one of many possibilities. For example, you could choose to start the music with only the strings and then bring in the brass part, and so on. The more parts your composition has, the greater the variety and possibilities. However, there are limits as to how many sound layers you can have. I recommend avoiding the use of more than four or five layers with Flash Lite. This limitation may not be an issue as technology advances and as mobile devices and the Flash Lite player become more robust. You should also keep in mind that currently only eight envelope points can be applied to any sound in a particular keyframe—use them wisely and creatively. Of course if you start a new instance of the sound in a new keyframe, you have eight new envelope points to play with.

Stream and Event Sounds

As you see, the sync setting for all the layers (with the exception of the silent layer) is set to event. With event, Flash Lite exports and reads each sound layer separately. The advantage to this method is that Flash Lite treats the sound files as instances. After Flash Lite loads all the individual components or sound files, it treats them as it treats graphics. So regardless of how many times you loop each sound file in its own layer, Flash Lite does not take extra file space to loop the sound files over the Timeline and does not tie the sound layers to the animation that is taking place. The sound files run independently of the graphics when using the event sync setting.

Occasionally I have encountered issues with devices that have slow processors. If memory is lacking, Flash Lite will not be able to read all the layers in the same frame at the same time. This may result in the sound layers being out of sync with each other. To remedy this problem, you can use a tiny, silent audio file to kick off the player into stream mode at the beginning of the music, just long enough to get the event sounds going. You can see that the silent layer, which is the only one set to stream, uses this tiny sound and starts before the other music layers. Starting the music with a sound set to stream locks the layers together in sync. I've included this file (silent.wav) separately, in case you want to use it with this technique in the future.

If you were to use stream as your sync setting on all of your layered sounds, the animation would be tied to the Timeline. With this setting, Flash Lite exports and reads the sound files as one sound file, on one channel. This locks all the sound files together in sync and therefore the silent sound is not needed. However, this setting does not take advantage of the small file size as a result of using the components as looped instances. Also, when using stream, the music will run as long as there are enough frames in your movie. Unlike the event setting, with stream the music will cut off if there are not enough frames to contain the audio or if you have an action that stops the movie from playing.

Compression

With regard to compression, you could either use a global compression setting or set the compression for each individual sound file. Sounds with low frequencies, such as bass sounds, will compress extremely well. Others such as drums with hi-hat may get cut off if you compress them too much. The advantage of setting the compression individually is that you can cut the file size down for parts that compress quite well while using less compression on more fidelity-sensitive parts to get a better sound quality. Set an individual file's compression by finding the sound file in the Library window, right-clicking it, and setting its compression in the Export Settings dialog box.

Depending on the limit of your file size, it may just be easier to set the compression settings globally (see Figure 5). Notice that the compression for the streamed sound (silent.wav) is set at the highest compression possible, since you will not hear this sound at all and you want to keep the file size small.

You can set your compression globally as you export the SWF movie.

Figure 5: You can set your compression globally as you export the SWF file.

Remember that the sound you produce will most likely be coming through a tiny monophonic speaker; therefore the sound quality will be only as good as the speaker allows. Ideally, you would have a sample of the actual device for testing. However, I found that a global export setting of ADPCM, 11kHz, 4 bit, Mono works fine for most scenarios. It provides a good balance of sound quality, for tiny speakers, and minimal file size. Note that, with Flash Lite and with this technique, ADPCM is your only choice of exporting format for seamless looping. Unlike desktop Flash productions, which would benefit far more from a compression using MP3, I found that sound in Flash Lite, exported with MP3 compression, will not properly play on mobile devices. MP3 compression in Flash Lite leaves a tiny gap of silence at each loop point so that the sound drops out for a split second as the sounds loop. Playing the SWF file on your desktop will not reveal this problem until you load it into your mobile device.