First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Inn Chan

Using Spectrum Lab to generate spectrum data

Spectrum Lab is a specialized audio analyser, it also has many other advance features, amongst which the powerfull data logging feature. It allows you to set the interval in miliseconds at which data is written to the text file and how many frequency bands you want to log and the range.
This tutorial will only cover up to what you need to obtain the spectrum data. The rest are left for you to explore.

So here is what you do: open the Spectrum Lab program, you will see something like the following, first of all go to "option" -"audio setings" as follows:

The configuration and display control panel comes up, set the sample rate to 44100Hz or 22050Hz, just make sure it's over 16000Hz.

Then in the same panel, go to Spectrum display and type in "93" under Waterfall Scroll Intv., make sure it's in millisecond. You can try out other values for the interval, the smaller the value is the largerer the text file it generates. A 1 min track analysed with 93ms interval results in a 14K text file which took 3 seconds for a 512M Ram PII 400MHz to load the file from hard drive, just over a second in a PIII 1.2GHz, whereas 100ms interval yields a 8K txt file, and 90ms yields 27K

In the same panel again, go to the Wave setting change the speed under the "File Analysis w/o audio reply" to Fast. Choosing this setting will speed up the analysing time, it does not affect the output of the log file.

After setting up the Spectrum Laboratory, we have to define the format of the output data, go to "File"-"Text file export" then the "File Contents" section and enter the parameters as follows:

When you are ready to analyse the wave file, go to the "File Export Format" panel (same as above) and go to the "Filename & Action" section. Enter the path and file name of the data file then check the Active check box to toggle the output mode. When the box is checked, the data file is locked and ready for data logging, and only Spectrum Lab can write data to the file. Spectrum lab append data to the end of the file, so make sure the data file donesn't contain spectrum data from previous runs.

Now every thing is ready, make sure you have activated text file export then go to "File"-"Wave Files"-"Analyze input from *.WAV-file", the audio File analysis panel will pop up. Now choose 1024 pts for the FFT option and press ok, you will see the spectrum graph starts to jump. when it stops jumping, that's when it finishes analysing the wav file.

Open the data file in notepad, you should see some thing like this:

Delete the first line which says ",,,,,,,,,", that's the names of the columns, since we didn't declare it in "File Export Format", only the separaters were written to the file. Now type in "sdata=" infront of the first row of data, and add "&loadstatus=1" to the last line, make sure there are no carrage returns nor spaces after that and save the the file as "data.txt" in the track directory:

So there you are, go to your swf directory run the Spectrum Analyzer.swf and see your own flash audio spectrum analyser in action.

As you may have noticed the way in which the spectrum data are organised and that it is an external source to the movie hugely increases the processing load. One way to reduce this load is to find another spectrum analysing program that interprets data in different scale, currently Spectrum Lab only measure amplitude in db and percentages, where db ranges from 0db to -140db, the negative number means there is one "Extra" character in each data entry, and percentage ranges from 0 to some big numbers far beyond 100 which is even worse for our case. Ideally we would have used the scale 0-9 to represent the amplitude of a specific frequency band, such scale will result in a reduction of 3/4 to the current file size. Another way to achieve that is to write a mini program and use string manipulation to organise the spectrum data. And by declaring the data as a variable from within the flash movie rather than loading it from an external source, runtime performance can be noticeably boosted up.

Coming Up Next

Fed up with volume sliders? How about a volume roller like the one on your Hi-fi system? It can be used to build a scratchable vinyl turntable too.

Here is an experimental piece I created with this roller.

Tutorial coming soon.
» Level Intermediate

Added: 2002-08-28
Rating: 8.76 Votes: 33
» Author
Multimedia Student eager to combine artistic skills, creativity and practical knowledge to innovate new concepts in interactive media
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.