changeset 14:812e4d021443

Merge
author Chris Cannam
date Wed, 04 Feb 2015 15:11:42 +0000
parents c74071731d74 (diff) 72cad1c30b79 (current diff)
children 994f5294996d
files chroma-compare-plugin/TuningDifference.cpp spectrum-compare-plugin/TuningDifference.cpp
diffstat 27 files changed, 1339 insertions(+), 662 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/chroma-compare-plugin/Makefile.inc	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,53 @@
+
+# Edit this to the base name of your plugin library
+#
+PLUGIN_LIBRARY_NAME := tuning-difference
+
+# Edit this to list the .cpp or .c files in your plugin project
+#
+PLUGIN_SOURCES := TuningDifference.cpp plugins.cpp
+
+# Edit this to list the .h files in your plugin project
+#
+PLUGIN_HEADERS := TuningDifference.h
+
+
+##  Normally you should not edit anything below this line
+
+SRC_DIR		:= .
+
+CFLAGS		:= $(ARCHFLAGS) $(CFLAGS)
+CXXFLAGS	:= $(CFLAGS) -I. -I$(VAMPSDK_DIR) -I../../constant-q-cpp $(CXXFLAGS)
+
+LDFLAGS		:= $(ARCHFLAGS) $(LDFLAGS) -L../../constant-q-cpp -lcq
+PLUGIN_LDFLAGS	:= $(LDFLAGS) $(PLUGIN_LDFLAGS)
+
+# Defaults, overridden from the platform-specific Makefile
+VAMPSDK_DIR	?= ../vamp-plugin-sdk
+PLUGIN_EXT	?= .so
+CXX 		?= g++
+CC 		?= gcc
+
+PLUGIN 		:= $(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT)
+
+PLUGIN_OBJECTS 	:= $(PLUGIN_SOURCES:.cpp=.o)
+PLUGIN_OBJECTS 	:= $(PLUGIN_OBJECTS:.c=.o)
+
+$(PLUGIN): $(PLUGIN_OBJECTS) 
+	   $(CXX) -o $@ $^ $(PLUGIN_LDFLAGS)
+
+$(PLUGIN_OBJECTS): $(PLUGIN_HEADERS)
+
+clean:
+	rm -f $(PLUGIN_OBJECTS)
+
+distclean:	clean
+	rm -f $(PLUGIN)
+
+depend:
+	makedepend -Y -fMakefile.inc $(PLUGIN_SOURCES) $(PLUGIN_HEADERS)
+
+# DO NOT DELETE
+
+TuningDifference.o: TuningDifference.h
+plugins.o: TuningDifference.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/chroma-compare-plugin/Makefile.linux	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,29 @@
+
+# For a debug build...
+
+CXXFLAGS	:= -Wall -Wextra -Werror -g -fPIC -std=c++11
+
+# ... or for a release build
+
+#CXXFLAGS	:= -Wall -Wextra -Werror -O3 -msse -msse2 -mfpmath=sse -ftree-vectorize -fPIC -std=c++11
+
+
+# Location of Vamp plugin SDK relative to the project directory
+
+VAMPSDK_DIR	:= ../../vamp-plugin-sdk
+
+
+# Libraries and linker flags required by plugin: add any -l<library>
+# options here
+
+PLUGIN_LDFLAGS	:= -shared -Wl,-Bsymbolic -Wl,-z,defs -Wl,--version-script=vamp-plugin.map $(VAMPSDK_DIR)/libvamp-sdk.a
+
+
+# File extension for plugin library on this platform
+
+PLUGIN_EXT	:= .so
+
+
+include Makefile.inc
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/chroma-compare-plugin/Makefile.mingw32	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,43 @@
+
+##  Makefile for Vamp plugin using MinGW tools on Windows.
+##
+##  Edit this to adjust compiler and library settings when
+##  building using MinGW.
+##
+##  Note that the list of source files, etc, goes in Makefile.inc
+##  instead so that it can be included by all platform Makefiles.
+
+TOOLPREFIX     ?= 
+CXX		= $(TOOLPREFIX)g++
+CC		= $(TOOLPREFIX)gcc
+LD		= $(TOOLPREFIX)g++
+AR		= $(TOOLPREFIX)ar
+RANLIB		= $(TOOLPREFIX)ranlib
+
+
+# For a debug build...
+
+CFLAGS		:= -Wall -Wextra -g
+
+# ... or for a release build
+
+#CFLAGS		:= -Wall -Wextra -O3 -ftree-vectorize
+
+
+# Location of Vamp plugin SDK relative to the project directory
+
+VAMPSDK_DIR	:= ../vamp-plugin-sdk
+
+
+# Libraries and linker flags required by plugin: add any -l<library>
+# options here
+
+PLUGIN_LDFLAGS	:= -shared -static -Wl,--retain-symbols-file=vamp-plugin.list $(VAMPSDK_DIR)/libvamp-sdk.a
+
+
+# File extension for plugin library on this platform
+
+PLUGIN_EXT	:= .dll
+
+
+include Makefile.inc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/chroma-compare-plugin/Makefile.osx	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,43 @@
+
+##  Makefile for Vamp plugin using command-line tools on OS/X.
+##
+##  Edit this to adjust compiler and library settings when
+##  building for OS/X.
+##
+##  Note that the list of source files, etc, goes in Makefile.inc
+##  instead so that it can be included by all platform Makefiles.
+
+
+# For a debug build...
+
+CFLAGS		:= -Wall -Wextra -g -fPIC
+
+# ... or for a release build
+
+#CFLAGS		:= -Wall -Wextra -O3 -ftree-vectorize -fPIC
+
+
+# Flags to determine processor architecture and system SDK
+
+ARCHFLAGS	?= -mmacosx-version-min=10.6 -arch x86_64 -arch i386
+
+
+# Location of Vamp plugin SDK relative to the project directory
+
+VAMPSDK_DIR	:= ../vamp-plugin-sdk
+
+
+# Libraries and linker flags required by plugin: add any -l<library>
+# options here
+
+PLUGIN_LDFLAGS	:= -dynamiclib -exported_symbols_list vamp-plugin.list $(VAMPSDK_DIR)/libvamp-sdk.a
+
+
+# File extension for plugin library on this platform
+
+PLUGIN_EXT	:= .dylib
+
+
+include Makefile.inc
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/chroma-compare-plugin/TuningDifference.cpp	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,410 @@
+
+#include "TuningDifference.h"
+
+#include <iostream>
+
+#include <cmath>
+#include <cstdio>
+
+#include <algorithm>
+
+using namespace std;
+
+static double pitchToFrequency(int pitch,
+			       double centsOffset = 0.,
+			       double concertA = 440.)
+{
+    double p = double(pitch) + (centsOffset / 100.);
+    return concertA * pow(2.0, (p - 69.0) / 12.0); 
+}
+
+static double frequencyForCentsAbove440(double cents)
+{
+    return pitchToFrequency(69, cents, 440.);
+}
+
+TuningDifference::TuningDifference(float inputSampleRate) :
+    Plugin(inputSampleRate),
+    m_bpo(60),
+    m_refCQ(new CQSpectrogram(paramsForTuningFrequency(440.),
+			      CQSpectrogram::InterpolateHold))
+{
+}
+
+TuningDifference::~TuningDifference()
+{
+}
+
+string
+TuningDifference::getIdentifier() const
+{
+    return "tuning-difference";
+}
+
+string
+TuningDifference::getName() const
+{
+    return "Tuning Difference";
+}
+
+string
+TuningDifference::getDescription() const
+{
+    // Return something helpful here!
+    return "";
+}
+
+string
+TuningDifference::getMaker() const
+{
+    // Your name here
+    return "";
+}
+
+int
+TuningDifference::getPluginVersion() const
+{
+    // Increment this each time you release a version that behaves
+    // differently from the previous one
+    return 1;
+}
+
+string
+TuningDifference::getCopyright() const
+{
+    // This function is not ideally named.  It does not necessarily
+    // need to say who made the plugin -- getMaker does that -- but it
+    // should indicate the terms under which it is distributed.  For
+    // example, "Copyright (year). All Rights Reserved", or "GPL"
+    return "";
+}
+
+TuningDifference::InputDomain
+TuningDifference::getInputDomain() const
+{
+    return TimeDomain;
+}
+
+size_t
+TuningDifference::getPreferredBlockSize() const
+{
+    return 0;
+}
+
+size_t 
+TuningDifference::getPreferredStepSize() const
+{
+    return 0;
+}
+
+size_t
+TuningDifference::getMinChannelCount() const
+{
+    return 2;
+}
+
+size_t
+TuningDifference::getMaxChannelCount() const
+{
+    return 2;
+}
+
+TuningDifference::ParameterList
+TuningDifference::getParameterDescriptors() const
+{
+    ParameterList list;
+    return list;
+}
+
+float
+TuningDifference::getParameter(string) const
+{
+    return 0;
+}
+
+void
+TuningDifference::setParameter(string, float) 
+{
+}
+
+TuningDifference::ProgramList
+TuningDifference::getPrograms() const
+{
+    ProgramList list;
+    return list;
+}
+
+string
+TuningDifference::getCurrentProgram() const
+{
+    return ""; // no programs
+}
+
+void
+TuningDifference::selectProgram(string)
+{
+}
+
+TuningDifference::OutputList
+TuningDifference::getOutputDescriptors() const
+{
+    OutputList list;
+
+    OutputDescriptor d;
+    d.identifier = "cents";
+    d.name = "Tuning Difference";
+    d.description = "Difference in averaged frequency profile between channels 1 and 2, in cents. A positive value means channel 2 is higher.";
+    d.unit = "cents";
+    d.hasFixedBinCount = true;
+    d.binCount = 1;
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::VariableSampleRate;
+    d.hasDuration = false;
+    m_outputs[d.identifier] = list.size();
+    list.push_back(d);
+
+    d.identifier = "tuningfreq";
+    d.name = "Relative Tuning Frequency";
+    d.description = "Tuning frequency of channel 2, if channel 1 is assumed to contain the same music as it at a tuning frequency of A=440Hz.";
+    d.unit = "hz";
+    d.hasFixedBinCount = true;
+    d.binCount = 1;
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::VariableSampleRate;
+    d.hasDuration = false;
+    m_outputs[d.identifier] = list.size();
+    list.push_back(d);
+
+    d.identifier = "reffeature";
+    d.name = "Reference Feature";
+    d.description = "Chroma feature from reference audio.";
+    d.unit = "";
+    d.hasFixedBinCount = true;
+    d.binCount = m_bpo;
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::FixedSampleRate;
+    d.sampleRate = 1;
+    d.hasDuration = false;
+    m_outputs[d.identifier] = list.size();
+    list.push_back(d);
+
+    d.identifier = "otherfeature";
+    d.name = "Other Feature";
+    d.description = "Chroma feature from other audio, before rotation.";
+    d.unit = "";
+    d.hasFixedBinCount = true;
+    d.binCount = m_bpo;
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::FixedSampleRate;
+    d.sampleRate = 1;
+    d.hasDuration = false;
+    m_outputs[d.identifier] = list.size();
+    list.push_back(d);
+
+    d.identifier = "rotfeature";
+    d.name = "Other Feature at Rotated Frequency";
+    d.description = "Chroma feature from reference audio calculated with the tuning frequency obtained from rotation matching.";
+    d.unit = "";
+    d.hasFixedBinCount = true;
+    d.binCount = m_bpo;
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::FixedSampleRate;
+    d.sampleRate = 1;
+    d.hasDuration = false;
+    m_outputs[d.identifier] = list.size();
+    list.push_back(d);
+
+    return list;
+}
+
+bool
+TuningDifference::initialise(size_t channels, size_t stepSize, size_t blockSize)
+{
+    if (channels < getMinChannelCount() ||
+	channels > getMaxChannelCount()) return false;
+
+    if (stepSize != blockSize) return false;
+
+    m_blockSize = blockSize;
+
+    reset();
+    
+    return true;
+}
+
+void
+TuningDifference::reset()
+{
+    if (m_frameCount > 0) {
+	m_refCQ.reset(new CQSpectrogram(paramsForTuningFrequency(440.),
+					CQSpectrogram::InterpolateHold));
+	m_frameCount = 0;
+    }
+    m_refTotals = Chroma(m_refCQ->getTotalBins(), 0.0);
+    m_other.clear();
+}
+
+template<typename T>
+void addTo(vector<T> &a, const vector<T> &b)
+{
+    transform(a.begin(), a.end(), b.begin(), a.begin(), plus<T>());
+}
+
+template<typename T>
+T distance(const vector<T> &a, const vector<T> &b)
+{
+    return inner_product(a.begin(), a.end(), b.begin(), T(),
+			 plus<T>(), [](T x, T y) { return fabs(x - y); });
+}
+
+TuningDifference::TFeature
+TuningDifference::computeFeatureFromTotals(const Chroma &totals) const
+{
+    TFeature feature(m_bpo);
+    double sum = 0.0;
+    
+    for (int i = 0; i < (int)totals.size(); ++i) {
+	double value = totals[i] / m_frameCount;
+	feature[i % m_bpo] += value;
+	sum += value;
+    }
+
+    for (int i = 0; i < m_bpo; ++i) {
+	feature[i] /= sum;
+    }
+
+    cerr << "computeFeatureFromTotals: feature values:" << endl;
+    for (auto v: feature) cerr << v << " ";
+    cerr << endl;
+    
+    return feature;
+}
+
+CQParameters
+TuningDifference::paramsForTuningFrequency(double hz) const
+{
+    return CQParameters(m_inputSampleRate,
+			pitchToFrequency(36, hz),
+			pitchToFrequency(96, hz),
+			m_bpo);
+}
+
+TuningDifference::TFeature
+TuningDifference::computeFeatureFromSignal(const Signal &signal, double hz) const
+{
+    CQSpectrogram cq(paramsForTuningFrequency(hz),
+		     CQSpectrogram::InterpolateHold);
+
+    Chroma totals(m_refCQ->getTotalBins(), 0.0);
+    
+    for (int i = 0; i < m_frameCount; ++i) {
+	Signal::const_iterator first = signal.begin() + i * m_blockSize;
+	Signal::const_iterator last = first + m_blockSize;
+	if (last > signal.end()) last = signal.end();
+	CQSpectrogram::RealSequence input(first, last);
+	input.resize(m_blockSize);
+	CQSpectrogram::RealBlock block = cq.process(input);
+	for (const auto &v: block) addTo(totals, v);
+    }
+
+    return computeFeatureFromTotals(totals);
+}
+
+TuningDifference::FeatureSet
+TuningDifference::process(const float *const *inputBuffers, Vamp::RealTime)
+{
+    CQSpectrogram::RealBlock block;
+    CQSpectrogram::RealSequence input;
+
+    input = CQSpectrogram::RealSequence
+	(inputBuffers[0], inputBuffers[0] + m_blockSize);
+    block = m_refCQ->process(input);
+    for (const auto &v: block) addTo(m_refTotals, v);
+
+    m_other.insert(m_other.end(),
+		   inputBuffers[1], inputBuffers[1] + m_blockSize);
+    
+    ++m_frameCount;
+    return FeatureSet();
+}
+
+double
+TuningDifference::featureDistance(const TFeature &other, int rotation) const
+{
+    if (rotation == 0) {
+	return distance(m_refFeature, other);
+    } else {
+	TFeature r(other);
+	if (rotation > 0) {
+	    rotate(r.begin(), r.begin() + rotation, r.end());
+	} else {
+	    rotate(r.begin(), r.end() + rotation, r.end());
+	}
+	return distance(m_refFeature, r);
+    }
+}
+
+int
+TuningDifference::findBestRotation(const TFeature &other) const
+{
+    map<double, int> dists;
+
+    int maxSemis = 6;
+    int maxRotation = (m_bpo * maxSemis) / 12;
+
+    for (int r = -maxRotation; r <= maxRotation; ++r) {
+	double dist = featureDistance(other, r);
+	dists[dist] = r;
+	cerr << "rotation " << r << ": score " << dist << endl;
+    }
+
+    int best = dists.begin()->second;
+
+    cerr << "best is " << best << endl;
+    return best;
+}
+
+TuningDifference::FeatureSet
+TuningDifference::getRemainingFeatures()
+{
+    FeatureSet fs;
+    if (m_frameCount == 0) return fs;
+
+    m_refFeature = computeFeatureFromTotals(m_refTotals);
+    TFeature otherFeature = computeFeatureFromSignal(m_other, 440.);
+
+    Feature f;
+
+    f.values.clear();
+    for (auto v: m_refFeature) f.values.push_back(v);
+    fs[m_outputs["reffeature"]].push_back(f);
+
+    f.values.clear();
+    for (auto v: otherFeature) f.values.push_back(v);
+    fs[m_outputs["otherfeature"]].push_back(f); 
+   
+    int rotation = findBestRotation(otherFeature);
+
+    int coarseCents = -(rotation * 100) / (m_bpo / 12);
+
+    cerr << "rotation " << rotation << " -> cents " << coarseCents << endl;
+
+    double coarseHz = frequencyForCentsAbove440(coarseCents);
+
+    TFeature coarseFeature = computeFeatureFromSignal(m_other, coarseHz);
+    double coarseScore = featureDistance(coarseFeature);
+
+    cerr << "corresponding Hz " << coarseHz << " scores " << coarseScore << endl;
+
+    f.values.clear();
+    for (auto v: coarseFeature) f.values.push_back(v);
+    fs[m_outputs["rotfeature"]].push_back(f);
+    
+    return fs;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/chroma-compare-plugin/TuningDifference.h	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,73 @@
+#ifndef TUNING_DIFFERENCE_H
+#define TUNING_DIFFERENCE_H
+
+#include <vamp-sdk/Plugin.h>
+
+#include <cq/CQSpectrogram.h>
+
+#include <memory>
+
+using std::string;
+using std::vector;
+
+class TuningDifference : public Vamp::Plugin
+{
+public:
+    TuningDifference(float inputSampleRate);
+    virtual ~TuningDifference();
+
+    string getIdentifier() const;
+    string getName() const;
+    string getDescription() const;
+    string getMaker() const;
+    int getPluginVersion() const;
+    string getCopyright() const;
+
+    InputDomain getInputDomain() const;
+    size_t getPreferredBlockSize() const;
+    size_t getPreferredStepSize() const;
+    size_t getMinChannelCount() const;
+    size_t getMaxChannelCount() const;
+
+    ParameterList getParameterDescriptors() const;
+    float getParameter(string identifier) const;
+    void setParameter(string identifier, float value);
+
+    ProgramList getPrograms() const;
+    string getCurrentProgram() const;
+    void selectProgram(string name);
+
+    OutputList getOutputDescriptors() const;
+
+    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
+    void reset();
+
+    FeatureSet process(const float *const *inputBuffers,
+                       Vamp::RealTime timestamp);
+
+    FeatureSet getRemainingFeatures();
+
+protected:
+    typedef vector<float> Signal;
+    typedef vector<double> Chroma;
+    typedef vector<double> TFeature;
+
+    int m_bpo;
+    std::unique_ptr<CQSpectrogram> m_refCQ;
+    Chroma m_refTotals;
+    TFeature m_refFeature;
+    Signal m_other;
+    int m_blockSize;
+    int m_frameCount;
+
+    CQParameters paramsForTuningFrequency(double hz) const;
+    TFeature computeFeatureFromTotals(const Chroma &totals) const;
+    TFeature computeFeatureFromSignal(const Signal &signal, double hz) const;
+    double featureDistance(const TFeature &other, int rotation = 0) const;
+    int findBestRotation(const TFeature &other) const;
+
+    mutable std::map<string, int> m_outputs;
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/chroma-compare-plugin/plugins.cpp	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,21 @@
+
+#include <vamp/vamp.h>
+#include <vamp-sdk/PluginAdapter.h>
+
+#include "TuningDifference.h"
+
+static Vamp::PluginAdapter<TuningDifference> tdAdapter;
+
+
+const VampPluginDescriptor *
+vampGetPluginDescriptor(unsigned int version, unsigned int index)
+{
+    if (version < 1) return 0;
+
+    switch (index) {
+    case  0: return tdAdapter.getDescriptor();
+    default: return 0;
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/chroma-compare-plugin/vamp-plugin.list	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,1 @@
+_vampGetPluginDescriptor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/chroma-compare-plugin/vamp-plugin.map	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,4 @@
+{
+	global: vampGetPluginDescriptor;
+	local: *;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spectrum-compare-plugin/Makefile.inc	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,77 @@
+
+##  Makefile for Vamp plugin builds using command-line tools.
+##
+##  This file defines all of the system-independent information about
+##  your project: the list of source files, plugin library name, etc.
+##  Edit this file to make sure it has all the right information.
+##
+##  This file does not define the system-specific stuff such as which
+##  compiler to use -- that goes into Makefile.osx, Makefile.mingw32,
+##  Makefile.linux etc.  Those files all include this file, so that
+##  they all have a consistent set of project data.
+##
+##  To build the plugin project, type
+##
+##    $ gmake -f Makefile.osx
+##
+##  or whatever the equivalent filename suffix is for your platform.
+##
+##  This requires GNU make, which is what you get with OS/X, Linux, or
+##  MinGW/Cygwin on Windows.
+##
+##  (For Windows builds using MS Visual Studio, start instead with the
+##  VampExamplePlugins project found in the build directory of the SDK.)
+
+
+# Edit this to the base name of your plugin library
+#
+PLUGIN_LIBRARY_NAME := tuning-difference
+
+# Edit this to list the .cpp or .c files in your plugin project
+#
+PLUGIN_SOURCES := TuningDifference.cpp plugins.cpp
+
+# Edit this to list the .h files in your plugin project
+#
+PLUGIN_HEADERS := TuningDifference.h
+
+
+##  Normally you should not edit anything below this line
+
+SRC_DIR		:= .
+
+CFLAGS		:= $(ARCHFLAGS) $(CFLAGS)
+CXXFLAGS	:= $(CFLAGS) -I. -I$(VAMPSDK_DIR) $(CXXFLAGS)
+
+LDFLAGS		:= $(ARCHFLAGS) $(LDFLAGS) 
+PLUGIN_LDFLAGS	:= $(LDFLAGS) $(PLUGIN_LDFLAGS)
+
+# Defaults, overridden from the platform-specific Makefile
+VAMPSDK_DIR	?= ../vamp-plugin-sdk
+PLUGIN_EXT	?= .so
+CXX 		?= g++
+CC 		?= gcc
+
+PLUGIN 		:= $(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT)
+
+PLUGIN_OBJECTS 	:= $(PLUGIN_SOURCES:.cpp=.o)
+PLUGIN_OBJECTS 	:= $(PLUGIN_OBJECTS:.c=.o)
+
+$(PLUGIN): $(PLUGIN_OBJECTS) 
+	   $(CXX) -o $@ $^ $(PLUGIN_LDFLAGS)
+
+$(PLUGIN_OBJECTS): $(PLUGIN_HEADERS)
+
+clean:
+	rm -f $(PLUGIN_OBJECTS)
+
+distclean:	clean
+	rm -f $(PLUGIN)
+
+depend:
+	makedepend -Y -fMakefile.inc $(PLUGIN_SOURCES) $(PLUGIN_HEADERS)
+
+# DO NOT DELETE
+
+TuningDifference.o: TuningDifference.h
+plugins.o: TuningDifference.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spectrum-compare-plugin/Makefile.linux	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,38 @@
+
+##  Makefile for Vamp plugin using GNU tools on Linux.
+##
+##  Edit this to adjust compiler and library settings when
+##  building for Linux.
+##
+##  Note that the list of source files, etc, goes in Makefile.inc
+##  instead so that it can be included by all platform Makefiles.
+
+
+# For a debug build...
+
+CFLAGS		:= -Wall -Wextra -g -fPIC
+
+# ... or for a release build
+
+#CFLAGS		:= -Wall -Wextra -O3 -msse -msse2 -mfpmath=sse -ftree-vectorize -fPIC
+
+
+# Location of Vamp plugin SDK relative to the project directory
+
+VAMPSDK_DIR	:= ../vamp-plugin-sdk
+
+
+# Libraries and linker flags required by plugin: add any -l<library>
+# options here
+
+PLUGIN_LDFLAGS	:= -shared -Wl,-Bsymbolic -Wl,-z,defs -Wl,--version-script=vamp-plugin.map $(VAMPSDK_DIR)/libvamp-sdk.a
+
+
+# File extension for plugin library on this platform
+
+PLUGIN_EXT	:= .so
+
+
+include Makefile.inc
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spectrum-compare-plugin/Makefile.mingw32	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,43 @@
+
+##  Makefile for Vamp plugin using MinGW tools on Windows.
+##
+##  Edit this to adjust compiler and library settings when
+##  building using MinGW.
+##
+##  Note that the list of source files, etc, goes in Makefile.inc
+##  instead so that it can be included by all platform Makefiles.
+
+TOOLPREFIX     ?= 
+CXX		= $(TOOLPREFIX)g++
+CC		= $(TOOLPREFIX)gcc
+LD		= $(TOOLPREFIX)g++
+AR		= $(TOOLPREFIX)ar
+RANLIB		= $(TOOLPREFIX)ranlib
+
+
+# For a debug build...
+
+CFLAGS		:= -Wall -Wextra -g
+
+# ... or for a release build
+
+#CFLAGS		:= -Wall -Wextra -O3 -ftree-vectorize
+
+
+# Location of Vamp plugin SDK relative to the project directory
+
+VAMPSDK_DIR	:= ../vamp-plugin-sdk
+
+
+# Libraries and linker flags required by plugin: add any -l<library>
+# options here
+
+PLUGIN_LDFLAGS	:= -shared -static -Wl,--retain-symbols-file=vamp-plugin.list $(VAMPSDK_DIR)/libvamp-sdk.a
+
+
+# File extension for plugin library on this platform
+
+PLUGIN_EXT	:= .dll
+
+
+include Makefile.inc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spectrum-compare-plugin/Makefile.osx	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,43 @@
+
+##  Makefile for Vamp plugin using command-line tools on OS/X.
+##
+##  Edit this to adjust compiler and library settings when
+##  building for OS/X.
+##
+##  Note that the list of source files, etc, goes in Makefile.inc
+##  instead so that it can be included by all platform Makefiles.
+
+
+# For a debug build...
+
+CFLAGS		:= -Wall -Wextra -g -fPIC
+
+# ... or for a release build
+
+#CFLAGS		:= -Wall -Wextra -O3 -ftree-vectorize -fPIC
+
+
+# Flags to determine processor architecture and system SDK
+
+ARCHFLAGS	?= -mmacosx-version-min=10.6 -arch x86_64 -arch i386
+
+
+# Location of Vamp plugin SDK relative to the project directory
+
+VAMPSDK_DIR	:= ../vamp-plugin-sdk
+
+
+# Libraries and linker flags required by plugin: add any -l<library>
+# options here
+
+PLUGIN_LDFLAGS	:= -dynamiclib -exported_symbols_list vamp-plugin.list $(VAMPSDK_DIR)/libvamp-sdk.a
+
+
+# File extension for plugin library on this platform
+
+PLUGIN_EXT	:= .dylib
+
+
+include Makefile.inc
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spectrum-compare-plugin/TuningDifference.cpp	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,382 @@
+
+#include "TuningDifference.h"
+
+#include <iostream>
+
+#include <cmath>
+#include <cstdio>
+
+using std::cerr;
+using std::endl;
+
+static double targetFmin = 60.0;
+static double targetFmax = 1500.0;
+
+TuningDifference::TuningDifference(float inputSampleRate) :
+    Plugin(inputSampleRate)
+{
+}
+
+TuningDifference::~TuningDifference()
+{
+}
+
+string
+TuningDifference::getIdentifier() const
+{
+    return "tuning-difference";
+}
+
+string
+TuningDifference::getName() const
+{
+    return "Tuning Difference";
+}
+
+string
+TuningDifference::getDescription() const
+{
+    // Return something helpful here!
+    return "";
+}
+
+string
+TuningDifference::getMaker() const
+{
+    // Your name here
+    return "";
+}
+
+int
+TuningDifference::getPluginVersion() const
+{
+    // Increment this each time you release a version that behaves
+    // differently from the previous one
+    return 1;
+}
+
+string
+TuningDifference::getCopyright() const
+{
+    // This function is not ideally named.  It does not necessarily
+    // need to say who made the plugin -- getMaker does that -- but it
+    // should indicate the terms under which it is distributed.  For
+    // example, "Copyright (year). All Rights Reserved", or "GPL"
+    return "";
+}
+
+TuningDifference::InputDomain
+TuningDifference::getInputDomain() const
+{
+    return FrequencyDomain;
+}
+
+size_t
+TuningDifference::getPreferredBlockSize() const
+{
+    return 16384;
+}
+
+size_t 
+TuningDifference::getPreferredStepSize() const
+{
+    return 0;
+}
+
+size_t
+TuningDifference::getMinChannelCount() const
+{
+    return 2;
+}
+
+size_t
+TuningDifference::getMaxChannelCount() const
+{
+    return 2;
+}
+
+TuningDifference::ParameterList
+TuningDifference::getParameterDescriptors() const
+{
+    ParameterList list;
+    return list;
+}
+
+float
+TuningDifference::getParameter(string) const
+{
+    return 0;
+}
+
+void
+TuningDifference::setParameter(string, float) 
+{
+}
+
+TuningDifference::ProgramList
+TuningDifference::getPrograms() const
+{
+    ProgramList list;
+    return list;
+}
+
+string
+TuningDifference::getCurrentProgram() const
+{
+    return ""; // no programs
+}
+
+void
+TuningDifference::selectProgram(string)
+{
+}
+
+TuningDifference::OutputList
+TuningDifference::getOutputDescriptors() const
+{
+    OutputList list;
+
+    OutputDescriptor d;
+    d.identifier = "cents";
+    d.name = "Tuning Difference";
+    d.description = "Difference in averaged frequency profile between channels 1 and 2, in cents. A positive value means channel 2 is higher.";
+    d.unit = "cents";
+    d.hasFixedBinCount = true;
+    d.binCount = 1;
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::VariableSampleRate;
+    d.hasDuration = false;
+    list.push_back(d);
+
+    d.identifier = "tuningfreq";
+    d.name = "Relative Tuning Frequency";
+    d.description = "Tuning frequency of channel 2, if channel 1 is assumed to contain the same music as it at a tuning frequency of A=440Hz.";
+    d.unit = "hz";
+    d.hasFixedBinCount = true;
+    d.binCount = 1;
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::VariableSampleRate;
+    d.hasDuration = false;
+    list.push_back(d);
+
+    d.identifier = "curve";
+    d.name = "Shift Correlation Curve";
+    d.description = "Correlation between shifted and unshifted sources, for each probed shift in cents.";
+    d.unit = "";
+    d.hasFixedBinCount = true;
+    d.binCount = 1;
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::FixedSampleRate;
+    d.sampleRate = 100;
+    d.hasDuration = false;
+    list.push_back(d);
+
+    int targetBinMin = int(floor(targetFmin * m_blockSize / m_inputSampleRate));
+    int targetBinMax = int(ceil(targetFmax * m_blockSize / m_inputSampleRate));
+    cerr << "target bin range: " << targetBinMin << " -> " << targetBinMax << endl;
+
+    d.identifier = "averages";
+    d.name = "Harmonic spectrum averages";
+    d.description = "Average of harmonic spectrum for each channel.";
+    d.unit = "";
+    d.hasFixedBinCount = true;
+    d.binCount = (targetBinMax > targetBinMin ? targetBinMax - targetBinMin + 1 : 100);
+    d.hasKnownExtents = false;
+    d.isQuantized = false;
+    d.sampleType = OutputDescriptor::FixedSampleRate;
+    d.sampleRate = 1;
+    d.hasDuration = false;
+    list.push_back(d);
+
+    return list;
+}
+
+bool
+TuningDifference::initialise(size_t channels, size_t stepSize, size_t blockSize)
+{
+    if (channels < getMinChannelCount() ||
+	channels > getMaxChannelCount()) return false;
+
+    if (blockSize != getPreferredBlockSize() ||
+	stepSize != blockSize/2) return false;
+
+    m_blockSize = blockSize;
+
+    reset();
+    
+    return true;
+}
+
+void
+TuningDifference::reset()
+{
+    m_sum[0].clear();
+    m_sum[1].clear();
+    m_frameCount = 0;
+}
+
+TuningDifference::FeatureSet
+TuningDifference::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
+{
+    for (int c = 0; c < 2; ++c) {
+	if (m_sum[c].size() == 0) {
+	    m_sum[c].resize(m_blockSize/2 + 1, 0.0);
+	}
+	vector<double> mags(m_blockSize/2 + 1, 0.0);
+	for (int i = 0; i <= m_blockSize/2; ++i) {
+	    double energy =
+		inputBuffers[c][i*2  ] * inputBuffers[c][i*2  ] +
+		inputBuffers[c][i*2+1] * inputBuffers[c][i*2+1];
+	    double mag = sqrt(energy);
+	    mags[i] = mag;
+	}
+	for (int i = 0; i <= m_blockSize/2; ++i) {
+	    for (int h = 2; h <= 4; ++h) {
+		double max = 0.0;
+		for (int j = 0; j <= h; ++j) {
+		    int ix = i * h + j - h/2;
+		    if (ix <= m_blockSize/2) {
+			double harmMag = mags[ix];
+			if (j == 0 || harmMag > max) {
+			    max = harmMag;
+			}
+		    }
+		}
+		mags[i] += max;
+	    }
+	}
+	for (int i = 0; i <= m_blockSize/2; ++i) {
+	    m_sum[c][i] += mags[i];
+	}
+    }
+    
+    ++m_frameCount;
+    return FeatureSet();
+}
+
+TuningDifference::FeatureSet
+TuningDifference::getRemainingFeatures()
+{
+    int n = m_sum[0].size();
+    if (n == 0) return FeatureSet();
+
+    Feature f;
+    FeatureSet fs;
+
+    int maxshift = 2400; // cents
+
+    int bestshift = -1;
+    double bestdist = 0;
+
+    for (int i = 0; i < n; ++i) {
+	m_sum[0][i] /= m_frameCount;
+	m_sum[1][i] /= m_frameCount;
+    }
+
+    for (int c = 0; c < 2; ++c) {
+	for (int i = 0; i < n; ++i) {
+	    if (i == 0 || i == n-1 ||
+		m_sum[c][i] < m_sum[c][i-1] ||
+		m_sum[c][i] < m_sum[c][i+1]) {
+		m_sum[c][i] = 0.0;
+	    }
+	}
+    }
+
+    int targetBinMin = int(floor(targetFmin * m_blockSize / m_inputSampleRate));
+    int targetBinMax = int(ceil(targetFmax * m_blockSize / m_inputSampleRate));
+    cerr << "target bin range: " << targetBinMin << " -> " << targetBinMax << endl;
+
+    for (int c = 0; c < 2; ++c) {
+	double tot = 0.0;
+	for (int i = targetBinMin; i <= targetBinMax; ++i) {
+	    tot += m_sum[c][i];
+	}
+	if (tot != 0.0) {
+	    for (int i = 0; i < n; ++i) {
+		m_sum[c][i] /= tot;
+	    }
+	}
+    }
+	
+    f.values.clear();
+    for (int i = targetBinMin; i < targetBinMax; ++i) {
+	f.values.push_back(m_sum[0][i]);
+    }
+    fs[3].push_back(f);
+    f.values.clear();
+    for (int i = targetBinMin; i < targetBinMax; ++i) {
+	f.values.push_back(m_sum[1][i]);
+    }
+    fs[3].push_back(f);
+
+    f.values.clear();
+    
+    for (int shift = -maxshift; shift <= maxshift; ++shift) {
+
+	double multiplier = pow(2.0, double(shift) / 1200.0);
+	double dist = 0.0;
+
+//	cerr << "shift = " << shift << ", multiplier = " << multiplier << endl;
+
+	int contributing = 0;
+	
+	for (int i = targetBinMin; i < targetBinMax; ++i) {
+
+	    double source = i / multiplier;
+	    int s0 = int(source), s1 = s0 + 1;
+	    double p1 = source - s0;
+	    double p0 = 1.0 - p1;
+
+	    double value = 0.0;
+	    if (s0 >= 0 && s0 < n) {
+		value += p0 * m_sum[1][s0];
+		++contributing;
+	    }
+	    if (s1 >= 0 && s1 < n) {
+		value += p1 * m_sum[1][s1];
+		++contributing;
+	    }
+
+//	    if (shift == -1) {
+//		cerr << "for multiplier " << multiplier << ", target " << i << ", source " << source << ", value " << p0 << " * " << m_sum[1][s0] << " + " << p1 << " * " << m_sum[1][s1] << " = " << value << ", other " << m_sum[0][i] << endl;
+//	    }
+	    
+	    double diff = fabs(m_sum[0][i] - value);
+	    dist += diff;
+	}
+
+	dist /= contributing;
+	
+	f.values.clear();
+	f.values.push_back(dist);
+	char label[100];
+	sprintf(label, "%f at shift %d freq mult %f", dist, shift, multiplier);
+	f.label = label;
+	fs[2].push_back(f);
+
+	if (bestshift == -1 || dist < bestdist) {
+	    bestshift = shift;
+	    bestdist = dist;
+	}
+    }
+
+    f.timestamp = Vamp::RealTime::zeroTime;
+    f.hasTimestamp = true;
+    f.label = "";
+
+    f.values.clear();
+    cerr << "best dist = " << bestdist << " at shift " << bestshift << endl;
+    f.values.push_back(-bestshift);
+    fs[0].push_back(f);
+
+    f.values.clear();
+    f.values.push_back(440.0 / pow(2.0, double(bestshift) / 1200.0));
+    fs[1].push_back(f);
+    
+    return fs;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spectrum-compare-plugin/TuningDifference.h	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,53 @@
+#ifndef TUNING_DIFFERENCE_H
+#define TUNING_DIFFERENCE_H
+
+#include <vamp-sdk/Plugin.h>
+
+using std::string;
+using std::vector;
+
+class TuningDifference : public Vamp::Plugin
+{
+public:
+    TuningDifference(float inputSampleRate);
+    virtual ~TuningDifference();
+
+    string getIdentifier() const;
+    string getName() const;
+    string getDescription() const;
+    string getMaker() const;
+    int getPluginVersion() const;
+    string getCopyright() const;
+
+    InputDomain getInputDomain() const;
+    size_t getPreferredBlockSize() const;
+    size_t getPreferredStepSize() const;
+    size_t getMinChannelCount() const;
+    size_t getMaxChannelCount() const;
+
+    ParameterList getParameterDescriptors() const;
+    float getParameter(string identifier) const;
+    void setParameter(string identifier, float value);
+
+    ProgramList getPrograms() const;
+    string getCurrentProgram() const;
+    void selectProgram(string name);
+
+    OutputList getOutputDescriptors() const;
+
+    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
+    void reset();
+
+    FeatureSet process(const float *const *inputBuffers,
+                       Vamp::RealTime timestamp);
+
+    FeatureSet getRemainingFeatures();
+
+protected:
+    int m_blockSize;
+    vector<double> m_sum[2];
+    int m_frameCount;
+};
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spectrum-compare-plugin/plugins.cpp	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,21 @@
+
+#include <vamp/vamp.h>
+#include <vamp-sdk/PluginAdapter.h>
+
+#include "TuningDifference.h"
+
+static Vamp::PluginAdapter<TuningDifference> tdAdapter;
+
+
+const VampPluginDescriptor *
+vampGetPluginDescriptor(unsigned int version, unsigned int index)
+{
+    if (version < 1) return 0;
+
+    switch (index) {
+    case  0: return tdAdapter.getDescriptor();
+    default: return 0;
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spectrum-compare-plugin/vamp-plugin.list	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,1 @@
+_vampGetPluginDescriptor
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spectrum-compare-plugin/vamp-plugin.map	Wed Feb 04 15:11:42 2015 +0000
@@ -0,0 +1,4 @@
+{
+	global: vampGetPluginDescriptor;
+	local: *;
+};
--- a/spectrum-compare/Makefile.inc	Tue Feb 03 18:46:54 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-
-##  Makefile for Vamp plugin builds using command-line tools.
-##
-##  This file defines all of the system-independent information about
-##  your project: the list of source files, plugin library name, etc.
-##  Edit this file to make sure it has all the right information.
-##
-##  This file does not define the system-specific stuff such as which
-##  compiler to use -- that goes into Makefile.osx, Makefile.mingw32,
-##  Makefile.linux etc.  Those files all include this file, so that
-##  they all have a consistent set of project data.
-##
-##  To build the plugin project, type
-##
-##    $ gmake -f Makefile.osx
-##
-##  or whatever the equivalent filename suffix is for your platform.
-##
-##  This requires GNU make, which is what you get with OS/X, Linux, or
-##  MinGW/Cygwin on Windows.
-##
-##  (For Windows builds using MS Visual Studio, start instead with the
-##  VampExamplePlugins project found in the build directory of the SDK.)
-
-
-# Edit this to the base name of your plugin library
-#
-PLUGIN_LIBRARY_NAME := tuning-difference
-
-# Edit this to list the .cpp or .c files in your plugin project
-#
-PLUGIN_SOURCES := TuningDifference.cpp plugins.cpp
-
-# Edit this to list the .h files in your plugin project
-#
-PLUGIN_HEADERS := TuningDifference.h
-
-
-##  Normally you should not edit anything below this line
-
-SRC_DIR		:= .
-
-CFLAGS		:= $(ARCHFLAGS) $(CFLAGS)
-CXXFLAGS	:= $(CFLAGS) -I. -I$(VAMPSDK_DIR) $(CXXFLAGS)
-
-LDFLAGS		:= $(ARCHFLAGS) $(LDFLAGS) 
-PLUGIN_LDFLAGS	:= $(LDFLAGS) $(PLUGIN_LDFLAGS)
-
-# Defaults, overridden from the platform-specific Makefile
-VAMPSDK_DIR	?= ../vamp-plugin-sdk
-PLUGIN_EXT	?= .so
-CXX 		?= g++
-CC 		?= gcc
-
-PLUGIN 		:= $(PLUGIN_LIBRARY_NAME)$(PLUGIN_EXT)
-
-PLUGIN_OBJECTS 	:= $(PLUGIN_SOURCES:.cpp=.o)
-PLUGIN_OBJECTS 	:= $(PLUGIN_OBJECTS:.c=.o)
-
-$(PLUGIN): $(PLUGIN_OBJECTS) 
-	   $(CXX) -o $@ $^ $(PLUGIN_LDFLAGS)
-
-$(PLUGIN_OBJECTS): $(PLUGIN_HEADERS)
-
-clean:
-	rm -f $(PLUGIN_OBJECTS)
-
-distclean:	clean
-	rm -f $(PLUGIN)
-
-depend:
-	makedepend -Y -fMakefile.inc $(PLUGIN_SOURCES) $(PLUGIN_HEADERS)
-
-# DO NOT DELETE
-
-TuningDifference.o: TuningDifference.h
-plugins.o: TuningDifference.h
--- a/spectrum-compare/Makefile.linux	Tue Feb 03 18:46:54 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-
-##  Makefile for Vamp plugin using GNU tools on Linux.
-##
-##  Edit this to adjust compiler and library settings when
-##  building for Linux.
-##
-##  Note that the list of source files, etc, goes in Makefile.inc
-##  instead so that it can be included by all platform Makefiles.
-
-
-# For a debug build...
-
-CFLAGS		:= -Wall -Wextra -g -fPIC
-
-# ... or for a release build
-
-#CFLAGS		:= -Wall -Wextra -O3 -msse -msse2 -mfpmath=sse -ftree-vectorize -fPIC
-
-
-# Location of Vamp plugin SDK relative to the project directory
-
-VAMPSDK_DIR	:= ../vamp-plugin-sdk
-
-
-# Libraries and linker flags required by plugin: add any -l<library>
-# options here
-
-PLUGIN_LDFLAGS	:= -shared -Wl,-Bsymbolic -Wl,-z,defs -Wl,--version-script=vamp-plugin.map $(VAMPSDK_DIR)/libvamp-sdk.a
-
-
-# File extension for plugin library on this platform
-
-PLUGIN_EXT	:= .so
-
-
-include Makefile.inc
-
-
--- a/spectrum-compare/Makefile.mingw32	Tue Feb 03 18:46:54 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-
-##  Makefile for Vamp plugin using MinGW tools on Windows.
-##
-##  Edit this to adjust compiler and library settings when
-##  building using MinGW.
-##
-##  Note that the list of source files, etc, goes in Makefile.inc
-##  instead so that it can be included by all platform Makefiles.
-
-TOOLPREFIX     ?= 
-CXX		= $(TOOLPREFIX)g++
-CC		= $(TOOLPREFIX)gcc
-LD		= $(TOOLPREFIX)g++
-AR		= $(TOOLPREFIX)ar
-RANLIB		= $(TOOLPREFIX)ranlib
-
-
-# For a debug build...
-
-CFLAGS		:= -Wall -Wextra -g
-
-# ... or for a release build
-
-#CFLAGS		:= -Wall -Wextra -O3 -ftree-vectorize
-
-
-# Location of Vamp plugin SDK relative to the project directory
-
-VAMPSDK_DIR	:= ../vamp-plugin-sdk
-
-
-# Libraries and linker flags required by plugin: add any -l<library>
-# options here
-
-PLUGIN_LDFLAGS	:= -shared -static -Wl,--retain-symbols-file=vamp-plugin.list $(VAMPSDK_DIR)/libvamp-sdk.a
-
-
-# File extension for plugin library on this platform
-
-PLUGIN_EXT	:= .dll
-
-
-include Makefile.inc
--- a/spectrum-compare/Makefile.osx	Tue Feb 03 18:46:54 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-
-##  Makefile for Vamp plugin using command-line tools on OS/X.
-##
-##  Edit this to adjust compiler and library settings when
-##  building for OS/X.
-##
-##  Note that the list of source files, etc, goes in Makefile.inc
-##  instead so that it can be included by all platform Makefiles.
-
-
-# For a debug build...
-
-CFLAGS		:= -Wall -Wextra -g -fPIC
-
-# ... or for a release build
-
-#CFLAGS		:= -Wall -Wextra -O3 -ftree-vectorize -fPIC
-
-
-# Flags to determine processor architecture and system SDK
-
-ARCHFLAGS	?= -mmacosx-version-min=10.6 -arch x86_64 -arch i386
-
-
-# Location of Vamp plugin SDK relative to the project directory
-
-VAMPSDK_DIR	:= ../vamp-plugin-sdk
-
-
-# Libraries and linker flags required by plugin: add any -l<library>
-# options here
-
-PLUGIN_LDFLAGS	:= -dynamiclib -exported_symbols_list vamp-plugin.list $(VAMPSDK_DIR)/libvamp-sdk.a
-
-
-# File extension for plugin library on this platform
-
-PLUGIN_EXT	:= .dylib
-
-
-include Makefile.inc
-
-
--- a/spectrum-compare/TuningDifference.cpp	Tue Feb 03 18:46:54 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,382 +0,0 @@
-
-#include "TuningDifference.h"
-
-#include <iostream>
-
-#include <cmath>
-#include <cstdio>
-
-using std::cerr;
-using std::endl;
-
-static double targetFmin = 60.0;
-static double targetFmax = 1500.0;
-
-TuningDifference::TuningDifference(float inputSampleRate) :
-    Plugin(inputSampleRate)
-{
-}
-
-TuningDifference::~TuningDifference()
-{
-}
-
-string
-TuningDifference::getIdentifier() const
-{
-    return "tuning-difference";
-}
-
-string
-TuningDifference::getName() const
-{
-    return "Tuning Difference";
-}
-
-string
-TuningDifference::getDescription() const
-{
-    // Return something helpful here!
-    return "";
-}
-
-string
-TuningDifference::getMaker() const
-{
-    // Your name here
-    return "";
-}
-
-int
-TuningDifference::getPluginVersion() const
-{
-    // Increment this each time you release a version that behaves
-    // differently from the previous one
-    return 1;
-}
-
-string
-TuningDifference::getCopyright() const
-{
-    // This function is not ideally named.  It does not necessarily
-    // need to say who made the plugin -- getMaker does that -- but it
-    // should indicate the terms under which it is distributed.  For
-    // example, "Copyright (year). All Rights Reserved", or "GPL"
-    return "";
-}
-
-TuningDifference::InputDomain
-TuningDifference::getInputDomain() const
-{
-    return FrequencyDomain;
-}
-
-size_t
-TuningDifference::getPreferredBlockSize() const
-{
-    return 16384;
-}
-
-size_t 
-TuningDifference::getPreferredStepSize() const
-{
-    return 0;
-}
-
-size_t
-TuningDifference::getMinChannelCount() const
-{
-    return 2;
-}
-
-size_t
-TuningDifference::getMaxChannelCount() const
-{
-    return 2;
-}
-
-TuningDifference::ParameterList
-TuningDifference::getParameterDescriptors() const
-{
-    ParameterList list;
-    return list;
-}
-
-float
-TuningDifference::getParameter(string) const
-{
-    return 0;
-}
-
-void
-TuningDifference::setParameter(string, float) 
-{
-}
-
-TuningDifference::ProgramList
-TuningDifference::getPrograms() const
-{
-    ProgramList list;
-    return list;
-}
-
-string
-TuningDifference::getCurrentProgram() const
-{
-    return ""; // no programs
-}
-
-void
-TuningDifference::selectProgram(string)
-{
-}
-
-TuningDifference::OutputList
-TuningDifference::getOutputDescriptors() const
-{
-    OutputList list;
-
-    OutputDescriptor d;
-    d.identifier = "cents";
-    d.name = "Tuning Difference";
-    d.description = "Difference in averaged frequency profile between channels 1 and 2, in cents. A positive value means channel 2 is higher.";
-    d.unit = "cents";
-    d.hasFixedBinCount = true;
-    d.binCount = 1;
-    d.hasKnownExtents = false;
-    d.isQuantized = false;
-    d.sampleType = OutputDescriptor::VariableSampleRate;
-    d.hasDuration = false;
-    list.push_back(d);
-
-    d.identifier = "tuningfreq";
-    d.name = "Relative Tuning Frequency";
-    d.description = "Tuning frequency of channel 2, if channel 1 is assumed to contain the same music as it at a tuning frequency of A=440Hz.";
-    d.unit = "hz";
-    d.hasFixedBinCount = true;
-    d.binCount = 1;
-    d.hasKnownExtents = false;
-    d.isQuantized = false;
-    d.sampleType = OutputDescriptor::VariableSampleRate;
-    d.hasDuration = false;
-    list.push_back(d);
-
-    d.identifier = "curve";
-    d.name = "Shift Correlation Curve";
-    d.description = "Correlation between shifted and unshifted sources, for each probed shift in cents.";
-    d.unit = "";
-    d.hasFixedBinCount = true;
-    d.binCount = 1;
-    d.hasKnownExtents = false;
-    d.isQuantized = false;
-    d.sampleType = OutputDescriptor::FixedSampleRate;
-    d.sampleRate = 100;
-    d.hasDuration = false;
-    list.push_back(d);
-
-    int targetBinMin = int(floor(targetFmin * m_blockSize / m_inputSampleRate));
-    int targetBinMax = int(ceil(targetFmax * m_blockSize / m_inputSampleRate));
-    cerr << "target bin range: " << targetBinMin << " -> " << targetBinMax << endl;
-
-    d.identifier = "averages";
-    d.name = "Harmonic spectrum averages";
-    d.description = "Average of harmonic spectrum for each channel.";
-    d.unit = "";
-    d.hasFixedBinCount = true;
-    d.binCount = (targetBinMax > targetBinMin ? targetBinMax - targetBinMin + 1 : 100);
-    d.hasKnownExtents = false;
-    d.isQuantized = false;
-    d.sampleType = OutputDescriptor::FixedSampleRate;
-    d.sampleRate = 1;
-    d.hasDuration = false;
-    list.push_back(d);
-
-    return list;
-}
-
-bool
-TuningDifference::initialise(size_t channels, size_t stepSize, size_t blockSize)
-{
-    if (channels < getMinChannelCount() ||
-	channels > getMaxChannelCount()) return false;
-
-    if (blockSize != getPreferredBlockSize() ||
-	stepSize != blockSize/2) return false;
-
-    m_blockSize = blockSize;
-
-    reset();
-    
-    return true;
-}
-
-void
-TuningDifference::reset()
-{
-    m_sum[0].clear();
-    m_sum[1].clear();
-    m_frameCount = 0;
-}
-
-TuningDifference::FeatureSet
-TuningDifference::process(const float *const *inputBuffers, Vamp::RealTime timestamp)
-{
-    for (int c = 0; c < 2; ++c) {
-	if (m_sum[c].size() == 0) {
-	    m_sum[c].resize(m_blockSize/2 + 1, 0.0);
-	}
-	vector<double> mags(m_blockSize/2 + 1, 0.0);
-	for (int i = 0; i <= m_blockSize/2; ++i) {
-	    double energy =
-		inputBuffers[c][i*2  ] * inputBuffers[c][i*2  ] +
-		inputBuffers[c][i*2+1] * inputBuffers[c][i*2+1];
-	    double mag = sqrt(energy);
-	    mags[i] = mag;
-	}
-	for (int i = 0; i <= m_blockSize/2; ++i) {
-	    for (int h = 2; h <= 4; ++h) {
-		double max = 0.0;
-		for (int j = 0; j <= h; ++j) {
-		    int ix = i * h + j - h/2;
-		    if (ix <= m_blockSize/2) {
-			double harmMag = mags[ix];
-			if (j == 0 || harmMag > max) {
-			    max = harmMag;
-			}
-		    }
-		}
-		mags[i] += max;
-	    }
-	}
-	for (int i = 0; i <= m_blockSize/2; ++i) {
-	    m_sum[c][i] += mags[i];
-	}
-    }
-    
-    ++m_frameCount;
-    return FeatureSet();
-}
-
-TuningDifference::FeatureSet
-TuningDifference::getRemainingFeatures()
-{
-    int n = m_sum[0].size();
-    if (n == 0) return FeatureSet();
-
-    Feature f;
-    FeatureSet fs;
-
-    int maxshift = 2400; // cents
-
-    int bestshift = -1;
-    double bestdist = 0;
-
-    for (int i = 0; i < n; ++i) {
-	m_sum[0][i] /= m_frameCount;
-	m_sum[1][i] /= m_frameCount;
-    }
-
-    for (int c = 0; c < 2; ++c) {
-	for (int i = 0; i < n; ++i) {
-	    if (i == 0 || i == n-1 ||
-		m_sum[c][i] < m_sum[c][i-1] ||
-		m_sum[c][i] < m_sum[c][i+1]) {
-		m_sum[c][i] = 0.0;
-	    }
-	}
-    }
-
-    int targetBinMin = int(floor(targetFmin * m_blockSize / m_inputSampleRate));
-    int targetBinMax = int(ceil(targetFmax * m_blockSize / m_inputSampleRate));
-    cerr << "target bin range: " << targetBinMin << " -> " << targetBinMax << endl;
-
-    for (int c = 0; c < 2; ++c) {
-	double tot = 0.0;
-	for (int i = targetBinMin; i <= targetBinMax; ++i) {
-	    tot += m_sum[c][i];
-	}
-	if (tot != 0.0) {
-	    for (int i = 0; i < n; ++i) {
-		m_sum[c][i] /= tot;
-	    }
-	}
-    }
-	
-    f.values.clear();
-    for (int i = targetBinMin; i < targetBinMax; ++i) {
-	f.values.push_back(m_sum[0][i]);
-    }
-    fs[3].push_back(f);
-    f.values.clear();
-    for (int i = targetBinMin; i < targetBinMax; ++i) {
-	f.values.push_back(m_sum[1][i]);
-    }
-    fs[3].push_back(f);
-
-    f.values.clear();
-    
-    for (int shift = -maxshift; shift <= maxshift; ++shift) {
-
-	double multiplier = pow(2.0, double(shift) / 1200.0);
-	double dist = 0.0;
-
-//	cerr << "shift = " << shift << ", multiplier = " << multiplier << endl;
-
-	int contributing = 0;
-	
-	for (int i = targetBinMin; i < targetBinMax; ++i) {
-
-	    double source = i / multiplier;
-	    int s0 = int(source), s1 = s0 + 1;
-	    double p1 = source - s0;
-	    double p0 = 1.0 - p1;
-
-	    double value = 0.0;
-	    if (s0 >= 0 && s0 < n) {
-		value += p0 * m_sum[1][s0];
-		++contributing;
-	    }
-	    if (s1 >= 0 && s1 < n) {
-		value += p1 * m_sum[1][s1];
-		++contributing;
-	    }
-
-//	    if (shift == -1) {
-//		cerr << "for multiplier " << multiplier << ", target " << i << ", source " << source << ", value " << p0 << " * " << m_sum[1][s0] << " + " << p1 << " * " << m_sum[1][s1] << " = " << value << ", other " << m_sum[0][i] << endl;
-//	    }
-	    
-	    double diff = fabs(m_sum[0][i] - value);
-	    dist += diff;
-	}
-
-	dist /= contributing;
-	
-	f.values.clear();
-	f.values.push_back(dist);
-	char label[100];
-	sprintf(label, "%f at shift %d freq mult %f", dist, shift, multiplier);
-	f.label = label;
-	fs[2].push_back(f);
-
-	if (bestshift == -1 || dist < bestdist) {
-	    bestshift = shift;
-	    bestdist = dist;
-	}
-    }
-
-    f.timestamp = Vamp::RealTime::zeroTime;
-    f.hasTimestamp = true;
-    f.label = "";
-
-    f.values.clear();
-    cerr << "best dist = " << bestdist << " at shift " << bestshift << endl;
-    f.values.push_back(-bestshift);
-    fs[0].push_back(f);
-
-    f.values.clear();
-    f.values.push_back(440.0 / pow(2.0, double(bestshift) / 1200.0));
-    fs[1].push_back(f);
-    
-    return fs;
-}
-
--- a/spectrum-compare/TuningDifference.h	Tue Feb 03 18:46:54 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-#ifndef TUNING_DIFFERENCE_H
-#define TUNING_DIFFERENCE_H
-
-#include <vamp-sdk/Plugin.h>
-
-using std::string;
-using std::vector;
-
-class TuningDifference : public Vamp::Plugin
-{
-public:
-    TuningDifference(float inputSampleRate);
-    virtual ~TuningDifference();
-
-    string getIdentifier() const;
-    string getName() const;
-    string getDescription() const;
-    string getMaker() const;
-    int getPluginVersion() const;
-    string getCopyright() const;
-
-    InputDomain getInputDomain() const;
-    size_t getPreferredBlockSize() const;
-    size_t getPreferredStepSize() const;
-    size_t getMinChannelCount() const;
-    size_t getMaxChannelCount() const;
-
-    ParameterList getParameterDescriptors() const;
-    float getParameter(string identifier) const;
-    void setParameter(string identifier, float value);
-
-    ProgramList getPrograms() const;
-    string getCurrentProgram() const;
-    void selectProgram(string name);
-
-    OutputList getOutputDescriptors() const;
-
-    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
-    void reset();
-
-    FeatureSet process(const float *const *inputBuffers,
-                       Vamp::RealTime timestamp);
-
-    FeatureSet getRemainingFeatures();
-
-protected:
-    int m_blockSize;
-    vector<double> m_sum[2];
-    int m_frameCount;
-};
-
-
-#endif
--- a/spectrum-compare/plugins.cpp	Tue Feb 03 18:46:54 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-
-#include <vamp/vamp.h>
-#include <vamp-sdk/PluginAdapter.h>
-
-#include "TuningDifference.h"
-
-static Vamp::PluginAdapter<TuningDifference> tdAdapter;
-
-
-const VampPluginDescriptor *
-vampGetPluginDescriptor(unsigned int version, unsigned int index)
-{
-    if (version < 1) return 0;
-
-    switch (index) {
-    case  0: return tdAdapter.getDescriptor();
-    default: return 0;
-    }
-}
-
-
--- a/spectrum-compare/vamp-plugin.list	Tue Feb 03 18:46:54 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-_vampGetPluginDescriptor
--- a/spectrum-compare/vamp-plugin.map	Tue Feb 03 18:46:54 2015 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-{
-	global: vampGetPluginDescriptor;
-	local: *;
-};