diff options
author | Eric Wong <e@80x24.org> | 2015-01-03 01:33:52 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-01-03 02:16:36 +0000 |
commit | 22d62a37c510737f5c46bd507c1e09cbbe52eb36 (patch) | |
tree | f1f48578f170234738aa2a76af603603aa5ddcfa /lib | |
parent | 7a43e7b2f7b483c0aee9cf01b8a15778dee69d5b (diff) | |
download | dtas-22d62a37c510737f5c46bd507c1e09cbbe52eb36.tar.gz |
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).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dtas/splitfx.rb | 27 |
1 files 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 |