1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-11 00:53:46 +02:00

Fix two bugs in loudness effect (#410)

* Calculate loudness for short or silent selections as well.

In case of selections shorter than 400ms (one momentary loudness block),
take what we have got and divide only be the actual length.

Abort loudness normalization silently if the selected audio is all
silent.

* Fix loudness effect bug when selection includes a gap.

If the selected audio in a track contained a gap between two clips,
an incorrect amount of samples was processed.
This commit is contained in:
Max Maisel
2020-01-24 19:04:19 +01:00
committed by Steve Daulton
parent 921d7f28ef
commit 17ef5b1c75
4 changed files with 96 additions and 53 deletions

View File

@@ -122,11 +122,29 @@ if TEST_LUFS_HELPER
printf("LUFS-selftest3.wav should be %f LUFS\n", calc_LUFS(x, fs));
end
## Test Loudness LUFS mode: block to short and all silent
CURRENT_TEST = "Loudness LUFS mode, short silent block";
fs= 44100;
x = zeros(ceil(fs*0.35), 2);
audiowrite(TMP_FILENAME, x, fs);
if EXPORT_TEST_SIGNALS
audiowrite(cstrcat(pwd(), "/Loudness-LUFS-silence-test.wav"), x, fs);
end
remove_all_tracks();
aud_do(cstrcat("Import2: Filename=\"", TMP_FILENAME, "\"\n"));
select_tracks(0, 100);
aud_do("LoudnessNormalization: LUFSLevel=-23 DualMono=1 NormalizeTo=0 StereoIndependent=0\n");
aud_do(cstrcat("Export2: Filename=\"", TMP_FILENAME, "\" NumChannels=2\n"));
system("sync");
y = audioread(TMP_FILENAME);
do_test_equ(y, x, "identity");
## Test Loudness LUFS mode: stereo dependent
CURRENT_TEST = "Loudness LUFS mode, keep DC and stereo balance";
randn("seed", 1);
fs= 44100;
# Include some silecne in the test signal to test loudness gating
# Include some silence in the test signal to test loudness gating
# and vary the overall loudness over time.
x = [0.1*randn(15*fs, 2).', zeros(5*fs, 2).', 0.1*randn(15*fs, 2).'].';
x(:,1) = x(:,1) .* sin(2*pi/fs/35*(1:1:35*fs)).' .* 1.2;