dtas-all
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/2] splitfx: support --err-suffix option


From: Eric Wong
Subject: [PATCH 2/2] splitfx: support --err-suffix option
Date: Thu, 9 Apr 2020 20:12:22 +0000

Write the contents of "stderr".  This is useful for capturing the
per-track output of the sox(1) "stats" effect when combined with
parallel "--jobs".
---
 Documentation/dtas-splitfx.pod | 6 ++++++
 bin/dtas-splitfx               | 7 +++++++
 lib/dtas/splitfx.rb            | 5 ++++-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/Documentation/dtas-splitfx.pod b/Documentation/dtas-splitfx.pod
index 54a633e..f10c6a3 100644
--- a/Documentation/dtas-splitfx.pod
+++ b/Documentation/dtas-splitfx.pod
@@ -41,6 +41,12 @@ Silent operation, commands are not printed as executed
 Disable automatic setting of the DITHERFX env.  This also passes
 the option to L<sox(1)> via SOX_OPTS.
 
+=item -E, --err-suffix SUFFIX
+
+Write the contents of C<stderr>.  This is useful for capturing
+the per-track output of the L<sox(1)> C<stats> effect when
+combined with parallel C<--jobs>.
+
 =item -O, --outdir OUTDIR
 
 Set output directory instead of current directory.
diff --git a/bin/dtas-splitfx b/bin/dtas-splitfx
index d041679..3ee812e 100755
--- a/bin/dtas-splitfx
+++ b/bin/dtas-splitfx
@@ -23,6 +23,9 @@
   end
   op.on('-b', '--bits RATE', Integer) { |val| opts[:bits] = val }
   op.on('-t', '--trim POSITION') { |val| opts[:trim] = val.tr(',', ' ') }
+  op.on('-E', '--err-suffix SUFFIX') do |val|
+    opts[:err_suffix] = val.start_with?('.') ? val.freeze : ".#{val}"
+  end
   op.on('-p', '--sox-pipe') do
     opts[:sox_pipe] = true
     default_target = 'sox'
@@ -30,6 +33,10 @@
   op.parse!(ARGV)
 end
 
+if opts[:sox_pipe] && opts[:err_suffix]
+  abort '--err-suffix and --sox-pipe are mutually exclusive'
+end
+
 args = []
 ARGV.each do |arg|
   case arg
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index 384df0f..58c8ff4 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -250,7 +250,10 @@ def splitfx_spawn(target, t, opts)
     command = 'true' if opts[:dryrun] # still gotta fork
 
     # pgroup: false so Ctrl-C on command-line will immediately stop everything
-    [ dtas_spawn(env, command, pgroup: false), comments ]
+    o = { pgroup: false }
+    e = opts[:err_suffix] and
+      o[:err] = [ "#{env['OUTDIR']}#{env['TRACKNUMBER']}#{e}", 'a' ]
+    [ dtas_spawn(env, command, o), comments ]
   end
 
   def load_tracks!(hash)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]