Hi
I’ve been doing some examples of loading a song and trying to detect its beats. Now I am getting there thanks to some articles I found online. Here is my question, while trying to get access to my own class FFT I got the error message as described on topic. Can someone tell me why this is happening? Thanks in advance. Here is my code, have a look.
usingUnityEngine;
usingSystem.Collections;
publicclassspec2 : MonoBehaviour
{
publicAudioSourcesong; //settheaudiosourcetodetect
float[ ] channelRight;
float[ ] channelLeft;
publicclassFFTElement
{
publicfloatre = 0.0f; //Realcomponent
publicfloatim = 0.0f; //Imaginarycomponent
publicFFTElementnext; //pointtonextelement
}
FFTElement[ ] _data = newFFTElement[1024];
voidStart ()
{
//allocateelementforlinkedlist
for(inti=0;i<1023;i++)
{
data = newFFTElement();
}
//setupnextpointer
for(inti=0;i<1023;i++)
{
data*.next = data[i+1];
_}*
}
voidUpdate ()
{
for(intj=0;j<channelLeft.Length;j++)
{
channelRight = song.audio.GetSpectrumData(1024,0,FFTWindow.BlackmanHarris);
channelLeft = song.audio.GetSpectrumData(1024,1,FFTWindow.BlackmanHarris);
//computetheinstantsoundenergy
e = e + ((channelLeft[j]*channelLeft[j]) + (channelRight[j]*channelRight[j]));
historyBuffer = e; //inserteintobuffertostore
_data[j].re = channelRight[j];
_data[j].im = channelLeft[j];
}
}
}