Class: DTAS::TrimFX
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#tbeg ⇒ Object
readonly
Returns the value of attribute tbeg.
-
#tlen ⇒ Object
readonly
Returns the value of attribute tlen.
Instance Method Summary collapse
-
#initialize(args) ⇒ TrimFX
constructor
A new instance of TrimFX.
- #parse_trim!(args) ⇒ Object
- #tfx_eca(args) ⇒ Object
- #tfx_sox(args) ⇒ Object
- #to_sox_arg(format) ⇒ Object
Methods included from ParseTime
Constructor Details
#initialize(args) ⇒ TrimFX
Returns a new instance of TrimFX.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/dtas/trimfx.rb', line 14 def initialize(args) args = args.dup case args.shift when "trim" parse_trim!(args) when "all" @tbeg = 0 @tlen = nil else raise ArgumentError, "#{args.inspect} not understood" end case tmp = args.shift when "sh" then @cmd = args when "sox" then tfx_sox(args) when "eca" then tfx_eca(args) when nil @cmd = [] else raise ArgumentError, "unknown effect type: #{tmp}" end end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd.
12 13 14 |
# File 'lib/dtas/trimfx.rb', line 12 def cmd @cmd end |
#tbeg ⇒ Object (readonly)
Returns the value of attribute tbeg.
10 11 12 |
# File 'lib/dtas/trimfx.rb', line 10 def tbeg @tbeg end |
#tlen ⇒ Object (readonly)
Returns the value of attribute tlen.
11 12 13 |
# File 'lib/dtas/trimfx.rb', line 11 def tlen @tlen end |
Instance Method Details
#parse_trim!(args) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/dtas/trimfx.rb', line 63 def parse_trim!(args) tbeg = parse_time(args.shift) if args[0] =~ /\A=?[\d\.]+\z/ tlen = args.shift is_stop_time = tlen.sub!(/\A=/, "") ? true : false tlen = parse_time(tlen) if is_stop_time tlen = tlen - tbeg end else tlen = nil end @tbeg = tbeg @tlen = tlen end |
#tfx_eca(args) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/dtas/trimfx.rb', line 42 def tfx_eca(args) @cmd = %w(sox $SOXIN $SOX2ECA $TRIMFX) @cmd.concat(%w(| ecasound $ECAFMT -i stdin -o stdout)) @cmd.concat(args) @cmd.concat(%w(| sox $ECA2SOX - $SOXOUT $FADEFX)) end |
#tfx_sox(args) ⇒ Object
36 37 38 39 40 |
# File 'lib/dtas/trimfx.rb', line 36 def tfx_sox(args) @cmd = %w(sox $SOXIN $SOXOUT $TRIMFX) @cmd.concat(args) @cmd.concat(%w($FADEFX)) end |
#to_sox_arg(format) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dtas/trimfx.rb', line 49 def to_sox_arg(format) if @tbeg && @tlen beg = @tbeg * format.rate len = @tlen * format.rate %W(trim #{beg.round}s #{len.round}s) elsif @tbeg return [] if @tbeg == 0 beg = @tbeg * format.rate %W(trim #{beg.round}s) else [] end end |