annotate misc/yeti/test.yeti @ 196:da283326bcd3 tip master

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