everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
From: Eric Wong <e@yhbt.net>
To: dtas-all@nongnu.org
Subject: [PATCH 2/2] splitfx: support --err-suffix option
Date: Thu,  9 Apr 2020 20:12:22 +0000	[thread overview]
Message-ID: <20200409201222.24112-3-e@yhbt.net> (raw)
In-Reply-To: <20200409201222.24112-1-e@yhbt.net>

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)


      parent reply	other threads:[~2020-04-09 20:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-09 20:12 [PATCH 0/2] some splitfx improvements Eric Wong
2020-04-09 20:12 ` [PATCH 1/2] splitfx: reduce syscalls for writing comments file Eric Wong
2020-04-09 20:12 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://80x24.org/dtas/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200409201222.24112-3-e@yhbt.net \
    --to=e@yhbt.net \
    --cc=dtas-all@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/dtas.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).