about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/dtas/rg_state.rb12
-rw-r--r--test/test_rg_integration.rb10
2 files changed, 13 insertions, 9 deletions
diff --git a/lib/dtas/rg_state.rb b/lib/dtas/rg_state.rb
index 6ab31b9..b124098 100644
--- a/lib/dtas/rg_state.rb
+++ b/lib/dtas/rg_state.rb
@@ -5,8 +5,10 @@
 # MAYBE: account for non-standard reference loudness (89.0 dB is standard)
 require_relative '../dtas'
 require_relative 'serialize'
+require_relative 'util'
 class DTAS::RGState # :nodoc:
   include DTAS::Serialize
+  include DTAS::Util
 
   RG_MODE = {
     # attribute name => method to use
@@ -53,19 +55,19 @@ class DTAS::RGState # :nodoc:
     to_hash.delete_if { |k,v| RG_DEFAULT[k] == v }
   end
 
-  # returns a dB argument to the "vol" effect, nil if nothing found
+  # returns a dB argument to the "gain" effect, nil if nothing found
   def rg_vol_gain(val)
     val = val.to_f + @preamp
     return if val.abs < @gain_threshold
-    sprintf('vol %0.8gdB', val)
+    sprintf('gain %0.8g', val)
   end
 
-  # returns a linear argument to the "vol" effect
+  # returns a DB argument to the "gain" effect
   def rg_vol_norm(val)
     diff = @norm_level - val.to_f
     return if (@norm_level - diff).abs < @norm_threshold
     diff += @norm_level
-    sprintf('vol %0.8g', diff)
+    sprintf('gain %0.8g', linear_to_db(diff))
   end
 
   # The ReplayGain fallback adjustment value (in dB), in case a file is
@@ -77,7 +79,7 @@ class DTAS::RGState # :nodoc:
     val = @fallback_gain + @preamp
     return if val.abs < @gain_threshold
     warn(reason) if $DEBUG
-    "vol #{val}dB"
+    "gain #{val}"
   end
 
   # returns an array (for command-line argument) for the effect needed
diff --git a/test/test_rg_integration.rb b/test/test_rg_integration.rb
index f8e81c2..efc8f97 100644
--- a/test/test_rg_integration.rb
+++ b/test/test_rg_integration.rb
@@ -1,8 +1,10 @@
 # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
 # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
 require './test/player_integration'
+require 'dtas/util'
 class TestRgIntegration < Testcase
   include PlayerIntegration
+  include DTAS::Util
 
   def tmp_pluck(len = 5)
     pluck = Tempfile.open(%w(pluck .flac))
@@ -58,10 +60,10 @@ class TestRgIntegration < Testcase
       assert_match expect, cur["current"]["env"]["RGFX"]
     end
 
-    check_gain.call(%r{vol -3dB}, "album_gain")
-    check_gain.call(%r{vol -2dB}, "track_gain")
-    check_gain.call(%r{vol 1\.3}, "track_peak")
-    check_gain.call(%r{vol 1\.0}, "album_peak")
+    check_gain.call(%r{gain -3}, "album_gain")
+    check_gain.call(%r{gain -2}, "track_gain")
+    check_gain.call(%r{gain 0\.0}, "album_peak")
+    check_gain.call(%r{gain 2\.5}, "track_peak")
 
     s.req_ok("rg preamp+=1")
     rg = YAML.load(yaml = s.req("rg"))