Tag Archives: Article

Creating a Dynamic Soundtrack

pwpcoverPractical Web Projects, May, 2005.

This is an article on how to use Flash to create a dynamically generated soundtrack. Using a careful blend of musical elements, with matching tempos, one could transition between different feelings and intensities of music, without a seams in the transition.

Making a dynamic soundtrack where music seamlessly shifts to match the visual subject matter.

Music is perhaps the most powerful tool we have at our disposal, as web and Flash developers, for drawing an emotional response from our visitors. For years, Hollywood has used music to enhance a scene and give it maximum emotional impact. In fact, music in movies often strictly guides our emotions along, making us feel certain ways from moment to moment; suspense, relief, suspense again, relief, more suspense, disaster, relief.

The ability of the composer to move the music smoothly from one state to another is something that we can imitate when we create dynamic soundtracks in our websites. Essentially, we’re going to be using several pieces of music and tying them smoothly together, changing based upon what we’re viewing on the main site. The music will be seamlessly transitioned from one piece to another.

The trick here is that all the pieces of music must have several fundamental things in common. First, they must all be in the same key. In order to transition from one piece to another, crossfading smoothly, we can’t use two pieces in harshly opposing keys, otherwise, as they fade, the sound will be jarring. Secondly, all the pieces must have the same tempo, or speed. This is necessary for them to “line up” properly.

In Flash, we’ll be using the Sound object extensively. We can have up to 8 sounds playing at once in Flash, and we’re going to take advantage of this. Our dynamic soundtrack will consist of 7 possible genres of music. Each genre consists of a single looping piece of music, 16 seconds in length. At the launch of the Flash site, all 7 pieces will be started, and set to loop indefinitely. The volume of all these will be set to zero (silent). We then smoothly fade between them to create our dynamic soundtrack.

Creating an Audio Mixer in Flash

wdcoverThis was a 3 part series for Web Designer Magazine, October, November and December 2004.

How to create an audio mixer in Flash, first looking at the task of drawing the graphic assets.

One of the things that Flash handles really well is audio. Flash has the ability to play up to 8 stereo audio channels at the same time, with independent volume and pan controls over each channel. This means that we can get 8 concurrent audio loops going at once, and using volume and pan, we can create our own mixes, and in essence build our own songs. Continue reading Creating an Audio Mixer in Flash

Drumming to a steady beat in Flash MX 2004

pwpcoverPractical Web Projects, September 2004

Using the built in sound timing in Flash MX 2004 to create a rock solid interactive drum machine.

Macromedia Flash MX 2004 is a powerful tool, and it allows us to do some amazing stuff. One of its catches, however, derives from the fact that all timing is frame based, and that actual, achieved frame rate is determined by something akin to luck, rather than the actual document frame rate setting.

In truth, Flash attempts to attain the frame rate you have requested, but often will fail, as external processes, or even animation within your movie take over and cause the playback to skip and sputter.

This does not engender much hope for a drum machine, which relies on rock solid timing. In fact, if you look at drummachFrames.swf, and try inputting a drum beat, you’ll see this effect in full swing. It sounds OK, but you occasionally hear the “drummer” lose time, and play a beat late.

Note that in years since, the audio timing has become better and better, and now things like drum machines, dynamically generated audio and effects are easy with AS3.0

Creating an Audio Player in Flash

wdcoverWeb Designer, June 2004

With inspiration from modern MP3 players, we build our own fully functional player in Flash MX 2004.

Flash MX introduced the ability to load and play MP3 files directly at runtime. Prior to this, the only thing we could do was import the sounds into Flash at design time, or embed our sounds in SWF files and load those in at runtime. This was not an ideal solution, as it required hours of overhead and tedium.

Today, we have the ability to load an MP3 and play it streaming, so that it plays as it’s downloading and doesn’t need the entire song to begin producing sound. Also, we have access to the ID3 tags associated with most MP3 files.  This means we have access to information such as song title, album, artist and year.  It is these elements that are expected in a good MP3 player.

In Flash we have the ability to stop a stream and pick up from where we left off, without having to restart.  This, coupled with information about play head position and duration of the entire song, allows us to create a progress bar that represents the playback position.

We’ll be including all the standards; play, stop, rewind, next track and previous track. We’ll also be representing a playlist in an array.