Skip to content
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

flac encoder clips poorly #10318

Closed
mixxxbot opened this issue Aug 23, 2022 · 17 comments
Closed

flac encoder clips poorly #10318

mixxxbot opened this issue Aug 23, 2022 · 17 comments
Labels
Milestone

Comments

@mixxxbot
Copy link
Collaborator

Reported by: ywwg
Date: 2021-02-10T17:00:53Z
Status: Fix Released
Importance: Low
Launchpad Issue: lp1915298
Attachments: [wave clipping](https://bugs.launchpad.net/bugs/1915298/+attachment/5462352/+files/wave clipping), [flac clipping](https://bugs.launchpad.net/bugs/1915298/+attachment/5462353/+files/flac clipping), [flac with clipping disabled](https://bugs.launchpad.net/bugs/1915298/+attachment/5462356/+files/flac with clipping disabled)


I recorded a set and there was some clipping, but it didn't sound bad out of my speakers. However the recorded flac has awful popping noises wherever the clipping happens. I did some testing and discovered that it clips incorrectly. If I record with WAVE, clipping looks like you'd expect (first image). But in flac, the clipped value bounces from 0 to 1 crazily (second image). I wonder if this is an issue with going from float to int?

@mixxxbot mixxxbot added the bug label Aug 23, 2022
@mixxxbot
Copy link
Collaborator Author

Commented by: ywwg
Date: 2021-02-10T17:00:53Z
Attachments: [wave clipping](https://bugs.launchpad.net/mixxx/+bug/1915298/+attachment/5462352/+files/wave clipping)

@mixxxbot
Copy link
Collaborator Author

Commented by: ywwg
Date: 2021-02-10T17:01:11Z
Attachments: [flac clipping](https://bugs.launchpad.net/mixxx/+bug/1915298/+attachment/5462353/+files/flac clipping)

@mixxxbot
Copy link
Collaborator Author

Commented by: ywwg
Date: 2021-02-10T17:03:06Z


this might be a bug in sndfile

@mixxxbot
Copy link
Collaborator Author

Commented by: ywwg
Date: 2021-02-10T17:08:12Z


According to our code:

// Tell the encoder that, when converting to integer formats, clip
// automatically the values that go outside of the allowed range.
// Warning! Depending on how libsndfile is compiled autoclip may not work.
// Ensure CPU_CLIPS_NEGATIVE and CPU_CLIPS_POSITIVE is setup properly in the build.

So this may be a case where the ubuntu-built sndfile is not compiled correctly. I am trying disabling clipping to see what happens.

@mixxxbot
Copy link
Collaborator Author

Commented by: ywwg
Date: 2021-02-10T17:14:47Z


Setting it to false appears to fix the issue, I'll make a PR and we should have people test it.

@mixxxbot
Copy link
Collaborator Author

Commented by: Be-ing
Date: 2021-02-10T17:18:31Z


Upstream bug in libsndfile, already fixed: libsndfile/libsndfile#309
libsndfile was practically unmaintained for a while so there was not a release with this fix until recently and Linux distros may still be shipping old libsndfile versions. 1.0.29 was the first version with the fix. #3615 will fix this for WIndows.

@mixxxbot
Copy link
Collaborator Author

Commented by: ywwg
Date: 2021-02-10T17:19:30Z
Attachments: [flac with clipping disabled](https://bugs.launchpad.net/mixxx/+bug/1915298/+attachment/5462356/+files/flac with clipping disabled)

@mixxxbot
Copy link
Collaborator Author

Commented by: ywwg
Date: 2021-02-10T17:19:59Z


oh cool thanks. yeah playing with the setting did not help. In the interim, using WAV output is a lot better

@mixxxbot
Copy link
Collaborator Author

Commented by: ywwg
Date: 2021-02-10T17:21:02Z


ubuntu 20.04 has 1.0.28-7

@mixxxbot
Copy link
Collaborator Author

Commented by: ywwg
Date: 2021-02-10T17:21:48Z


thanks <3

@mixxxbot
Copy link
Collaborator Author

Commented by: ywwg
Date: 2021-02-10T18:06:51Z


yup, updating to git sndfile fixes the issue

@mixxxbot
Copy link
Collaborator Author

Commented by: Be-ing
Date: 2021-03-08T20:38:42Z


Fixed for Windows and macOS: #3615
Linux distros update at their own pace.

@mixxxbot
Copy link
Collaborator Author

Commented by: daschuer
Date: 2021-03-11T09:02:24Z


The fix was done in this commit.
libsndfile/libsndfile@b9e5443
part of v1.0.29

Ubuntu Bionic LTS has 1.0.28-4ubuntu0.18.04.1
Ubuntu Focal LTS has 1.0.28-7
Ubuntu Groovy has 1.0.28-8
Ubuntu Hisure has 1.0.31-1ubuntu1

Fedora 33 has 1.0.31

https://repology.org/project/libsndfile/versions

@mixxxbot
Copy link
Collaborator Author

Commented by: daschuer
Date: 2021-03-11T09:23:54Z


I cannot confirm that the issue is fixed after upgrade, because we don't set
SFC_SET_CLIPPING for flac.

@mixxxbot
Copy link
Collaborator Author

Commented by: daschuer
Date: 2021-03-11T09:35:55Z


Oh, we do set it.. strange, something else must be wrong.

@mixxxbot
Copy link
Collaborator Author

Commented by: daschuer
Date: 2021-03-12T18:57:58Z


#3697

@mixxxbot
Copy link
Collaborator Author

Issue closed with status Fix Released.

@mixxxbot mixxxbot transferred this issue from another repository Aug 24, 2022
@mixxxbot mixxxbot added this to the 2.3.0 milestone Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant