Audio Insider
Online Monthly Pass

Register for an Account Forgot your Password?

Most Popular


The EM Poll


This is not a scientific poll but a tabulation of readers responses and is purely just for fun!

See Past Poll Results

pop_quiz_button

browse back issues

Newsletters

emusicianXtra icon
EMSoftware update icon
MET Extra icon
eDeals Newsletter icon


Subscribe to newsletters here...

Composing Music for Macromedia Flash

May 1, 2002 12:00 PM, By Hayden Porter



         Subscribe in NewsGator Online   Subscribe in Bloglines

CURRENT NEWSSTAND ISSUE

Read the full Table of Contents for the issue on sale now! Click here

Subscribe for only $1.84 an issue!

Please tell us about yourself so we can better serve you. Click here to take our user survey.

Personal Studio Series

Mastering Steinberg's Cubase™

This special issue is not only a must-read for users of Cubase™ software, but it also delivers essential information for anyone recording/producing music in a personal-studio.

Click for more
EM Podcasts

Listen to these latest podcasts and more:
Engineer Chuck Ainlay on his mixing techniques. Go

What's New: Sony Creative sound library, Expanse Refill for Reason, more. Go

eDeals Newsletter for Discounts on Gear

Get First Dibs on Hot Gear Discounts, Manufacturer Close-Outs and Job Opportunities when you sign up to receive eDeals E-newsletter, sent twice a month. Check out an issue get advertising info or subscribe

Because of the ubiquitous presence of Macromedia Flash on the Web, many desktop musicians are interested in composing soundtracks for Flash movies. However, composers often become frustrated with the limited nature of short repetitive loops and the poor quality of Macromedia Flash's streaming audio, which breaks up because of network congestion. Fortunately, there is a lesser-known type of backing track called a loop mix. Flash loop mixes are bandwidth-friendly (40 to 100 KB downloads) long-form compositions (typically 30 seconds to 2 minutes in length) that don't suffer from streaming dropouts.

Macromedia Flash loop mixes take advantage of the software's multitrack mixing capabilities to present an evolving soundtrack. Rather than compose a standard linear composition, you create several loop tracks and simulate a sequence by muting, unmuting, and crossfading the loops over time. The combined volume changes for each track determine the “linear” nature of the composition. Listen to audio examples 1 and 2 (drumjam.swf and 70slounge.swf, respectively) on the EM Web site to hear two styles of Flash loop-mix compositions.

In this column, you will learn how to convert a MIDI loop mix into a Macromedia Flash-based loop mix. I will assume that you have the Flash authoring software (see Fig. 1) and are familiar with how to use the Sound panel and the Edit Envelope and Sound Properties dialog boxes. If you're new to Flash, you can download a 30-day trial version from Macromedia (www.macromedia.com).

LOOPING LIMITS

There are two Macromedia Flash authoring limitations to consider while preparing your composition. The first is that Flash Player can play a maximum of eight sounds simultaneously. That means you can have as many as eight tracks in your loop mix. Flash movies, however, often have other sounds in addition to the soundtrack. Therefore it is advisable to limit your composition to three to five tracks, allowing for playback of other audio resources, such as streaming voice-over narration and interactive button sounds. The second limitation is that the Macromedia Flash authoring software supports only eight changes in volume per sound, which means that you can mute and unmute a track just twice using square-wave-shaped volume envelopes.

To maintain a reasonable file size, each looping track should be short in duration. The music should rely on the mix to reuse material and create musical variety from a small number of looping ideas. As long as you work within the necessary constraints, you can create compelling, bandwidth-friendly soundtracks for any Flash movie.

SEQUENCING SECRETS

To create a loop-mix composition, use a MIDI sequencer to compose multiple looping parts and record volume changes in separate but corresponding volume tracks. Loop tracks are commonly a few beats or measures long and are not long enough to hold all of the volume-change information. Thus, your MIDI file must have two tracks for each musical part: one to contain the loop and a second to hold the corresponding Volume controller data (Control Change 7). Download audio example 3 (70slounge.mid) to see and hear this concept in a MIDI file.

