-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-1. sometimes flips to 1. when reading FLAC format #274
Comments
Forgot to append the output of the code on my machine: 0.9.0 |
Sorry see that this was already reported in #265, and that the cause is in libsndfile. I hope this is fixed because converting from wav to flac is something that is probably done a lot to compress losslessly. Edit: it even seems to be related to FLAC itself: see https://sourceforge.net/p/flac/bugs/476/ But it appears that this bug does not have a high priority, which I find very surprising. It introduces large artifacts in audio files without warning. I would warn people not to use FLAC for important applications. The fact that it is seen as lossless may lead people to delete their wav files after converting (I almost did this, glad I verified first...). |
Thank you for reporting this error! This is troubling indeed. Let's hope they publish a fix soon. |
In the meantime, for those who want to avoid being bitten by this bug: when reading FLAC data in SoundFile, don't use the default dtype='float64' (which causes the buggy normalization to [-1,1) in the underlying libsndfile). Read it with dtype='int32', which avoids normalization and the bug. Having said that, I was just trying to verify the above in practice practive by creating 16+ hours of FLAC data from WAV PCM_24, and when comparing them. I find indeed no numeric differences when using 'int32', whereas 'float64' does lead to normalization sign-flip errors. But I do get "RuntimeError: Internal psf_fseek() failed" in one of the FLAC files when reading somewhere in the middle.... whereas trying to read before or after this spot is fine. I can play the file fine in VLC or open it in Audacity. |
This (or a similar) problem has also been mentioned in the
Here's a link to the mentioned patch: https://github.com/roebel/conda_packages/blob/master/pysndfile/flac.c.patch |
I noticed when converting WAV PCM_24 to FLAC PCM_24 (but same goes for PCM_16) that values -1. in the wave file sometimes are flipped to 1 when reading the FLAC file. This was in a long sound file, but I managed to reproduce the issue with the code and fragment of the sound pasted below. The issue seems to be when reading the file because when I open the flac in Audacity, it is OK, no sign flip. This is on windows, pysoundfile version 0.9.0, libsnd version 1.0.27.
The text was updated successfully, but these errors were encountered: