diff qm-dsp-decimate/decimate.cpp @ 28:69ee50c19c0c tip

Add decimate-b
author Chris Cannam
date Tue, 22 Oct 2013 08:59:42 +0100
parents f8efad075df0
children
line wrap: on
line diff
--- a/qm-dsp-decimate/decimate.cpp	Mon Oct 21 17:41:43 2013 +0100
+++ b/qm-dsp-decimate/decimate.cpp	Tue Oct 22 08:59:42 2013 +0100
@@ -1,6 +1,11 @@
 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
 
+#ifdef DECIMATE_B
+#include "qm-dsp/dsp/rateconversion/DecimatorB.h"
+#else
 #include "qm-dsp/dsp/rateconversion/Decimator.h"
+#endif
+
 #include "qm-dsp/maths/MathUtilities.h"
 
 #include <iostream>
@@ -62,12 +67,19 @@
         cerr << "ERROR: Factor must be a power of two" << endl;
         return 1;
     }
+#ifdef DECIMATE_B
+    if (factor < 2) {
+        cerr << "ERROR: Factor must be at least 2" << endl;
+        return 1;
+    }
+#else    
     if (factor < 2 || factor > Decimator::getHighestSupportedFactor()) {
         cerr << "ERROR: Only factors between 2 and "
              << Decimator::getHighestSupportedFactor() 
              << " inclusive are supported" <<endl;
         return 1;
     }
+#endif
     
     timeval tv;
     (void)gettimeofday(&tv, 0);
@@ -115,14 +127,20 @@
     }
 
     int channels = sfinfo.channels;
-    vector<Decimator *> decimators; // one per channel
-
     int ibs = 1024;
     int obs = ibs / factor;
 
+#ifdef DECIMATE_B
+    vector<DecimatorB *> decimators; // one per channel
+    for (int c = 0; c < channels; ++c) {
+	decimators.push_back(new DecimatorB(ibs, factor));
+    }
+#else
+    vector<Decimator *> decimators; // one per channel
     for (int c = 0; c < channels; ++c) {
 	decimators.push_back(new Decimator(ibs, factor));
     }
+#endif
 
     float *ibuf = new float[channels * ibs];
     float *obuf = new float[channels * obs];