Mercurial > hg > may
view yetilab/stream/test/test_audiofile.yeti @ 218:a7f4eb1cdd72 matrix_opaque_immutable
More block -> vector
author | Chris Cannam |
---|---|
date | Sat, 11 May 2013 12:04:05 +0100 |
parents | 26111c11d8e4 |
children | 77c6a81c577f |
line wrap: on
line source
module yetilab.stream.test.test_audiofile; af = load yetilab.stream.audiofile; vec = load yetilab.block.vector; mat = load yetilab.matrix.matrix; { 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": \( all id (map do opener: f = opener (testfile "20samples"); first15 = f.read 15; last5 = f.read 10; compare (mat.size first15) { rows = 1, columns = 15 } and compare (mat.size last5) { rows = 1, columns = 5 } and compare (vec.list (mat.getRow 0 first15)) [ float (32767/32768),0,0,0,0,0,0,0,0,0,0,0,0,0,0 ] and compare (vec.list (mat.getRow 0 last5)) [ 0,0,0,0,-1 ] and ( f.close () ; true ) done [ af.open, af.openMono ]); ), ] is hash<string, () -> boolean>