c@116: /* c@116: Constant-Q library c@116: Copyright (c) 2013-2014 Queen Mary, University of London c@116: c@116: Permission is hereby granted, free of charge, to any person c@116: obtaining a copy of this software and associated documentation c@116: files (the "Software"), to deal in the Software without c@116: restriction, including without limitation the rights to use, copy, c@116: modify, merge, publish, distribute, sublicense, and/or sell copies c@116: of the Software, and to permit persons to whom the Software is c@116: furnished to do so, subject to the following conditions: c@116: c@116: The above copyright notice and this permission notice shall be c@116: included in all copies or substantial portions of the Software. c@116: c@116: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, c@116: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF c@116: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND c@116: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY c@116: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF c@116: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION c@116: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. c@116: c@116: Except as contained in this notice, the names of the Centre for c@116: Digital Music; Queen Mary, University of London; and Chris Cannam c@116: shall not be used in advertising or otherwise to promote the sale, c@116: use or other dealings in this Software without prior written c@116: authorization. c@116: */ c@116: c@116: program test; c@116: c@116: { runTests } = load may.test; c@116: c@116: // We want to test: c@116: // c@116: // Kernel design -- check size (number of bins, number of atoms); c@116: // check an example kernel against known data c@116: // c@116: // Time alignment -- feed a dirac train, check that peaks in all bins c@116: // align c@116: // c@116: // Frequency discrimination -- feed a sinusoid, check peaks c@116: // c@116: // Latency compensation -- for dirac at 0, check peak can be found at c@116: // 0 plus the declared latency c@116: // c@116: // Signal-noise ratio c@116: // c@116: // Specimen output for simple test case c@116: c@116: tests = [ c@116: "kernel" : load test_cqtkernel, c@116: "frequency" : load test_frequency, c@116: ]; c@116: c@116: bad = sum (mapHash do name testHash: runTests name testHash done tests); c@116: c@116: if (bad > 0) then c@116: println "\n** \(bad) test(s) failed!"; c@116: threadExit 1 c@116: else c@116: () c@116: fi c@116: c@116: c@116: c@116: c@116: /* c@116: //testStream = manipulate.withDuration 96000 (syn.sinusoid 48000 500); c@116: //testStream = manipulate.withDuration 96000 (syn.pulseTrain 48000 4); c@116: testStream = af.open "sweep-48000.wav"; c@116: //testStream = af.open "sweep.wav"; c@116: c@116: // So the stream is [ 0, 1, 0, -1, 0, 1, 0, -1, ... ] : c@116: //testStream = manipulate.withDuration 64 (syn.sinusoid 8 2); c@116: c@116: testStream = manipulate.withDuration 32 (syn.pulseTrain 8 0.001); c@116: c@116: eprintln "have test stream"; c@116: c@116: cq = cqt { maxFreq = testStream.sampleRate/2, minFreq = 50, binsPerOctave = 24 } testStream; c@116: c@116: eprintln "bin frequencies: \(cq.kernel.binFrequencies)"; c@116: c@116: bigM = mat.concatHorizontal (map cm.magnitudes cq.output); c@116: c@116: eprintln "overall output size = \(mat.size bigM)"; c@116: c@116: mat.print bigM; c@116: c@116: //\() (plot.plot [Contour bigM]); c@116: \() (plot.plot [Grid bigM]); c@116: */ c@116: //() c@116: