From 7da4d0e4730ecdc8fcf82c97f1bc466ddf28e8b3 Mon Sep 17 00:00:00 2001 From: Roderick van Domburg Date: Wed, 1 Sep 2021 20:54:47 +0200 Subject: [PATCH 1/2] Attenuate after normalisation --- playback/src/player.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/playback/src/player.rs b/playback/src/player.rs index a6e71aad..21afdbbe 100644 --- a/playback/src/player.rs +++ b/playback/src/player.rs @@ -1186,10 +1186,6 @@ impl PlayerInternal { Some(mut packet) => { if !packet.is_empty() { if let AudioPacket::Samples(ref mut data) = packet { - if let Some(ref editor) = self.audio_filter { - editor.modify_stream(data) - } - if self.config.normalisation && !(f64::abs(normalisation_factor - 1.0) <= f64::EPSILON && self.config.normalisation_method == NormalisationMethod::Basic) @@ -1302,6 +1298,10 @@ impl PlayerInternal { } } } + + if let Some(ref editor) = self.audio_filter { + editor.modify_stream(data) + } } if let Err(err) = self.sink.write(&packet, &mut self.converter) { From d8e35bf0c4f9ee3909da276665ac1d9df8386e00 Mon Sep 17 00:00:00 2001 From: Roderick van Domburg Date: Wed, 1 Sep 2021 20:55:28 +0200 Subject: [PATCH 2/2] Remove clamping of float samples --- playback/src/player.rs | 9 --------- 1 file changed, 9 deletions(-) diff --git a/playback/src/player.rs b/playback/src/player.rs index 21afdbbe..361c24a7 100644 --- a/playback/src/player.rs +++ b/playback/src/player.rs @@ -1286,16 +1286,7 @@ impl PlayerInternal { } } } - *sample *= actual_normalisation_factor; - - // Extremely sharp attacks, however unlikely, *may* still clip and provide - // undefined results, so strictly enforce output within [-1.0, 1.0]. - if *sample < -1.0 { - *sample = -1.0; - } else if *sample > 1.0 { - *sample = 1.0; - } } }