Layering musical parts one at a time is the most natural process for composing loop mixes. It's an easy way to create variety and growth while working within the given limitations. Polymetric loops are another way to create rhythmic variety with minimal file size, because the combined pattern is longer than any one of its parts. I used that technique in Audio Example 1.

You can use other techniques, as well. In Audio Example 2, I created the intro by offsetting the bass loop by four beats in my MIDI sequence. The eight-bar bass loop emphasizes a Bb tonality in the first four bars and an Ab tonality in the last four bars. I wanted to solo the organ accompaniment for four bars and then introduce the bass on the Bb tonality. To solve that problem, I offset the Bb bars to the end of the bass line, so that when I unmuted the bass part four bars into the song, the loop was in the Bb tonality. I also offset the melody so that its phrases would coincide with the altered bass part. That is just another example of how to compose your loop mix to maximize musical effect.

CONVERTING WITH CAUTION

Once you finish the composition, you can begin the process of converting it into a Flash loop mix. First, record each loop track from your MIDI loop-mix composition into an audio-editing program. Be sure to disable looping for each track and mute the corresponding volume tracks before you record.

Next, edit your loop tracks for importing into Flash. The most important audio-editing issue is precisely measuring and setting the lengths of each loop. Accurate loop lengths determine whether the Flash player can sync your loop mix.

Flash uses “trigger” sync to synchronize multiple tracks; the program starts multiple sounds simultaneously and lets them play without subsequent resynchronization. If you don't accurately edit each track length, eventually your tracks will drift out of sync, because the downbeats won't properly coincide. Therefore, you must be precise in how you edit each loop length (see Fig. 2).

Use the following formula to determine the length of a loop in samples, the most accurate unit of measurement for digital sound:

(sampling rate × 60) ÷ tempo = number of samples per beat

Take the real-world example of a four-beat bass loop recorded at 120 bpm that uses a 44.1 kHz sampling rate. First, calculate the number of samples in one beat:

(44,100 × 60) ÷ 120 = 22,050 samples per beat

Next, multiply the samples per beat by the number of beats in the loop to determine the total number of samples in the loop:

4 × 22,050 = 88,200 samples in the bass-line loop

In your audio editor, delete any extra samples at the beginning of the loop and set the selection range to start at 0 and end at 88,200. When you crop the selection, your loop will be the exact length necessary to remain in sync with your other loops as long as you follow the same process with the other loops.

Mix each loop to mono and downsample the loops to 22 kHz or 11 kHz before importing them into Flash. Save each edited loop as an uncompressed WAV (Windows) or AIFF (Mac) file.

Flash Bit-Rate Guide

Track Sampling
Rate (kHz)

Channels

Flash MP3 Bit
Rate (kbps)

44

mono and stereo

160 to 80

44/22

mono/stereo

64

22

mono and stereo

56 to 48

22

mono

32

22/11

mono/stereo

24

11

mono and stereo

20

11

mono

16 to 8

Your last audio-editing task is to create a short, silent 11 kHz sync sound to aid in the synchronization of the loop tracks. By setting this short track to Sync:Stream in the Flash Sound panel and having it play before and during the start of the loop tracks (overlapping the other tracks by at least a couple of frames), you can force Flash Player to improve its timing consistency. This work-around engages the player in Stream mode before the loops start to play so that all the tracks are triggered simultaneously instead of with a ragged start. Save the sync sound with your loop tracks.

MOVIEMAKING

Now you are ready to start creating your Flash movie. Start up the Flash authoring software and import each loop and the sync sound as tracks in a new Flash movie. The audio files should appear in your movie's Library window.

The following steps explain how to set up your movie's timeline. See Fig. 1 for an example of how your timeline should look. Download Audio Example 4 (70slounge.fla) to see how I set up the sync sound and volume envelopes for each track.

  1. Import each track and the sync sound into Flash.

  2. Create and name a layer for each loop and the sync track.

  3. Add a key frame to the sync-track layer and insert four more frames for a total of five.

  4. Attach the sync sound in frame 1 of the sync-track layer.

  5. Choose a number of loops in the Sound panel that will extend the duration of the sync sound across all five frames of this layer.

  6. Choose MP3, 8 kbps for stream-sound compression in the Flash tab of the Sound Properties dialog box.

  7. Return to the main window, add a sixth key frame to the sync-track layer, and attach a Stop action to prevent the entire movie from looping and prematurely replaying your mix.

  8. Add a key frame to frame 3 of the remaining layers.

  9. Attach each loop track to frame 3 of their respective layers.

