annotate yeti/test_cqtkernel.yeti @ 113:26217edee359

Adjust frequency extents so as to place semitones in the middle of their spaces (if >1 bin per semitone)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 14 May 2014 15:58:22 +0100
parents 788799487b1e
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@65 30
c@65 31 module test_cqtkernel;
c@65 32
c@65 33 cm = load may.matrix.complex;
c@81 34 mm = load may.mathmisc;
c@81 35
c@81 36 { compare, compareUsing } = load may.test;
c@65 37
c@65 38 { makeKernel } = load cqtkernel;
c@65 39
c@81 40 eps = 1e-7;
c@81 41
c@81 42 compareClose = compareUsing do a b: abs (a - b) < eps done;
c@81 43
c@65 44 [
c@65 45
c@65 46 "minimal": \(
c@65 47 k = makeKernel { sampleRate = 16, maxFreq = 8, binsPerOctave = 4 };
c@81 48 compare k.binsPerOctave 4 and
c@81 49 compare (cm.size k.kernel) {
c@81 50 rows = k.binsPerOctave * k.atomsPerFrame,
c@81 51 columns = k.fftSize
c@81 52 } and
c@81 53 compareClose k.maxFrequency 8 and
c@81 54 compareClose k.minFrequency (4 * (mm.pow 2 (1/4))) and
c@81 55 compare k.atomsPerFrame 5 and
c@81 56 compare k.fftSize 32 and
c@81 57 compare (length k.binFrequencies) k.binsPerOctave and
c@81 58 compareClose (head k.binFrequencies) k.minFrequency and
c@81 59 compareClose (head (reverse k.binFrequencies)) k.maxFrequency
c@65 60 ),
c@65 61
c@65 62 ] is hash<string, () -> boolean>
c@65 63