Open kenders2000 opened 3 years ago
Hi, first of all, your understanding about the current implementation is correct.
But I set it intentionally and named it magnitude_
, instead of either amplitude_
or power_
. So it's not quite a DSP thing, it's rather an implementation of what people often apply after abs(STFT)
.
Hi,
I think there is an issue with
backend.magnitude_to_decibel()
. This calculates the db value as10 * log10(x)
, wherex
is the magnitude(i.e. x = abs(stft))
.As I understand, the decibel value of the magnitude of a signal should be
20 * log10(x)
not10 * log10(x)
. The latter is the decibel value of the signal power, i.e. it expects:10 * log10(x**2)
.I was confused as it is passing unit tests against librosa, but I think I know why. In
tests.test_backend.test_magnitude_to_decibel()
magnitude_to_decibel()
is being tested againstlibrosa.power_to_db()
which expects power as an input.And in
tests.test_time_frequency.test_melspectrogram_correctness()
the reference melspectrogram is being computed with a power of 1, which I believe returns a magnitude melspectrogram not the power spectrum as is usual.Basically at the moment
backend.magnitude_to_decibel()
is equivalent tolibrosa.core.spectrum.power_to_db()
but I think it should be equivalent tolibrosa.core.spectrum.amplitude_to_db()
, see librosa.core.spectrum.Let me know if I have got the wrong end of the stick here! But if not I am happy to fix this. I just wanted to check that my thinking is correct. The result would be that all spectrograms would be scaled by a factor of two, so while trivial, all spectrogram converted to decibels would change in this way.
Kind regards
Paul