From: Eric Wong <e@80x24.org>
To: <dtas-all@nongnu.org>
Subject: [PATCH] splitfx: add INDIR and INBASE environment variables
Date: Sat, 3 Jan 2015 03:08:52 +0000 [thread overview]
Message-ID: <1420254534-9581-1-git-send-email-e@80x24.org> (raw)
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
reply other threads:[~2015-01-03 3:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://80x24.org/dtas/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420254534-9581-1-git-send-email-e@80x24.org \
--to=e@80x24.org \
--cc=dtas-all@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://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).