about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-01-03 01:09:02 +0000
committerEric Wong <e@80x24.org>2015-01-03 01:09:02 +0000
commit7a43e7b2f7b483c0aee9cf01b8a15778dee69d5b (patch)
treecca7f675d592f8875f2bbcf71eebb2efd24b2482 /lib
parent54956f0529053fbf7a10c44419d97836e7817a6e (diff)
downloaddtas-7a43e7b2f7b483c0aee9cf01b8a15778dee69d5b.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/dtas/source/splitfx.rb5
-rw-r--r--lib/dtas/splitfx.rb7
2 files changed, 9 insertions, 3 deletions
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