public int freqToIndex(float freq){
  if (freq < getBandWidth() / 2)   return 0;
  if (freq > sampleRate / 2 - getBandWidth() / 2)   return spectrum.length - 1;
  float fraction=freq / (float)sampleRate;
  int i=Math.round(timeSize * fraction);
  return i;
}

public int freqToIndex ( float freq ) { if ( freq < getBandWidth ( ) / 2 ) return 0 ; if ( freq > sampleRate / 2 - getBandWidth ( ) / 2 ) return spectrum . length - 1 ; float fraction = freq / ( float ) sampleRate ; int i = Math . round ( timeSize * fraction ) ; return i ; }
returns the index of the frequency band that contains the requested frequency .
