ddiakopoulos / libnyquist

:microphone: Cross platform C++11 library for decoding audio (mp3, wav, ogg, opus, flac, etc)
BSD 2-Clause "Simplified" License
540 stars 66 forks source link

Normalization #37

Closed sevagh closed 5 years ago

sevagh commented 5 years ago

Hello,

I'm using libnyquist for a pitch tracking application. I decode the audio from a wav file, and run it through some algorithms (Mcleod, YIN, etc.)

For a few minutes I was scratching my head about why I was getting completely wrong results until I noticed the normalized between [-1.0, 1.0] part of the README. When I multiply the samples vector output by the decoder by a constant e.g. 100 or 1000 to amplify the signal, my pitch tracking algorithms produce correct results.

My question is,

ddiakopoulos commented 5 years ago

Hi @sevagh - I think that must be a bug in your pitch detection pipeline! Normalized floating point values are quite frequent in audio systems, and many audio APIs will hard clip values over the -1 to 1 range. I'm closing this issue for now but feel free to chime in again if you uncover any mysteries in your code :)