changeset 168:45199077b043

Start on audiofile tests
author Chris Cannam
date Thu, 02 May 2013 09:29:10 +0100
parents 463437b9e625
children fb0000d15b53
files yetilab/stream/test/test_audiofile.yeti yetilab/test/all.yeti
diffstat 2 files changed, 43 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yetilab/stream/test/test_audiofile.yeti	Thu May 02 09:29:10 2013 +0100
@@ -0,0 +1,42 @@
+
+module yetilab.stream.test.test_audiofile;
+
+af = load yetilab.stream.audiofile;
+bl = load yetilab.block.block;
+
+{ compare } = load yetilab.test.test;
+
+testfile name = "yetilab/test/data/\(name).wav";
+
+float n is number -> number =
+    // round number to float precision (for comparison with floats)
+   (arr = new float[1];
+    arr[0] := n;
+    arr[0]);
+
+[ 
+
+"20samples-open": \(
+    f = af.open (testfile "20samples");
+    compare f.position 0 and
+        compare f.channels 1 and
+        compare f.sampleRate 44100 and
+        compare f.available (Known 20) and
+        compare f.finished? false and
+        ( f.close () ; true )
+),
+
+"20samples-read": \(
+    f = af.open (testfile "20samples");
+    first15 = f.read 15;
+    last5 = f.read 10;
+    compare first15.size { rows = 1, columns = 15 } and
+        compare last5.size { rows = 1, columns = 5 } and
+        compare (bl.list (first15.getRow 0))
+            [ float (32767/32768),0,0,0,0,0,0,0,0,0,0,0,0,0,0 ] and
+        compare (bl.list (last5.getRow 0)) [ 0,0,0,0,-1 ] and
+        ( f.close () ; true )
+),
+
+] is hash<string, () -> boolean>
+
--- a/yetilab/test/all.yeti	Thu May 02 09:14:56 2013 +0100
+++ b/yetilab/test/all.yeti	Thu May 02 09:29:10 2013 +0100
@@ -9,6 +9,7 @@
 "complex"    : load yetilab.block.test.test_complex,
 "framer"     : load yetilab.stream.test.test_framer,
 "channels"   : load yetilab.stream.test.test_channels,
+"audiofile"  : load yetilab.stream.test.test_audiofile,
 "fft"        : load yetilab.transform.test.test_fft,
 "vamppost"   : load yetilab.vamp.test.test_vamppost,
 "vamp"       : load yetilab.vamp.test.test_vamp,