Mercurial > hg > decimation
changeset 28:69ee50c19c0c tip
Add decimate-b
author | Chris Cannam |
---|---|
date | Tue, 22 Oct 2013 08:59:42 +0100 |
parents | ece2031120c9 |
children | |
files | Makefile qm-dsp-decimate/Makefile qm-dsp-decimate/decimate.cpp run-tests.sh |
diffstat | 4 files changed, 46 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Mon Oct 21 17:41:43 2013 +0100 +++ b/Makefile Tue Oct 22 08:59:42 2013 +0100 @@ -4,3 +4,7 @@ $(MAKE) -C qm-dsp-decimate ./run-tests.sh +clean: + $(MAKE) -C qm-dsp-resample clean + $(MAKE) -C qm-dsp-decimate clean +
--- a/qm-dsp-decimate/Makefile Mon Oct 21 17:41:43 2013 +0100 +++ b/qm-dsp-decimate/Makefile Tue Oct 22 08:59:42 2013 +0100 @@ -11,15 +11,21 @@ LDFLAGS := $(LDFLAGS) -PROGRAM := decimate +PROGRAMS := decimate decimate-b #VG := valgrind -all: $(PROGRAM) +all: $(PROGRAMS) decimate: decimate.o $(CXX) -o $@ $^ $(LDFLAGS) $(LIBS) $(PROGRAM_LIBS) +decimate-b: decimate-b.o + $(CXX) -o $@ $^ $(LDFLAGS) $(LIBS) $(PROGRAM_LIBS) + +decimate-b.o: decimate.cpp + $(CXX) -c -o $@ $^ $(CXXFLAGS) -DDECIMATE_B=1 + clean: rm -f *.o
--- 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];
--- a/run-tests.sh Mon Oct 21 17:41:43 2013 +0100 +++ b/run-tests.sh Tue Oct 22 08:59:42 2013 +0100 @@ -7,12 +7,13 @@ factors="2 4 8 16 32 64" signals="sweep lengthy" -impls="zoh decimate resample_hq resample_mq resample_lq src" +impls="zoh decimate decimate_b resample_hq resample_mq resample_lq src" original=96000 resample="$mydir/qm-dsp-resample/resample" decimate="$mydir/qm-dsp-decimate/decimate" +decimate_b="$mydir/qm-dsp-decimate/decimate-b" indir="$mydir"/testsignals @@ -29,6 +30,11 @@ exit 1 fi +if [ ! -x "$decimate_b" ]; then + echo "Program $decimate_b not found: make not run, or make failed?" + exit 1 +fi + if ! sndfile-resample 2>&1 | grep -q samplerate ; then echo "Program sndfile-resample not found in PATH?" exit 1 @@ -96,6 +102,13 @@ esac } +do_decimate_b() { + factor="$1" + infile="$2" + outfile="$3" + time "$decimate_b" --by "$factor" "$infile" "$outfile" +} + for s in $signals; do for f in $factors; do for impl in $impls; do