Unity Audio Spectrum Visualisation problem

I have a code from tutorial…The code compiles but no effect of scaling objects. In addition i dont quite undersund thse spectrum things. I know that a spectrum number represents Hz (spectrum of 1024 devided by 22050 Hz) so spectrum[1]= around 21Hz

but what I can se there is something like var c1=spectrum[1]+spectrum[2] and the question is why?
i know that C2 represents a sound of specific frq. but why these spectrums are added.

#pragma strict

function Start () {

}

function Update () {
var spectrum :float[]=AudioListener.GetSpectrumData(1024,0,FFTWindow.Hamming);


var c1:float=spectrum[1]+spectrum[1]+spectrum[1];
var c2:float=spectrum[11]+spectrum[12]+spectrum[13];
var c3:float=spectrum[22]+spectrum[23]+spectrum[24];
var c4:float=spectrum[44]+spectrum[45]+spectrum[46]+spectrum[47]+spectrum[48]+spectrum[49];


var cubes: GameObject[] = GameObject.FindGameObjectsWithTag("cube");
for( var  i=0;i<cubes.length;i++){
     switch(cubes[i].name){
     case "c1":cubes[i].transform.localScale.x=c1;Debug.Log("super"  +c2);break;
     case "c2":cubes[i].transform.localScale.x=c2;break;
     case "c3":cubes[i].transform.localScale.x=c3;break;
     case "c1":cubes[i].transform.localScale.x=c4;break;
     }}
  
     }

the code is from

thx in advance. This post will be seen for 12 months to help others to understand that thing

Fffff that’s terrible
Anyway, tagged the cubes as cube?

Its because the spectrum values are small, by summing multiple bands you get a larger value, and your bars will scale more across a range of frequencies

tags are fine… there is a yellow warning"
Assets/musick/musick analiser.js(8,37): BCW0012: WARNING: ‘UnityEngine.AudioListener.GetSpectrumData(int, int, UnityEngine.FFTWindow)’ is obsolete. GetSpectrumData returning a float[ ] is deprecated, use GetOutputData and pass a pre allocated array instead."

Not sure that would change anything, but worth trying.
It works like this:

var spectrum : float[] = new float[1024];
AudioListener.GetSpectrumData(spectrum, 0, FFTWindow)

(not spellchecked)

  • Assets/musick/musick analiser.js(9,30): BCE0023: No appropriate version of ‘UnityEngine.AudioListener.GetSpectrumData’ for the argument list ‘(float[ ], int, System.Type)’ was found.

the main script is in js

for example this thing code wokrs
#pragma strict
var object:GameObject;
function Start () {

}

function Update () {
var spectrum :float[ ]=AudioListener.GetSpectrumData(1024,0,FFTWindow.Hamming);

var c1:float=spectrum[1]+spectrum[1]+spectrum[1];
var c2:float=spectrum[11]+spectrum[12]+spectrum[13];
var c3:float=spectrum[22]+spectrum[23]+spectrum[24];
var c4:float=spectrum[44]+spectrum[45]+spectrum[46]+spectrum[47]+spectrum[48]+spectrum[49];

object.transform.localScale.y=c1*39;

}

so the problem must be in other part