From 974854f21a1787a62b4cf8d7716c65f3712819df Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 9 Apr 2020 20:12:22 +0000 Subject: splitfx: support --err-suffix option 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 via SOX_OPTS. +=item -E, --err-suffix SUFFIX + +Write the contents of C. This is useful for capturing +the per-track output of the L C 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 @@ OptionParser.new('', 24, ' ') do |op| 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 @@ OptionParser.new('', 24, ' ') do |op| 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 @@ class DTAS::SplitFX # :nodoc: 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) -- cgit v1.2.3-24-ge0c7