Class: DTAS::SplitFX::T

Inherits:
Struct
  • Object
show all
Defined in:
lib/dtas/splitfx.rb

Overview

a standard “track” for splitfx

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commentsObject

Returns the value of attribute comments

Returns:

  • (Object)

    the current value of comments



36
37
38
# File 'lib/dtas/splitfx.rb', line 36

def comments
  @comments
end

#envObject

Returns the value of attribute env

Returns:

  • (Object)

    the current value of env



36
37
38
# File 'lib/dtas/splitfx.rb', line 36

def env
  @env
end

#fade_inObject

Returns the value of attribute fade_in

Returns:

  • (Object)

    the current value of fade_in



36
37
38
# File 'lib/dtas/splitfx.rb', line 36

def fade_in
  @fade_in
end

#fade_outObject

Returns the value of attribute fade_out

Returns:

  • (Object)

    the current value of fade_out



36
37
38
# File 'lib/dtas/splitfx.rb', line 36

def fade_out
  @fade_out
end

#tbegObject

Returns the value of attribute tbeg

Returns:

  • (Object)

    the current value of tbeg



36
37
38
# File 'lib/dtas/splitfx.rb', line 36

def tbeg
  @tbeg
end

Instance Method Details

#commit(advance_track_samples) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/dtas/splitfx.rb', line 37

def commit(advance_track_samples)
  tlen = advance_track_samples - tbeg
  trimfx = "trim #{tbeg}s #{tlen}s".dup
  if fade_in
    # generate fade-in effect
    # $1 = "t 4" => "fade t 4 0 0"
    tmp = fade_in.dup
    fade_in_len = tmp.pop or
                     raise ArgumentError, 'fade_in needs a time value'
    fade_type = tmp.pop # may be nil
    fade = " fade #{fade_type} #{fade_in_len} 0 0"
    trimfx << fade
  end
  if fade_out
    tmp = fade_out.dup
    fade_out_len = tmp.pop or
                     raise ArgumentError, "fade_out needs a time value"
    fade_type = tmp.pop # may be nil
    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