Mercurial > hg > constant-q-cpp
comparison yeti/cqtkernel.yeti @ 40:031386846e3c
Return bin frequencies, for reference; some padding
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Tue, 19 Nov 2013 14:37:23 +0000 |
parents | 5435f00a4103 |
children | f5bd00c97de3 |
comparison
equal
deleted
inserted
replaced
39:c0514dd5be60 | 40:031386846e3c |
---|---|
41 | 41 |
42 // Note the MATLAB uses exp(2*pi*1i*x) for a complex generating | 42 // Note the MATLAB uses exp(2*pi*1i*x) for a complex generating |
43 // function. We can't do that here; we need to generate real and imag | 43 // function. We can't do that here; we need to generate real and imag |
44 // parts separately as real = cos(2*pi*x), imag = sin(2*pi*x). | 44 // parts separately as real = cos(2*pi*x), imag = sin(2*pi*x). |
45 | 45 |
46 binFrequencies = array []; | |
47 | |
46 kernels = map do k: | 48 kernels = map do k: |
47 | 49 |
48 nk = round(bigQ * sampleRate / (minFreq * (pow 2 ((k-1)/binsPerOctave)))); | 50 nk = round(bigQ * sampleRate / (minFreq * (pow 2 ((k-1)/binsPerOctave)))); |
49 | 51 |
50 // the cq MATLAB toolbox uses a symmetric window for | 52 // the cq MATLAB toolbox uses a symmetric window for |
53 win = vec.divideBy nk | 55 win = vec.divideBy nk |
54 (vec.sqrt | 56 (vec.sqrt |
55 (window.windowFunction (BlackmanHarris ()) [Symmetric true] nk)); | 57 (window.windowFunction (BlackmanHarris ()) [Symmetric true] nk)); |
56 | 58 |
57 fk = minFreq * (pow 2 ((k-1)/binsPerOctave)); | 59 fk = minFreq * (pow 2 ((k-1)/binsPerOctave)); |
60 | |
61 push binFrequencies fk; | |
58 | 62 |
59 genKernel f = vec.multiply win | 63 genKernel f = vec.multiply win |
60 (vec.fromList | 64 (vec.fromList |
61 (map do i: f (2 * pi * fk * i / sampleRate) done [0..nk-1])); | 65 (map do i: f (2 * pi * fk * i / sampleRate) done [0..nk-1])); |
62 | 66 |
110 fftHop, | 114 fftHop, |
111 binsPerOctave, | 115 binsPerOctave, |
112 atomsPerFrame = winNr, | 116 atomsPerFrame = winNr, |
113 atomSpacing = atomHop, | 117 atomSpacing = atomHop, |
114 firstCentre, | 118 firstCentre, |
115 maxFreq, | 119 maxFrequency = maxFreq, |
116 minFreq, | 120 minFrequency = minFreq, |
121 binFrequencies, | |
117 bigQ | 122 bigQ |
118 }); | 123 }); |
119 | 124 |
120 { | 125 { |
121 makeKernel | 126 makeKernel |