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 has -6dB gain in mixxx 2.1.0 #9255

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

Flac has -6dB gain in mixxx 2.1.0 #9255

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

Comments

@mixxxbot
Copy link
Collaborator

Reported by: jamie.gifford
Date: 2018-04-22T01:52:11Z
Status: Fix Released
Importance: High
Launchpad Issue: lp1766042


In Mixxx 2.1.0, FLAC files are decoded with a -6dB gain. Tested on Linux and Mac.

The problem is reproducible always. Eg, create a 440Hz full-scale sine in both WAV and FLAC formats with "sox -r 44100 -n a440.wav synth 20 sine 440" and "sox -r 44100 -n a440.flac synth 20 sine 440". The WAV file plays correctly; the FLAC file will play at -6dB. 

Looks to me that the problem is in soundsourceflac.cpp, in void SoundSourceFLAC::flacMetadata(const FLAC__StreamMetadata* metadata), in the code:

m_sampleScaleFactor = CSAMPLE_PEAK
                    / CSAMPLE(FLAC__int32(1) << bitsPerSample);

Since FLAC samples are signed, a FLAC full-scale sample will only reach bitsPerSample-1, not bitsPerSample (eg, in a 24 bit stream the maximum sample magnitude would be 1<<23). This means that m_sampleScaleFactor is out by a factor of two, hence -6dB. 

I think the code should read

m_sampleScaleFactor = CSAMPLE_PEAK
                    / CSAMPLE(FLAC__int32(1) << (bitsPerSample - 1));
@mixxxbot mixxxbot added the bug label Aug 23, 2022
@mixxxbot
Copy link
Collaborator Author

Commented by: Pegasus-RPG
Date: 2018-04-22T06:02:37Z


I /thought/ my FLAC files sounded quieter! Thank you very much for the detailed analysis! (Do you use GitHub and want to make a pull request so you get credit in the commit history?)

@mixxxbot
Copy link
Collaborator Author

Commented by: jamie.gifford
Date: 2018-04-22T06:27:44Z


Pull request sent...

@mixxxbot
Copy link
Collaborator Author

Commented by: uklotzde
Date: 2018-04-22T13:47:50Z


#1636

@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.1.1 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