From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 208.118.235.0/24 X-Spam-Status: No, score=-6.9 required=3.0 tests=BAYES_00,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: dtas-all@80x24.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 9E4CC1FA74 for ; Sat, 3 Jan 2015 03:09:07 +0000 (UTC) Received: from localhost ([::1]:53360 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7F5O-0006dM-W0 for dtas-all@80x24.org; Fri, 02 Jan 2015 22:09:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7F5M-0006aR-Gg for dtas-all@nongnu.org; Fri, 02 Jan 2015 22:09:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y7F5G-0004vO-CE for dtas-all@nongnu.org; Fri, 02 Jan 2015 22:09:04 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:47303) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7F5G-0004vK-7H for dtas-all@nongnu.org; Fri, 02 Jan 2015 22:08:58 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 206781FA70 for ; Sat, 3 Jan 2015 03:08:55 +0000 (UTC) From: Eric Wong To: Subject: [PATCH] dtas-splitfx: use the top-level command used by -player Date: Sat, 3 Jan 2015 03:08:53 +0000 Message-Id: <1420254534-9581-2-git-send-email-e@80x24.org> X-Mailer: git-send-email 2.2.1.202.g55b961f X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.71.152.64 X-BeenThere: dtas-all@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dtas-all-bounces+dtas-all=80x24.org@nongnu.org Sender: dtas-all-bounces+dtas-all=80x24.org@nongnu.org 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