about summary refs log tree commit homepage
path: root/lib/dtas
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-01-19 08:42:09 +0000
committerEric Wong <e@80x24.org>2015-01-19 09:58:47 +0000
commit723cd6da883bda87e092707ce17c31190a1c5205 (patch)
treec43b78e599006063b41c0fe99d52a9e851e44d59 /lib/dtas
parent72977765a3c30f2a8a89ccbf23fde8289c81bdf9 (diff)
downloaddtas-723cd6da883bda87e092707ce17c31190a1c5205.tar.gz
These are the raw sample counts for the "trim" effect
and may be useful for arithmetic in the shell.
Diffstat (limited to 'lib/dtas')
-rw-r--r--lib/dtas/splitfx.rb22
1 files changed, 13 insertions, 9 deletions
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)