Question by 
               buleon29 · Mar 30, 2018 at 12:08 PM · 
                audioaudiosourceaudioclipgetspectrumdata  
              
 
              All my spectrums from GetSpectrumData are the same
Hi,
I need to do some Audio recognition, so I use a base of 15 prerecorded sounds, get there spectrum with AudioSource.GetSpectrumData() and then I try to recognize a sound from the microphone by comparing it's spectrum with the 15 other ones.
Here is my problem : all the 15 spectums are exactly the same. Nothing changes from one to another.
Here is my code :
  void Start()
     {
         clips = new AudioSource[15];
         spectrums = new float[15][];
         GetClips();
         GetClipsSpectrum();
     }
 
     // Update is called once per frame
     void Update()
     {
     }
 
     // Getting one of the prerecorded clips
     AudioSource GetClip(string fileName)
     {
         AudioClip ac = Resources.Load(fileName) as AudioClip;
         AudioSource a = gameObject.AddComponent<AudioSource>();
         a.clip = ac;
         return a;
     }
 
     void GetClips()
     {
         clips[0] = GetClip("doigt1");
         clips[1] = GetClip("doigt2");
         clips[2] = GetClip("doigt3");
         clips[3] = GetClip("doigt4");
         clips[4] = GetClip("doigt5");
         clips[5] = GetClip("main1");
         clips[6] = GetClip("main2");
         clips[7] = GetClip("main3");
         clips[8] = GetClip("main4");
         clips[9] = GetClip("main5");
         clips[10] = GetClip("prout1");
         clips[11] = GetClip("prout2");
         clips[12] = GetClip("prout3");
         clips[13] = GetClip("prout4");
         clips[14] = GetClip("prout5");
     }
 
     // Computing spectrums of the prerecorded clips
     void GetClipsSpectrum()
     {
         int l = clips.Length;
         for (int i = 0; i < l; i++)
         {
             spectrums[i] = new float[8192];
             clips[i].GetSpectrumData(spectrums[i], 0, FFTWindow.Rectangular);
         }
     }
 
               What did I do wrong ? Please help me :(
               Comment
              
 
               
              Your answer