FlashVis ActionScript

When your Flash movie is loaded by FlashVis, FlashVis processes and pumps music data to your movie. This page describes how to add FlashVis support into your movie. Don't forget to also setup an INI file for your movie.


Adding The FlashVis ActionScript

The first step is to include the FlashVis.as file in the first frame of your movie. The Actionscript in this file contains all the code for interfacing with FlashVis. The ActionScript to include this file looks like this:

#include "FlashVis.as"

Note that you need to copy this file to the same directory as your FLA file.


Receiving FlashVis Data

Whenever FlashVis gets new music data, it will execute the Actionscript in the frame named FlashVisHandler in the root timeline. Thus, to take advantage of FlashVis, you must create a frame labeled FlashVisHandler and make it do something.

The music data that FlashVis generates is split into two parts called waveform and spectrum. Waveform is the raw audio data that comes from the music. Spectrum is the frequencies of the audio data, like you would see in a graphic equalizer. Each of these parts is split into two channels -- channel 0 is the left speaker and channel 1 is the right speaker.

There are 576 data values for each channel. Each value can be from 0 to 255.

The following table lists the various FlashVis Actionscript variables and functions you can use in your movie.

Function Name
Description
FlashVisConvert()
Converts all the encoded FlashVis string data into Actionscript arrays. Call this each time at the beginning of the FlashVisHandler frame, before you access any of the array variables described below.
GetWaveform0( i )
GetWaveform1( i )
Extracts the i'th value of the waveform (either channel 0 or 1). i must be between 0 and 575.
GetSpectrum0( i )
GetSpectrum1( i )
Extracts the i'th value of spectrum 0 (either channel 0 or 1). i must be between 0 and 575.

 

Variable Name
Description

fvWaveform0[ ]
fvWaveform1[ ]

Integer arrays holding the waveform values (either channel 0 or channel 1). These arrays are 576 entries long and each entry is between 0 and 255.
fvSpectrum0[ ]
fvSpectrum1[ ]
Integer arrays holding the spectrum values (either channel 0 or channel 1). These arrays are 576 entries long and each entry is between 0 and 255.
fvbConvertW0
fvbConvertW1
fvbConvertW0
fvbConvertS1
Boolean values that specify whether to convert a particular channel. The value of true enables conversion and is the default.
fvsW0
fvsW1
fvsS0
fvsS1
The raw strings set by FlashVis. Convert them to the integer arrays by calling FlashVisConvert(). Most people will not need to use these directly.


Performance Considerations

FlashVis is a real-time visualization system. It pumps a lot of data to your Flash movie. Depending on what you are trying to do, the performance of FlashVis might be low. To achieve the best visualizations, it is important that you take advantage of the optimizations FlashVis makes available to you.

The key point is: Don't Process Data That You Don't Need!

For example, if you don't need stereo data, then set the fvbConvertW1 and fvbConvertS1 variables to false and set the SendWaveform1 and SendSpectrum1 entries to 0 in your INI file.

If you only need a few values from the channels, instead of converting the values with FlashVisConvert, extract them directly using the GetWaveform0() family of functions. Thus you will only need to convert those few entries, rather than all 576 entries.


Examples

SimpleSource -- This is a simple sample movie which increments a number each time it receives new data from FlashVis.


Future Enhancements

A definite future enhancement is the calculation of BPM and beat triggering (like Winamp AVS).

If you can think of other things that one can calculate in FlashVis and hand to the Flash movie, please tell me.


Last updated by dogboy on Monday, November 26, 2001