# Audio Analysis: isolating frequency values

I’m looking for the amplitude of frequencies 570-650. how could i obtain those from GetOutputData?

I’m trying to read certain frequencies from the audio output data, but no idea how many samples this requires or which FFTWindow to use?

You must use GetSpectrumData to analyse a frequency range: allocate a float array with a power-of-two size and pass it to GetSpectrumData. The size (lets call it Q ) defines the frequency resolution: each element shows the relative amplitude (0…1) of the frequency N * 24000/Q Hertz (where N is the element index and 24000 is half the audio sampling rate in a typical PC - read [AudioSettings.outputSampleRate][1] for the correct sampling rate). With a 1024 array, for instance, you will have a resolution of 23.4 hertz (each element refers to a frequency 23.4 Hz higher than the previous one). You can use 2048 samples as well, which gives a resolution of 11.7 Hz, but the time taken to get the spectrum may lower your frame rate. Use the BlackmanHarris window - it gives more precise results and isn’t so expensive.

The function BandVol below gets the spectrum and returns the average intensity of the range of frequencies specified. You can place this code in your script and attach it to the AudioSource. Play the sound and call BandVol to get the frequency band volume. You can call the function during several Update cycles and average the results, for instance:

``````private var freqData: float[];
private var nSamples: int = 1024;
private var fMax: float;

function BandVol(fLow:float, fHigh:float): float {

fLow = Mathf.Clamp(fLow, 20, fMax); // limit low...
fHigh = Mathf.Clamp(fHigh, fLow, fMax); // and high frequencies
// get spectrum
audio.GetSpectrumData(freqData, 0, FFTWindow.BlackmanHarris);
var n1: int = Mathf.Floor(fLow * nSamples / fMax);
var n2: int = Mathf.Floor(fHigh * nSamples / fMax);
var sum: float = 0;
// average the volumes of frequencies fLow to fHigh
for (var i=n1; i<=n2; i++){
sum += freqData*;*
``````