···1111#include "kiss_fftr.h"
12121313// Generate logarithmically spaced center frequencies for musical notes
1414-// Keeps equal-tempered semitone spacing exact (2^(1/12)) without scaling the ladder.
1515-// If the last bin slightly exceeds maxFreq due to floating-point error, adjust the
1616-// base frequency minimally so that the last bin matches maxFreq exactly.
1414+// Keeps equal-tempered semitone spacing exact (2^(1/12)) without any scaling.
1515+// Uses minFreq as the musical base and ignores maxFreq for placement.
1716void VQT_GenerateCenterFrequencies(float* frequencies, int numBins, float minFreq, float maxFreq)
1817{
1919- const double step = pow(2.0, 1.0 / 12.0); // semitone ratio
2020- const double stepsToTop = (double)(numBins - 1) / 12.0; // octaves to the top bin
2121-2222- // Compute the ideal top frequency using high precision
2323- double base = (double)minFreq;
2424- double idealTop = base * pow(2.0, stepsToTop);
2525-2626- // Allow a tiny tolerance for FP error before correcting the base
2727- const double eps = 1e-7; // relative tolerance
2828- if (idealTop > (double)maxFreq * (1.0 + eps))
2929- {
3030- // Adjust base so that the top bin lands exactly at maxFreq
3131- base = (double)maxFreq / pow(2.0, stepsToTop);
3232- }
3333-3434- // Fill frequencies using exact semitone spacing from the (possibly adjusted) base
1818+ (void)maxFreq; // base is authoritative; maxFreq is not used to scale bins
1919+ const double base = (double)minFreq;
3520 for (int i = 0; i < numBins; i++)
3621 {
3737- double f = base * pow(2.0, (double)i / 12.0);
3838- frequencies[i] = (float)f;
2222+ frequencies[i] = (float)(base * pow(2.0, (double)i / 12.0));
3923 }
4024}
4125