# How can I use spectrum data to calculate energy values of certain frequency bands?

I'm working on a rhythm game, and need to detect beats in a piece of music.

After all the research and reading through old posts in unity forum/reddit etc., as far as I understood, I need to calculate the average energy, and if there is a sudden energy change/spike, I want to register them as beats.

So here's the thing as far as I understood ;

 public class something : MonoBehaviour {

public AudioSource audioSource;

public float[] freqData = new float[1024];

void Start ()
{
audioSource = GetComponent<AudioSource> ();
}

void Update ()
{
audioSource.GetSpectrumData (freqData, 0, FFTWindow.BlackmanHarris);
}
}


Let's say I have this code in place. My sampling rate is at 48000 Hz. The array size determines the frequency range of each element. So with a size of 1024, my frequency resolution is 23.4 Hz. So freqData[0] represents the freq between 0-23.4 Hz. freqData[1] represents 23.4-46.8 Hz. so on and so forth. And I want to detect, let's say bass beats between 60Hz and 250 Hz.

How can I translate this data into the average energy value for this frequency band?