@@ -133,7 +133,7 @@ func (sp *Spectrum) Process(win window.Function) {
133133
134134 sf = math .Pow (sf , float64 (sp .sampleSize )/ sp .sampleRate )
135135
136- var bassCut = sp .freqToIdx (Frequencies [2 ], math .Round )
136+ var bassCut = sp .freqToIdx (Frequencies [2 ], math .Ceil )
137137 var fBassCut = float64 (bassCut )
138138
139139 for _ , stream := range sp .streams {
@@ -233,11 +233,14 @@ func (sp *Spectrum) distributeLog(bins int) {
233233 var lo = (Frequencies [1 ])
234234 var hi = Frequencies [4 ]
235235
236- var cF = math .Log10 (lo / hi ) / ((1 / float64 (bins )) - 1 )
236+ var loLog = math .Log10 (lo )
237+ var hiLog = math .Log10 (hi )
238+
239+ var cF = (hiLog - loLog ) / float64 (bins )
237240
238241 var getBinBase = func (b int ) int {
239- var vFreq = ((float64 (b ) / float64 ( bins )) * cF ) - cF
240- vFreq = math .Pow (10.0 , vFreq ) * hi
242+ var vFreq = ((float64 (b ) * cF ) + loLog )
243+ vFreq = math .Pow (10.0 , vFreq )
241244 return sp .freqToIdx (vFreq , math .Floor )
242245 }
243246
@@ -262,7 +265,7 @@ func (sp *Spectrum) distributeEqual(bins int) {
262265 var loF = Frequencies [0 ]
263266 var hiF = math .Min (Frequencies [4 ], sp .sampleRate / 2 )
264267 var minIdx = sp .freqToIdx (loF , math .Floor )
265- var maxIdx = sp .freqToIdx (hiF , math .Ceil )
268+ var maxIdx = sp .freqToIdx (hiF , math .Round )
266269
267270 var size = maxIdx - minIdx
268271
0 commit comments