changeset 29:63959419587f

Tidy up, use a faster resampler configuration
author Chris Cannam
date Wed, 30 Sep 2015 13:44:50 +0100
parents 7b618e3f9a8b
children 00df792783e3
files Makefile.inc src/PitchFilterbank.cpp
diffstat 2 files changed, 14 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.inc	Wed Sep 30 11:43:40 2015 +0100
+++ b/Makefile.inc	Wed Sep 30 13:44:50 2015 +0100
@@ -95,7 +95,7 @@
 
 src/Filter.o: src/Filter.h bqvec/bqvec/Restrict.h bqvec/bqvec/VectorOps.h
 src/Filter.o: bqvec/bqvec/Restrict.h bqvec/bqvec/Allocators.h
-src/Filter.o: bqvec/bqvec/VectorOps.h
+src/Filter.o: bqvec/bqvec/Allocators.h
 src/PitchFilterbank.o: src/PitchFilterbank.h src/Types.h src/Filter.h
 src/PitchFilterbank.o: bqvec/bqvec/Restrict.h src/delays.h src/filter-a.h
 src/PitchFilterbank.o: src/filter-b.h
@@ -107,9 +107,11 @@
 src/Chroma.o: src/OctaveFold.h src/Resize.h
 src/TipicVampPlugin.o: src/TipicVampPlugin.h src/Types.h
 src/TipicVampPlugin.o: src/PitchFilterbank.h src/CRP.h src/DCTReduce.h
-src/TipicVampPlugin.o: src/DCT.h bqvec/bqvec/Range.h bqvec/bqvec/VectorOps.h
-src/TipicVampPlugin.o: bqvec/bqvec/Restrict.h
+src/TipicVampPlugin.o: src/DCT.h src/Chroma.h bqvec/bqvec/Range.h
+src/TipicVampPlugin.o: bqvec/bqvec/VectorOps.h bqvec/bqvec/Restrict.h
+src/TipicVampPlugin.o: bqvec/bqvec/Allocators.h
 src/libmain.o: src/TipicVampPlugin.h src/Types.h
+bqvec/src/Allocators.o: bqvec/bqvec/Allocators.h
 src/test-filter.o: src/Filter.h bqvec/bqvec/Restrict.h
 src/test-dct.o: src/DCT.h
 src/test-normalise.o: src/Normalise.h
--- a/src/PitchFilterbank.cpp	Wed Sep 30 11:43:40 2015 +0100
+++ b/src/PitchFilterbank.cpp	Wed Sep 30 13:44:50 2015 +0100
@@ -43,23 +43,21 @@
 	// quantization close to 440Hz in 44.1kHz audio -- we could do
 	// better by using multiples of our source and target sample
 	// rates, but I think it probably isn't necessary.
-	m_effectiveInputSampleRate =
+	m_effectiveInputRate =
 	    int(round(m_sampleRate * (440.0 / m_tuningFrequency)));
 
-	//!!! todo: tuning frequency adjustment
-	// * resample input by a small amount
-	// * adjust output block timings by a small amount
-
 	//!!! nb "we use forward-backward filtering such that the
 	// resulting output signal has precisely zero phase distortion
 	// and a magnitude modified by the square of the filter’s
 	// magnitude response" -- we are not doing forward-backward
 	// here & so need to adapt magnitudes in compensation to match
 	// original
-	
-	m_resamplers[882] = new Resampler(m_effectiveInputSampleRate, 882);
-	m_resamplers[4410] = new Resampler(m_effectiveInputSampleRate, 4410);
-	m_resamplers[22050] = new Resampler(m_effectiveInputSampleRate, 22050);
+
+	double snr = 50.0;
+	double bw = 0.05;
+	m_resamplers[882] = new Resampler(m_effectiveInputRate, 882, snr, bw);
+	m_resamplers[4410] = new Resampler(m_effectiveInputRate, 4410, snr, bw);
+	m_resamplers[22050] = new Resampler(m_effectiveInputRate, 22050, snr, bw);
 	
 	for (int i = 0; i < m_nfilters; ++i) {
 	    int ix = i + 20;
@@ -128,24 +126,17 @@
 	double rate = filterRate(i);
 	double topRate = 22050.0;
 	double rateRatio = topRate / rate;
-	double tuningRatio = m_sampleRate / double(m_effectiveInputSampleRate);
+	double tuningRatio = m_sampleRate / double(m_effectiveInputRate);
 	double sizeRatio = tuningRatio / rateRatio;
 
 	uint64_t start(round((hop * block) * sizeRatio));
 	int size(round((hop * 2) * sizeRatio));
 
-//	cerr << "block " << block << ", i " << i << ": start " << start << ", size "
-//	     << size << endl;
-	
 	return { start, size, rateRatio };
     }
     
     RealBlock energiesFromFiltered(bool drain) {
 
-	//!!! This is all quite inefficient -- we're counting
-	//!!! everything twice. Since there is no actual window shape,
-	//!!! isn't the overlap just averaging?
-
 	for (int i = 0; i < m_nfilters; ++i) {
 
 	    WindowPosition here = windowPosition(m_blockNo, i);
@@ -157,12 +148,6 @@
 	    unsigned int minReq = n;
 	    if (drain) minReq = hop;
 
-	    //!!! strictly, we don't actually need to store the
-	    //!!! filtered outputs since our overlapped windows are
-	    //!!! not shaped -- each one is the sum of two half-size
-	    //!!! windows, so we can just push the energies of those
-	    //!!! directly. that's a TODO
-	    
 	    while (m_filtered[i].size() >= minReq) {
 		double energy = calculateEnergy(m_filtered[i], n, here.factor);
 		m_energies[i].push_back(energy);
@@ -249,7 +234,7 @@
 private:
     int m_nfilters;
     int m_sampleRate;
-    int m_effectiveInputSampleRate;
+    int m_effectiveInputRate;
     double m_tuningFrequency;
 
     // This vector is initialised with 88 filter instances.