about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-12-01 06:36:56 +0000
committerEric Wong <normalperson@yhbt.net>2013-12-01 06:44:48 +0000
commit3338a0cf6087b981702227734af7817e97498a8e (patch)
tree508a4e832a1a39707e8101b46b3d7c4419556572
parent6283ff9870cd151ca5a4c62710e4b10f7d1447ef (diff)
downloaddtas-3338a0cf6087b981702227734af7817e97498a8e.tar.gz
splitfx is incapable of knowing in 100% of cases whether dithering
should be used (as it has no visibility into sox internals), so
support disabling it completely via command-line.
This is like the identical sox option, and passed to sox(1), too.

This feature is useful for splitting already-mastered 16-bit
recordings.
-rw-r--r--Documentation/dtas-splitfx.txt4
-rwxr-xr-xbin/dtas-splitfx1
-rw-r--r--lib/dtas/splitfx.rb6
3 files changed, 10 insertions, 1 deletions
diff --git a/Documentation/dtas-splitfx.txt b/Documentation/dtas-splitfx.txt
index 2367aba..49e55dc 100644
--- a/Documentation/dtas-splitfx.txt
+++ b/Documentation/dtas-splitfx.txt
@@ -31,6 +31,10 @@ to use ecasound(1), too.
 -s, \--quiet, \--silent
 :    Silent operation, commands are not printed as executed
 
+-D, \--no-dither
+:    Disable automatic setting of the DITHERFX env.  This also passes
+    the option to sox(1) via SOX_OPTS.
+
 # FILE FORMAT
 
 * infile - string, the pathname of the original audio file
diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx
index d75c1de..6e98aba 100755
--- a/bin/dtas-splitfx
+++ b/bin/dtas-splitfx
@@ -13,6 +13,7 @@ OptionParser.new('', 24, '  ') do |op|
   op.on('-n', '--dry-run') { opts[:dryrun] = true }
   op.on('-j', '--jobs [JOBS]', Integer) { |val| opts[:jobs] = val }
   op.on('-s', '--quiet', '--silent') { |val| opts[:silent] = true }
+  op.on('-D', '--no-dither') { |val| opts[:no_dither] = true }
   op.parse!(ARGV)
 end
 
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index 6f1654e..2a0b9de 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -173,7 +173,11 @@ class DTAS::SplitFX # :nodoc:
     end
 
     # add noise-shaped dither for 16-bit (sox manual seems to recommend this)
-    outfmt.bits && outfmt.bits <= 16 and env["DITHERFX"] = "dither -s"
+    if opts[:no_dither]
+      env["SOX_OPTS"] = "#{ENV["SOX_OPTS"]} -D"
+    else outfmt.bits && outfmt.bits <= 16
+      env["DITHERFX"] = "dither -s"
+    end
     comments = Tempfile.new(%W(dtas-splitfx-#{t.comments["TRACKNUMBER"]} .txt))
     comments.sync = true
     t.comments.each do |k,v|