diff --git a/spectrogramplot.cpp b/spectrogramplot.cpp index 291c3fc..f994216 100644 --- a/spectrogramplot.cpp +++ b/spectrogramplot.cpp @@ -143,14 +143,14 @@ void SpectrogramPlot::getLine(float *dest, off_t sample) fft->process(buffer.get(), buffer.get()); const float invFFTSize = 1.0f / fftSize; - const float dbMult = 10.0f / log2f(10.0f); + const float dbMult = 5.0f / log2f(10.0f); for (int i = 0; i < fftSize; i++) { // Start from the middle of the FFTW array and wrap // to rearrange the data int k = (i + fftSize / 2) & (fftSize - 1); auto s = buffer[k] * invFFTSize; - float mag = sqrt(s.real() * s.real() + s.imag() * s.imag()); - float magdb = log2f(mag) * dbMult; + float power = s.real() * s.real() + s.imag() * s.imag(); + float magdb = log2f(power) * dbMult; *dest = magdb; dest++; }