about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/dtas/replaygain.rb8
-rw-r--r--lib/dtas/rg_state.rb4
-rw-r--r--lib/dtas/source/file.rb6
-rw-r--r--test/test_source_av.rb4
-rw-r--r--test/test_source_sox.rb4
5 files changed, 13 insertions, 13 deletions
diff --git a/lib/dtas/replaygain.rb b/lib/dtas/replaygain.rb
index b94ded2..635e96e 100644
--- a/lib/dtas/replaygain.rb
+++ b/lib/dtas/replaygain.rb
@@ -40,7 +40,7 @@ class DTAS::ReplayGain # :nodoc:
   def initialize(comments)
     comments or return
 
-    # the replaygain standard specifies 89.0 dB, but maybe some apps are
+    # the ReplayGain standard specifies 89.0 dB, but maybe some apps are
     # different...
     @reference_loudness = check_gain(comments["REPLAYGAIN_REFERENCE_LOUDNESS"])
 
@@ -50,8 +50,8 @@ class DTAS::ReplayGain # :nodoc:
     @album_peak = check_float(comments["REPLAYGAIN_ALBUM_PEAK"])
   end
 
-  def self.new(comments)
-    tmp = super
-    tmp.track_gain ? tmp : nil
+  def self.new(comments, field)
+    tmp = super(comments)
+    tmp.__send__(field) ? tmp : nil
   end
 end
diff --git a/lib/dtas/rg_state.rb b/lib/dtas/rg_state.rb
index 883515d..d6f8d81 100644
--- a/lib/dtas/rg_state.rb
+++ b/lib/dtas/rg_state.rb
@@ -111,8 +111,8 @@ class DTAS::RGState # :nodoc:
     unless @mode
       return @volume == 1.0 ? nil : to_sox_gain(vol_db)
     end
-    rg = source.replaygain or
-      return rg_fallback_effect("ReplayGain tags missing")
+    rg = source.replaygain(@mode) or
+      return rg_fallback_effect("ReplayGain tags missing for #@mode")
     val = rg.__send__(@mode)
     if ! val && @fallback_track && @mode =~ /\Aalbum_(\w+)/
       tag = "track_#$1"
diff --git a/lib/dtas/source/file.rb b/lib/dtas/source/file.rb
index 33ecc25..00b8f8e 100644
--- a/lib/dtas/source/file.rb
+++ b/lib/dtas/source/file.rb
@@ -92,9 +92,9 @@ module DTAS::Source::File # :nodoc:
     rv
   end
 
-  def replaygain
-    @rg ||= DTAS::ReplayGain.new(comments) ||
-            DTAS::ReplayGain.new(mp3gain_comments)
+  def replaygain(mode)
+    @rg ||= DTAS::ReplayGain.new(comments, mode) ||
+            DTAS::ReplayGain.new(mp3gain_comments, mode)
   end
 
   def to_source_cat
diff --git a/test/test_source_av.rb b/test/test_source_av.rb
index 3106fe9..6047de7 100644
--- a/test/test_source_av.rb
+++ b/test/test_source_av.rb
@@ -35,7 +35,7 @@ class TestSourceAv < Testcase
     x(%W(metaflac --add-replay-gain #{tmp.path}))
     source = DTAS::Source::Av.new.try(tmp.path)
     assert_equal source.comments["FOO"], "BAR", source.inspect
-    rg = source.replaygain
+    rg = source.replaygain('track_gain')
     assert_kind_of DTAS::ReplayGain, rg
     assert_in_delta 0.0, rg.track_peak.to_f, 0.00000001
     assert_in_delta 0.0, rg.album_peak.to_f, 0.00000001
@@ -61,7 +61,7 @@ class TestSourceAv < Testcase
     end
 
     source = DTAS::Source::Av.new.try(a.path)
-    rg = source.replaygain
+    rg = source.replaygain('track_gain')
     assert_kind_of DTAS::ReplayGain, rg
     assert_in_delta 0.0, rg.track_peak.to_f, 0.00000001
     assert_in_delta 0.0, rg.album_peak.to_f, 0.00000001
diff --git a/test/test_source_sox.rb b/test/test_source_sox.rb
index ce4fe93..05ea9a8 100644
--- a/test/test_source_sox.rb
+++ b/test/test_source_sox.rb
@@ -35,7 +35,7 @@ class TestSource < Testcase
     x(%W(metaflac --set-tag=FOO=BAR #{tmp.path}))
     x(%W(metaflac --add-replay-gain #{tmp.path}))
     assert_equal source.comments["FOO"], "BAR"
-    rg = source.replaygain
+    rg = source.replaygain('track_gain')
     assert_kind_of DTAS::ReplayGain, rg
     assert_in_delta 0.0, rg.track_peak.to_f, 0.00000001
     assert_in_delta 0.0, rg.album_peak.to_f, 0.00000001
@@ -62,7 +62,7 @@ class TestSource < Testcase
       end
     end
 
-    rg = source.replaygain
+    rg = source.replaygain('track_gain')
     assert_kind_of DTAS::ReplayGain, rg
     assert_in_delta 0.0, rg.track_peak.to_f, 0.00000001
     assert_in_delta 0.0, rg.album_peak.to_f, 0.00000001