about summary refs log tree commit homepage
path: root/lib/dtas/source/sox.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dtas/source/sox.rb')
-rw-r--r--lib/dtas/source/sox.rb16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/dtas/source/sox.rb b/lib/dtas/source/sox.rb
index 64ce095..954c1a5 100644
--- a/lib/dtas/source/sox.rb
+++ b/lib/dtas/source/sox.rb
@@ -8,16 +8,23 @@ require_relative '../replaygain'
 # this is usually one input file
 class DTAS::Source::Sox # :nodoc:
   require_relative 'file'
-  require_relative 'mp3gain'
 
   include DTAS::Source::File
-  include DTAS::Source::Mp3gain
 
   SOX_DEFAULTS = COMMAND_DEFAULTS.merge(
     "command" => 'exec sox "$INFILE" $SOXFMT - $TRIMFX $RGFX',
     "comments" => nil,
   )
 
+
+  def self.try(infile, offset = nil)
+    err = ""
+    DTAS::Process.qx(%W(soxi #{infile}), err: err)
+    return if err =~ /soxi FAIL formats:/
+    new(infile, offset)
+  rescue
+  end
+
   def initialize(infile, offset = nil)
     command_init(SOX_DEFAULTS)
     source_file_init(infile, offset)
@@ -79,11 +86,6 @@ class DTAS::Source::Sox # :nodoc:
     tmp
   end
 
-  def replaygain
-    @rg = DTAS::ReplayGain.new(comments) ||
-          DTAS::ReplayGain.new(mp3gain_comments)
-  end
-
   def spawn(format, rg_state, opts)
     raise "BUG: #{self.inspect}#spawn called twice" if @to_io
     e = format.to_env