Flash & Swish  Home Flash & Swish Flash Tutorials Layering Audio
rss

Layering Audio

Author: Bluegelmedia.com More by this author


Download .FLA - 2.1 Mb zipped Flash® file

View the final result. Click here.

Summary: killersound recognizes that Flash® can be used as a sequencer or mixer similar to software used by digital musicians to sequence music. Generally each composition is made up of various elements or components such as bass, drums, melody, etc. Each element is recorded and optimized separately and imported as an individual sound file into Flash®. The lengths of these sound files are either identical or in exact proportion of each other. In other words, in order for the sounds to loop properly in their own layers and mix with each other, each sound must be in exact proportion (in milliseconds or better yet exact number of samples) to the others. For example, if you have a bass part that is 1 measure in length (or 151,000 samples) and you have a melody that is 2 measures in length, make sure that the number of samples in your melody is 302,000 (2 x 151,000). When all the parts are initiated and looped at the same frame and in their own individual layers, they are mixed together, using the envelope points provided, to create the illusion of an unfolding and varied musical composition over time. There are three benefits to this method: 1. The viewer is spared from mindless loops 2. The Flash® developer retains the creativity and freedom to mix or arrange the elements as desired while minimizing file size and 3. File size is kept to a minimum by using Flash®'s looping capability.

The following instructions are to be used when scoring the individual components or sound files in Flash®.

1. Import the optimized sound files into your Flash® file.

2. Create a layer for each separate sound. For example, the "bass" file will have its own layer. The "synth" file will have its own layer, etc. as show in Diagram 1. We will discuss the importance of the first layer "null" later on.



Diagram 1

3. Create a keyframe at the beginning of the scene (or wherever you wish the song to begin) for each sound layer. It is best to not to begin on the first frame but let's say on frame 5. We've found that this gives the Flash® Player time to "buffer" the sounds.

4. In each layer, attach the sound at that frame. IMPORTANT: All the sounds must start on the same frame number. That is, if you choose to start the sounds on frame 5, the "electronic" sound, in its own layer, must start on frame 5. The "synth" layer, in its own layer, must start at frame 5... etc.

5. In the sound window, where you attach the sound, set the loop factor to a large number to have plenty of material to work with. In Diagram 2, it is set to 50.

6. You should have an idea of how you wish to score the music. For example, you can begin by playing the "electronic" sound only or simply start all of the sounds playing together. There are many ways you can arrange the music to your liking. It is important to note that once you start the sounds looping, you are limited to 8 envelope points in Flash® until they stop. 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. It is very important to note that setting the volume levels to maximum on every sound layer may result in distortion. This result is due to the fact that each sound is optimized by itself for maximum volume. To remedy this you should balance out the volume levels in all layers; that is, you should adjust the volume levels appropriately in 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 wish to create some effect such as panning.

If you use the "event" option for synching, the sound(s) will have to download first before starting to play. It is important to keep in mind that when using "event" Flash® exports and reads each sound layer separately. The advantage to this method is that Flash® treats the sound files as instances. Once all the individual components or sound files are loaded, they are treated similarly as graphics. So regardless of how many times you loop each sound file in its own layer, Flash® 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 separately and independently of the graphics when using the "event" setting. Occasionally we have encountered issues with computers that have slow processors. If memory is lacking, Flash® 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, VR Professionals came up with a way to kick off the Flash® Player into "stream" mode at the beginning of the music, just long enough to get the "event" sounds going. In this case, you can see in Diagram 1 that we used a very small sound called "null" and started that sound right before all the other layered sounds. This particular sound is set to "stream" and is the only sound set to "stream". It is also looped just enough to overlap with the other layered sounds. This "null" sound can be any short sound; ideally it should be super small and silent. You can download this file from the Goodies page.

If you use "stream" on all of your layered sounds, the animation will skip frames, if necessary, to keep up with the flow of the music; however, the music will start to play as soon as enough material has downloaded. This means that the animation is tied to the timeline once audio is involved. So you can of course score your sound files as discussed above and use the "stream" setting. With this setting, Flash® exports and reads the sound files as one sound file, not as separate layers. This locks all the sound files together in sync and therefore the "null" sound is not needed. This setting does not take advantage of the small file size as a result of using the components. For example if you imported a 30 second song into Flash® as an alternative to mixing the short segments or components right in Flash®, the result in file size is the same. Note again however that "stream" lets the music begin playing as soon as enough material has been loaded.

TIP: If you do not wish to tie the animation to your audio, you should create a movie or swf file that contains only the audio. Then in your main movie that contains the animation, you can call on this swf file containing the audio to play. The audio will play but will not be tied to the animation in your main movie.



Diagram 2

7. The individual parts that you imported into Flash® are proportionate of each other. Remember that we are creating an illusion of an entire composition with variety and parts fading in and out, using these little clips of sound. When you are viewing the sound in the sound window, you can zoom in and out. You can view the sound over the timeline or view it over frame numbers. Refer to your manual on the sound window for more details. You will need to zoom in at maximum zoom at certain frames to fade in, mute or bring up to volume a particular sound (by clicking and dragging the envelope points). Diagram 3 below illustrates maximum zoom and the end and start of the bass loop. For example, if you wish to start the "bass" sound at the same time that you wish to mute the "synth" sound, you will need to zoom in to the correct frame (in this example, let's say frame 500). At frame 500, you will need to use the envelope points in the "bass" layer to bring up the "bass" sound. Then you will need to go into the "synth" layer and, using the envelope points, mute the "synth" sound by creating, clicking and dragging down an envelope point at frame 500. You will always need to be aware of where the loop for each sound begins and ends.

8. Once you use each of the 8 envelope points in each layer, you will either have to let the music run its course until you create a "stop all sounds" command or fade out the music using your last envelope points. Once all the sounds have stopped, you can again begin a new set of sounds, if you wish, at a different frame (for example, frame 1,500). Then you will have a whole new set of envelope points. The idea here is that this method allows you to be creative in the way you score the music.



Diagram 3

9. Compression: You will want to 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 cutoff if you compress them too much. Use your judgment and keep in mind the role the music plays in your project. Above all, you will need to experiment with all of your sounds to get the right mix and settings.

10. To take this technique further and to view a practical application of this method, see Keith Kubal's technique or engine for delivering multiple compositions based on, but independent of the content of a Flash® site. His method is discussed in: The Enstar Flash® Audio Engine.

This information should be sufficient to get you started with scoring your sounds in Flash®. And with Flash5®'s ActionScripting features, you should be able to take this technique even further!


Rate this Material: Bad 1 2 3 4 5 Excellent
print this page tell a friend subscribe to newsletter subscribe to rss

Add comments to "Layering Audio"