about summary refs log tree commit homepage
path: root/test/test_fadefx.rb
blob: 5c8457847813e3ef56faeae02f14d119f37665c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
require_relative 'helper'
require 'dtas/fadefx'
require 'dtas/format'

class TestFadeFX < Testcase
  def test_fadefx
    ffx = DTAS::FadeFX.new("t1,t3.1;l4,t1")
    assert_equal 't', ffx.out_prev.type
    assert_equal 1, ffx.out_prev.flen
    assert_equal 't', ffx.in_cur.type
    assert_equal 3.1, ffx.in_cur.flen
    assert_equal 'l', ffx.out_cur.type
    assert_equal 4, ffx.out_cur.flen
    assert_equal 't', ffx.in_next.type
    assert_equal 1, ffx.in_next.flen

    fmt = DTAS::Format.new
    fmt.rate = 48000
    tbeg = 0
    tlen = 48000 * 9

    # XXX: this isn't testing much...
    cur = ffx.fade_cur_fx(fmt, tbeg, tlen, %w(vol +3dB))
    assert_equal(%w(trim 0s 432000s vol +3dB
                    fade t 3.1 0 0 fade l 0 432000s 4), cur)
    out = ffx.fade_out_prev_fx(fmt, tbeg, tlen)
    assert_equal(%w(trim 0s
                    fade t 0 48000s 48000s pad 384000s@48000s), out)
    inn = ffx.fade_in_next_fx(fmt, tbeg, tlen)
    assert_equal(%w(trim 384000s 48000s
                    fade t 48000s 0 0 pad 384000s@0s), inn)
  end

  def test_fadefx_no_cur
    ffx = DTAS::FadeFX.new("t1,;,t1")
    assert_equal 't', ffx.out_prev.type
    assert_equal 1, ffx.out_prev.flen
    assert_nil ffx.in_cur
    assert_nil ffx.out_cur
    assert_equal 't', ffx.in_next.type
    assert_equal 1, ffx.in_next.flen
  end
end