# HG changeset patch # User Chris Cannam # Date 1444214793 -3600 # Node ID 00b6ae41efbe0d8984603926609d04d8adad816b # Parent 6daf77dab8a44a885ca0f2fe72a36b8e087f19b5 Update to use qm-dsp instead of files from constant-q-cpp and bqvec. Some of the classes here (e.g. DCT) have moved to qm-dsp in the meantime. diff -r 6daf77dab8a4 -r 00b6ae41efbe .hgsub --- a/.hgsub Wed Oct 07 09:22:40 2015 +0100 +++ b/.hgsub Wed Oct 07 11:46:33 2015 +0100 @@ -1,2 +1,1 @@ -constant-q-cpp = https://code.soundsoftware.ac.uk/hg/constant-q-cpp -bqvec = https://bitbucket.org/breakfastquay/bqvec +qm-dsp = https://code.soundsoftware.ac.uk/hg/qm-dsp diff -r 6daf77dab8a4 -r 00b6ae41efbe .hgsubstate --- a/.hgsubstate Wed Oct 07 09:22:40 2015 +0100 +++ b/.hgsubstate Wed Oct 07 11:46:33 2015 +0100 @@ -1,2 +1,1 @@ -b5c7ca480bf7dc5c602e456480d53ecce3d58e42 bqvec -9c8ca37028b9d030d611bf02ae232c7fde6d7ff7 constant-q-cpp +4e57fb34d9e653c639b8870dadeb85f48d6751a9 qm-dsp diff -r 6daf77dab8a4 -r 00b6ae41efbe Makefile.inc --- a/Makefile.inc Wed Oct 07 09:22:40 2015 +0100 +++ b/Makefile.inc Wed Oct 07 11:46:33 2015 +0100 @@ -3,8 +3,7 @@ VAMPSDK_DIR ?= ../vamp-plugin-sdk -CQ_DIR ?= constant-q-cpp -BQVEC_DIR ?= bqvec +QMDSP_DIR := qm-dsp PLUGIN_EXT ?= .so @@ -13,8 +12,8 @@ AR ?= ar RANLIB ?= ranlib -CFLAGS := $(CFLAGS) -CXXFLAGS := $(CFLAGS) -I. -I$(VAMPSDK_DIR) -I$(CQ_DIR) -I$(BQVEC_DIR) -I$(BQVEC_DIR)/bqvec -I$(CQ_DIR)/src/dsp $(CXXFLAGS) +CFLAGS := $(CFLAGS) -I$(QMDSP_DIR)/ext/kissfft -I$(QMDSP_DIR)/ext/kissfft/tools -Dkiss_fft_scalar=double +CXXFLAGS := $(CFLAGS) -I. -I$(VAMPSDK_DIR) -I$(QMDSP_DIR) $(CXXFLAGS) LDFLAGS := $(LDFLAGS) PLUGIN_LDFLAGS := $(LDFLAGS) $(PLUGIN_LDFLAGS) @@ -28,29 +27,41 @@ $(SRC_DIR)/delays.h \ $(SRC_DIR)/filter-a.h \ $(SRC_DIR)/filter-b.h \ - $(SRC_DIR)/Filter.h \ $(SRC_DIR)/PitchFilterbank.h \ - $(SRC_DIR)/DCT.h \ $(SRC_DIR)/Types.h \ $(SRC_DIR)/CRP.h \ - $(SRC_DIR)/Normalise.h \ $(SRC_DIR)/LogCompress.h \ $(SRC_DIR)/OctaveFold.h \ $(SRC_DIR)/Resize.h \ $(SRC_DIR)/Chroma.h \ $(SRC_DIR)/FeatureDownsample.h \ $(SRC_DIR)/Quantize.h \ - $(SRC_DIR)/CENS.h - + $(SRC_DIR)/CENS.h \ + $(QMDSP_DIR)/dsp/signalconditioning/Filter.h \ + $(QMDSP_DIR)/dsp/transforms/DCT.h \ + $(QMDSP_DIR)/dsp/transforms/FFT.h \ + $(QMDSP_DIR)/dsp/rateconversion/Resampler.h \ + $(QMDSP_DIR)/maths/MathUtilities.h \ + $(QMDSP_DIR)/base/Window.h \ + $(QMDSP_DIR)/base/KaiserWindow.h \ + $(QMDSP_DIR)/base/SincWindow.h \ + $(QMDSP_DIR)/ext/kissfft/tools/kiss_fftr.h + LIB_SOURCES := \ - $(SRC_DIR)/Filter.cpp \ $(SRC_DIR)/PitchFilterbank.cpp \ - $(SRC_DIR)/DCT.cpp \ $(SRC_DIR)/CRP.cpp \ - $(SRC_DIR)/Normalise.cpp \ $(SRC_DIR)/Chroma.cpp \ $(SRC_DIR)/FeatureDownsample.cpp \ - $(SRC_DIR)/CENS.cpp + $(SRC_DIR)/CENS.cpp \ + $(QMDSP_DIR)/dsp/signalconditioning/Filter.cpp \ + $(QMDSP_DIR)/dsp/transforms/DCT.cpp \ + $(QMDSP_DIR)/dsp/transforms/FFT.cpp \ + $(QMDSP_DIR)/dsp/rateconversion/Resampler.cpp \ + $(QMDSP_DIR)/maths/MathUtilities.cpp \ + $(QMDSP_DIR)/base/KaiserWindow.cpp \ + $(QMDSP_DIR)/base/SincWindow.cpp \ + $(QMDSP_DIR)/ext/kissfft/kiss_fft.c \ + $(QMDSP_DIR)/ext/kissfft/tools/kiss_fftr.c LIB_OBJECTS := $(LIB_SOURCES:.cpp=.o) LIB_OBJECTS := $(LIB_OBJECTS:.c=.o) @@ -60,93 +71,74 @@ PLUGIN_OBJECTS := $(PLUGIN_SOURCES:.cpp=.o) PLUGIN_OBJECTS := $(PLUGIN_OBJECTS:.c=.o) -BQVEC_HEADERS := $(BQVEC_DIR)/Allocators.h $(BQVEC_DIR)/Restrict.h $(BQVEC_DIR)/VectorOps.h -BQVEC_SOURCES := $(BQVEC_DIR)/src/Allocators.cpp -BQVEC_OBJECTS := $(BQVEC_SOURCES:.cpp=.o) -BQVEC_OBJECTS := $(BQVEC_OBJECTS:.c=.o) - TEST_SOURCES := $(SRC_DIR)/test-filter.cpp $(SRC_DIR)/test-dct.cpp $(SRC_DIR)/test-normalise.cpp TEST_OBJECTS := $(TEST_SOURCES:.cpp=.o) TEST_OBJECTS := $(TEST_OBJECTS:.c=.o) -OTHER_OBJECTS := $(CQ_DIR)/src/dsp/FFT.o $(CQ_DIR)/src/ext/kissfft/kiss_fft.o $(CQ_DIR)/src/ext/kissfft/tools/kiss_fftr.o - -HEADERS := $(PUBLIC_HEADERS) $(LIB_HEADERS) $(PLUGIN_HEADERS) $(BQVEC_HEADERS) -SOURCES := $(PUBLIC_SOURCES) $(LIB_SOURCES) $(PLUGIN_SOURCES) $(BQVEC_SOURCES) $(TEST_SOURCES) +HEADERS := $(PUBLIC_HEADERS) $(LIB_HEADERS) $(PLUGIN_HEADERS) +SOURCES := $(PUBLIC_SOURCES) $(LIB_SOURCES) $(PLUGIN_SOURCES) $(TEST_SOURCES) OBJECTS := $(SOURCES:.cpp=.o) OBJECTS := $(OBJECTS:.c=.o) -LIBS := $(CQ_DIR)/libcq.a $(VAMPSDK_DIR)/libvamp-sdk.a +LIBS := $(VAMPSDK_DIR)/libvamp-sdk.a -all: constant-q-cpp $(LIBRARY) $(PLUGIN) tests +all: $(LIBRARY) $(PLUGIN) -.PHONY: constant-q-cpp -constant-q-cpp: - $(MAKE) -C $@ -f Makefile$(MAKEFILE_EXT) libcq.a - -$(PLUGIN): $(PLUGIN_OBJECTS) $(LIB_OBJECTS) $(BQVEC_OBJECTS) $(LIBS) +$(PLUGIN): $(PLUGIN_OBJECTS) $(LIB_OBJECTS) $(LIBS) $(CXX) -o $@ $^ $(LIBS) $(PLUGIN_LDFLAGS) -$(LIBRARY): $(LIB_OBJECTS) $(BQVEC_OBJECTS) $(OTHER_OBJECTS) +$(LIBRARY): $(LIB_OBJECTS) $(RM) -f $@ $(AR) cr $@ $^ $(RANLIB) $@ -.PHONY: tests -tests: test-dct test-filter test-normalise - ./test-dct - ./test-filter - ./test-normalise - -test-dct: $(TEST_OBJECTS) $(LIBRARY) - $(CXX) -o $@ src/test-dct.o $(LIBRARY) - -test-filter: $(TEST_OBJECTS) $(LIBRARY) - $(CXX) -o $@ src/test-filter.o $(LIBRARY) - -test-normalise: $(TEST_OBJECTS) $(LIBRARY) - $(CXX) -o $@ src/test-normalise.o $(LIBRARY) - clean: rm -f $(OBJECTS) - $(MAKE) -C constant-q-cpp -f Makefile$(MAKEFILE_EXT) clean distclean: clean rm -f $(PLUGIN) depend: - makedepend -I$(BQVEC_DIR) -Y -fMakefile.inc $(SOURCES) $(HEADERS) - + makedepend -Y -fMakefile.inc $(SOURCES) $(HEADERS) + # DO NOT DELETE -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/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 -src/DCT.o: src/DCT.h -src/CRP.o: src/CRP.h src/Types.h src/DCTReduce.h src/DCT.h src/Normalise.h -src/CRP.o: src/LogCompress.h src/OctaveFold.h src/Resize.h -src/Normalise.o: src/Normalise.h -src/Chroma.o: src/Chroma.h src/Types.h src/Normalise.h src/LogCompress.h -src/Chroma.o: src/OctaveFold.h src/Resize.h -src/FeatureDownsample.o: src/FeatureDownsample.h src/Types.h src/Filter.h -src/FeatureDownsample.o: bqvec/bqvec/Restrict.h src/Normalise.h -src/CENS.o: src/CENS.h src/Types.h src/Quantize.h src/Normalise.h -src/CENS.o: src/OctaveFold.h src/Resize.h +src/PitchFilterbank.o: src/PitchFilterbank.h src/Types.h src/delays.h +src/PitchFilterbank.o: src/filter-a.h src/filter-b.h +src/CRP.o: src/CRP.h src/Types.h src/DCTReduce.h src/LogCompress.h +src/CRP.o: src/OctaveFold.h src/Resize.h +src/Chroma.o: src/Chroma.h src/Types.h src/LogCompress.h src/OctaveFold.h +src/Chroma.o: src/Resize.h +src/FeatureDownsample.o: src/FeatureDownsample.h src/Types.h +src/CENS.o: src/CENS.h src/Types.h src/Quantize.h src/OctaveFold.h +src/CENS.o: src/Resize.h +qm-dsp/dsp/signalconditioning/Filter.o: qm-dsp/dsp/signalconditioning/Filter.h +qm-dsp/dsp/transforms/DCT.o: qm-dsp/dsp/transforms/DCT.h +qm-dsp/dsp/transforms/DCT.o: qm-dsp/dsp/transforms/FFT.h +qm-dsp/dsp/transforms/FFT.o: qm-dsp/dsp/transforms/FFT.h +qm-dsp/dsp/rateconversion/Resampler.o: qm-dsp/dsp/rateconversion/Resampler.h +qm-dsp/maths/MathUtilities.o: qm-dsp/maths/MathUtilities.h +qm-dsp/maths/MathUtilities.o: qm-dsp/maths/nan-inf.h +qm-dsp/base/KaiserWindow.o: qm-dsp/base/KaiserWindow.h +qm-dsp/base/SincWindow.o: qm-dsp/base/SincWindow.h +qm-dsp/ext/kissfft/kiss_fft.o: qm-dsp/ext/kissfft/_kiss_fft_guts.h +qm-dsp/ext/kissfft/kiss_fft.o: qm-dsp/ext/kissfft/kiss_fft.h +qm-dsp/ext/kissfft/tools/kiss_fftr.o: qm-dsp/ext/kissfft/tools/kiss_fftr.h +qm-dsp/ext/kissfft/tools/kiss_fftr.o: qm-dsp/ext/kissfft/kiss_fft.h +qm-dsp/ext/kissfft/tools/kiss_fftr.o: qm-dsp/ext/kissfft/_kiss_fft_guts.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 src/Chroma.h src/CENS.h src/Quantize.h -src/TipicVampPlugin.o: src/FeatureDownsample.h bqvec/bqvec/Range.h -src/TipicVampPlugin.o: bqvec/bqvec/VectorOps.h bqvec/bqvec/Restrict.h +src/TipicVampPlugin.o: src/Chroma.h src/CENS.h src/Quantize.h +src/TipicVampPlugin.o: src/FeatureDownsample.h src/libmain.o: src/TipicVampPlugin.h src/Types.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 -src/Filter.o: bqvec/bqvec/Restrict.h +src/test-filter.o: qm-dsp/dsp/signalconditioning/Filter.h +src/test-dct.o: qm-dsp/dsp/transforms/DCT.h qm-dsp/dsp/transforms/FFT.h src/PitchFilterbank.o: src/Types.h -src/CRP.o: src/Types.h src/DCTReduce.h src/DCT.h +src/CRP.o: src/Types.h src/DCTReduce.h src/Chroma.o: src/Types.h src/FeatureDownsample.o: src/Types.h src/CENS.o: src/Types.h src/Quantize.h +qm-dsp/dsp/transforms/DCT.o: qm-dsp/dsp/transforms/FFT.h +qm-dsp/maths/MathUtilities.o: qm-dsp/maths/nan-inf.h +qm-dsp/ext/kissfft/tools/kiss_fftr.o: qm-dsp/ext/kissfft/kiss_fft.h src/TipicVampPlugin.o: src/Types.h diff -r 6daf77dab8a4 -r 00b6ae41efbe src/CENS.cpp --- a/src/CENS.cpp Wed Oct 07 09:22:40 2015 +0100 +++ b/src/CENS.cpp Wed Oct 07 11:46:33 2015 +0100 @@ -1,8 +1,20 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #include "CENS.h" -#include "Normalise.h" +#include "maths/MathUtilities.h" #include "OctaveFold.h" #include "Resize.h" @@ -42,7 +54,7 @@ for (RealColumn col: in) { out.push_back(m_quantize.process - (Normalise::normalise + (MathUtilities::normaliseLp (OctaveFold::process (Resize::process(col)), m_params.normP, m_params.normThresh))); diff -r 6daf77dab8a4 -r 00b6ae41efbe src/CENS.h --- a/src/CENS.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/CENS.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,5 +1,17 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef CENS_H #define CENS_H diff -r 6daf77dab8a4 -r 00b6ae41efbe src/CRP.cpp --- a/src/CRP.cpp Wed Oct 07 09:22:40 2015 +0100 +++ b/src/CRP.cpp Wed Oct 07 11:46:33 2015 +0100 @@ -1,8 +1,20 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #include "CRP.h" -#include "Normalise.h" +#include "maths/MathUtilities.h" #include "LogCompress.h" #include "OctaveFold.h" #include "Resize.h" @@ -35,7 +47,7 @@ col = LogCompress::process(col, m_params.logFactor, m_params.logAddTerm); } - out.push_back(Normalise::normalise + out.push_back(MathUtilities::normaliseLp (OctaveFold::process (m_dctReduce.process (Resize::process(col))), diff -r 6daf77dab8a4 -r 00b6ae41efbe src/CRP.h --- a/src/CRP.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/CRP.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,5 +1,17 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef CRP_H #define CRP_H diff -r 6daf77dab8a4 -r 00b6ae41efbe src/Chroma.cpp --- a/src/Chroma.cpp Wed Oct 07 09:22:40 2015 +0100 +++ b/src/Chroma.cpp Wed Oct 07 11:46:33 2015 +0100 @@ -1,8 +1,20 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #include "Chroma.h" -#include "Normalise.h" +#include "maths/MathUtilities.h" #include "LogCompress.h" #include "OctaveFold.h" #include "Resize.h" @@ -36,7 +48,7 @@ col = LogCompress::process(col, m_params.logFactor, m_params.logAddTerm); } - out.push_back(Normalise::normalise + out.push_back(MathUtilities::normaliseLp (OctaveFold::process (Resize::process(col)), m_params.normP, m_params.normThresh)); diff -r 6daf77dab8a4 -r 00b6ae41efbe src/Chroma.h --- a/src/Chroma.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/Chroma.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,5 +1,17 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef CHROMA_H #define CHROMA_H diff -r 6daf77dab8a4 -r 00b6ae41efbe src/DCT.cpp --- a/src/DCT.cpp Wed Oct 07 09:22:40 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -#include "DCT.h" - -#include - -DCT::DCT(int n) : - m_n(n), - m_scaled(n, 0.0), - m_time2(n*4, 0.0), - m_freq2r(n*4, 0.0), - m_freq2i(n*4, 0.0), - m_fft(n*4) -{ - m_scale = m_n * sqrt(2.0 / m_n); -} - -DCT::~DCT() -{ -} - -void -DCT::forward(const double *in, double *out) -{ - for (int i = 0; i < m_n; ++i) { - m_time2[i*2 + 1] = in[i]; - m_time2[m_n*4 - i*2 - 1] = in[i]; - } - - m_fft.forward(m_time2.data(), m_freq2r.data(), m_freq2i.data()); - - for (int i = 0; i < m_n; ++i) { - out[i] = m_freq2r[i]; - } -} - -void -DCT::forwardUnitary(const double *in, double *out) -{ - forward(in, out); - for (int i = 0; i < m_n; ++i) { - out[i] /= m_scale; - } - out[0] /= sqrt(2.0); -} - -void -DCT::inverse(const double *in, double *out) -{ - for (int i = 0; i < m_n; ++i) { - m_freq2r[i] = in[i]; - } - for (int i = 0; i < m_n; ++i) { - m_freq2r[m_n*2 - i] = -in[i]; - } - m_freq2r[m_n] = 0.0; - - for (int i = 0; i <= m_n*2; ++i) { - m_freq2i[i] = 0.0; - } - - m_fft.inverse(m_freq2r.data(), m_freq2i.data(), m_time2.data()); - - for (int i = 0; i < m_n; ++i) { - out[i] = m_time2[i*2 + 1]; - } -} - -void -DCT::inverseUnitary(const double *in, double *out) -{ - for (int i = 0; i < m_n; ++i) { - m_scaled[i] = in[i] * m_scale; - } - m_scaled[0] *= sqrt(2.0); - inverse(m_scaled.data(), out); -} - diff -r 6daf77dab8a4 -r 00b6ae41efbe src/DCT.h --- a/src/DCT.h Wed Oct 07 09:22:40 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -#ifndef DCT_H -#define DCT_H - -#include "FFT.h" - -#include - -class DCT -{ -public: - /** - * Construct a DCT object to calculate the Discrete Cosine - * Transform given input of size n samples. The transform is - * implemented using an FFT of size 4n, for simplicity. - */ - DCT(int n); - - ~DCT(); - - /** - * Carry out a type-II DCT of size n, where n is the value - * provided to the constructor above. - * - * The in and out pointers must point to (enough space for) n - * values. - */ - void forward(const double *in, double *out); - - /** - * Carry out a type-II unitary DCT of size n, where n is the value - * provided to the constructor above. This is a scaled version of - * the type-II DCT corresponding to a transform with an orthogonal - * matrix. This is the transform implemented by the dct() function - * in MATLAB. - * - * The in and out pointers must point to (enough space for) n - * values. - */ - void forwardUnitary(const double *in, double *out); - - /** - * Carry out a type-III (inverse) DCT of size n, where n is the - * value provided to the constructor above. - * - * The in and out pointers must point to (enough space for) n - * values. - */ - void inverse(const double *in, double *out); - - /** - * Carry out a type-III (inverse) unitary DCT of size n, where n - * is the value provided to the constructor above. This is the - * inverse of forwardUnitary(). - * - * The in and out pointers must point to (enough space for) n - * values. - */ - void inverseUnitary(const double *in, double *out); - -private: - int m_n; - double m_scale; - std::vector m_scaled; - std::vector m_time2; - std::vector m_freq2r; - std::vector m_freq2i; - FFTReal m_fft; -}; - -#endif diff -r 6daf77dab8a4 -r 00b6ae41efbe src/DCTReduce.h --- a/src/DCTReduce.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/DCTReduce.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,9 +1,22 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef DCTREDUCE_H #define DCTREDUCE_H -#include "DCT.h" +#include "dsp/transforms/DCT.h" + #include class DCTReduce diff -r 6daf77dab8a4 -r 00b6ae41efbe src/FeatureDownsample.cpp --- a/src/FeatureDownsample.cpp Wed Oct 07 09:22:40 2015 +0100 +++ b/src/FeatureDownsample.cpp Wed Oct 07 11:46:33 2015 +0100 @@ -1,10 +1,22 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #include "FeatureDownsample.h" -#include "Filter.h" -#include "Window.h" -#include "Normalise.h" +#include "dsp/signalconditioning/Filter.h" +#include "base/Window.h" +#include "maths/MathUtilities.h" #include @@ -74,7 +86,7 @@ } } if (m_toNext == 0) { - out.push_back(Normalise::normalise + out.push_back(MathUtilities::normaliseLp (outcol, m_params.normP, m_params.normThresh)); m_toNext = m_params.downsampleFactor; ++m_outCount; @@ -95,7 +107,7 @@ for (int i = 0; m_outCount < expected && i < int(tail.size()); ++i, ++m_outCount) { - out.push_back(Normalise::normalise + out.push_back(MathUtilities::normaliseLp (tail[i], m_params.normP, m_params.normThresh)); } return out; diff -r 6daf77dab8a4 -r 00b6ae41efbe src/FeatureDownsample.h --- a/src/FeatureDownsample.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/FeatureDownsample.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,5 +1,17 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef FEATURE_DOWNSAMPLE_H #define FEATURE_DOWNSAMPLE_H diff -r 6daf77dab8a4 -r 00b6ae41efbe src/Filter.cpp --- a/src/Filter.cpp Wed Oct 07 09:22:40 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -#include "Filter.h" - -#include -#include - -#include - -using namespace std; -using namespace breakfastquay; - -Filter::Filter(Parameters params) -{ - if (params.a.empty()) { - m_fir = true; - if (params.b.empty()) { - throw logic_error("Filter must have at least one pair of coefficients"); - } - } else { - m_fir = false; - if (params.a.size() != params.b.size()) { - throw logic_error("Inconsistent numbers of filter coefficients"); - } - } - - m_sz = int(params.b.size()); - m_order = m_sz - 1; - - // We keep some empty space at the start of the buffer, and - // encroach gradually into it as we add individual sample - // calculations at the start. Then when we run out of space, we - // move the buffer back to the end and begin again. This is - // significantly faster than moving the whole buffer along in - // 1-sample steps every time. - - m_offmax = 20; - m_offa = m_offmax; - m_offb = m_offmax; - - if (m_fir) { - m_a = 0; - m_bufa = 0; - } else { - m_a = allocate(m_sz); - m_bufa = allocate_and_zero(m_order + m_offmax); - v_copy(m_a, ¶ms.a[0], m_sz); - } - - m_b = allocate(m_sz); - v_copy(m_b, ¶ms.b[0], m_sz); - m_bufb = allocate_and_zero(m_sz + m_offmax); -} - -Filter::~Filter() -{ - deallocate(m_a); - deallocate(m_bufa); - deallocate(m_b); - deallocate(m_bufb); -} - -void -Filter::reset() -{ - m_offb = m_offmax; - m_offa = m_offmax; - v_zero(m_bufb, m_sz + m_offmax); - if (!m_fir) v_zero(m_bufa, m_order + m_offmax); -} - -void -Filter::process(const double *const BQ_R__ in, - double *const BQ_R__ out, - const int n) -{ - for (int s = 0; s < n; ++s) { - - if (m_offb > 0) --m_offb; - else { - v_move(m_bufb + m_offmax + 1, m_bufb, m_sz - 1); - m_offb = m_offmax; - } - m_bufb[m_offb] = in[s]; - - double b_sum = v_multiply_and_sum(m_b, m_bufb + m_offb, m_sz); - - double outval; - - if (m_fir) { - - outval = b_sum; - - } else { - - double a_sum = v_multiply_and_sum(m_a + 1, m_bufa + m_offa, m_order); - outval = b_sum - a_sum; - - if (m_offa > 0) --m_offa; - else { - v_move(m_bufa + m_offmax + 1, m_bufa, m_order - 1); - m_offa = m_offmax; - } - m_bufa[m_offa] = outval; - } - - out[s] = outval; - } -} - diff -r 6daf77dab8a4 -r 00b6ae41efbe src/Filter.h --- a/src/Filter.h Wed Oct 07 09:22:40 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -#ifndef FILTER_H -#define FILTER_H - -#include - -#include - -class Filter -{ -public: - struct Parameters { - std::vector a; - std::vector b; - }; - - /** - * Construct an IIR filter with numerators b and denominators - * a. To make an FIR filter instead (i.e. with denominator = 1), - * leave the vector a in the param struct empty. Otherwise, the - * vectors a and b must have the same number of values. - */ - Filter(Parameters params); - - ~Filter(); - - void reset(); - - /** - * Filter the input sequence \arg in of length \arg n samples, and - * write the resulting \arg n samples into \arg out. There must be - * enough room in \arg out for \arg n samples to be written. - */ - void process(const double *const BQ_R__ in, - double *const BQ_R__ out, - const int n); - -private: - int m_order; - int m_sz; - double *m_a; - double *m_b; - double *m_bufa; - double *m_bufb; - int m_offa; - int m_offb; - int m_offmax; - bool m_fir; - - Filter(const Filter &); // not supplied - Filter &operator=(const Filter &); // not supplied -}; - -#endif diff -r 6daf77dab8a4 -r 00b6ae41efbe src/LogCompress.h --- a/src/LogCompress.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/LogCompress.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,5 +1,17 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef LOGCOMPRESS_H #define LOGCOMPRESS_H diff -r 6daf77dab8a4 -r 00b6ae41efbe src/Normalise.cpp --- a/src/Normalise.cpp Wed Oct 07 09:22:40 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -#include "Normalise.h" - -#include - -using namespace std; - -double -Normalise::norm(vector v, int p) -{ - double tot = 0.0; - for (auto x: v) tot += abs(pow(x, p)); - return pow(tot, 1.0 / p); -} - -vector -Normalise::normalise(vector v, int p, double threshold) -{ - if (p == 0) return v; // no normalisation - int n = v.size(); - double nv = norm(v, p); - if (nv < threshold) { - return vector(n, 1.0 / pow(n, 1.0 / p)); // unit vector - } - vector out; - for (auto x: v) out.push_back(x / nv); - return out; -} - diff -r 6daf77dab8a4 -r 00b6ae41efbe src/Normalise.h --- a/src/Normalise.h Wed Oct 07 09:22:40 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ - -#ifndef NORMALISE_H -#define NORMALISE_H - -#include - -class Normalise -{ -public: - static double norm(std::vector v, - int p); // L^p norm - - static std::vector normalise(std::vector v, - int p, - double threshold = 1e-6); -}; - -#endif diff -r 6daf77dab8a4 -r 00b6ae41efbe src/OctaveFold.h --- a/src/OctaveFold.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/OctaveFold.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,5 +1,17 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef OCTAVEFOLD_H #define OCTAVEFOLD_H diff -r 6daf77dab8a4 -r 00b6ae41efbe src/PitchFilterbank.cpp --- a/src/PitchFilterbank.cpp Wed Oct 07 09:22:40 2015 +0100 +++ b/src/PitchFilterbank.cpp Wed Oct 07 11:46:33 2015 +0100 @@ -1,8 +1,21 @@ +/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ + +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ #include "PitchFilterbank.h" -#include "Resampler.h" -#include "Filter.h" +#include "dsp/rateconversion/Resampler.h" +#include "dsp/signalconditioning/Filter.h" #include "delays.h" #include "filter-a.h" diff -r 6daf77dab8a4 -r 00b6ae41efbe src/PitchFilterbank.h --- a/src/PitchFilterbank.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/PitchFilterbank.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,5 +1,17 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef PITCH_FILTERBANK_H #define PITCH_FILTERBANK_H diff -r 6daf77dab8a4 -r 00b6ae41efbe src/Quantize.h --- a/src/Quantize.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/Quantize.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,5 +1,17 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef QUANTIZE_H #define QUANTIZE_H diff -r 6daf77dab8a4 -r 00b6ae41efbe src/Resize.h --- a/src/Resize.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/Resize.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,5 +1,17 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef RESIZE_H #define RESIZE_H diff -r 6daf77dab8a4 -r 00b6ae41efbe src/TipicVampPlugin.cpp --- a/src/TipicVampPlugin.cpp Wed Oct 07 09:22:40 2015 +0100 +++ b/src/TipicVampPlugin.cpp Wed Oct 07 11:46:33 2015 +0100 @@ -7,16 +7,11 @@ #include "CENS.h" #include "FeatureDownsample.h" -#include -#include - #include #include using namespace std; -using namespace breakfastquay; - static const float defaultTuningFrequency = 440.f; Tipic::Tipic(float inputSampleRate) : @@ -334,7 +329,9 @@ { RealSequence in; in.resize(m_blockSize); - v_convert(in.data(), inputBuffers[0], m_blockSize); + for (int i = 0; i < m_blockSize; ++i) { + in[i] = inputBuffers[0][i]; + } RealBlock pitchFiltered = m_filterbank->process(in); @@ -382,12 +379,16 @@ downsampledOutputNo = outputNo; } + int n = block.size(); + if (outputNo != downsampledOutputNo) { - for (int i = 0; in_range_for(block, i); ++i) { + for (int i = 0; i < n; ++i) { Feature f; int h = block[i].size(); f.values.resize(h); - v_convert(f.values.data(), block[i].data(), h); + for (int j = 0; j < h; ++j) { + f.values[j] = block[i][j]; + } fs[outputNo].push_back(f); } } @@ -404,12 +405,16 @@ RealBlock remaining = m_downsamplers[outputNo]->getRemainingOutput(); downsampled.insert(downsampled.end(), remaining.begin(), remaining.end()); } + + n = downsampled.size(); - for (int i = 0; in_range_for(downsampled, i); ++i) { + for (int i = 0; i < n; ++i) { Feature f; int h = downsampled[i].size(); f.values.resize(h); - v_convert(f.values.data(), downsampled[i].data(), h); + for (int j = 0; j < h; ++j) { + f.values[j] = downsampled[i][j]; + } fs[downsampledOutputNo].push_back(f); } } diff -r 6daf77dab8a4 -r 00b6ae41efbe src/Types.h --- a/src/Types.h Wed Oct 07 09:22:40 2015 +0100 +++ b/src/Types.h Wed Oct 07 11:46:33 2015 +0100 @@ -1,5 +1,17 @@ /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ +/* + Tipic + + Centre for Digital Music, Queen Mary, University of London. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. See the file + COPYING included with this distribution for more information. +*/ + #ifndef TIPIC_TYPES_H #define TIPIC_TYPES_H diff -r 6daf77dab8a4 -r 00b6ae41efbe src/test-dct.cpp --- a/src/test-dct.cpp Wed Oct 07 09:22:40 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ - -#include "DCT.h" - -#include -#include - -using namespace std; - -void check(string context, vector got, vector expected, bool &good) -{ -// cerr << "Checking " << context << "..." << endl; - double thresh = 1e-4; - for (int i = 0; i < int(got.size()); ++i) { - if (fabs(got[i] - expected[i]) > thresh) { - cerr << "ERROR: " << context << "[" << i << "] (" << got[i] - << ") differs from expected " << expected[i] << endl; - good = false; - } - } -} - -int main(int argc, char **argv) -{ - bool good = true; - - vector in4 { 1, 2, 3, 5 }; - vector out4(4), inv4(4); - vector expected4nu { 22.0, -8.1564, 1.4142, -1.2137 }; - vector expected4u { 5.5, -2.8837, 0.5, -0.4291 }; - - DCT d4(4); - - d4.forward(in4.data(), out4.data()); - check("out4", out4, expected4nu, good); - - d4.inverse(out4.data(), inv4.data()); - check("inverse4", inv4, in4, good); - - d4.forwardUnitary(in4.data(), out4.data()); - check("out4u", out4, expected4u, good); - - d4.inverseUnitary(out4.data(), inv4.data()); - check("inverse4u", inv4, in4, good); - - // do it again, just in case some internal state was modified in inverse - - d4.forwardUnitary(in4.data(), out4.data()); - check("out4u", out4, expected4u, good); - - d4.inverseUnitary(out4.data(), inv4.data()); - check("inverse4u", inv4, in4, good); - - vector in5 { 1, 2, 3, 5, 6 }; - vector out5(5), inv5(5); - vector expected5u { 7.6026, -4.1227, 0.3162, -0.0542, -0.3162 }; - - DCT d5(5); - - d5.forwardUnitary(in5.data(), out5.data()); - check("out5u", out5, expected5u, good); - - d5.inverseUnitary(out5.data(), inv5.data()); - check("inverse5u", inv5, in5, good); - - if (good) { - cerr << "Success" << endl; - return 0; - } else { - return 1; - } -} - diff -r 6daf77dab8a4 -r 00b6ae41efbe src/test-filter.cpp --- a/src/test-filter.cpp Wed Oct 07 09:22:40 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ - -#include "Filter.h" - -#include -#include - -using namespace std; - -int main(int argc, char **argv) -{ - // IIR - - vector a { 1,5.75501989315662,16.326056867468,28.779190797823,34.2874379215653,28.137815126537,15.6064643257793,5.37874515231553,0.913800050254382,0.0,0.0 }; - vector b { 0.0031954608137085,0.0180937089815597,0.0508407778575426,0.0895040074158415,0.107385387168148,0.0895040074158415,0.0508407778575426,0.0180937089815597,0.0031954608137085,0.0,0.0 }; - - Filter f({ a, b }); - - vector in { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; - - vector expected { 0.003195460813709, 0.006094690058282, 0.009370240771381, 0.012857578361690, 0.015328760300750, 0.019107809614909, 0.022257958968869, 0.024598034053011, 0.029106103380941, 0.031152166476509, 0.034424013713795, 0.038775350541015, 0.039924063374886, 0.044846280036012, 0.047614917256999, 0.049338485830505 }; - - int n = expected.size(); - vector out(n, 0.0); - - f.process(in.data(), out.data(), n); - - bool good = true; - double thresh = 1e-12; - - for (int i = 0; i < n; ++i) { - if (fabs(out[i] - expected[i]) > thresh) { - cerr << "ERROR: out[" << i << "] (" << out[i] - << ") differs from expected[" << i << "] (" << expected[i] - << ") by " << out[i] - expected[i] << endl; - good = false; - } - } - - // FIR - - b = { -1.5511e-18,-0.022664,1.047e-17,0.27398,0.49737,0.27398,1.047e-17,-0.022664,-1.5511e-18 }; - Filter ff({ {}, b }); - - expected = { -1.5511e-18,-0.022664,-0.045328,0.20599,0.95467,1.9773,3,4,5,6,7,8,9,10,11,12 }; - - n = expected.size(); - - ff.process(in.data(), out.data(), n); - - thresh = 1e-4; - - for (int i = 0; i < n; ++i) { - if (fabs(out[i] - expected[i]) > thresh) { - cerr << "ERROR: out[" << i << "] (" << out[i] - << ") differs from expected[" << i << "] (" << expected[i] - << ") by " << out[i] - expected[i] << endl; - good = false; - } - } - - if (good) { - cerr << "Success" << endl; - return 0; - } else { - return 1; - } -} - diff -r 6daf77dab8a4 -r 00b6ae41efbe src/test-normalise.cpp --- a/src/test-normalise.cpp Wed Oct 07 09:22:40 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ - -#include "Normalise.h" - -#include -#include - -using namespace std; - -void check(string context, vector got, vector expected, bool &good) -{ - double thresh = 1e-4; - for (int i = 0; i < int(got.size()); ++i) { - if (fabs(got[i] - expected[i]) > thresh) { - cerr << "ERROR: " << context << "[" << i << "] (" << got[i] - << ") differs from expected " << expected[i] << endl; - good = false; - } - } -} - -int main(int argc, char **argv) -{ - bool good = true; - - vector in { -1, 1.5, 3, 5 }; - - vector out, expected; - - out = Normalise::normalise(in, 1); - expected = { -0.095238, 0.142857, 0.285714, 0.476190 }; - check("L1", out, expected, good); - - out = Normalise::normalise(in, 2); - expected = { -0.16385, 0.24577, 0.49154, 0.81923 }; - check("L2", out, expected, good); - - out = Normalise::normalise(in, 3); - expected = { -0.18561, 0.27842, 0.55684, 0.92807 }; - check("L3", out, expected, good); - - in = { 0, 0, 0, 0 }; - - out = Normalise::normalise(in, 1); - expected = { 0.25, 0.25, 0.25, 0.25 }; - check("L1_zero", out, expected, good); - - out = Normalise::normalise(in, 2); - expected = { 0.5, 0.5, 0.5, 0.5 }; - check("L2_zero", out, expected, good); - - out = Normalise::normalise(in, 3); - expected = { 0.62996, 0.62996, 0.62996, 0.62996 }; - check("L3_zero", out, expected, good); - - if (good) { - cerr << "Success" << endl; - return 0; - } else { - return 1; - } -} - -