KinWaiCheuk / nnAudio

Audio processing by using pytorch 1D convolution network
MIT License
1.01k stars 89 forks source link

MelSpectrogram does not return magnitude #24

Closed janvainer closed 4 years ago

janvainer commented 4 years ago

Hi, I went through the source code of your project and I noticed there is a difference in what is returned by MelSpectrogram and STFT. The spectrogram returns magnitude, ie sqrt(Re2 + Im2), but MelSpectrogram only returns the powers - Re2 + Im2. Is there any reason behind this? Would it be possibe to specify 'power' as an argument to MelSpectrogram similarly to librosa?

KinWaiCheuk commented 4 years ago

Hi @LordOfLuck , thanks for the suggestion. Indeed, it would be better for users to have controls over the Mel spectrogram output. I have already added the power argument. Please install the most updated version 0.0.11 via the following command pip install nnAudio==0.0.11

Just for your information, for STFT you can also choose different outputs by changing the output_format argument. You can choose either Magnitude, Complex, or Phase.

Thanks for the suggestion again. nnAudio becomes better and better because of users like you.

janvainer commented 4 years ago

Great, thank you :)