MIXING AND MUTING

The final part of the conversion process is re-creating the volume mix for each track in the Edit Envelope dialog box (see Fig. 3). At this point, you should have your MIDI sequence and Flash movie open at the same time. Set your sequencer to display time positions in SMPTE time code.

At maximum zoom, the Edit Envelope display shows time values in hundredths of a second. (Click on the Watch icon to show elapsed seconds.) SMPTE time code shows durations in a similar timing system based on hours, minutes, seconds, and frames. One frame at SMPTE 30 or 29.97 fps is approximately 0.03 seconds. You can determine the corresponding hundredth of a second position in the Edit Envelope display by multiplying the number of frames in a given SMPTE position by 0.03. Follow these steps to complete the conversion process:

  1. Set each track to Sync:Start in the Sound panel.

  2. Set each track's loop value in the Sound panel to the same number of loops as the original MIDI track.

  3. Add handles to the sound envelope in the Edit Envelope dialog box to re-create each track's Volume controller data. Make sure that the envelopes of both channels are identical.

  4. Choose an MP3 bit rate in the Sound Properties dialog box based on the sampling rate for each track (see the table, “Flash Bit-Rate Guide”).

  5. Listen to an uncompressed version of your loop mix by clicking on the Play button in the Flash transport. Select Test Movie in the Control menu to hear the compressed version. You can stop sounds in both modes by selecting Mute Sounds in the Control menu. (For more tips on optimizing your loop mixes, see the sidebar, “Flashy Tricks.”)

Deliver your finished Flash loop mix to Flash developers in SWF format or provide the original FLA file so that they can remix your music in a way that fits the needs of their presentation. Flash developers can load your sound into their existing presentation without alteration only when it's in SWF format.

The techniques that I've described are compatible with versions 3.0 and greater of Flash Player; the current version is 5.0 (as of this writing, version 6.0 is in beta). Flash Player 4.0 (and greater) supports MP3 compression; Flash Player 3.0 supports ADPCM compression only. However, the majority of Web users have at least Flash 4.0 capability, so most of the time, you can use MP3 compression without concern.

Because of the widespread nature of Flash Player, a potentially large audience exists for your Flash loop mixes, and there is also commercial potential for selling music libraries online. In addition, you may want to submit your loop mixes or Web site to Flash sound-collection sites such as Flash Kit (www.flashkit.com/loops) or Were Here (www.were-here.com).

Finally, feel free to ask further questions about this topic in the Flash Audio forums that I moderate at Sonify.org (www.sonify.org/cgi-bin/ultimatebb.cgi).


Hayden Porter is a Web developer and musician who specializes in sound for the Web. He also writes “Remixology,” a biweekly column published at Sonify.org.

FLASHY TRICKS

To get the best results from your Flash soundtracks, follow these tips.

Audio-Quality Tips

Compression noises are often covered up by other parts in the mix.

Downsample before importing tracks into Flash to avoid its poor-quality algorithm.

Reduce the volume of a track in the Edit Envelope dialog box to minimize compression noise.

Test your mix on typical computer multimedia speakers.

Compression Tips

Bass tracks can be longer and can be compressed more than melody and accompaniment tracks.

Low-frequency timbres compress more than high-frequency timbres.

MP3 compresses stereo and mono sounds to approximately the same file size and with similar quality.

Use 3-bit ADPCM 22 kHz compression to improve the quality of cymbal sounds.

File-Size Tips

Faster tempos can shorten audio track lengths and reduce file size.

Having fewer tracks decreases the file size.

Keep the track lengths short.

Merge MIDI tracks with the same length and volume mix into a single WAV or AIFF file.

Rely on the mix to create musical variety.

Create more variety with one track by crossfading stereo channels in the Edit Envelope dialog box.

Get Copyright ClearanceWant to use this article? Click here for options!
© 2008 Penton Media, Inc.

Back to Top