From 1a9d174f4aabbba37a32b6d4fea6bd8d2bc5b0ae Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 14 Dec 2015 09:09:06 +0000 Subject: rg_state: fixup replaygain normalization Oops, normalization is probably a forgotten feature... --- lib/dtas/rg_state.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/dtas') diff --git a/lib/dtas/rg_state.rb b/lib/dtas/rg_state.rb index 67706aa..18f4429 100644 --- a/lib/dtas/rg_state.rb +++ b/lib/dtas/rg_state.rb @@ -85,9 +85,10 @@ class DTAS::RGState # :nodoc: # returns a DB argument to the "gain" effect def rg_vol_norm(val) - diff = @norm_level - val.to_f + @volume - return if (@norm_level - diff).abs < @norm_threshold - diff += @norm_level + n = @norm_level == 1.0 ? @volume : @norm_level + diff = n - val.to_f + return if (n - diff).abs < @norm_threshold + diff += n to_sox_gain(linear_to_db(diff)) end -- cgit v1.2.3-24-ge0c7