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
recording to wav/aiff causes very distorted audio if it saturates #8674
Comments
Commented by: daschuer Thank you for adopting this! Here you will find some more info to th issue: Mixxx clamps the samples when passing them to the soundcard here: mixxx/src/soundio/sounddevice.cpp Line 132 in 8d191bf
The broken normalization in sndfile is enabled here: mixxx/src/engine/sidechain/enginerecord.cpp Line 310 in 8d191bf
|
Commented by: JosepMaJAZ Thanks. I knew the but was already reported, but didn't find the correct words to find them. The bug itself is fixed ( libsndfile normalization is ok, but it needs the clip option too ). Manual clamping was the first natural idea, but one that I could not implement, because the buffer that is received in process is constant, so the compiler prevents it to be modified. Dynamically creating a buffer just for clamping seemed like a bad idea too. And I will definitely try to implement the different bitsize saving. Should be trivial. |
Commented by: daschuer Fix Committed = Pull Request is merged. |
Commented by: daschuer The libsndfile normalization is IMHO heavily broken by design. It is up to the user to level the gain of the recoded samples before he starts recording. You may apply the clipping in This would prevent to record samples above 1 in a float recording |
Commented by: JosepMaJAZ I believe we are not on the same page. As I understand libsndfile option of normalize, it simply means that it translates the full scale. It does not try to guess which is the peak value. That is, if normalization is not selected, in order to get a 16 bit PCM audio with -32768 to 32767 range, the floating point data provided should be -32768.0 to 32767.0, whereas if normalization is used, that same PCM range is obtained from a floating point data between -1.0 to 1.0. And that's it, no more. So, what if the floating point data is -1.3 to 1.2 due to excessive gain? Then you need to tell it to clip at full scale. And that's what I've just changed in the code. |
Commented by: daschuer Oh yes, you are right, I have misread the docs. You proposed solution is correct. Reading it again, I noticed the dither topic. Could you check if dithering is enabled on write? I have found noting in the API docs about it. Only the test code: |
Commented by: JosepMaJAZ Mmmm... Indeed, it's not documented. But the code exists since many years ago: https://github.com/erikd/libsndfile/blob/master/src/dither.c I've written there an issue so that they are aware of this. Going to try the code and see. |
Commented by: JosepMaJAZ |
Issue closed with status Fix Released. |
Reported by: JosepMaJAZ
Date: 2016-10-30T00:55:35Z
Status: Fix Released
Importance: Undecided
Launchpad Issue: lp1637786
Mixxx 2.0 and above.
Recording the mix to wav or aiff generates audio files that distort in the places where audio saturates (goes above full scale).
The root of the cause is that the conversion from float to integer does not clip the values and they overflow.
The text was updated successfully, but these errors were encountered: