diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-10-17 06:36:28 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-17 06:36:28 +0000 |
commit | 27157b3a8cf6d2e37d80dfa130b56711dcb8cd28 (patch) | |
tree | 37dedc444a2b2d723954ae67214d6e03ad9a86ca /lib/dtas | |
parent | 605b8403bec9607b2aa818ca9e1daeea607e89fa (diff) | |
download | dtas-27157b3a8cf6d2e37d80dfa130b56711dcb8cd28.tar.gz |
This allows parsing and will eventually interact with trimfx.
Diffstat (limited to 'lib/dtas')
-rw-r--r-- | lib/dtas/fadefx.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/dtas/fadefx.rb b/lib/dtas/fadefx.rb new file mode 100644 index 0000000..7e0e65f --- /dev/null +++ b/lib/dtas/fadefx.rb @@ -0,0 +1,32 @@ +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +require_relative '../dtas' +require_relative 'parse_time' + +class DTAS::FadeFX + include DTAS::ParseTime + attr_reader :out_prev, :in_main, :out_main, :in_next + F = Struct.new(:type, :len) + + def initialize(args) + args =~ /\Afade=([^,]*),([^,]*);([^,]*),([^,]*)\z/ or + raise ArgumentError, "bad fade format" + fades = [ $1, $2, $3, $4 ] + %w(out_prev in_main out_main in_next).each do |iv| + instance_variable_set("@#{iv}", parse!(fades.shift)) + end + end + + # q - quarter of a sine wave + # h - half a sine wave + # t - linear (`triangular') slope + # l - logarithmic + # p - inverted parabola + # default is 't' (sox defaults to 'l', but triangular makes more sense + # when concatenating + def parse!(str) + type = "t" + str.sub!(/\A([a-z])/, "") and type = $1 + F[type, parse_time(str)] + end +end |