about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--Documentation/dtas-splitfx.txt4
-rw-r--r--lib/dtas/splitfx.rb22
2 files changed, 16 insertions, 10 deletions
diff --git a/Documentation/dtas-splitfx.txt b/Documentation/dtas-splitfx.txt
index beee4bf..91894d1 100644
--- a/Documentation/dtas-splitfx.txt
+++ b/Documentation/dtas-splitfx.txt
@@ -101,8 +101,10 @@ use in targets:
 * INFILE - this matches the "infile" directive in the YAML file
 * INDIR - the directory INFILE belongs to, without trailing slash
 * INBASE - the basename of INFILE
+* TBEG - the integer sample offset where the sox(1) trim effect starts
+* TLEN - the integer sample count representing the length of the trim
 * TRIMFX - essential, this supplys the necessary sox(1) trim effect to
-  each track.
+  each track. In other words, this is: "trim ${TBEG}s ${TLEN}s"
 * COMMENTS - expands to --comment-file=PATH for sox(1)
 * OUTFMT - sox(1) arguments for the output format (e.g. "-ts32 -c2 * -r44100")
 * SUFFIX - the suffix of the output format without "." (e.g. "flac", "ogg")
diff --git a/lib/dtas/splitfx.rb b/lib/dtas/splitfx.rb
index 2335636..71b716a 100644
--- a/lib/dtas/splitfx.rb
+++ b/lib/dtas/splitfx.rb
@@ -14,16 +14,16 @@ class DTAS::SplitFX # :nodoc:
   include DTAS::XS
   attr_reader :infile, :env
 
-  class Skip < Struct.new(:tstart) # :nodoc:
+  class Skip < Struct.new(:tbeg) # :nodoc:
     def commit(_)
       # noop
     end
   end
 
-  class T < Struct.new(:env, :comments, :tstart, :fade_in, :fade_out) # :nodoc:
+  class T < Struct.new(:env, :comments, :tbeg, :fade_in, :fade_out) # :nodoc:
     def commit(advance_track_samples)
-      tlen = advance_track_samples - tstart
-      trimfx = "trim #{tstart}s #{tlen}s"
+      tlen = advance_track_samples - tbeg
+      trimfx = "trim #{tbeg}s #{tlen}s"
       if fade_in
         trimfx << " #{fade_in}"
       end
@@ -35,6 +35,10 @@ class DTAS::SplitFX # :nodoc:
         fade = " fade #{fade_type} 0 #{tlen}s #{fade_out_len}"
         trimfx << fade
       end
+
+      # raw sample counts (without 's' suffix)
+      env["TBEG"] = tbeg.to_s
+      env["TLEN"] = tlen.to_s
       env["TRIMFX"] = trimfx
     end
   end
@@ -255,7 +259,7 @@ class DTAS::SplitFX # :nodoc:
       start_time = argv.shift
       title = argv.shift
       t = T.new
-      t.tstart = @t2s.call(start_time)
+      t.tbeg = @t2s.call(start_time)
       t.comments = @comments.dup
       t.comments["TITLE"] = title
       t.env = @env.dup
@@ -274,17 +278,17 @@ class DTAS::SplitFX # :nodoc:
         end
       end
 
-      prev = @tracks.last and prev.commit(t.tstart)
+      prev = @tracks.last and prev.commit(t.tbeg)
       @tracks << t
     when "skip"
       stop_time = argv.shift
       argv.empty? or raise ArgumentError, "skip does not take extra args"
       s = Skip.new
-      s.tstart = @t2s.call(stop_time)
+      s.tbeg = @t2s.call(stop_time)
       # s.comments = {}
       # s.env = {}
       prev = @tracks.last or raise ArgumentError, "no tracks to skip"
-      prev.commit(s.tstart)
+      prev.commit(s.tbeg)
       @tracks << s
     when "stop"
       stop_time = argv.shift
@@ -352,7 +356,7 @@ class DTAS::SplitFX # :nodoc:
   def cuebreakpoints
     rv = @cuebp and return rv
     require_relative 'cue_index'
-    @cuebp = @tracks.map { |t| DTAS::CueIndex.new(1, "#{t.tstart}s") }
+    @cuebp = @tracks.map { |t| DTAS::CueIndex.new(1, "#{t.tbeg}s") }
   end
 
   def infile_env(env, infile)