I was wondering how to get the frequency of a wav file.
at the moment i have NumSample = 512 and get the spectrum data of the wav file using FFT every second.
What i want to know is what do i get back from FFT is it 0-511 array of frequency values for that particular bin and if so how can i equate a Hz frequency value from that? HELP
public struct ANALYSIS_DATA
{
public float[] number;
public double Freak;
public double Bin;
}
void Start ()
{
analData = new ANALYSIS_DATA();
analData.number = new float[numSamples];
InvokeRepeating("UpdateAnalysis",0.0f,1.0f);
}
public void UpdateAnalysis()
{
/* updates every 1 second */
double max = 0;
int maxpos = 0;
AudioListener.GetSpectrumData(analData.number, 0,FFTWindow.Rectangular);
for(int i=0; i < numSamples; i++)
{
if(Mathf.Abs(analData.number[i])> max)
{
max = Mathf.Abs(analData.number[i]);
maxpos = i;
}
}
if(maxpos > 0)
GetAvgBin(maxpos);
}
public void GetAvgBin(double num)
{
if(num > analData.Bin)
analData.Bin = num;
}