everything related to duct tape audio suite (dtas)
 help / color / Atom feed
* [PATCH] dtas-splitfx: use the top-level command used by -player
@ 2015-01-03  3:08 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-01-03  3:08 UTC (permalink / raw)
  To: dtas-all

If somebody is using dtas-player to help edit a file for
dtas-splitfx, it is likely they will want to use it when
generating the final files (regardless of "target" format).
---
 lib/dtas/splitfx.rb | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index e31972a..dac2a97 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -78,6 +78,7 @@ class DTAS::SplitFX # :nodoc:
     @tracks = []
     @infmt = nil # wait until input is assigned
     @cuebp = nil # for playback
+    @command = nil # top-level, for playback
   end
 
   def _bool(hash, key)
@@ -134,6 +135,7 @@ class DTAS::SplitFX # :nodoc:
 
     load_input!(hash)
     load_tracks!(hash)
+    @command = hash["command"] # nil by default
   end
 
   def load_input!(hash)
@@ -193,10 +195,23 @@ class DTAS::SplitFX # :nodoc:
     env.merge!(t.env)
 
     command = target["command"]
-    tmp = Shellwords.split(command).map do |arg|
-      qx(env, "printf %s \"#{arg}\"")
+
+    # if a default dtas-player command is set, use that.
+    # we'll clobber our default environment since we assume play_cmd
+    # already takes those into account.  In other words, use our
+    # target-specific commands like a dtas-player sink:
+    #   @command | (INFILE= FX= TRIMFX=; target['command'])
+    if player_cmd = @command
+      sub_env = { 'INFILE' => '-', 'FX' => '', 'TRIMFX' => '' }
+      sub_env_s = sub_env.inject("") { |s,(k,v)| s << "#{k}=#{v} " }
+      command = "#{player_cmd} | (#{sub_env_s}; #{command})"
+      show_cmd = [ _expand_cmd(env, player_cmd), '|', '(', "#{sub_env_s};",
+                   _expand_cmd(env.merge(sub_env), command), ')' ].flatten
+    else
+      show_cmd = _expand_cmd(env, command)
     end
-    echo = "echo #{xs(tmp)}"
+
+    echo = "echo #{xs(show_cmd)}"
     if opts[:dryrun]
       command = echo
     else
@@ -347,4 +362,10 @@ class DTAS::SplitFX # :nodoc:
     env["INFILE"] = infile
     env["INDIR"], env["INBASE"] = File.split(File.expand_path(infile))
   end
+
+  def _expand_cmd(env, command)
+    Shellwords.split(command).map do |arg|
+      qx(env, "printf %s \"#{arg}\"")
+    end
+  end
 end
-- 
EW



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-03  3:08 [PATCH] dtas-splitfx: use the top-level command used by -player Eric Wong

everything related to duct tape audio suite (dtas)

Archives are clonable:
	git clone --mirror https://80x24.org/dtas-all
	git clone --mirror http://ou63pmih66umazou.onion/dtas-all

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.audio.dtas
	nntp://ou63pmih66umazou.onion/inbox.comp.audio.dtas

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git