From 34a5c2c0ae02d261191442acc3907f2346bf2f95 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 23 Jun 2014 07:21:30 +0000 Subject: trimfx: initial cut of scheduling + gap filling The names are subject to change, but the idea is to make multiple passes over the audio if effects overlap and combine everything afterwards. Unedited portions will be passed through sox (via trim and no other effects) --- test/test_trimfx.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'test') diff --git a/test/test_trimfx.rb b/test/test_trimfx.rb index ff40594..3a3bdc0 100644 --- a/test/test_trimfx.rb +++ b/test/test_trimfx.rb @@ -47,4 +47,35 @@ class TestTrimFX < Testcase tfx = DTAS::TrimFX.new(%w(trim 1 sox vol -1dB)) assert_equal %w(sox $SOXIN $SOXOUT $TRIMFX vol -1dB $FADEFX), tfx.cmd end + + def test_schedule_simple + fx = [ + DTAS::TrimFX.new(%w(trim 1 0.3)), + DTAS::TrimFX.new(%w(trim 2 0.2)), + DTAS::TrimFX.new(%w(trim 0.5 0.5)), + ].shuffle + ary = DTAS::TrimFX.schedule(fx) + assert_operator 1, :==, ary.size + assert_equal [ 0.5, 1, 2 ], ary[0].map(&:tbeg) + assert_equal [ 0.5, 0.3, 0.2 ], ary[0].map(&:tlen) + end + + def test_schedule_overlaps + fx = [ + DTAS::TrimFX.new(%w(trim 1 0.3 sox)), + DTAS::TrimFX.new(%w(trim 1.1 0.2 sox)), + DTAS::TrimFX.new(%w(trim 0.5 0.5 sox)), + ] + ary = DTAS::TrimFX.schedule(fx) + assert_equal 2, ary.size + assert_equal [ 0.5, 1 ], ary[0].map(&:tbeg) + assert_equal [ 1.1 ], ary[1].map(&:tbeg) + + ex = DTAS::TrimFX.expand(fx, 10) + assert_equal 2, ex.size + assert_equal 0, ex[0][0].tbeg + assert_equal 3, ex[0].size + assert_equal 0, ex[1][0].tbeg + assert_equal 3, ex[1].size + end end -- cgit v1.2.3-24-ge0c7