Sunday
May182008
Cheesy Music
Sunday, May 18, 2008 at 09:00PM I'm doing a session at Dev Days next week in their Geek Night slot. It is on XNA, and so I thought I'd have a play with "Hot Salad Death with Cheese" and get it running on the Zune.
Took 30 minutes.
Took another 20 to make the game play a random music track and display a spectrum analyzer as the music plays. Great stuff. I'm really looking forward to the talk now..
Hot salad death with music and cheese.
Rob |
4 Comments | in
XNA
XNA 
Reader Comments (4)
I'm really curious about the spectrum analyser. Is that something which you coded in XNA yourself, or is it an inbuilt function of the Zune which you can now access in XNA 3.0?
The XNA 3.0 API gives you all you need to do this, I've pulled this text from the help documentation:
public static void GetVisualizationData (
float[] frequencies,
float[] samples
)
Parameters
frequencies
Array of 256 floats that receives frequency data. Frequency data is a normalized array over the frequency bands from 20Hz to 20KHz, on a logarithmic scale. Each value in the array is a float value from 0.0f to 1.0f, and is the logarithmic scaled power level for that frequency band. See Remarks below.
samples
Array of 256 floats that receives sample data. Sample data is an array of 256 floats in the range -1.0f to 1.0f, which approximate the wave form of the sound.
Remarks
Visualization data can be used to create visualizers, which are graphical representations of sound. For example, a simple visualizer might be an equalizer spectrum display that shows the current power level for each frequency band.
The frequency data is an array of 256 float values. Each element corresponds to a frequency band, ranging from 20Hz (frequencies[0]) to 20KHz (frequencies[255]). In the array, the distribution of bands from 20Hz to 20KHz is logarithmic, not linear. This means that elements at the lower end of the spectrum represent a smaller frequency range than those at the upper end of the spectrum.
Each value in the frequency array is a normalized float value from 0.0f to 1.0f, and is the logarithmic scaled power level for that frequency band.