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 C3F871FA70 for ; Sat, 3 Jan 2015 03:09:03 +0000 (UTC) Received: from localhost ([::1]:53358 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7F5K-0006XQ-Qr for dtas-all@80x24.org; Fri, 02 Jan 2015 22:09:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53166) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7F5I-0006TY-AI for dtas-all@nongnu.org; Fri, 02 Jan 2015 22:09:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y7F5E-0004vD-Ud for dtas-all@nongnu.org; Fri, 02 Jan 2015 22:09:00 -0500 Received: from dcvr.yhbt.net ([64.71.152.64]:47302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y7F5E-0004sT-Oo for dtas-all@nongnu.org; Fri, 02 Jan 2015 22:08:56 -0500 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E9D831F7BA for ; Sat, 3 Jan 2015 03:08:54 +0000 (UTC) From: Eric Wong To: Subject: [PATCH] splitfx: add INDIR and INBASE environment variables Date: Sat, 3 Jan 2015 03:08:52 +0000 Message-Id: <1420254534-9581-1-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 These are intended to act like `$(@D)' and `$(@F)' in GNU make(1) and to ease managing temporary files for some effects (e.g. noiseprof + noisered in sox) for splitfx users. --- Documentation/dtas-splitfx.txt | 2 ++ lib/dtas/source/splitfx.rb | 5 +++-- lib/dtas/splitfx.rb | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Documentation/dtas-splitfx.txt b/Documentation/dtas-splitfx.txt index 5aa3086..0fd2f3a 100644 --- a/Documentation/dtas-splitfx.txt +++ b/Documentation/dtas-splitfx.txt @@ -99,6 +99,8 @@ dtas-splitfx sets several default environment variables for commands to use in targets: * INFILE - this matches the "infile" directive in the YAML file +* INDIR - the directory INFILE belongs to +* INBASE - the basename of INFILE * TRIMFX - essential, this supplys the necessary sox(1) trim effect to each track. * COMMENTS - expands to --comment-file=PATH for sox(1) diff --git a/lib/dtas/source/splitfx.rb b/lib/dtas/source/splitfx.rb index 5340f3d..19b2c16 100644 --- a/lib/dtas/source/splitfx.rb +++ b/lib/dtas/source/splitfx.rb @@ -7,7 +7,7 @@ require_relative 'watchable' class DTAS::Source::SplitFX < DTAS::Source::Sox # :nodoc: MAX_YAML_SIZE = 512 * 1024 - attr_writer :sox + attr_writer :sox, :sfx include DTAS::Source::Watchable if defined?(DTAS::Source::Watchable) SPLITFX_DEFAULTS = SOX_DEFAULTS.merge( @@ -45,6 +45,7 @@ class DTAS::Source::SplitFX < DTAS::Source::Sox # :nodoc: rv = source_file_dup(ymlfile, offset) rv.sox = sox rv.env = sfx.env + rv.sfx = sfx rv rescue => e warn "#{e.message} (#{e.class})" @@ -62,7 +63,7 @@ class DTAS::Source::SplitFX < DTAS::Source::Sox # :nodoc: def spawn(player_format, rg_state, opts) raise "BUG: #{self.inspect}#spawn called twice" if @to_io e = @env.merge!(player_format.to_env) - e["INFILE"] = @sox.infile + @sfx.infile_env(e, @sox.infile) # make sure these are visible to the "current" command... e["TRIMFX"] = @offset ? "trim #@offset" : nil diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb index 36cdf9f..e31972a 100644 --- a/lib/dtas/splitfx.rb +++ b/lib/dtas/splitfx.rb @@ -187,7 +187,7 @@ class DTAS::SplitFX # :nodoc: comments.puts("#{k}=#{v}") end env["COMMENTS"] = "--comment-file=#{comments.path}" - env["INFILE"] = @infile + infile_env(env, @infile) env["OUTFMT"] = xs(outfmt.to_sox_arg) env["SUFFIX"] = outfmt.type env.merge!(t.env) @@ -342,4 +342,9 @@ class DTAS::SplitFX # :nodoc: require_relative 'cue_index' @cuebp = @tracks.map { |t| DTAS::CueIndex.new(1, "#{t.tstart}s") } end + + def infile_env(env, infile) + env["INFILE"] = infile + env["INDIR"], env["INBASE"] = File.split(File.expand_path(infile)) + end end -- EW