annotate yeti/test.yeti @ 65:bb1799a6d690

Pull out tests
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 14 Feb 2014 11:55:03 +0000
parents 5b6c000589a7
children 3d165bf186f1
rev   line source
c@37 1
c@37 2 program test;
c@65 3 /*
c@37 4 af = load may.stream.audiofile;
c@37 5 plot = load may.plot;
c@37 6 cm = load may.matrix.complex;
c@37 7 mat = load may.matrix;
c@37 8 vec = load may.vector;
c@59 9 win = load may.signal.window;
c@59 10 mm = load may.mathmisc;
c@37 11 manipulate = load may.stream.manipulate;
c@37 12 syn = load may.stream.syntheticstream;
c@65 13 */
c@37 14
c@65 15 { runTests } = load may.test;
c@65 16
c@65 17 //{ makeKernel } = load cqtkernel;
c@65 18 //{ cqt } = load cqt;
c@37 19
c@60 20 // We want to test:
c@60 21 //
c@60 22 // Kernel design -- check size (number of bins, number of atoms);
c@60 23 // check an example kernel against known data
c@60 24 //
c@60 25 // Time alignment -- feed a dirac train, check that peaks in all bins
c@60 26 // align
c@60 27 //
c@60 28 // Frequency discrimination -- feed a sinusoid, check peaks
c@60 29 //
c@60 30 // Latency compensation -- for dirac at 0, check peak can be found at
c@60 31 // 0 plus the declared latency
c@60 32 //
c@60 33 // Signal-noise ratio
c@60 34 //
c@60 35 // Specimen output for simple test case
c@60 36
c@65 37 tests = [
c@65 38 "kernel" : load test_cqtkernel,
c@65 39 "frequency" : load test_frequency,
c@65 40 ];
c@59 41
c@65 42 bad = sum (mapHash do name testHash: runTests name testHash done tests);
c@59 43
c@65 44 if (bad > 0) then
c@65 45 println "\n** \(bad) test(s) failed!";
c@65 46 threadExit 1
c@65 47 else
c@65 48 ()
c@65 49 fi
c@59 50
c@59 51
c@59 52
c@59 53
c@59 54 /*
c@37 55 //testStream = manipulate.withDuration 96000 (syn.sinusoid 48000 500);
c@37 56 //testStream = manipulate.withDuration 96000 (syn.pulseTrain 48000 4);
c@44 57 testStream = af.open "sweep-48000.wav";
c@37 58 //testStream = af.open "sweep.wav";
c@37 59
c@43 60 // So the stream is [ 0, 1, 0, -1, 0, 1, 0, -1, ... ] :
c@44 61 //testStream = manipulate.withDuration 64 (syn.sinusoid 8 2);
c@38 62
c@56 63 testStream = manipulate.withDuration 32 (syn.pulseTrain 8 0.001);
c@37 64
c@37 65 eprintln "have test stream";
c@37 66
c@44 67 cq = cqt { maxFreq = testStream.sampleRate/2, minFreq = 50, binsPerOctave = 24 } testStream;
c@37 68
c@40 69 eprintln "bin frequencies: \(cq.kernel.binFrequencies)";
c@40 70
c@40 71 bigM = mat.concatHorizontal (map cm.magnitudes cq.output);
c@37 72
c@38 73 eprintln "overall output size = \(mat.size bigM)";
c@38 74
c@39 75 mat.print bigM;
c@38 76
c@38 77 //\() (plot.plot [Contour bigM]);
c@56 78 \() (plot.plot [Grid bigM]);
c@59 79 */
c@65 80 //()
c@37 81