Mercurial > hg > constant-q-cpp
changeset 80:872fc9dc0321
Start on inverse code, fix up forward interface a bit
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 29 Apr 2014 08:36:47 +0100 |
parents | 021f69b2987a |
children | 788799487b1e |
files | yeti/cqt.yeti yeti/cqtkernel.yeti yeti/icqt.yeti yeti/plotfile.yeti yeti/test_frequency.yeti |
diffstat | 5 files changed, 53 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/yeti/cqt.yeti Mon Apr 07 16:14:24 2014 +0100 +++ b/yeti/cqt.yeti Tue Apr 29 08:36:47 2014 +0100 @@ -178,8 +178,8 @@ assembleBlockSpectrogram bits = (// As assembleBlock, but producing a dense magnitude - // spectrogram (rather than a complex output with zeros - // between the cell values in lower octaves). (todo: smoothing) + // spectrogram (rather than a complex output). (todo: + // interpolation, smoothing) //eprintln "assembleBlockSpectrogram: structure of bits is:"; //eprintln (map length bits); @@ -248,14 +248,10 @@ done (reverse (list kdata.binFrequencies)) done [0..octaves-1]) }, + sampleRate, octaves, - output type = //!!! this api is not good - case type of - ComplexCQ (): - Complex (processOctaveLists assembleBlock octaveLists); - Spectrogram (): - Real (processOctaveLists assembleBlockSpectrogram octaveLists); - esac + get cqComplex () = processOctaveLists assembleBlock octaveLists, + get cqSpectrogram () = processOctaveLists assembleBlockSpectrogram octaveLists, } );
--- a/yeti/cqtkernel.yeti Mon Apr 07 16:14:24 2014 +0100 +++ b/yeti/cqtkernel.yeti Tue Apr 29 08:36:47 2014 +0100 @@ -134,10 +134,12 @@ weight = (fftHop / fftSize) / (vec.mean (vec.abs wK)); weight = sqrt(weight); + kernel = cm.scaled weight kmat; + // eprintln "weight = \(weight)"; { - kernel = cm.scaled weight kmat, + kernel, fftSize, fftHop, binsPerOctave,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/yeti/icqt.yeti Tue Apr 29 08:36:47 2014 +0100 @@ -0,0 +1,43 @@ +/* + Constant-Q library + Copyright (c) 2013-2014 Queen Mary, University of London + + Permission is hereby granted, free of charge, to any person + obtaining a copy of this software and associated documentation + files (the "Software"), to deal in the Software without + restriction, including without limitation the rights to use, copy, + modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + Except as contained in this notice, the names of the Centre for + Digital Music; Queen Mary, University of London; and Chris Cannam + shall not be used in advertising or otherwise to promote the sale, + use or other dealings in this Software without prior written + authorization. +*/ + +module icqt; + +cqt = load cqt; + +icqt cq = + (kdata = cq.kernel; + + // kdata.kernel is the kernel matrix for a single octave, of width + // kdata.fftSize and height kdata.binsPerOctave. !!! todo: unit + // tests for kernel size etc kdata.fftHop is the overlap between + // kernel matrices in a single octave. cq.sampleRate is the + // output stream sample rate. +
--- a/yeti/plotfile.yeti Mon Apr 07 16:14:24 2014 +0100 +++ b/yeti/plotfile.yeti Tue Apr 29 08:36:47 2014 +0100 @@ -23,10 +23,7 @@ } testStream; middle = System#currentTimeMillis(); eprintln "Generated kernel \(cm.size cq.kernel.kernel) and primed transform (\(cq.octaves) octaves), took \(middle-start)ms, now calculating..."; - bigM = case (cq.output (Spectrogram ())) of - Real s: mat.concatHorizontal s; - _: failWith "Real expected"; - esac; + bigM = mat.concatHorizontal cq.cqSpectrogram; finish = System#currentTimeMillis(); eprintln "Done, that part took \(finish-middle)ms, all CQ stuff took \(finish-start)ms"; eprintln "Plotting...";
--- a/yeti/test_frequency.yeti Mon Apr 07 16:14:24 2014 +0100 +++ b/yeti/test_frequency.yeti Tue Apr 29 08:36:47 2014 +0100 @@ -81,10 +81,7 @@ do f: \( str = streamBuilder f; cq = cqt { maxFreq = cqmax, minFreq = cqmin, binsPerOctave = bpo } str; - out = case cq.output (ComplexCQ ()) of - Complex c: c; - _: failWith "expected complex"; - esac; + out = cq.cqComplex; m = mat.concatHorizontal (map cm.magnitudes out); // println "binFrequencies = \(cq.kernel.binFrequencies)"; // println "binForFreq \(f) = \(binForFreq f)";