changeset 58:0284955e31e5 host-factory-stuff

* reshuffle
author cannam
date Thu, 24 May 2007 10:05:00 +0000
parents 09a1aac6c362
children fa79c4ec847d
files Makefile README vamp-hostsdk/PluginHostAdapter.cpp vamp-hostsdk/PluginHostAdapter.h vamp-hostsdk/PluginInputDomainAdapter.cpp vamp-hostsdk/PluginInputDomainAdapter.h vamp-hostsdk/PluginLoader.cpp vamp-hostsdk/PluginLoader.h vamp-hostsdk/PluginWrapper.cpp vamp-hostsdk/PluginWrapper.h vamp-hostsdk/system.h vamp-sdk/PluginHostAdapter.cpp vamp-sdk/PluginHostAdapter.h vamp-sdk/hostext/PluginInputDomainAdapter.cpp vamp-sdk/hostext/PluginInputDomainAdapter.h vamp-sdk/hostext/PluginLoader.cpp vamp-sdk/hostext/PluginLoader.h vamp-sdk/hostext/PluginWrapper.cpp vamp-sdk/hostext/PluginWrapper.h vamp-sdk/hostext/system.h
diffstat 20 files changed, 1706 insertions(+), 1680 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Wed May 09 15:21:37 2007 +0000
+++ b/Makefile	Thu May 24 10:05:00 2007 +0000
@@ -3,14 +3,57 @@
 # libraries, example plugins, and the test host.  Please adjust to
 # suit your operating system requirements.
 
+## Choose your 
+
+APIDIR		= vamp
 SDKDIR		= vamp-sdk
-HOSTSDKDIR      = vamp-hostsdk
-APIDIR		= vamp
+HOSTEXTDIR      = vamp-sdk/hostext
 EXAMPLEDIR	= examples
 HOSTDIR		= host
 
+###
+### Start of user-serviceable parts
+###
 
-### Start of user-serviceable parts
+# Default build target (or use "make <target>" to select one).
+# Targets are:
+#   all       -- build everything
+#   sdk       -- build all the Vamp SDK libraries for plugins and hosts
+#   plugins   -- build the example plugins (and the SDK if required)
+#   host      -- build the simple Vamp plugin host (and the SDK if required)
+#   test      -- build the host and example plugins, and run a quick test
+#   clean     -- remove binary targets
+#   distclean -- remove all targets
+#
+default:	all
+
+# Compile flags
+#
+CXXFLAGS	:= $(CXXFLAGS) -O2 -Wall -I$(SDKDIR) -I$(HOSTEXTDIR) -I$(APIDIR) -I.
+
+# Libraries required for the plugins.
+# (Note that it is desirable to statically link libstdc++ if possible,
+# because our plugin exposes only a C API so there are no boundary
+# compatibility problems.)
+#
+PLUGIN_LIBS	= $(SDKDIR)/libvamp-sdk.a
+#PLUGIN_LIBS	= vamp-sdk/libvamp-sdk.a $(shell g++ -print-file-name=libstdc++.a)
+
+# Flags required to tell the compiler to link to a dynamically loadable object
+#
+PLUGIN_LDFLAGS	= -shared -Wl,-Bsymbolic -static-libgcc
+
+# File extension for a dynamically loadable object
+#
+PLUGIN_EXT	= .so
+
+## For OS/X with g++:
+#PLUGIN_LDFLAGS	= -dynamiclib
+#PLUGIN_EXT	= .dylib
+
+# Libraries required for the host.
+#
+HOST_LIBS	= $(SDKDIR)/libvamp-hostsdk.a -lsndfile -ldl
 
 # Locations for "make install".  This will need quite a bit of 
 # editing for non-Linux platforms.  Of course you don't necessarily
@@ -35,33 +78,6 @@
 
 INSTALL_PKGCONFIG	  := $(INSTALL_PREFIX)/lib/pkgconfig
 
-# Compile flags
-#
-CXXFLAGS	:= $(CXXFLAGS) -O2 -Wall -I$(SDKDIR) -I$(HOSTSDKDIR) -I$(APIDIR) -I.
-
-# Libraries required for the host at link time
-#
-HOST_LIBS	= $(HOSTSDKDIR)/libvamp-hostsdk.a -lsndfile -ldl
-
-# Libraries required for the plugin.  Note that we can (and actively
-# want to) statically link libstdc++, because our plugin exposes only
-# a C API so there are no boundary compatibility problems.
-#
-PLUGIN_LIBS	= $(SDKDIR)/libvamp-sdk.a
-#PLUGIN_LIBS	= vamp-sdk/libvamp-sdk.a $(shell g++ -print-file-name=libstdc++.a)
-
-# Flags required to tell the compiler to link to a dynamically loadable object
-#
-PLUGIN_LDFLAGS	= -shared -Wl,-Bsymbolic -static-libgcc
-
-# File extension for a dynamically loadable object
-#
-PLUGIN_EXT	= .so
-
-## For OS/X with g++:
-#PLUGIN_LDFLAGS	= -dynamiclib
-#PLUGIN_EXT	= .dylib
-
 ### End of user-serviceable parts
 
 
@@ -77,10 +93,10 @@
 HOSTSDK_HEADERS	= \
 		$(SDKDIR)/Plugin.h \
 		$(SDKDIR)/PluginBase.h \
-		$(HOSTSDKDIR)/PluginHostAdapter.h \
-		$(HOSTSDKDIR)/PluginInputDomainAdapter.h \
-		$(HOSTSDKDIR)/PluginLoader.h \
-		$(HOSTSDKDIR)/PluginWrapper.h \
+		$(SDKDIR)/PluginHostAdapter.h \
+		$(HOSTEXTDIR)/PluginInputDomainAdapter.h \
+		$(HOSTEXTDIR)/PluginLoader.h \
+		$(HOSTEXTDIR)/PluginWrapper.h \
 		$(SDKDIR)/RealTime.h
 
 SDK_OBJECTS	= \
@@ -88,23 +104,23 @@
 		$(SDKDIR)/RealTime.o
 
 HOSTSDK_OBJECTS	= \
-		$(HOSTSDKDIR)/PluginHostAdapter.o \
-		$(HOSTSDKDIR)/PluginInputDomainAdapter.o \
-		$(HOSTSDKDIR)/PluginLoader.o \
-		$(HOSTSDKDIR)/PluginWrapper.o \
+		$(SDKDIR)/PluginHostAdapter.o \
+		$(HOSTEXTDIR)/PluginInputDomainAdapter.o \
+		$(HOSTEXTDIR)/PluginLoader.o \
+		$(HOSTEXTDIR)/PluginWrapper.o \
 		$(SDKDIR)/RealTime.o
 
 SDK_STATIC	= \
 		$(SDKDIR)/libvamp-sdk.a
 
 HOSTSDK_STATIC	= \
-		$(HOSTSDKDIR)/libvamp-hostsdk.a
+		$(SDKDIR)/libvamp-hostsdk.a
 
 SDK_DYNAMIC	= \
 		$(SDKDIR)/libvamp-sdk.so
 
 HOSTSDK_DYNAMIC	= \
-		$(HOSTSDKDIR)/libvamp-hostsdk.so
+		$(SDKDIR)/libvamp-hostsdk.so
 
 SDK_LA		= \
 		$(SDKDIR)/libvamp-sdk.la
@@ -134,7 +150,13 @@
 HOST_TARGET	= \
 		$(HOSTDIR)/vamp-simple-host
 
-all:		$(SDK_STATIC) $(SDK_DYNAMIC) $(HOSTSDK_STATIC) $(HOSTSDK_DYNAMIC) $(PLUGIN_TARGET) $(HOST_TARGET) test
+sdk:		$(SDK_STATIC) $(SDK_DYNAMIC) $(HOSTSDK_STATIC) $(HOSTSDK_DYNAMIC)
+
+plugins:	sdk $(PLUGIN_TARGET)
+
+host:		sdk $(HOST_TARGET)
+
+all:		sdk plugins host test
 
 $(SDK_STATIC):	$(SDK_OBJECTS) $(API_HEADERS) $(SDK_HEADERS)
 		$(AR) r $@ $(SDK_OBJECTS)
@@ -154,7 +176,7 @@
 $(HOST_TARGET):	$(HOST_OBJECTS) $(HOSTSDK_TARGET) $(HOST_HEADERS)
 		$(CXX) $(LDFLAGS) $(HOST_LDFLAGS) -o $@ $(HOST_OBJECTS) $(HOST_LIBS)
 
-test:		$(HOST_TARGET) $(PLUGIN_TARGET)
+test:		plugins host
 		$(HOST_TARGET) $(PLUGIN_TARGET)
 
 clean:		
--- a/README	Wed May 09 15:21:37 2007 +0000
+++ b/README	Thu May 24 10:05:00 2007 +0000
@@ -92,7 +92,11 @@
 
 A simple command-line Vamp host, capable of loading a plugin and using
 it to process a complete audio file, with its default parameters.
-Requires libsndfile.
+Requires libsndfile (http://www.mega-nerd.com/libsndfile/).
+
+If you don't have libsndfile, you may want to edit the Makefile to
+change the default build target from "all" to "sdk" so as to compile
+only the SDK.
 
 
 Plugin Lookup and Categorisation
--- a/vamp-hostsdk/PluginHostAdapter.cpp	Wed May 09 15:21:37 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,418 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Vamp
-
-    An API for audio analysis and feature extraction plugins.
-
-    Centre for Digital Music, Queen Mary, University of London.
-    Copyright 2006 Chris Cannam.
-  
-    Permission is hereby granted, free of charge, to any person
-    obtaining a copy of this software and associated documentation
-    files (the "Software"), to deal in the Software without
-    restriction, including without limitation the rights to use, copy,
-    modify, merge, publish, distribute, sublicense, and/or sell copies
-    of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be
-    included in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-    Except as contained in this notice, the names of the Centre for
-    Digital Music; Queen Mary, University of London; and Chris Cannam
-    shall not be used in advertising or otherwise to promote the sale,
-    use or other dealings in this Software without prior written
-    authorization.
-*/
-
-#include "PluginHostAdapter.h"
-
-namespace Vamp
-{
-
-PluginHostAdapter::PluginHostAdapter(const VampPluginDescriptor *descriptor,
-                                     float inputSampleRate) :
-    Plugin(inputSampleRate),
-    m_descriptor(descriptor)
-{
-//    std::cerr << "PluginHostAdapter::PluginHostAdapter (plugin = " << descriptor->name << ")" << std::endl;
-    m_handle = m_descriptor->instantiate(m_descriptor, inputSampleRate);
-    if (!m_handle) {
-//        std::cerr << "WARNING: PluginHostAdapter: Plugin instantiation failed for plugin " << m_descriptor->name << std::endl;
-    }
-}
-
-PluginHostAdapter::~PluginHostAdapter()
-{
-//    std::cerr << "PluginHostAdapter::~PluginHostAdapter (plugin = " << m_descriptor->name << ")" << std::endl;
-    if (m_handle) m_descriptor->cleanup(m_handle);
-}
-
-std::vector<std::string>
-PluginHostAdapter::getPluginPath()
-{
-    std::vector<std::string> path;
-    std::string envPath;
-
-    char *cpath = getenv("VAMP_PATH");
-    if (cpath) envPath = cpath;
-
-#ifdef _WIN32
-#define PATH_SEPARATOR ';'
-#define DEFAULT_VAMP_PATH "%ProgramFiles%\\Vamp Plugins"
-#else
-#define PATH_SEPARATOR ':'
-#ifdef __APPLE__
-#define DEFAULT_VAMP_PATH "$HOME/Library/Audio/Plug-Ins/Vamp:/Library/Audio/Plug-Ins/Vamp"
-#else
-#define DEFAULT_VAMP_PATH "$HOME/vamp:$HOME/.vamp:/usr/local/lib/vamp:/usr/lib/vamp"
-#endif
-#endif
-
-    if (envPath == "") {
-        envPath = DEFAULT_VAMP_PATH;
-        char *chome = getenv("HOME");
-        if (chome) {
-            std::string home(chome);
-            std::string::size_type f;
-            while ((f = envPath.find("$HOME")) != std::string::npos &&
-                    f < envPath.length()) {
-                envPath.replace(f, 5, home);
-            }
-        }
-#ifdef _WIN32
-        char *cpfiles = getenv("ProgramFiles");
-        if (!cpfiles) cpfiles = "C:\\Program Files";
-        std::string pfiles(cpfiles);
-        std::string::size_type f;
-        while ((f = envPath.find("%ProgramFiles%")) != std::string::npos &&
-               f < envPath.length()) {
-            envPath.replace(f, 14, pfiles);
-        }
-#endif
-    }
-
-    std::string::size_type index = 0, newindex = 0;
-
-    while ((newindex = envPath.find(PATH_SEPARATOR, index)) < envPath.size()) {
-	path.push_back(envPath.substr(index, newindex - index));
-	index = newindex + 1;
-    }
-    
-    path.push_back(envPath.substr(index));
-
-    return path;
-}
-
-bool
-PluginHostAdapter::initialise(size_t channels,
-                              size_t stepSize,
-                              size_t blockSize)
-{
-    if (!m_handle) return false;
-    return m_descriptor->initialise(m_handle, channels, stepSize, blockSize) ?
-        true : false;
-}
-
-void
-PluginHostAdapter::reset()
-{
-    if (!m_handle) return;
-    m_descriptor->reset(m_handle);
-}
-
-PluginHostAdapter::InputDomain
-PluginHostAdapter::getInputDomain() const
-{
-    if (m_descriptor->inputDomain == vampFrequencyDomain) {
-        return FrequencyDomain;
-    } else {
-        return TimeDomain;
-    }
-}
-
-unsigned int
-PluginHostAdapter::getVampApiVersion() const
-{
-    return m_descriptor->vampApiVersion;
-}
-
-std::string
-PluginHostAdapter::getIdentifier() const
-{
-    return m_descriptor->identifier;
-}
-
-std::string
-PluginHostAdapter::getName() const
-{
-    return m_descriptor->name;
-}
-
-std::string
-PluginHostAdapter::getDescription() const
-{
-    return m_descriptor->description;
-}
-
-std::string
-PluginHostAdapter::getMaker() const
-{
-    return m_descriptor->maker;
-}
-
-int
-PluginHostAdapter::getPluginVersion() const
-{
-    return m_descriptor->pluginVersion;
-}
-
-std::string
-PluginHostAdapter::getCopyright() const
-{
-    return m_descriptor->copyright;
-}
-
-PluginHostAdapter::ParameterList
-PluginHostAdapter::getParameterDescriptors() const
-{
-    ParameterList list;
-    for (unsigned int i = 0; i < m_descriptor->parameterCount; ++i) {
-        const VampParameterDescriptor *spd = m_descriptor->parameters[i];
-        ParameterDescriptor pd;
-        pd.identifier = spd->identifier;
-        pd.name = spd->name;
-        pd.description = spd->description;
-        pd.unit = spd->unit;
-        pd.minValue = spd->minValue;
-        pd.maxValue = spd->maxValue;
-        pd.defaultValue = spd->defaultValue;
-        pd.isQuantized = spd->isQuantized;
-        pd.quantizeStep = spd->quantizeStep;
-        if (pd.isQuantized && spd->valueNames) {
-            for (unsigned int j = 0; spd->valueNames[j]; ++j) {
-                pd.valueNames.push_back(spd->valueNames[j]);
-            }
-        }
-        list.push_back(pd);
-    }
-    return list;
-}
-
-float
-PluginHostAdapter::getParameter(std::string param) const
-{
-    if (!m_handle) return 0.0;
-
-    for (unsigned int i = 0; i < m_descriptor->parameterCount; ++i) {
-        if (param == m_descriptor->parameters[i]->identifier) {
-            return m_descriptor->getParameter(m_handle, i);
-        }
-    }
-
-    return 0.0;
-}
-
-void
-PluginHostAdapter::setParameter(std::string param, 
-                                float value)
-{
-    if (!m_handle) return;
-
-    for (unsigned int i = 0; i < m_descriptor->parameterCount; ++i) {
-        if (param == m_descriptor->parameters[i]->identifier) {
-            m_descriptor->setParameter(m_handle, i, value);
-            return;
-        }
-    }
-}
-
-PluginHostAdapter::ProgramList
-PluginHostAdapter::getPrograms() const
-{
-    ProgramList list;
-    
-    for (unsigned int i = 0; i < m_descriptor->programCount; ++i) {
-        list.push_back(m_descriptor->programs[i]);
-    }
-    
-    return list;
-}
-
-std::string
-PluginHostAdapter::getCurrentProgram() const
-{
-    if (!m_handle) return "";
-
-    int pn = m_descriptor->getCurrentProgram(m_handle);
-    return m_descriptor->programs[pn];
-}
-
-void
-PluginHostAdapter::selectProgram(std::string program)
-{
-    if (!m_handle) return;
-
-    for (unsigned int i = 0; i < m_descriptor->programCount; ++i) {
-        if (program == m_descriptor->programs[i]) {
-            m_descriptor->selectProgram(m_handle, i);
-            return;
-        }
-    }
-}
-
-size_t
-PluginHostAdapter::getPreferredStepSize() const
-{
-    if (!m_handle) return 0;
-    return m_descriptor->getPreferredStepSize(m_handle);
-}
-
-size_t
-PluginHostAdapter::getPreferredBlockSize() const
-{
-    if (!m_handle) return 0;
-    return m_descriptor->getPreferredBlockSize(m_handle);
-}
-
-size_t
-PluginHostAdapter::getMinChannelCount() const
-{
-    if (!m_handle) return 0;
-    return m_descriptor->getMinChannelCount(m_handle);
-}
-
-size_t
-PluginHostAdapter::getMaxChannelCount() const
-{
-    if (!m_handle) return 0;
-    return m_descriptor->getMaxChannelCount(m_handle);
-}
-
-PluginHostAdapter::OutputList
-PluginHostAdapter::getOutputDescriptors() const
-{
-    OutputList list;
-    if (!m_handle) {
-//        std::cerr << "PluginHostAdapter::getOutputDescriptors: no handle " << std::endl;
-        return list;
-    }
-
-    unsigned int count = m_descriptor->getOutputCount(m_handle);
-
-    for (unsigned int i = 0; i < count; ++i) {
-        VampOutputDescriptor *sd = m_descriptor->getOutputDescriptor(m_handle, i);
-        OutputDescriptor d;
-        d.identifier = sd->identifier;
-        d.name = sd->name;
-        d.description = sd->description;
-        d.unit = sd->unit;
-        d.hasFixedBinCount = sd->hasFixedBinCount;
-        d.binCount = sd->binCount;
-        if (d.hasFixedBinCount) {
-            for (unsigned int j = 0; j < sd->binCount; ++j) {
-                d.binNames.push_back(sd->binNames[j] ? sd->binNames[j] : "");
-            }
-        }
-        d.hasKnownExtents = sd->hasKnownExtents;
-        d.minValue = sd->minValue;
-        d.maxValue = sd->maxValue;
-        d.isQuantized = sd->isQuantized;
-        d.quantizeStep = sd->quantizeStep;
-
-        switch (sd->sampleType) {
-        case vampOneSamplePerStep:
-            d.sampleType = OutputDescriptor::OneSamplePerStep; break;
-        case vampFixedSampleRate:
-            d.sampleType = OutputDescriptor::FixedSampleRate; break;
-        case vampVariableSampleRate:
-            d.sampleType = OutputDescriptor::VariableSampleRate; break;
-        }
-
-        d.sampleRate = sd->sampleRate;
-
-        list.push_back(d);
-
-        m_descriptor->releaseOutputDescriptor(sd);
-    }
-
-    return list;
-}
-
-PluginHostAdapter::FeatureSet
-PluginHostAdapter::process(const float *const *inputBuffers,
-                           RealTime timestamp)
-{
-    FeatureSet fs;
-    if (!m_handle) return fs;
-
-    int sec = timestamp.sec;
-    int nsec = timestamp.nsec;
-    
-    VampFeatureList *features = m_descriptor->process(m_handle,
-                                                      inputBuffers,
-                                                      sec, nsec);
-    
-    convertFeatures(features, fs);
-    m_descriptor->releaseFeatureSet(features);
-    return fs;
-}
-
-PluginHostAdapter::FeatureSet
-PluginHostAdapter::getRemainingFeatures()
-{
-    FeatureSet fs;
-    if (!m_handle) return fs;
-    
-    VampFeatureList *features = m_descriptor->getRemainingFeatures(m_handle); 
-
-    convertFeatures(features, fs);
-    m_descriptor->releaseFeatureSet(features);
-    return fs;
-}
-
-void
-PluginHostAdapter::convertFeatures(VampFeatureList *features,
-                                   FeatureSet &fs)
-{
-    if (!features) return;
-
-    unsigned int outputs = m_descriptor->getOutputCount(m_handle);
-
-    for (unsigned int i = 0; i < outputs; ++i) {
-        
-        VampFeatureList &list = features[i];
-
-        if (list.featureCount > 0) {
-
-            for (unsigned int j = 0; j < list.featureCount; ++j) {
-                
-                Feature feature;
-                feature.hasTimestamp = list.features[j].hasTimestamp;
-                feature.timestamp = RealTime(list.features[j].sec,
-                                             list.features[j].nsec);
-
-                for (unsigned int k = 0; k < list.features[j].valueCount; ++k) {
-                    feature.values.push_back(list.features[j].values[k]);
-                }
-
-                if (list.features[j].label) {
-                    feature.label = list.features[j].label;
-                }
-
-                fs[i].push_back(feature);
-            }
-        }
-    }
-}
-
-}
--- a/vamp-hostsdk/PluginHostAdapter.h	Wed May 09 15:21:37 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Vamp
-
-    An API for audio analysis and feature extraction plugins.
-
-    Centre for Digital Music, Queen Mary, University of London.
-    Copyright 2006 Chris Cannam.
-  
-    Permission is hereby granted, free of charge, to any person
-    obtaining a copy of this software and associated documentation
-    files (the "Software"), to deal in the Software without
-    restriction, including without limitation the rights to use, copy,
-    modify, merge, publish, distribute, sublicense, and/or sell copies
-    of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be
-    included in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-    Except as contained in this notice, the names of the Centre for
-    Digital Music; Queen Mary, University of London; and Chris Cannam
-    shall not be used in advertising or otherwise to promote the sale,
-    use or other dealings in this Software without prior written
-    authorization.
-*/
-
-#ifndef _VAMP_PLUGIN_HOST_ADAPTER_H_
-#define _VAMP_PLUGIN_HOST_ADAPTER_H_
-
-#include <vamp/vamp.h>
-#include <vamp-sdk/Plugin.h>
-
-#include <vector>
-
-namespace Vamp {
-
-/**
- * PluginHostAdapter is a wrapper class that a Vamp host can use to
- * make the C-language VampPluginDescriptor object appear as a C++
- * Vamp::Plugin object.
- *
- * The Vamp API is defined in vamp/vamp.h as a C API.  The C++ objects
- * used for convenience by plugins and hosts actually communicate
- * using the C low-level API, but the details of this communication
- * are handled seamlessly by the Vamp SDK implementation provided the
- * plugin and host use the proper C++ wrapper objects.
- *
- * See also PluginAdapter, the plugin-side wrapper that makes a C++
- * plugin object available using the C query API.
- */
-
-class PluginHostAdapter : public Plugin
-{
-public:
-    PluginHostAdapter(const VampPluginDescriptor *descriptor,
-                      float inputSampleRate);
-    virtual ~PluginHostAdapter();
-    
-    static std::vector<std::string> getPluginPath();
-
-    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
-    void reset();
-
-    InputDomain getInputDomain() const;
-
-    unsigned int getVampApiVersion() const;
-    std::string getIdentifier() const;
-    std::string getName() const;
-    std::string getDescription() const;
-    std::string getMaker() const;
-    int getPluginVersion() const;
-    std::string getCopyright() const;
-
-    ParameterList getParameterDescriptors() const;
-    float getParameter(std::string) const;
-    void setParameter(std::string, float);
-
-    ProgramList getPrograms() const;
-    std::string getCurrentProgram() const;
-    void selectProgram(std::string);
-
-    size_t getPreferredStepSize() const;
-    size_t getPreferredBlockSize() const;
-
-    size_t getMinChannelCount() const;
-    size_t getMaxChannelCount() const;
-
-    OutputList getOutputDescriptors() const;
-
-    FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
-
-    FeatureSet getRemainingFeatures();
-
-protected:
-    void convertFeatures(VampFeatureList *, FeatureSet &);
-
-    const VampPluginDescriptor *m_descriptor;
-    VampPluginHandle m_handle;
-};
-
-}
-
-#endif
-
-
--- a/vamp-hostsdk/PluginInputDomainAdapter.cpp	Wed May 09 15:21:37 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,274 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Vamp
-
-    An API for audio analysis and feature extraction plugins.
-
-    Centre for Digital Music, Queen Mary, University of London.
-    Copyright 2006 Chris Cannam.
-  
-    Permission is hereby granted, free of charge, to any person
-    obtaining a copy of this software and associated documentation
-    files (the "Software"), to deal in the Software without
-    restriction, including without limitation the rights to use, copy,
-    modify, merge, publish, distribute, sublicense, and/or sell copies
-    of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be
-    included in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-    Except as contained in this notice, the names of the Centre for
-    Digital Music; Queen Mary, University of London; and Chris Cannam
-    shall not be used in advertising or otherwise to promote the sale,
-    use or other dealings in this Software without prior written
-    authorization.
-*/
-
-#include "PluginInputDomainAdapter.h"
-
-#include <cmath>
-
-namespace Vamp {
-
-PluginInputDomainAdapter::PluginInputDomainAdapter(Plugin *plugin) :
-    PluginWrapper(plugin),
-    m_channels(0),
-    m_blockSize(0),
-    m_freqbuf(0)
-{
-}
-
-PluginInputDomainAdapter::~PluginInputDomainAdapter()
-{
-}
-    
-bool
-PluginInputDomainAdapter::initialise(size_t channels, size_t stepSize, size_t blockSize)
-{
-    //!!! complain and die if blocksize is not a power of 2
-
-    if (m_plugin->getInputDomain() == FrequencyDomain) {
-        if (m_channels > 0) {
-            for (size_t c = 0; c < m_channels; ++c) {
-                delete[] m_freqbuf[c];
-            }
-            delete[] m_freqbuf;
-            delete[] m_ri;
-            delete[] m_ro;
-            delete[] m_io;
-        }
-    }
-
-    m_channels = channels;
-    m_blockSize = blockSize;
-
-    if (m_plugin->getInputDomain() == FrequencyDomain) {
-        m_freqbuf = new float *[m_channels];
-        for (size_t c = 0; c < m_channels; ++c) {
-            m_freqbuf[c] = new float[m_blockSize + 2];
-        }
-        m_ri = new double[m_blockSize];
-        m_ro = new double[m_blockSize];
-        m_io = new double[m_blockSize];
-    }
-
-    return m_plugin->initialise(channels, stepSize, blockSize);
-}
-
-Plugin::InputDomain
-PluginInputDomainAdapter::getInputDomain() const
-{
-    return TimeDomain;
-}
-
-size_t
-PluginInputDomainAdapter::getPreferredStepSize() const
-{
-    size_t step = m_plugin->getPreferredStepSize();
-
-    if (step == 0 && (m_plugin->getInputDomain() == FrequencyDomain)) {
-        step = getPreferredBlockSize() / 2;
-    }
-
-    return step;
-}
-
-size_t
-PluginInputDomainAdapter::getPreferredBlockSize() const
-{
-    size_t block = m_plugin->getPreferredBlockSize();
-
-    if (block == 0 && (m_plugin->getInputDomain() == FrequencyDomain)) {
-        block = 1024;
-    }
-
-    return block;
-}
-
-Plugin::FeatureSet
-PluginInputDomainAdapter::process(const float *const *inputBuffers, RealTime timestamp)
-{
-    if (m_plugin->getInputDomain() == TimeDomain) {
-        return m_plugin->process(inputBuffers, timestamp);
-    }
-
-    for (size_t c = 0; c < m_channels; ++c) {
-
-        for (size_t i = 0; i < m_blockSize; ++i) {
-            // Hanning window
-            m_ri[i] = double(inputBuffers[c][i])
-                * (0.50 - 0.50 * cos((2 * M_PI * i)
-                                     / m_blockSize));
-        }
-
-        for (size_t i = 0; i < m_blockSize/2; ++i) {
-            // FFT shift
-            double value = m_ri[i];
-            m_ri[i] = m_ri[i + m_blockSize/2];
-            m_ri[i + m_blockSize/2] = value;
-        }
-
-        fft(m_blockSize, false, m_ri, 0, m_ro, m_io);
-
-        for (size_t i = 0; i < m_blockSize/2; ++i) {
-            m_freqbuf[c][i * 2] = m_ro[i];
-            m_freqbuf[c][i * 2 + 1] = m_io[i];
-        }
-    }
-
-    //!!! do we want to adjust the timestamp or anything so as to
-    // effectively centre the frame?
-
-    return m_plugin->process(m_freqbuf, timestamp);
-}
-
-void
-PluginInputDomainAdapter::fft(unsigned int n, bool inverse,
-                              double *ri, double *ii, double *ro, double *io)
-{
-    if (!ri || !ro || !io) return;
-
-    unsigned int bits;
-    unsigned int i, j, k, m;
-    unsigned int blockSize, blockEnd;
-
-    double tr, ti;
-
-    if (n < 2) return;
-    if (n & (n-1)) return;
-
-    double angle = 2.0 * M_PI;
-    if (inverse) angle = -angle;
-
-    for (i = 0; ; ++i) {
-	if (n & (1 << i)) {
-	    bits = i;
-	    break;
-	}
-    }
-
-    static unsigned int tableSize = 0;
-    static int *table = 0;
-
-    if (tableSize != n) {
-
-	delete[] table;
-
-	table = new int[n];
-
-	for (i = 0; i < n; ++i) {
-	
-	    m = i;
-
-	    for (j = k = 0; j < bits; ++j) {
-		k = (k << 1) | (m & 1);
-		m >>= 1;
-	    }
-
-	    table[i] = k;
-	}
-
-	tableSize = n;
-    }
-
-    if (ii) {
-	for (i = 0; i < n; ++i) {
-	    ro[table[i]] = ri[i];
-	    io[table[i]] = ii[i];
-	}
-    } else {
-	for (i = 0; i < n; ++i) {
-	    ro[table[i]] = ri[i];
-	    io[table[i]] = 0.0;
-	}
-    }
-
-    blockEnd = 1;
-
-    for (blockSize = 2; blockSize <= n; blockSize <<= 1) {
-
-	double delta = angle / (double)blockSize;
-	double sm2 = -sin(-2 * delta);
-	double sm1 = -sin(-delta);
-	double cm2 = cos(-2 * delta);
-	double cm1 = cos(-delta);
-	double w = 2 * cm1;
-	double ar[3], ai[3];
-
-	for (i = 0; i < n; i += blockSize) {
-
-	    ar[2] = cm2;
-	    ar[1] = cm1;
-
-	    ai[2] = sm2;
-	    ai[1] = sm1;
-
-	    for (j = i, m = 0; m < blockEnd; j++, m++) {
-
-		ar[0] = w * ar[1] - ar[2];
-		ar[2] = ar[1];
-		ar[1] = ar[0];
-
-		ai[0] = w * ai[1] - ai[2];
-		ai[2] = ai[1];
-		ai[1] = ai[0];
-
-		k = j + blockEnd;
-		tr = ar[0] * ro[k] - ai[0] * io[k];
-		ti = ar[0] * io[k] + ai[0] * ro[k];
-
-		ro[k] = ro[j] - tr;
-		io[k] = io[j] - ti;
-
-		ro[j] += tr;
-		io[j] += ti;
-	    }
-	}
-
-	blockEnd = blockSize;
-    }
-
-    if (inverse) {
-
-	double denom = (double)n;
-
-	for (i = 0; i < n; i++) {
-	    ro[i] /= denom;
-	    io[i] /= denom;
-	}
-    }
-}
-
-        
-}
-
--- a/vamp-hostsdk/PluginInputDomainAdapter.h	Wed May 09 15:21:37 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Vamp
-
-    An API for audio analysis and feature extraction plugins.
-
-    Centre for Digital Music, Queen Mary, University of London.
-    Copyright 2006 Chris Cannam.
-  
-    Permission is hereby granted, free of charge, to any person
-    obtaining a copy of this software and associated documentation
-    files (the "Software"), to deal in the Software without
-    restriction, including without limitation the rights to use, copy,
-    modify, merge, publish, distribute, sublicense, and/or sell copies
-    of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be
-    included in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-    Except as contained in this notice, the names of the Centre for
-    Digital Music; Queen Mary, University of London; and Chris Cannam
-    shall not be used in advertising or otherwise to promote the sale,
-    use or other dealings in this Software without prior written
-    authorization.
-*/
-
-#ifndef _PLUGIN_INPUT_DOMAIN_ADAPTER_H_
-
-#include "PluginWrapper.h"
-
-namespace Vamp {
-
-/**
- * An adapter that converts time-domain input into frequency-domain
- * input for plugins that need it.  In every other respect this
- * adapter behaves like the plugin it wraps.  The wrapped plugin may
- * be a time-domain plugin, in which case this wrapper does nothing.
- *
- * Uses a Hanning windowed FFT.  The FFT implementation is not the
- * fastest, so a host can do much better if it cares enough, but it is
- * simple and self-contained.
- *
- * Note that this adapter does not support non-power-of-two block
- * sizes.
- */
-
-//!!! It would also be nice to have a channel wrapper, which deals
-//with mixing down channels if the plugin needs a different number
-//from the input source.  It would have some sort of mixdown/channel
-//input policy selection.  Probably this class and that one should
-//both inherit a PluginAdapter class which contains a plugin and
-//delegates all calls through to it; the subclass can then override
-//only the ones it needs to handle.
-
-class PluginInputDomainAdapter : public PluginWrapper
-{
-public:
-    PluginInputDomainAdapter(Plugin *plugin); // I take ownership of plugin
-    virtual ~PluginInputDomainAdapter();
-    
-    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
-
-    InputDomain getInputDomain() const;
-
-    size_t getPreferredStepSize() const;
-    size_t getPreferredBlockSize() const;
-
-    FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
-
-protected:
-    Plugin *m_plugin;
-    size_t m_channels;
-    size_t m_blockSize;
-    float **m_freqbuf;
-    double *m_ri;
-    double *m_ro;
-    double *m_io;
-
-    void fft(unsigned int n, bool inverse,
-             double *ri, double *ii, double *ro, double *io);
-};
-
-}
-
-#endif
--- a/vamp-hostsdk/PluginLoader.cpp	Wed May 09 15:21:37 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,303 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Vamp
-
-    An API for audio analysis and feature extraction plugins.
-
-    Centre for Digital Music, Queen Mary, University of London.
-    Copyright 2006 Chris Cannam.
-  
-    Permission is hereby granted, free of charge, to any person
-    obtaining a copy of this software and associated documentation
-    files (the "Software"), to deal in the Software without
-    restriction, including without limitation the rights to use, copy,
-    modify, merge, publish, distribute, sublicense, and/or sell copies
-    of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be
-    included in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-    Except as contained in this notice, the names of the Centre for
-    Digital Music; Queen Mary, University of London; and Chris Cannam
-    shall not be used in advertising or otherwise to promote the sale,
-    use or other dealings in this Software without prior written
-    authorization.
-*/
-
-#include "PluginLoader.h"
-#include "PluginHostAdapter.h"
-
-#include "system.h"
-
-#include <fstream>
-
-#include <dirent.h> // POSIX directory open and read
-
-using namespace std;
-
-namespace Vamp {
-	
-PluginLoader::PluginLoader()
-{
-}
-
-PluginLoader::~PluginLoader()
-{
-}
-
-vector<PluginLoader::PluginKey>
-PluginLoader::listPlugins() 
-{
-    if (m_pluginLibraryMap.empty()) {
-
-        vector<string> path = PluginHostAdapter::getPluginPath();
-
-        size_t suffixLen = strlen(PLUGIN_SUFFIX);
-
-        for (size_t i = 0; i < path.size(); ++i) {
-            
-            vector<string> files = getFilesInDir(path[i], PLUGIN_SUFFIX);
-            
-
-            for (vector<string>::iterator fi = files.begin();
-                 fi != files.end(); ++fi) {
-
-                string basename = *fi;
-                basename = basename.substr(0, basename.length() - suffixLen - 1);
-
-                string fullPath = path[i];
-                fullPath = fullPath + "/" + *fi; //!!! systemize
-                void *handle = DLOPEN(fullPath, RTLD_LAZY);
-
-                if (!handle) {
-                    cerr << "Vamp::PluginLoader: " << *fi
-                              << ": unable to load library (" << DLERROR()
-                              << ")" << endl;
-                    continue;
-                }
-            
-                VampGetPluginDescriptorFunction fn =
-                    (VampGetPluginDescriptorFunction)DLSYM
-                    (handle, "vampGetPluginDescriptor");
-
-                if (!fn) {
-                    DLCLOSE(handle);
-                    continue;
-                }
-
-                int index = 0;
-                const VampPluginDescriptor *descriptor = 0;
-
-                while ((descriptor = fn(VAMP_API_VERSION, index))) {
-                    PluginKey key = basename + ":" + descriptor->identifier;
-                    if (m_pluginLibraryMap.find(key) ==
-                        m_pluginLibraryMap.end()) {
-                        m_pluginLibraryMap[key] = fullPath;
-                    }
-                    ++index;
-                }
-
-                DLCLOSE(handle);
-            }
-        }
-    }
-
-    vector<PluginKey> plugins;
-    for (map<PluginKey, string>::iterator mi =
-             m_pluginLibraryMap.begin();
-         mi != m_pluginLibraryMap.end(); ++mi) {
-        plugins.push_back(mi->first);
-    }
-
-    return plugins;
-}
-
-PluginLoader::PluginCategoryHierarchy
-PluginLoader::getPluginCategory(PluginKey plugin)
-{
-    if (m_taxonomy.empty()) generateTaxonomy();
-    if (m_taxonomy.find(plugin) == m_taxonomy.end()) return PluginCategoryHierarchy();
-    return m_taxonomy[plugin];
-}
-
-string
-PluginLoader::getLibraryPathForPlugin(PluginKey plugin)
-{
-    if (m_pluginLibraryMap.empty()) (void)listPlugins();
-    if (m_pluginLibraryMap.find(plugin) == m_pluginLibraryMap.end()) return "";
-    return m_pluginLibraryMap[plugin];
-}    
-
-Plugin *
-PluginLoader::load(PluginKey key, float inputSampleRate)
-{
-    string fullPath = getLibraryPathForPlugin(key);
-    if (fullPath == "") return 0;
-    
-    string::size_type ki = key.find(':');
-    if (ki == string::npos) {
-        //!!! flag error
-        return 0;
-    }
-
-    string identifier = key.substr(ki + 1);
-    
-    void *handle = DLOPEN(fullPath, RTLD_LAZY);
-
-    if (!handle) {
-        cerr << "Vamp::PluginLoader: " << fullPath
-                  << ": unable to load library (" << DLERROR()
-                  << ")" << endl;
-        return 0;
-    }
-    
-    VampGetPluginDescriptorFunction fn =
-        (VampGetPluginDescriptorFunction)DLSYM
-        (handle, "vampGetPluginDescriptor");
-
-    if (!fn) {
-        //!!! refcount this! --!!! no, POSIX says dlopen/dlclose will
-        // reference count. check on win32
-        DLCLOSE(handle);
-        return 0;
-    }
-
-    int index = 0;
-    const VampPluginDescriptor *descriptor = 0;
-
-    while ((descriptor = fn(VAMP_API_VERSION, index))) {
-        if (string(descriptor->identifier) == identifier) {
-            return new Vamp::PluginHostAdapter(descriptor, inputSampleRate);
-        }
-        ++index;
-    }
-    
-    //!!! flag error
-    return 0;
-}
-
-vector<string>
-PluginLoader::getFilesInDir(string dir, string extension)
-{
-    vector<string> files;
-
-    DIR *d = opendir(dir.c_str());
-    if (!d) return files;
-            
-    struct dirent *e = 0;
-    while ((e = readdir(d))) {
-        
-        if (!(e->d_type & DT_REG) || !e->d_name) {
-            continue;
-        }
-        
-        int len = strlen(e->d_name);
-        if (len < int(extension.length() + 2) ||
-            e->d_name[len - extension.length() - 1] != '.' ||
-            strcmp(e->d_name + len - extension.length(), extension.c_str())) {
-            continue;
-        }
-
-        files.push_back(e->d_name);
-    }
-
-    closedir(d);
-
-    return files;
-}
-
-void
-PluginLoader::generateTaxonomy()
-{
-//    cerr << "PluginLoader::generateTaxonomy" << endl;
-
-    vector<string> path = PluginHostAdapter::getPluginPath();
-    string libfragment = "/lib/";
-    vector<string> catpath;
-
-    string suffix = "cat";
-
-    for (vector<string>::iterator i = path.begin();
-         i != path.end(); ++i) {
-        
-        string dir = *i;
-        string::size_type li = dir.find(libfragment);
-
-        if (li != string::npos) {
-            catpath.push_back
-                (dir.substr(0, li)
-                 + "/share/"
-                 + dir.substr(li + libfragment.length()));
-        }
-
-        catpath.push_back(dir);
-    }
-
-    char buffer[1024];
-
-    for (vector<string>::iterator i = catpath.begin();
-         i != catpath.end(); ++i) {
-        
-        vector<string> files = getFilesInDir(*i, suffix);
-
-        for (vector<string>::iterator fi = files.begin();
-             fi != files.end(); ++fi) {
-
-            string filepath = *i + "/" + *fi; //!!! systemize
-            ifstream is(filepath.c_str(), ifstream::in | ifstream::binary);
-
-            if (is.fail()) {
-//                cerr << "failed to open: " << filepath << endl;
-                continue;
-            }
-
-//            cerr << "opened: " << filepath << endl;
-
-            while (!!is.getline(buffer, 1024)) {
-
-                string line(buffer);
-
-//                cerr << "line = " << line << endl;
-
-                string::size_type di = line.find("::");
-                if (di == string::npos) continue;
-
-                string id = line.substr(0, di);
-                string encodedCat = line.substr(di + 2);
-
-                if (id.substr(0, 5) != "vamp:") continue;
-                id = id.substr(5);
-
-                while (encodedCat.length() >= 1 &&
-                       encodedCat[encodedCat.length()-1] == '\r') {
-                    encodedCat = encodedCat.substr(0, encodedCat.length()-1);
-                }
-
-//                cerr << "id = " << id << ", cat = " << encodedCat << endl;
-
-                PluginCategoryHierarchy category;
-                string::size_type ai;
-                while ((ai = encodedCat.find(" > ")) != string::npos) {
-                    category.push_back(encodedCat.substr(0, ai));
-                    encodedCat = encodedCat.substr(ai + 3);
-                }
-                if (encodedCat != "") category.push_back(encodedCat);
-
-                m_taxonomy[id] = category;
-            }
-        }
-    }
-}    
-
-
-}
--- a/vamp-hostsdk/PluginLoader.h	Wed May 09 15:21:37 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Vamp
-
-    An API for audio analysis and feature extraction plugins.
-
-    Centre for Digital Music, Queen Mary, University of London.
-    Copyright 2006 Chris Cannam.
-  
-    Permission is hereby granted, free of charge, to any person
-    obtaining a copy of this software and associated documentation
-    files (the "Software"), to deal in the Software without
-    restriction, including without limitation the rights to use, copy,
-    modify, merge, publish, distribute, sublicense, and/or sell copies
-    of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be
-    included in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-    Except as contained in this notice, the names of the Centre for
-    Digital Music; Queen Mary, University of London; and Chris Cannam
-    shall not be used in advertising or otherwise to promote the sale,
-    use or other dealings in this Software without prior written
-    authorization.
-*/
-
-#ifndef _VAMP_PLUGIN_LOADER_H_
-#define _VAMP_PLUGIN_LOADER_H_
-
-#include <vector>
-#include <string>
-#include <map>
-
-namespace Vamp {
-
-class Plugin;
-
-class PluginLoader
-{
-public:
-    PluginLoader();
-    virtual ~PluginLoader();
-
-    typedef std::string PluginKey;
-    typedef std::vector<std::string> PluginCategoryHierarchy;
-
-    std::vector<PluginKey> listPlugins(); //!!! pass in version number?
-
-    //!!! want to be able to just "delete" the plugin later -- hence
-    //have to consider library loading issues -- do we have a wrapper
-    //class that tells us when it's been deleted, and keep a reference
-    //count for the dynamic library?
-    Plugin *load(PluginKey plugin, float inputSampleRate);
-
-    PluginCategoryHierarchy getPluginCategory(PluginKey plugin);
-
-    std::string getLibraryPathForPlugin(PluginKey plugin);
-
-protected:
-    std::map<PluginKey, std::string> m_pluginLibraryMap;
-    std::map<PluginKey, PluginCategoryHierarchy> m_taxonomy;
-    void generateTaxonomy();
-    std::vector<std::string> getFilesInDir(std::string dir, std::string ext);
-};
-
-}
-
-
-#endif
-
--- a/vamp-hostsdk/PluginWrapper.cpp	Wed May 09 15:21:37 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,189 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Vamp
-
-    An API for audio analysis and feature extraction plugins.
-
-    Centre for Digital Music, Queen Mary, University of London.
-    Copyright 2006 Chris Cannam.
-  
-    Permission is hereby granted, free of charge, to any person
-    obtaining a copy of this software and associated documentation
-    files (the "Software"), to deal in the Software without
-    restriction, including without limitation the rights to use, copy,
-    modify, merge, publish, distribute, sublicense, and/or sell copies
-    of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be
-    included in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-    Except as contained in this notice, the names of the Centre for
-    Digital Music; Queen Mary, University of London; and Chris Cannam
-    shall not be used in advertising or otherwise to promote the sale,
-    use or other dealings in this Software without prior written
-    authorization.
-*/
-
-#include "PluginWrapper.h"
-
-namespace Vamp {
-
-PluginWrapper::PluginWrapper(Plugin *plugin) :
-    Plugin(0)
-{
-}
-
-PluginWrapper::~PluginWrapper()
-{
-    delete m_plugin;
-}
-    
-bool
-PluginWrapper::initialise(size_t channels, size_t stepSize, size_t blockSize)
-{
-    return m_plugin->initialise(channels, stepSize, blockSize);
-}
-
-void
-PluginWrapper::reset()
-{
-    m_plugin->reset();
-}
-
-Plugin::InputDomain
-PluginWrapper::getInputDomain() const
-{
-    return m_plugin->getInputDomain();
-}
-
-unsigned int
-PluginWrapper::getVampApiVersion() const
-{
-    return m_plugin->getVampApiVersion();
-}
-
-std::string
-PluginWrapper::getIdentifier() const
-{
-    return m_plugin->getIdentifier();
-}
-
-std::string
-PluginWrapper::getName() const
-{
-    return m_plugin->getName();
-}
-
-std::string
-PluginWrapper::getDescription() const
-{
-    return m_plugin->getDescription();
-}
-
-std::string
-PluginWrapper::getMaker() const
-{
-    return m_plugin->getMaker();
-}
-
-int
-PluginWrapper::getPluginVersion() const
-{
-    return m_plugin->getPluginVersion();
-}
-
-std::string
-PluginWrapper::getCopyright() const
-{
-    return m_plugin->getCopyright();
-}
-
-PluginBase::ParameterList
-PluginWrapper::getParameterDescriptors() const
-{
-    return m_plugin->getParameterDescriptors();
-}
-
-float
-PluginWrapper::getParameter(std::string parameter) const
-{
-    return m_plugin->getParameter(parameter);
-}
-
-void
-PluginWrapper::setParameter(std::string parameter, float value)
-{
-    m_plugin->setParameter(parameter, value);
-}
-
-PluginBase::ProgramList
-PluginWrapper::getPrograms() const
-{
-    return m_plugin->getPrograms();
-}
-
-std::string
-PluginWrapper::getCurrentProgram() const
-{
-    return m_plugin->getCurrentProgram();
-}
-
-void
-PluginWrapper::selectProgram(std::string program)
-{
-    m_plugin->selectProgram(program);
-}
-
-size_t
-PluginWrapper::getPreferredStepSize() const
-{
-    return m_plugin->getPreferredStepSize();
-}
-
-size_t
-PluginWrapper::getPreferredBlockSize() const
-{
-    return m_plugin->getPreferredBlockSize();
-}
-
-size_t
-PluginWrapper::getMinChannelCount() const
-{
-    return m_plugin->getMinChannelCount();
-}
-
-size_t PluginWrapper::getMaxChannelCount() const
-{
-    return m_plugin->getMaxChannelCount();
-}
-
-Plugin::OutputList
-PluginWrapper::getOutputDescriptors() const
-{
-    return m_plugin->getOutputDescriptors();
-}
-
-Plugin::FeatureSet
-PluginWrapper::process(const float *const *inputBuffers, RealTime timestamp)
-{
-    return m_plugin->process(inputBuffers, timestamp);
-}
-
-Plugin::FeatureSet
-PluginWrapper::getRemainingFeatures()
-{
-    return m_plugin->getRemainingFeatures();
-}
-
-}
-
--- a/vamp-hostsdk/PluginWrapper.h	Wed May 09 15:21:37 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Vamp
-
-    An API for audio analysis and feature extraction plugins.
-
-    Centre for Digital Music, Queen Mary, University of London.
-    Copyright 2006 Chris Cannam.
-  
-    Permission is hereby granted, free of charge, to any person
-    obtaining a copy of this software and associated documentation
-    files (the "Software"), to deal in the Software without
-    restriction, including without limitation the rights to use, copy,
-    modify, merge, publish, distribute, sublicense, and/or sell copies
-    of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be
-    included in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-    Except as contained in this notice, the names of the Centre for
-    Digital Music; Queen Mary, University of London; and Chris Cannam
-    shall not be used in advertising or otherwise to promote the sale,
-    use or other dealings in this Software without prior written
-    authorization.
-*/
-
-#ifndef _PLUGIN_WRAPPER_H_
-
-#include <vamp-sdk/Plugin.h>
-
-namespace Vamp {
-
-class PluginWrapper : public Plugin
-{
-public:
-    virtual ~PluginWrapper();
-    
-    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
-    void reset();
-
-    InputDomain getInputDomain() const;
-
-    unsigned int getVampApiVersion() const;
-    std::string getIdentifier() const;
-    std::string getName() const;
-    std::string getDescription() const;
-    std::string getMaker() const;
-    int getPluginVersion() const;
-    std::string getCopyright() const;
-
-    ParameterList getParameterDescriptors() const;
-    float getParameter(std::string) const;
-    void setParameter(std::string, float);
-
-    ProgramList getPrograms() const;
-    std::string getCurrentProgram() const;
-    void selectProgram(std::string);
-
-    size_t getPreferredStepSize() const;
-    size_t getPreferredBlockSize() const;
-
-    size_t getMinChannelCount() const;
-    size_t getMaxChannelCount() const;
-
-    OutputList getOutputDescriptors() const;
-
-    FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
-
-    FeatureSet getRemainingFeatures();
-
-protected:
-    PluginWrapper(Plugin *plugin); // I take ownership of plugin
-    Plugin *m_plugin;
-};
-
-}
-
-#endif
--- a/vamp-hostsdk/system.h	Wed May 09 15:21:37 2007 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
-
-/*
-    Vamp
-
-    An API for audio analysis and feature extraction plugins.
-
-    Centre for Digital Music, Queen Mary, University of London.
-    Copyright 2006 Chris Cannam.
-  
-    Permission is hereby granted, free of charge, to any person
-    obtaining a copy of this software and associated documentation
-    files (the "Software"), to deal in the Software without
-    restriction, including without limitation the rights to use, copy,
-    modify, merge, publish, distribute, sublicense, and/or sell copies
-    of the Software, and to permit persons to whom the Software is
-    furnished to do so, subject to the following conditions:
-
-    The above copyright notice and this permission notice shall be
-    included in all copies or substantial portions of the Software.
-
-    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
-    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-    Except as contained in this notice, the names of the Centre for
-    Digital Music; Queen Mary, University of London; and Chris Cannam
-    shall not be used in advertising or otherwise to promote the sale,
-    use or other dealings in this Software without prior written
-    authorization.
-*/
-
-#ifndef _SYSTEM_H_
-#define _SYSTEM_H_
-
-#ifdef _WIN32
-
-#include <windows.h>
-
-#define DLOPEN(a,b)  LoadLibrary((a).c_str())
-#define DLSYM(a,b)   GetProcAddress((HINSTANCE)(a),(b))
-#define DLCLOSE(a)   FreeLibrary((HINSTANCE)(a))
-#define DLERROR()    ""
-
-#define PLUGIN_SUFFIX "dll"
-
-#else
-
-#include <dlfcn.h>
-
-#define DLOPEN(a,b)  dlopen((a).c_str(),(b))
-#define DLSYM(a,b)   dlsym((a),(b))
-#define DLCLOSE(a)   dlclose((a))
-#define DLERROR()    dlerror()
-
-#ifdef __APPLE__
-
-#define PLUGIN_SUFFIX  "dylib"
-#define HAVE_OPENDIR 1
-
-#else 
-
-#define PLUGIN_SUFFIX  "so"
-#define HAVE_OPENDIR 1
-
-#endif /* __APPLE__ */
-
-#endif /* ! _WIN32 */
-
-#endif
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-sdk/PluginHostAdapter.cpp	Thu May 24 10:05:00 2007 +0000
@@ -0,0 +1,418 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp
+
+    An API for audio analysis and feature extraction plugins.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    Copyright 2006 Chris Cannam.
+  
+    Permission is hereby granted, free of charge, to any person
+    obtaining a copy of this software and associated documentation
+    files (the "Software"), to deal in the Software without
+    restriction, including without limitation the rights to use, copy,
+    modify, merge, publish, distribute, sublicense, and/or sell copies
+    of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be
+    included in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    Except as contained in this notice, the names of the Centre for
+    Digital Music; Queen Mary, University of London; and Chris Cannam
+    shall not be used in advertising or otherwise to promote the sale,
+    use or other dealings in this Software without prior written
+    authorization.
+*/
+
+#include "PluginHostAdapter.h"
+
+namespace Vamp
+{
+
+PluginHostAdapter::PluginHostAdapter(const VampPluginDescriptor *descriptor,
+                                     float inputSampleRate) :
+    Plugin(inputSampleRate),
+    m_descriptor(descriptor)
+{
+//    std::cerr << "PluginHostAdapter::PluginHostAdapter (plugin = " << descriptor->name << ")" << std::endl;
+    m_handle = m_descriptor->instantiate(m_descriptor, inputSampleRate);
+    if (!m_handle) {
+//        std::cerr << "WARNING: PluginHostAdapter: Plugin instantiation failed for plugin " << m_descriptor->name << std::endl;
+    }
+}
+
+PluginHostAdapter::~PluginHostAdapter()
+{
+//    std::cerr << "PluginHostAdapter::~PluginHostAdapter (plugin = " << m_descriptor->name << ")" << std::endl;
+    if (m_handle) m_descriptor->cleanup(m_handle);
+}
+
+std::vector<std::string>
+PluginHostAdapter::getPluginPath()
+{
+    std::vector<std::string> path;
+    std::string envPath;
+
+    char *cpath = getenv("VAMP_PATH");
+    if (cpath) envPath = cpath;
+
+#ifdef _WIN32
+#define PATH_SEPARATOR ';'
+#define DEFAULT_VAMP_PATH "%ProgramFiles%\\Vamp Plugins"
+#else
+#define PATH_SEPARATOR ':'
+#ifdef __APPLE__
+#define DEFAULT_VAMP_PATH "$HOME/Library/Audio/Plug-Ins/Vamp:/Library/Audio/Plug-Ins/Vamp"
+#else
+#define DEFAULT_VAMP_PATH "$HOME/vamp:$HOME/.vamp:/usr/local/lib/vamp:/usr/lib/vamp"
+#endif
+#endif
+
+    if (envPath == "") {
+        envPath = DEFAULT_VAMP_PATH;
+        char *chome = getenv("HOME");
+        if (chome) {
+            std::string home(chome);
+            std::string::size_type f;
+            while ((f = envPath.find("$HOME")) != std::string::npos &&
+                    f < envPath.length()) {
+                envPath.replace(f, 5, home);
+            }
+        }
+#ifdef _WIN32
+        char *cpfiles = getenv("ProgramFiles");
+        if (!cpfiles) cpfiles = "C:\\Program Files";
+        std::string pfiles(cpfiles);
+        std::string::size_type f;
+        while ((f = envPath.find("%ProgramFiles%")) != std::string::npos &&
+               f < envPath.length()) {
+            envPath.replace(f, 14, pfiles);
+        }
+#endif
+    }
+
+    std::string::size_type index = 0, newindex = 0;
+
+    while ((newindex = envPath.find(PATH_SEPARATOR, index)) < envPath.size()) {
+	path.push_back(envPath.substr(index, newindex - index));
+	index = newindex + 1;
+    }
+    
+    path.push_back(envPath.substr(index));
+
+    return path;
+}
+
+bool
+PluginHostAdapter::initialise(size_t channels,
+                              size_t stepSize,
+                              size_t blockSize)
+{
+    if (!m_handle) return false;
+    return m_descriptor->initialise(m_handle, channels, stepSize, blockSize) ?
+        true : false;
+}
+
+void
+PluginHostAdapter::reset()
+{
+    if (!m_handle) return;
+    m_descriptor->reset(m_handle);
+}
+
+PluginHostAdapter::InputDomain
+PluginHostAdapter::getInputDomain() const
+{
+    if (m_descriptor->inputDomain == vampFrequencyDomain) {
+        return FrequencyDomain;
+    } else {
+        return TimeDomain;
+    }
+}
+
+unsigned int
+PluginHostAdapter::getVampApiVersion() const
+{
+    return m_descriptor->vampApiVersion;
+}
+
+std::string
+PluginHostAdapter::getIdentifier() const
+{
+    return m_descriptor->identifier;
+}
+
+std::string
+PluginHostAdapter::getName() const
+{
+    return m_descriptor->name;
+}
+
+std::string
+PluginHostAdapter::getDescription() const
+{
+    return m_descriptor->description;
+}
+
+std::string
+PluginHostAdapter::getMaker() const
+{
+    return m_descriptor->maker;
+}
+
+int
+PluginHostAdapter::getPluginVersion() const
+{
+    return m_descriptor->pluginVersion;
+}
+
+std::string
+PluginHostAdapter::getCopyright() const
+{
+    return m_descriptor->copyright;
+}
+
+PluginHostAdapter::ParameterList
+PluginHostAdapter::getParameterDescriptors() const
+{
+    ParameterList list;
+    for (unsigned int i = 0; i < m_descriptor->parameterCount; ++i) {
+        const VampParameterDescriptor *spd = m_descriptor->parameters[i];
+        ParameterDescriptor pd;
+        pd.identifier = spd->identifier;
+        pd.name = spd->name;
+        pd.description = spd->description;
+        pd.unit = spd->unit;
+        pd.minValue = spd->minValue;
+        pd.maxValue = spd->maxValue;
+        pd.defaultValue = spd->defaultValue;
+        pd.isQuantized = spd->isQuantized;
+        pd.quantizeStep = spd->quantizeStep;
+        if (pd.isQuantized && spd->valueNames) {
+            for (unsigned int j = 0; spd->valueNames[j]; ++j) {
+                pd.valueNames.push_back(spd->valueNames[j]);
+            }
+        }
+        list.push_back(pd);
+    }
+    return list;
+}
+
+float
+PluginHostAdapter::getParameter(std::string param) const
+{
+    if (!m_handle) return 0.0;
+
+    for (unsigned int i = 0; i < m_descriptor->parameterCount; ++i) {
+        if (param == m_descriptor->parameters[i]->identifier) {
+            return m_descriptor->getParameter(m_handle, i);
+        }
+    }
+
+    return 0.0;
+}
+
+void
+PluginHostAdapter::setParameter(std::string param, 
+                                float value)
+{
+    if (!m_handle) return;
+
+    for (unsigned int i = 0; i < m_descriptor->parameterCount; ++i) {
+        if (param == m_descriptor->parameters[i]->identifier) {
+            m_descriptor->setParameter(m_handle, i, value);
+            return;
+        }
+    }
+}
+
+PluginHostAdapter::ProgramList
+PluginHostAdapter::getPrograms() const
+{
+    ProgramList list;
+    
+    for (unsigned int i = 0; i < m_descriptor->programCount; ++i) {
+        list.push_back(m_descriptor->programs[i]);
+    }
+    
+    return list;
+}
+
+std::string
+PluginHostAdapter::getCurrentProgram() const
+{
+    if (!m_handle) return "";
+
+    int pn = m_descriptor->getCurrentProgram(m_handle);
+    return m_descriptor->programs[pn];
+}
+
+void
+PluginHostAdapter::selectProgram(std::string program)
+{
+    if (!m_handle) return;
+
+    for (unsigned int i = 0; i < m_descriptor->programCount; ++i) {
+        if (program == m_descriptor->programs[i]) {
+            m_descriptor->selectProgram(m_handle, i);
+            return;
+        }
+    }
+}
+
+size_t
+PluginHostAdapter::getPreferredStepSize() const
+{
+    if (!m_handle) return 0;
+    return m_descriptor->getPreferredStepSize(m_handle);
+}
+
+size_t
+PluginHostAdapter::getPreferredBlockSize() const
+{
+    if (!m_handle) return 0;
+    return m_descriptor->getPreferredBlockSize(m_handle);
+}
+
+size_t
+PluginHostAdapter::getMinChannelCount() const
+{
+    if (!m_handle) return 0;
+    return m_descriptor->getMinChannelCount(m_handle);
+}
+
+size_t
+PluginHostAdapter::getMaxChannelCount() const
+{
+    if (!m_handle) return 0;
+    return m_descriptor->getMaxChannelCount(m_handle);
+}
+
+PluginHostAdapter::OutputList
+PluginHostAdapter::getOutputDescriptors() const
+{
+    OutputList list;
+    if (!m_handle) {
+//        std::cerr << "PluginHostAdapter::getOutputDescriptors: no handle " << std::endl;
+        return list;
+    }
+
+    unsigned int count = m_descriptor->getOutputCount(m_handle);
+
+    for (unsigned int i = 0; i < count; ++i) {
+        VampOutputDescriptor *sd = m_descriptor->getOutputDescriptor(m_handle, i);
+        OutputDescriptor d;
+        d.identifier = sd->identifier;
+        d.name = sd->name;
+        d.description = sd->description;
+        d.unit = sd->unit;
+        d.hasFixedBinCount = sd->hasFixedBinCount;
+        d.binCount = sd->binCount;
+        if (d.hasFixedBinCount) {
+            for (unsigned int j = 0; j < sd->binCount; ++j) {
+                d.binNames.push_back(sd->binNames[j] ? sd->binNames[j] : "");
+            }
+        }
+        d.hasKnownExtents = sd->hasKnownExtents;
+        d.minValue = sd->minValue;
+        d.maxValue = sd->maxValue;
+        d.isQuantized = sd->isQuantized;
+        d.quantizeStep = sd->quantizeStep;
+
+        switch (sd->sampleType) {
+        case vampOneSamplePerStep:
+            d.sampleType = OutputDescriptor::OneSamplePerStep; break;
+        case vampFixedSampleRate:
+            d.sampleType = OutputDescriptor::FixedSampleRate; break;
+        case vampVariableSampleRate:
+            d.sampleType = OutputDescriptor::VariableSampleRate; break;
+        }
+
+        d.sampleRate = sd->sampleRate;
+
+        list.push_back(d);
+
+        m_descriptor->releaseOutputDescriptor(sd);
+    }
+
+    return list;
+}
+
+PluginHostAdapter::FeatureSet
+PluginHostAdapter::process(const float *const *inputBuffers,
+                           RealTime timestamp)
+{
+    FeatureSet fs;
+    if (!m_handle) return fs;
+
+    int sec = timestamp.sec;
+    int nsec = timestamp.nsec;
+    
+    VampFeatureList *features = m_descriptor->process(m_handle,
+                                                      inputBuffers,
+                                                      sec, nsec);
+    
+    convertFeatures(features, fs);
+    m_descriptor->releaseFeatureSet(features);
+    return fs;
+}
+
+PluginHostAdapter::FeatureSet
+PluginHostAdapter::getRemainingFeatures()
+{
+    FeatureSet fs;
+    if (!m_handle) return fs;
+    
+    VampFeatureList *features = m_descriptor->getRemainingFeatures(m_handle); 
+
+    convertFeatures(features, fs);
+    m_descriptor->releaseFeatureSet(features);
+    return fs;
+}
+
+void
+PluginHostAdapter::convertFeatures(VampFeatureList *features,
+                                   FeatureSet &fs)
+{
+    if (!features) return;
+
+    unsigned int outputs = m_descriptor->getOutputCount(m_handle);
+
+    for (unsigned int i = 0; i < outputs; ++i) {
+        
+        VampFeatureList &list = features[i];
+
+        if (list.featureCount > 0) {
+
+            for (unsigned int j = 0; j < list.featureCount; ++j) {
+                
+                Feature feature;
+                feature.hasTimestamp = list.features[j].hasTimestamp;
+                feature.timestamp = RealTime(list.features[j].sec,
+                                             list.features[j].nsec);
+
+                for (unsigned int k = 0; k < list.features[j].valueCount; ++k) {
+                    feature.values.push_back(list.features[j].values[k]);
+                }
+
+                if (list.features[j].label) {
+                    feature.label = list.features[j].label;
+                }
+
+                fs[i].push_back(feature);
+            }
+        }
+    }
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-sdk/PluginHostAdapter.h	Thu May 24 10:05:00 2007 +0000
@@ -0,0 +1,115 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp
+
+    An API for audio analysis and feature extraction plugins.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    Copyright 2006 Chris Cannam.
+  
+    Permission is hereby granted, free of charge, to any person
+    obtaining a copy of this software and associated documentation
+    files (the "Software"), to deal in the Software without
+    restriction, including without limitation the rights to use, copy,
+    modify, merge, publish, distribute, sublicense, and/or sell copies
+    of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be
+    included in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    Except as contained in this notice, the names of the Centre for
+    Digital Music; Queen Mary, University of London; and Chris Cannam
+    shall not be used in advertising or otherwise to promote the sale,
+    use or other dealings in this Software without prior written
+    authorization.
+*/
+
+#ifndef _VAMP_PLUGIN_HOST_ADAPTER_H_
+#define _VAMP_PLUGIN_HOST_ADAPTER_H_
+
+#include <vamp/vamp.h>
+#include <vamp-sdk/Plugin.h>
+
+#include <vector>
+
+namespace Vamp {
+
+/**
+ * PluginHostAdapter is a wrapper class that a Vamp host can use to
+ * make the C-language VampPluginDescriptor object appear as a C++
+ * Vamp::Plugin object.
+ *
+ * The Vamp API is defined in vamp/vamp.h as a C API.  The C++ objects
+ * used for convenience by plugins and hosts actually communicate
+ * using the C low-level API, but the details of this communication
+ * are handled seamlessly by the Vamp SDK implementation provided the
+ * plugin and host use the proper C++ wrapper objects.
+ *
+ * See also PluginAdapter, the plugin-side wrapper that makes a C++
+ * plugin object available using the C query API.
+ */
+
+class PluginHostAdapter : public Plugin
+{
+public:
+    PluginHostAdapter(const VampPluginDescriptor *descriptor,
+                      float inputSampleRate);
+    virtual ~PluginHostAdapter();
+    
+    static std::vector<std::string> getPluginPath();
+
+    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
+    void reset();
+
+    InputDomain getInputDomain() const;
+
+    unsigned int getVampApiVersion() const;
+    std::string getIdentifier() const;
+    std::string getName() const;
+    std::string getDescription() const;
+    std::string getMaker() const;
+    int getPluginVersion() const;
+    std::string getCopyright() const;
+
+    ParameterList getParameterDescriptors() const;
+    float getParameter(std::string) const;
+    void setParameter(std::string, float);
+
+    ProgramList getPrograms() const;
+    std::string getCurrentProgram() const;
+    void selectProgram(std::string);
+
+    size_t getPreferredStepSize() const;
+    size_t getPreferredBlockSize() const;
+
+    size_t getMinChannelCount() const;
+    size_t getMaxChannelCount() const;
+
+    OutputList getOutputDescriptors() const;
+
+    FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
+
+    FeatureSet getRemainingFeatures();
+
+protected:
+    void convertFeatures(VampFeatureList *, FeatureSet &);
+
+    const VampPluginDescriptor *m_descriptor;
+    VampPluginHandle m_handle;
+};
+
+}
+
+#endif
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-sdk/hostext/PluginInputDomainAdapter.cpp	Thu May 24 10:05:00 2007 +0000
@@ -0,0 +1,274 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp
+
+    An API for audio analysis and feature extraction plugins.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    Copyright 2006 Chris Cannam.
+  
+    Permission is hereby granted, free of charge, to any person
+    obtaining a copy of this software and associated documentation
+    files (the "Software"), to deal in the Software without
+    restriction, including without limitation the rights to use, copy,
+    modify, merge, publish, distribute, sublicense, and/or sell copies
+    of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be
+    included in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    Except as contained in this notice, the names of the Centre for
+    Digital Music; Queen Mary, University of London; and Chris Cannam
+    shall not be used in advertising or otherwise to promote the sale,
+    use or other dealings in this Software without prior written
+    authorization.
+*/
+
+#include "PluginInputDomainAdapter.h"
+
+#include <cmath>
+
+namespace Vamp {
+
+PluginInputDomainAdapter::PluginInputDomainAdapter(Plugin *plugin) :
+    PluginWrapper(plugin),
+    m_channels(0),
+    m_blockSize(0),
+    m_freqbuf(0)
+{
+}
+
+PluginInputDomainAdapter::~PluginInputDomainAdapter()
+{
+}
+    
+bool
+PluginInputDomainAdapter::initialise(size_t channels, size_t stepSize, size_t blockSize)
+{
+    //!!! complain and die if blocksize is not a power of 2
+
+    if (m_plugin->getInputDomain() == FrequencyDomain) {
+        if (m_channels > 0) {
+            for (size_t c = 0; c < m_channels; ++c) {
+                delete[] m_freqbuf[c];
+            }
+            delete[] m_freqbuf;
+            delete[] m_ri;
+            delete[] m_ro;
+            delete[] m_io;
+        }
+    }
+
+    m_channels = channels;
+    m_blockSize = blockSize;
+
+    if (m_plugin->getInputDomain() == FrequencyDomain) {
+        m_freqbuf = new float *[m_channels];
+        for (size_t c = 0; c < m_channels; ++c) {
+            m_freqbuf[c] = new float[m_blockSize + 2];
+        }
+        m_ri = new double[m_blockSize];
+        m_ro = new double[m_blockSize];
+        m_io = new double[m_blockSize];
+    }
+
+    return m_plugin->initialise(channels, stepSize, blockSize);
+}
+
+Plugin::InputDomain
+PluginInputDomainAdapter::getInputDomain() const
+{
+    return TimeDomain;
+}
+
+size_t
+PluginInputDomainAdapter::getPreferredStepSize() const
+{
+    size_t step = m_plugin->getPreferredStepSize();
+
+    if (step == 0 && (m_plugin->getInputDomain() == FrequencyDomain)) {
+        step = getPreferredBlockSize() / 2;
+    }
+
+    return step;
+}
+
+size_t
+PluginInputDomainAdapter::getPreferredBlockSize() const
+{
+    size_t block = m_plugin->getPreferredBlockSize();
+
+    if (block == 0 && (m_plugin->getInputDomain() == FrequencyDomain)) {
+        block = 1024;
+    }
+
+    return block;
+}
+
+Plugin::FeatureSet
+PluginInputDomainAdapter::process(const float *const *inputBuffers, RealTime timestamp)
+{
+    if (m_plugin->getInputDomain() == TimeDomain) {
+        return m_plugin->process(inputBuffers, timestamp);
+    }
+
+    for (size_t c = 0; c < m_channels; ++c) {
+
+        for (size_t i = 0; i < m_blockSize; ++i) {
+            // Hanning window
+            m_ri[i] = double(inputBuffers[c][i])
+                * (0.50 - 0.50 * cos((2 * M_PI * i)
+                                     / m_blockSize));
+        }
+
+        for (size_t i = 0; i < m_blockSize/2; ++i) {
+            // FFT shift
+            double value = m_ri[i];
+            m_ri[i] = m_ri[i + m_blockSize/2];
+            m_ri[i + m_blockSize/2] = value;
+        }
+
+        fft(m_blockSize, false, m_ri, 0, m_ro, m_io);
+
+        for (size_t i = 0; i < m_blockSize/2; ++i) {
+            m_freqbuf[c][i * 2] = m_ro[i];
+            m_freqbuf[c][i * 2 + 1] = m_io[i];
+        }
+    }
+
+    //!!! do we want to adjust the timestamp or anything so as to
+    // effectively centre the frame?
+
+    return m_plugin->process(m_freqbuf, timestamp);
+}
+
+void
+PluginInputDomainAdapter::fft(unsigned int n, bool inverse,
+                              double *ri, double *ii, double *ro, double *io)
+{
+    if (!ri || !ro || !io) return;
+
+    unsigned int bits;
+    unsigned int i, j, k, m;
+    unsigned int blockSize, blockEnd;
+
+    double tr, ti;
+
+    if (n < 2) return;
+    if (n & (n-1)) return;
+
+    double angle = 2.0 * M_PI;
+    if (inverse) angle = -angle;
+
+    for (i = 0; ; ++i) {
+	if (n & (1 << i)) {
+	    bits = i;
+	    break;
+	}
+    }
+
+    static unsigned int tableSize = 0;
+    static int *table = 0;
+
+    if (tableSize != n) {
+
+	delete[] table;
+
+	table = new int[n];
+
+	for (i = 0; i < n; ++i) {
+	
+	    m = i;
+
+	    for (j = k = 0; j < bits; ++j) {
+		k = (k << 1) | (m & 1);
+		m >>= 1;
+	    }
+
+	    table[i] = k;
+	}
+
+	tableSize = n;
+    }
+
+    if (ii) {
+	for (i = 0; i < n; ++i) {
+	    ro[table[i]] = ri[i];
+	    io[table[i]] = ii[i];
+	}
+    } else {
+	for (i = 0; i < n; ++i) {
+	    ro[table[i]] = ri[i];
+	    io[table[i]] = 0.0;
+	}
+    }
+
+    blockEnd = 1;
+
+    for (blockSize = 2; blockSize <= n; blockSize <<= 1) {
+
+	double delta = angle / (double)blockSize;
+	double sm2 = -sin(-2 * delta);
+	double sm1 = -sin(-delta);
+	double cm2 = cos(-2 * delta);
+	double cm1 = cos(-delta);
+	double w = 2 * cm1;
+	double ar[3], ai[3];
+
+	for (i = 0; i < n; i += blockSize) {
+
+	    ar[2] = cm2;
+	    ar[1] = cm1;
+
+	    ai[2] = sm2;
+	    ai[1] = sm1;
+
+	    for (j = i, m = 0; m < blockEnd; j++, m++) {
+
+		ar[0] = w * ar[1] - ar[2];
+		ar[2] = ar[1];
+		ar[1] = ar[0];
+
+		ai[0] = w * ai[1] - ai[2];
+		ai[2] = ai[1];
+		ai[1] = ai[0];
+
+		k = j + blockEnd;
+		tr = ar[0] * ro[k] - ai[0] * io[k];
+		ti = ar[0] * io[k] + ai[0] * ro[k];
+
+		ro[k] = ro[j] - tr;
+		io[k] = io[j] - ti;
+
+		ro[j] += tr;
+		io[j] += ti;
+	    }
+	}
+
+	blockEnd = blockSize;
+    }
+
+    if (inverse) {
+
+	double denom = (double)n;
+
+	for (i = 0; i < n; i++) {
+	    ro[i] /= denom;
+	    io[i] /= denom;
+	}
+    }
+}
+
+        
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-sdk/hostext/PluginInputDomainAdapter.h	Thu May 24 10:05:00 2007 +0000
@@ -0,0 +1,95 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp
+
+    An API for audio analysis and feature extraction plugins.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    Copyright 2006 Chris Cannam.
+  
+    Permission is hereby granted, free of charge, to any person
+    obtaining a copy of this software and associated documentation
+    files (the "Software"), to deal in the Software without
+    restriction, including without limitation the rights to use, copy,
+    modify, merge, publish, distribute, sublicense, and/or sell copies
+    of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be
+    included in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    Except as contained in this notice, the names of the Centre for
+    Digital Music; Queen Mary, University of London; and Chris Cannam
+    shall not be used in advertising or otherwise to promote the sale,
+    use or other dealings in this Software without prior written
+    authorization.
+*/
+
+#ifndef _PLUGIN_INPUT_DOMAIN_ADAPTER_H_
+
+#include "PluginWrapper.h"
+
+namespace Vamp {
+
+/**
+ * An adapter that converts time-domain input into frequency-domain
+ * input for plugins that need it.  In every other respect this
+ * adapter behaves like the plugin it wraps.  The wrapped plugin may
+ * be a time-domain plugin, in which case this wrapper does nothing.
+ *
+ * Uses a Hanning windowed FFT.  The FFT implementation is not the
+ * fastest, so a host can do much better if it cares enough, but it is
+ * simple and self-contained.
+ *
+ * Note that this adapter does not support non-power-of-two block
+ * sizes.
+ */
+
+//!!! It would also be nice to have a channel wrapper, which deals
+//with mixing down channels if the plugin needs a different number
+//from the input source.  It would have some sort of mixdown/channel
+//input policy selection.  Probably this class and that one should
+//both inherit a PluginAdapter class which contains a plugin and
+//delegates all calls through to it; the subclass can then override
+//only the ones it needs to handle.
+
+class PluginInputDomainAdapter : public PluginWrapper
+{
+public:
+    PluginInputDomainAdapter(Plugin *plugin); // I take ownership of plugin
+    virtual ~PluginInputDomainAdapter();
+    
+    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
+
+    InputDomain getInputDomain() const;
+
+    size_t getPreferredStepSize() const;
+    size_t getPreferredBlockSize() const;
+
+    FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
+
+protected:
+    Plugin *m_plugin;
+    size_t m_channels;
+    size_t m_blockSize;
+    float **m_freqbuf;
+    double *m_ri;
+    double *m_ro;
+    double *m_io;
+
+    void fft(unsigned int n, bool inverse,
+             double *ri, double *ii, double *ro, double *io);
+};
+
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-sdk/hostext/PluginLoader.cpp	Thu May 24 10:05:00 2007 +0000
@@ -0,0 +1,303 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp
+
+    An API for audio analysis and feature extraction plugins.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    Copyright 2006 Chris Cannam.
+  
+    Permission is hereby granted, free of charge, to any person
+    obtaining a copy of this software and associated documentation
+    files (the "Software"), to deal in the Software without
+    restriction, including without limitation the rights to use, copy,
+    modify, merge, publish, distribute, sublicense, and/or sell copies
+    of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be
+    included in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    Except as contained in this notice, the names of the Centre for
+    Digital Music; Queen Mary, University of London; and Chris Cannam
+    shall not be used in advertising or otherwise to promote the sale,
+    use or other dealings in this Software without prior written
+    authorization.
+*/
+
+#include "PluginLoader.h"
+#include "PluginHostAdapter.h"
+
+#include "system.h"
+
+#include <fstream>
+
+#include <dirent.h> // POSIX directory open and read
+
+using namespace std;
+
+namespace Vamp {
+	
+PluginLoader::PluginLoader()
+{
+}
+
+PluginLoader::~PluginLoader()
+{
+}
+
+vector<PluginLoader::PluginKey>
+PluginLoader::listPlugins() 
+{
+    if (m_pluginLibraryMap.empty()) {
+
+        vector<string> path = PluginHostAdapter::getPluginPath();
+
+        size_t suffixLen = strlen(PLUGIN_SUFFIX);
+
+        for (size_t i = 0; i < path.size(); ++i) {
+            
+            vector<string> files = getFilesInDir(path[i], PLUGIN_SUFFIX);
+            
+
+            for (vector<string>::iterator fi = files.begin();
+                 fi != files.end(); ++fi) {
+
+                string basename = *fi;
+                basename = basename.substr(0, basename.length() - suffixLen - 1);
+
+                string fullPath = path[i];
+                fullPath = fullPath + "/" + *fi; //!!! systemize
+                void *handle = DLOPEN(fullPath, RTLD_LAZY);
+
+                if (!handle) {
+                    cerr << "Vamp::PluginLoader: " << *fi
+                              << ": unable to load library (" << DLERROR()
+                              << ")" << endl;
+                    continue;
+                }
+            
+                VampGetPluginDescriptorFunction fn =
+                    (VampGetPluginDescriptorFunction)DLSYM
+                    (handle, "vampGetPluginDescriptor");
+
+                if (!fn) {
+                    DLCLOSE(handle);
+                    continue;
+                }
+
+                int index = 0;
+                const VampPluginDescriptor *descriptor = 0;
+
+                while ((descriptor = fn(VAMP_API_VERSION, index))) {
+                    PluginKey key = basename + ":" + descriptor->identifier;
+                    if (m_pluginLibraryMap.find(key) ==
+                        m_pluginLibraryMap.end()) {
+                        m_pluginLibraryMap[key] = fullPath;
+                    }
+                    ++index;
+                }
+
+                DLCLOSE(handle);
+            }
+        }
+    }
+
+    vector<PluginKey> plugins;
+    for (map<PluginKey, string>::iterator mi =
+             m_pluginLibraryMap.begin();
+         mi != m_pluginLibraryMap.end(); ++mi) {
+        plugins.push_back(mi->first);
+    }
+
+    return plugins;
+}
+
+PluginLoader::PluginCategoryHierarchy
+PluginLoader::getPluginCategory(PluginKey plugin)
+{
+    if (m_taxonomy.empty()) generateTaxonomy();
+    if (m_taxonomy.find(plugin) == m_taxonomy.end()) return PluginCategoryHierarchy();
+    return m_taxonomy[plugin];
+}
+
+string
+PluginLoader::getLibraryPathForPlugin(PluginKey plugin)
+{
+    if (m_pluginLibraryMap.empty()) (void)listPlugins();
+    if (m_pluginLibraryMap.find(plugin) == m_pluginLibraryMap.end()) return "";
+    return m_pluginLibraryMap[plugin];
+}    
+
+Plugin *
+PluginLoader::load(PluginKey key, float inputSampleRate)
+{
+    string fullPath = getLibraryPathForPlugin(key);
+    if (fullPath == "") return 0;
+    
+    string::size_type ki = key.find(':');
+    if (ki == string::npos) {
+        //!!! flag error
+        return 0;
+    }
+
+    string identifier = key.substr(ki + 1);
+    
+    void *handle = DLOPEN(fullPath, RTLD_LAZY);
+
+    if (!handle) {
+        cerr << "Vamp::PluginLoader: " << fullPath
+                  << ": unable to load library (" << DLERROR()
+                  << ")" << endl;
+        return 0;
+    }
+    
+    VampGetPluginDescriptorFunction fn =
+        (VampGetPluginDescriptorFunction)DLSYM
+        (handle, "vampGetPluginDescriptor");
+
+    if (!fn) {
+        //!!! refcount this! --!!! no, POSIX says dlopen/dlclose will
+        // reference count. check on win32
+        DLCLOSE(handle);
+        return 0;
+    }
+
+    int index = 0;
+    const VampPluginDescriptor *descriptor = 0;
+
+    while ((descriptor = fn(VAMP_API_VERSION, index))) {
+        if (string(descriptor->identifier) == identifier) {
+            return new Vamp::PluginHostAdapter(descriptor, inputSampleRate);
+        }
+        ++index;
+    }
+    
+    //!!! flag error
+    return 0;
+}
+
+vector<string>
+PluginLoader::getFilesInDir(string dir, string extension)
+{
+    vector<string> files;
+
+    DIR *d = opendir(dir.c_str());
+    if (!d) return files;
+            
+    struct dirent *e = 0;
+    while ((e = readdir(d))) {
+        
+        if (!(e->d_type & DT_REG) || !e->d_name) {
+            continue;
+        }
+        
+        int len = strlen(e->d_name);
+        if (len < int(extension.length() + 2) ||
+            e->d_name[len - extension.length() - 1] != '.' ||
+            strcmp(e->d_name + len - extension.length(), extension.c_str())) {
+            continue;
+        }
+
+        files.push_back(e->d_name);
+    }
+
+    closedir(d);
+
+    return files;
+}
+
+void
+PluginLoader::generateTaxonomy()
+{
+//    cerr << "PluginLoader::generateTaxonomy" << endl;
+
+    vector<string> path = PluginHostAdapter::getPluginPath();
+    string libfragment = "/lib/";
+    vector<string> catpath;
+
+    string suffix = "cat";
+
+    for (vector<string>::iterator i = path.begin();
+         i != path.end(); ++i) {
+        
+        string dir = *i;
+        string::size_type li = dir.find(libfragment);
+
+        if (li != string::npos) {
+            catpath.push_back
+                (dir.substr(0, li)
+                 + "/share/"
+                 + dir.substr(li + libfragment.length()));
+        }
+
+        catpath.push_back(dir);
+    }
+
+    char buffer[1024];
+
+    for (vector<string>::iterator i = catpath.begin();
+         i != catpath.end(); ++i) {
+        
+        vector<string> files = getFilesInDir(*i, suffix);
+
+        for (vector<string>::iterator fi = files.begin();
+             fi != files.end(); ++fi) {
+
+            string filepath = *i + "/" + *fi; //!!! systemize
+            ifstream is(filepath.c_str(), ifstream::in | ifstream::binary);
+
+            if (is.fail()) {
+//                cerr << "failed to open: " << filepath << endl;
+                continue;
+            }
+
+//            cerr << "opened: " << filepath << endl;
+
+            while (!!is.getline(buffer, 1024)) {
+
+                string line(buffer);
+
+//                cerr << "line = " << line << endl;
+
+                string::size_type di = line.find("::");
+                if (di == string::npos) continue;
+
+                string id = line.substr(0, di);
+                string encodedCat = line.substr(di + 2);
+
+                if (id.substr(0, 5) != "vamp:") continue;
+                id = id.substr(5);
+
+                while (encodedCat.length() >= 1 &&
+                       encodedCat[encodedCat.length()-1] == '\r') {
+                    encodedCat = encodedCat.substr(0, encodedCat.length()-1);
+                }
+
+//                cerr << "id = " << id << ", cat = " << encodedCat << endl;
+
+                PluginCategoryHierarchy category;
+                string::size_type ai;
+                while ((ai = encodedCat.find(" > ")) != string::npos) {
+                    category.push_back(encodedCat.substr(0, ai));
+                    encodedCat = encodedCat.substr(ai + 3);
+                }
+                if (encodedCat != "") category.push_back(encodedCat);
+
+                m_taxonomy[id] = category;
+            }
+        }
+    }
+}    
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-sdk/hostext/PluginLoader.h	Thu May 24 10:05:00 2007 +0000
@@ -0,0 +1,80 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp
+
+    An API for audio analysis and feature extraction plugins.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    Copyright 2006 Chris Cannam.
+  
+    Permission is hereby granted, free of charge, to any person
+    obtaining a copy of this software and associated documentation
+    files (the "Software"), to deal in the Software without
+    restriction, including without limitation the rights to use, copy,
+    modify, merge, publish, distribute, sublicense, and/or sell copies
+    of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be
+    included in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    Except as contained in this notice, the names of the Centre for
+    Digital Music; Queen Mary, University of London; and Chris Cannam
+    shall not be used in advertising or otherwise to promote the sale,
+    use or other dealings in this Software without prior written
+    authorization.
+*/
+
+#ifndef _VAMP_PLUGIN_LOADER_H_
+#define _VAMP_PLUGIN_LOADER_H_
+
+#include <vector>
+#include <string>
+#include <map>
+
+namespace Vamp {
+
+class Plugin;
+
+class PluginLoader
+{
+public:
+    PluginLoader();
+    virtual ~PluginLoader();
+
+    typedef std::string PluginKey;
+    typedef std::vector<std::string> PluginCategoryHierarchy;
+
+    std::vector<PluginKey> listPlugins(); //!!! pass in version number?
+
+    //!!! want to be able to just "delete" the plugin later -- hence
+    //have to consider library loading issues -- do we have a wrapper
+    //class that tells us when it's been deleted, and keep a reference
+    //count for the dynamic library?
+    Plugin *load(PluginKey plugin, float inputSampleRate);
+
+    PluginCategoryHierarchy getPluginCategory(PluginKey plugin);
+
+    std::string getLibraryPathForPlugin(PluginKey plugin);
+
+protected:
+    std::map<PluginKey, std::string> m_pluginLibraryMap;
+    std::map<PluginKey, PluginCategoryHierarchy> m_taxonomy;
+    void generateTaxonomy();
+    std::vector<std::string> getFilesInDir(std::string dir, std::string ext);
+};
+
+}
+
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-sdk/hostext/PluginWrapper.cpp	Thu May 24 10:05:00 2007 +0000
@@ -0,0 +1,189 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp
+
+    An API for audio analysis and feature extraction plugins.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    Copyright 2006 Chris Cannam.
+  
+    Permission is hereby granted, free of charge, to any person
+    obtaining a copy of this software and associated documentation
+    files (the "Software"), to deal in the Software without
+    restriction, including without limitation the rights to use, copy,
+    modify, merge, publish, distribute, sublicense, and/or sell copies
+    of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be
+    included in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    Except as contained in this notice, the names of the Centre for
+    Digital Music; Queen Mary, University of London; and Chris Cannam
+    shall not be used in advertising or otherwise to promote the sale,
+    use or other dealings in this Software without prior written
+    authorization.
+*/
+
+#include "PluginWrapper.h"
+
+namespace Vamp {
+
+PluginWrapper::PluginWrapper(Plugin *plugin) :
+    Plugin(0)
+{
+}
+
+PluginWrapper::~PluginWrapper()
+{
+    delete m_plugin;
+}
+    
+bool
+PluginWrapper::initialise(size_t channels, size_t stepSize, size_t blockSize)
+{
+    return m_plugin->initialise(channels, stepSize, blockSize);
+}
+
+void
+PluginWrapper::reset()
+{
+    m_plugin->reset();
+}
+
+Plugin::InputDomain
+PluginWrapper::getInputDomain() const
+{
+    return m_plugin->getInputDomain();
+}
+
+unsigned int
+PluginWrapper::getVampApiVersion() const
+{
+    return m_plugin->getVampApiVersion();
+}
+
+std::string
+PluginWrapper::getIdentifier() const
+{
+    return m_plugin->getIdentifier();
+}
+
+std::string
+PluginWrapper::getName() const
+{
+    return m_plugin->getName();
+}
+
+std::string
+PluginWrapper::getDescription() const
+{
+    return m_plugin->getDescription();
+}
+
+std::string
+PluginWrapper::getMaker() const
+{
+    return m_plugin->getMaker();
+}
+
+int
+PluginWrapper::getPluginVersion() const
+{
+    return m_plugin->getPluginVersion();
+}
+
+std::string
+PluginWrapper::getCopyright() const
+{
+    return m_plugin->getCopyright();
+}
+
+PluginBase::ParameterList
+PluginWrapper::getParameterDescriptors() const
+{
+    return m_plugin->getParameterDescriptors();
+}
+
+float
+PluginWrapper::getParameter(std::string parameter) const
+{
+    return m_plugin->getParameter(parameter);
+}
+
+void
+PluginWrapper::setParameter(std::string parameter, float value)
+{
+    m_plugin->setParameter(parameter, value);
+}
+
+PluginBase::ProgramList
+PluginWrapper::getPrograms() const
+{
+    return m_plugin->getPrograms();
+}
+
+std::string
+PluginWrapper::getCurrentProgram() const
+{
+    return m_plugin->getCurrentProgram();
+}
+
+void
+PluginWrapper::selectProgram(std::string program)
+{
+    m_plugin->selectProgram(program);
+}
+
+size_t
+PluginWrapper::getPreferredStepSize() const
+{
+    return m_plugin->getPreferredStepSize();
+}
+
+size_t
+PluginWrapper::getPreferredBlockSize() const
+{
+    return m_plugin->getPreferredBlockSize();
+}
+
+size_t
+PluginWrapper::getMinChannelCount() const
+{
+    return m_plugin->getMinChannelCount();
+}
+
+size_t PluginWrapper::getMaxChannelCount() const
+{
+    return m_plugin->getMaxChannelCount();
+}
+
+Plugin::OutputList
+PluginWrapper::getOutputDescriptors() const
+{
+    return m_plugin->getOutputDescriptors();
+}
+
+Plugin::FeatureSet
+PluginWrapper::process(const float *const *inputBuffers, RealTime timestamp)
+{
+    return m_plugin->process(inputBuffers, timestamp);
+}
+
+Plugin::FeatureSet
+PluginWrapper::getRemainingFeatures()
+{
+    return m_plugin->getRemainingFeatures();
+}
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-sdk/hostext/PluginWrapper.h	Thu May 24 10:05:00 2007 +0000
@@ -0,0 +1,88 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp
+
+    An API for audio analysis and feature extraction plugins.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    Copyright 2006 Chris Cannam.
+  
+    Permission is hereby granted, free of charge, to any person
+    obtaining a copy of this software and associated documentation
+    files (the "Software"), to deal in the Software without
+    restriction, including without limitation the rights to use, copy,
+    modify, merge, publish, distribute, sublicense, and/or sell copies
+    of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be
+    included in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    Except as contained in this notice, the names of the Centre for
+    Digital Music; Queen Mary, University of London; and Chris Cannam
+    shall not be used in advertising or otherwise to promote the sale,
+    use or other dealings in this Software without prior written
+    authorization.
+*/
+
+#ifndef _PLUGIN_WRAPPER_H_
+
+#include <vamp-sdk/Plugin.h>
+
+namespace Vamp {
+
+class PluginWrapper : public Plugin
+{
+public:
+    virtual ~PluginWrapper();
+    
+    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
+    void reset();
+
+    InputDomain getInputDomain() const;
+
+    unsigned int getVampApiVersion() const;
+    std::string getIdentifier() const;
+    std::string getName() const;
+    std::string getDescription() const;
+    std::string getMaker() const;
+    int getPluginVersion() const;
+    std::string getCopyright() const;
+
+    ParameterList getParameterDescriptors() const;
+    float getParameter(std::string) const;
+    void setParameter(std::string, float);
+
+    ProgramList getPrograms() const;
+    std::string getCurrentProgram() const;
+    void selectProgram(std::string);
+
+    size_t getPreferredStepSize() const;
+    size_t getPreferredBlockSize() const;
+
+    size_t getMinChannelCount() const;
+    size_t getMaxChannelCount() const;
+
+    OutputList getOutputDescriptors() const;
+
+    FeatureSet process(const float *const *inputBuffers, RealTime timestamp);
+
+    FeatureSet getRemainingFeatures();
+
+protected:
+    PluginWrapper(Plugin *plugin); // I take ownership of plugin
+    Plugin *m_plugin;
+};
+
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vamp-sdk/hostext/system.h	Thu May 24 10:05:00 2007 +0000
@@ -0,0 +1,75 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Vamp
+
+    An API for audio analysis and feature extraction plugins.
+
+    Centre for Digital Music, Queen Mary, University of London.
+    Copyright 2006 Chris Cannam.
+  
+    Permission is hereby granted, free of charge, to any person
+    obtaining a copy of this software and associated documentation
+    files (the "Software"), to deal in the Software without
+    restriction, including without limitation the rights to use, copy,
+    modify, merge, publish, distribute, sublicense, and/or sell copies
+    of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be
+    included in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
+    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+    Except as contained in this notice, the names of the Centre for
+    Digital Music; Queen Mary, University of London; and Chris Cannam
+    shall not be used in advertising or otherwise to promote the sale,
+    use or other dealings in this Software without prior written
+    authorization.
+*/
+
+#ifndef _SYSTEM_H_
+#define _SYSTEM_H_
+
+#ifdef _WIN32
+
+#include <windows.h>
+
+#define DLOPEN(a,b)  LoadLibrary((a).c_str())
+#define DLSYM(a,b)   GetProcAddress((HINSTANCE)(a),(b))
+#define DLCLOSE(a)   FreeLibrary((HINSTANCE)(a))
+#define DLERROR()    ""
+
+#define PLUGIN_SUFFIX "dll"
+
+#else
+
+#include <dlfcn.h>
+
+#define DLOPEN(a,b)  dlopen((a).c_str(),(b))
+#define DLSYM(a,b)   dlsym((a),(b))
+#define DLCLOSE(a)   dlclose((a))
+#define DLERROR()    dlerror()
+
+#ifdef __APPLE__
+
+#define PLUGIN_SUFFIX  "dylib"
+#define HAVE_OPENDIR 1
+
+#else 
+
+#define PLUGIN_SUFFIX  "so"
+#define HAVE_OPENDIR 1
+
+#endif /* __APPLE__ */
+
+#endif /* ! _WIN32 */
+
+#endif
+