about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2014-12-29 06:35:09 +0000
committerEric Wong <e@80x24.org>2014-12-29 06:50:38 +0000
commit3ce3983c3cb958fa0c7f946c331914134b5c43b7 (patch)
tree9da37a5864f776ebbe1ab976f058417edd25a28f /test
parent2004631d2c9ca793fa4f4832a289ca80aa1d5237 (diff)
downloaddtas-3ce3983c3cb958fa0c7f946c331914134b5c43b7.tar.gz
This makes things easier for scheduling/expansion since we
won't have to deal with floating point numbers when we work
directly with with sample counts (like the rest of dtas).
Diffstat (limited to 'test')
-rw-r--r--test/test_trimfx.rb28
1 files changed, 16 insertions, 12 deletions
diff --git a/test/test_trimfx.rb b/test/test_trimfx.rb
index a8fd902..a59ad73 100644
--- a/test/test_trimfx.rb
+++ b/test/test_trimfx.rb
@@ -6,6 +6,10 @@ require 'dtas/format'
 require 'yaml'
 
 class TestTrimFX < Testcase
+  def rate
+    44100
+  end
+
   def test_example
     ex = YAML.load(File.read("examples/trimfx.sample.yml"))
     effects = []
@@ -14,8 +18,8 @@ class TestTrimFX < Testcase
       case words[0]
       when "trim"
         tfx = DTAS::TrimFX.new(words)
-        assert_equal 52.0, tfx.tbeg
-        assert_equal 1.0, tfx.tlen
+        assert_equal 52 * rate, tfx.tbeg
+        assert_equal rate, tfx.tlen
         effects << tfx
       end
     end
@@ -26,21 +30,21 @@ class TestTrimFX < Testcase
     tfx = DTAS::TrimFX.new(%w(all))
     assert_equal 0, tfx.tbeg
     assert_nil tfx.tlen
-    assert_equal [], tfx.to_sox_arg(DTAS::Format.new)
+    assert_equal [], tfx.to_sox_arg
   end
 
   def test_time
     tfx = DTAS::TrimFX.new(%w(trim 2:30 3.1))
-    assert_equal 150, tfx.tbeg
-    assert_equal 3.1, tfx.tlen
+    assert_equal 150 * rate, tfx.tbeg
+    assert_equal((3.1 * rate).round, tfx.tlen)
   end
 
   def test_to_sox_arg
     tfx = DTAS::TrimFX.new(%w(trim 1 0.5))
-    assert_equal %w(trim 44100s 22050s), tfx.to_sox_arg(DTAS::Format.new)
+    assert_equal %w(trim 44100s 22050s), tfx.to_sox_arg
 
     tfx = DTAS::TrimFX.new(%w(trim 1 sox vol -1dB))
-    assert_equal %w(trim 44100s), tfx.to_sox_arg(DTAS::Format.new)
+    assert_equal %w(trim 44100s), tfx.to_sox_arg
   end
 
   def test_tfx_effects
@@ -56,8 +60,8 @@ class TestTrimFX < Testcase
     ].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)
+    assert_equal [ 22050, 44100, 88200 ], ary[0].map(&:tbeg)
+    assert_equal [ 22050, 13230, 8820 ], ary[0].map(&:tlen)
   end
 
   def test_schedule_overlaps
@@ -68,10 +72,10 @@ class TestTrimFX < Testcase
     ]
     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)
+    assert_equal [ 22050, 44100 ], ary[0].map(&:tbeg)
+    assert_equal [ 48510 ], ary[1].map(&:tbeg)
 
-    ex = DTAS::TrimFX.expand(fx, 10)
+    ex = DTAS::TrimFX.expand(fx, 10 * rate)
     assert_equal 2, ex.size
     assert_equal 0, ex[0][0].tbeg
     assert_equal 3, ex[0].size