-
Notifications
You must be signed in to change notification settings - Fork 34
Added album normalization as recommended in AES77 #168
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
Conversation
|
Code looks fine at a quick glance. I'll have time to do a more in-depth review and testing later. Please add "Fixes #132" to the end of your post so that issue is auto-closed if this PR is merged. |
src/scan.cpp
Outdated
| track.result.album_peak = album_peak; | ||
| track.result.album_loudness = album_loudness; | ||
| if (config.album_as_aes77) { | ||
| double album_loudness = -HUGE_VAL, album_peak = 0.0, album_gain; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use multiple statements in a line. Please separate them.
src/scan.cpp
Outdated
| for (const Track &track : tracks) { | ||
| if (album_loudness < track.result.track_loudness) { | ||
| album_loudness = track.result.track_loudness; | ||
| album_gain = track.result.track_gain; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assign album loudness only. Album gain will be calculated later at the end of the loop.
src/scan.cpp
Outdated
| double album_gain = (type == FileType::OPUS && config.opus_mode == 's' ? -23.0 : config.target_loudness) | ||
| - album_loudness; | ||
| for (Track &track : tracks) { | ||
| track.result.album_gain = album_gain; | ||
| track.result.album_peak = album_peak; | ||
| track.result.album_loudness = album_loudness; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this code to after the if/else block so that it is common to both -a and -e cases.
src/scan.cpp
Outdated
| for (Track &track : tracks) { | ||
| track.result.album_gain = album_gain; | ||
| track.result.album_peak = album_peak; | ||
| track.result.album_loudness = album_loudness; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete (see above comment about making this code common).
I needed the option to calculate the album loudness according to the AES77 specification, which recommends to just use the loudest track of an album as the reference for all tracks, and thought it may be helpful for others as well.
Fixes #132