annotate yeti/test.yeti @ 69:27007f8302f4

Copyrights, licence
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 12 Mar 2014 08:53:45 +0000
parents 3d165bf186f1
children
rev   line source
c@69 1 /*
c@69 2 Constant-Q library
c@69 3 Copyright (c) 2013-2014 Queen Mary, University of London
c@69 4
c@69 5 Permission is hereby granted, free of charge, to any person
c@69 6 obtaining a copy of this software and associated documentation
c@69 7 files (the "Software"), to deal in the Software without
c@69 8 restriction, including without limitation the rights to use, copy,
c@69 9 modify, merge, publish, distribute, sublicense, and/or sell copies
c@69 10 of the Software, and to permit persons to whom the Software is
c@69 11 furnished to do so, subject to the following conditions:
c@69 12
c@69 13 The above copyright notice and this permission notice shall be
c@69 14 included in all copies or substantial portions of the Software.
c@69 15
c@69 16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
c@69 17 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
c@69 18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
c@69 19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
c@69 20 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
c@69 21 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
c@69 22 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
c@69 23
c@69 24 Except as contained in this notice, the names of the Centre for
c@69 25 Digital Music; Queen Mary, University of London; and Chris Cannam
c@69 26 shall not be used in advertising or otherwise to promote the sale,
c@69 27 use or other dealings in this Software without prior written
c@69 28 authorization.
c@69 29 */
c@37 30
c@37 31 program test;
c@37 32
c@65 33 { runTests } = load may.test;
c@65 34
c@60 35 // We want to test:
c@60 36 //
c@60 37 // Kernel design -- check size (number of bins, number of atoms);
c@60 38 // check an example kernel against known data
c@60 39 //
c@60 40 // Time alignment -- feed a dirac train, check that peaks in all bins
c@60 41 // align
c@60 42 //
c@60 43 // Frequency discrimination -- feed a sinusoid, check peaks
c@60 44 //
c@60 45 // Latency compensation -- for dirac at 0, check peak can be found at
c@60 46 // 0 plus the declared latency
c@60 47 //
c@60 48 // Signal-noise ratio
c@60 49 //
c@60 50 // Specimen output for simple test case
c@60 51
c@65 52 tests = [
c@65 53 "kernel" : load test_cqtkernel,
c@65 54 "frequency" : load test_frequency,
c@65 55 ];
c@59 56
c@65 57 bad = sum (mapHash do name testHash: runTests name testHash done tests);
c@59 58
c@65 59 if (bad > 0) then
c@65 60 println "\n** \(bad) test(s) failed!";
c@65 61 threadExit 1
c@65 62 else
c@65 63 ()
c@65 64 fi
c@59 65
c@59 66
c@59 67
c@59 68
c@59 69 /*
c@37 70 //testStream = manipulate.withDuration 96000 (syn.sinusoid 48000 500);
c@37 71 //testStream = manipulate.withDuration 96000 (syn.pulseTrain 48000 4);
c@44 72 testStream = af.open "sweep-48000.wav";
c@37 73 //testStream = af.open "sweep.wav";
c@37 74
c@43 75 // So the stream is [ 0, 1, 0, -1, 0, 1, 0, -1, ... ] :
c@44 76 //testStream = manipulate.withDuration 64 (syn.sinusoid 8 2);
c@38 77
c@56 78 testStream = manipulate.withDuration 32 (syn.pulseTrain 8 0.001);
c@37 79
c@37 80 eprintln "have test stream";
c@37 81
c@44 82 cq = cqt { maxFreq = testStream.sampleRate/2, minFreq = 50, binsPerOctave = 24 } testStream;
c@37 83
c@40 84 eprintln "bin frequencies: \(cq.kernel.binFrequencies)";
c@40 85
c@40 86 bigM = mat.concatHorizontal (map cm.magnitudes cq.output);
c@37 87
c@38 88 eprintln "overall output size = \(mat.size bigM)";
c@38 89
c@39 90 mat.print bigM;
c@38 91
c@38 92 //\() (plot.plot [Contour bigM]);
c@56 93 \() (plot.plot [Grid bigM]);
c@59 94 */
c@65 95 //()
c@37 96