everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
* [PATCH 0/2] some splitfx improvements
@ 2020-04-09 20:12 Eric Wong
  2020-04-09 20:12 ` [PATCH 1/2] splitfx: reduce syscalls for writing comments file Eric Wong
  2020-04-09 20:12 ` [PATCH 2/2] splitfx: support --err-suffix option Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2020-04-09 20:12 UTC (permalink / raw)
  To: dtas-all

Eric Wong (2):
  splitfx: reduce syscalls for writing comments file
  splitfx: support --err-suffix option

 Documentation/dtas-splitfx.pod | 6 ++++++
 bin/dtas-splitfx               | 7 +++++++
 lib/dtas/splitfx.rb            | 7 +++++--
 3 files changed, 18 insertions(+), 2 deletions(-)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] splitfx: reduce syscalls for writing comments file
  2020-04-09 20:12 [PATCH 0/2] some splitfx improvements Eric Wong
@ 2020-04-09 20:12 ` Eric Wong
  2020-04-09 20:12 ` [PATCH 2/2] splitfx: support --err-suffix option Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2020-04-09 20:12 UTC (permalink / raw)
  To: dtas-all

We can flush when all comments are buffered to avoid a writev(2)
syscall on every comment.
---
 lib/dtas/splitfx.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index 8ad919e..384df0f 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -207,11 +207,11 @@ def splitfx_spawn(target, t, opts)
       env["DITHERFX"] = "dither -s"
     end
     comments = Tempfile.new(%W(dtas-splitfx-#{t.comments["TRACKNUMBER"]} .txt))
-    comments.sync = true
     t.comments.each do |k,v|
       env[k] = v.to_s
       comments.puts("#{k}=#{v}")
     end
+    comments.flush
     env["COMMENTS"] = "--comment-file=#{comments.path}"
     infile_env(env, @infile)
     outarg = outfmt.to_sox_arg


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] splitfx: support --err-suffix option
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2020-04-09 20:12 UTC (permalink / raw)
  To: dtas-all

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)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-04-09 20:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/2] splitfx: support --err-suffix option Eric Wong

Code repositories for project(s) associated with this public inbox

	http://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).