diff options
author | Uwe Klotz <uwe_klotz@web.de> | 2016-03-05 13:48:42 +0100 |
---|---|---|
committer | Uwe Klotz <uwe_klotz@web.de> | 2016-03-05 14:41:48 +0100 |
commit | b44e0b4d0ed8d357cfc829d0548cd0f66c83ff74 (patch) | |
tree | 69cc3c3f2f54338b7d29f5cfc24cd4e630f3068c /lib | |
parent | cd462ea73be77f2c697f2c1d8d2f4b7fc4992ba8 (diff) |
Upgrade Vamp plugin SDK: 2.3 -> 2.6
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vamp-2.6/src/doc-overview | 162 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/Files.cpp | 277 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/Files.h | 63 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/PluginBufferingAdapter.cpp (renamed from lib/vamp-2.3/src/vamp-hostsdk/PluginBufferingAdapter.cpp) | 43 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/PluginChannelAdapter.cpp (renamed from lib/vamp-2.3/src/vamp-hostsdk/PluginChannelAdapter.cpp) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/PluginHostAdapter.cpp (renamed from lib/vamp-2.3/src/vamp-hostsdk/PluginHostAdapter.cpp) | 8 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/PluginInputDomainAdapter.cpp (renamed from lib/vamp-2.3/src/vamp-hostsdk/PluginInputDomainAdapter.cpp) | 133 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/PluginLoader.cpp (renamed from lib/vamp-2.3/src/vamp-hostsdk/PluginLoader.cpp) | 298 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/PluginSummarisingAdapter.cpp (renamed from lib/vamp-2.3/src/vamp-hostsdk/PluginSummarisingAdapter.cpp) | 12 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/PluginWrapper.cpp (renamed from lib/vamp-2.3/src/vamp-hostsdk/PluginWrapper.cpp) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/RealTime.cpp (renamed from lib/vamp-2.3/src/vamp-hostsdk/RealTime.cpp) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-hostsdk/Window.h (renamed from lib/vamp-2.3/src/vamp-hostsdk/Window.h) | 6 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-sdk/FFT.cpp | 75 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-sdk/FFTimpl.cpp | 116 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-sdk/PluginAdapter.cpp (renamed from lib/vamp-2.3/src/vamp-sdk/PluginAdapter.cpp) | 4 | ||||
-rw-r--r-- | lib/vamp-2.6/src/vamp-sdk/RealTime.cpp (renamed from lib/vamp-2.3/src/vamp-sdk/RealTime.cpp) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/Plugin.h (renamed from lib/vamp-2.3/vamp-hostsdk/Plugin.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/PluginBase.h (renamed from lib/vamp-2.3/vamp-hostsdk/PluginBase.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/PluginBufferingAdapter.h (renamed from lib/vamp-2.3/vamp-hostsdk/PluginBufferingAdapter.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/PluginChannelAdapter.h (renamed from lib/vamp-2.3/vamp-hostsdk/PluginChannelAdapter.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/PluginHostAdapter.h (renamed from lib/vamp-2.3/vamp-hostsdk/PluginHostAdapter.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/PluginInputDomainAdapter.h (renamed from lib/vamp-2.3/vamp-hostsdk/PluginInputDomainAdapter.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/PluginLoader.h (renamed from lib/vamp-2.3/vamp-hostsdk/PluginLoader.h) | 3 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/PluginSummarisingAdapter.h (renamed from lib/vamp-2.3/vamp-hostsdk/PluginSummarisingAdapter.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/PluginWrapper.h (renamed from lib/vamp-2.3/vamp-hostsdk/PluginWrapper.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/RealTime.h (renamed from lib/vamp-2.3/vamp-hostsdk/RealTime.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/host-c.h | 147 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/hostguard.h (renamed from lib/vamp-2.3/vamp-hostsdk/hostguard.h) | 4 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-hostsdk/vamp-hostsdk.h (renamed from lib/vamp-2.3/vamp-hostsdk/vamp-hostsdk.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-sdk/FFT.h | 100 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-sdk/Plugin.h (renamed from lib/vamp-2.3/vamp-sdk/Plugin.h) | 12 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-sdk/PluginAdapter.h (renamed from lib/vamp-2.3/vamp-sdk/PluginAdapter.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-sdk/PluginBase.h (renamed from lib/vamp-2.3/vamp-sdk/PluginBase.h) | 10 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-sdk/RealTime.h (renamed from lib/vamp-2.3/vamp-sdk/RealTime.h) | 0 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-sdk/plugguard.h (renamed from lib/vamp-2.3/vamp-sdk/plugguard.h) | 4 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp-sdk/vamp-sdk.h (renamed from lib/vamp-2.3/vamp-sdk/vamp-sdk.h) | 1 | ||||
-rw-r--r-- | lib/vamp-2.6/vamp/vamp.h (renamed from lib/vamp-2.3/vamp/vamp.h) | 2 |
37 files changed, 1076 insertions, 404 deletions
diff --git a/lib/vamp-2.6/src/doc-overview b/lib/vamp-2.6/src/doc-overview new file mode 100644 index 0000000000..e48fa91af7 --- /dev/null +++ b/lib/vamp-2.6/src/doc-overview @@ -0,0 +1,162 @@ + +/** \mainpage Vamp Plugin SDK + +\section about About Vamp + +Vamp is an API for C and C++ plugins that process sampled audio data +to produce descriptive output (measurements or semantic observations). +Find more information at http://www.vamp-plugins.org/ . + +Although the official API for Vamp plugins is defined in C for maximum +binary compatibility, we strongly recommend using the provided C++ +classes in the SDK to implement your own plugins and hosts. + +\section plugins For Plugins + +Plugins should subclass Vamp::Plugin, and then use a +Vamp::PluginAdapter to expose the correct C API for the plugin. Read +the documentation for Vamp::PluginBase and Vamp::Plugin before +starting. + +Plugins should be compiled and linked into dynamic libraries using the +usual convention for your platform, and should link (preferably +statically) with -lvamp-sdk. Any number of plugins can reside in a +single dynamic library. See plugins.cpp in the example plugins +directory for the sort of code that will need to accompany your plugin +class or classes, to make it possible for a host to look up your +plugins properly. + +Please read the relevant README file for your platform found in the +Vamp SDK build/ directory, for details about how to ensure the +resulting dynamic library exports the correct linker symbols. + +The following example plugins are provided. You may legally reuse any +amount of the code from these examples in any plugins you write, +whether proprietary or open-source. + + - ZeroCrossing calculates the positions and density of zero-crossing + points in an audio waveform. + + - SpectralCentroid calculates the centre of gravity of the frequency + domain representation of each block of audio. + + - PowerSpectrum calculates a power spectrum from the input audio. + Actually, it doesn't do any work except calculating power from a + cartesian complex FFT output. The work of calculating this frequency + domain output is done for it by the host or host SDK; the plugin just + needs to declare that it wants frequency domain input. This is the + simplest of the example plugins. + + - AmplitudeFollower is a simple implementation of SuperCollider's + amplitude-follower algorithm. + + - PercussionOnsetDetector estimates the locations of percussive + onsets using a simple method described in "Drum Source Separation + using Percussive Feature Detection and Spectral Modulation" by Dan + Barry, Derry Fitzgerald, Eugene Coyle and Bob Lawlor, ISSC 2005. + + - FixedTempoEstimator calculates a single beats-per-minute value + which is an estimate of the tempo of a piece of music that is assumed + to be of fixed tempo, using autocorrelation of a frequency domain + energy rise metric. It has several outputs that return intermediate + results used in the calculation, and may be a useful example of a + plugin having several outputs with varying feature structures. + +Plugin authors should also read the Programmer's Guide at +http://vamp-plugins.org/guide.pdf . + +\section hosts For Hosts + +Hosts will normally use a Vamp::PluginHostAdapter to convert each +plugin's exposed C API back into a useful Vamp::Plugin C++ object. + +The Vamp::HostExt namespace contains several additional C++ classes to +do this work for them, and make the host's life easier: + + - Vamp::HostExt::PluginLoader provides a very easy interface for a + host to discover, load, and find out category information about the + available plugins. Most Vamp hosts will probably want to use this + class. + + - Vamp::HostExt::PluginInputDomainAdapter provides a simple means for + hosts to handle plugins that want frequency-domain input, without + having to convert the input themselves. + + - Vamp::HostExt::PluginChannelAdapter provides a simple means for + hosts to use plugins that do not necessarily support the same number + of audio channels as they have available, without having to apply a + channel management / mixdown policy themselves. + + - Vamp::HostExt::PluginBufferingAdapter provides a means for hosts to + avoid having to negotiate the input step and block size, instead + permitting the host to use any block size they desire (and a step + size equal to it). This is particularly useful for "streaming" hosts + that cannot seek backwards in the input audio stream and so would + otherwise need to implement an additional buffer to support step + sizes smaller than the block size. + + - Vamp::HostExt::PluginSummarisingAdapter provides summarisation + methods such as mean and median averages of output features, for use + in any context where an available plugin produces individual values + but the result that is actually needed is some sort of aggregate. + +The PluginLoader class can also use the input domain, channel, and +buffering adapters automatically to make these conversions transparent +to the host if required. + +Host authors should also refer to the example host code in the host +directory of the SDK. + +Hosts should link with -lvamp-hostsdk. + +(The following notes in this section are mostly relevant for +developers that are not using the HostExt classes, or that wish to +know more about the policy they implement.) + +The Vamp API does not officially specify how to load plugin libraries +or where to find them. However, the SDK does include a function +(Vamp::PluginHostAdapter::getPluginPath()) that returns a recommended +directory search path that hosts may use for plugin libraries, and a +class (Vamp::HostExt::PluginLoader) that implements a sensible +cross-platform lookup policy using this path. We recommend using this +class in your host unless you have a good reason not to want to. This +implementation also permits the user to set the environment variable +VAMP_PATH to override the default path if desired. + +The policy used by Vamp::HostExt::PluginLoader -- and our +recommendation for any host -- is to search each directory in this +path for .DLL (on Windows), .so (on Linux, Solaris, BSD etc) or .dylib +(on OS/X) files, then to load each one and perform a dynamic name +lookup on the vampGetPluginDescriptor function to enumerate the +plugins in the library. The example host has some code that may help, +but this operation will necessarily be system-dependent. + +Vamp also has an informal convention for sorting plugins into +functional categories. In addition to the library file itself, a +plugin library may install a category file with the same name as the +library but .cat extension. The existence and format of this file are +not specified by the Vamp API, but by convention the file may contain +lines of the format + +\code +vamp:pluginlibrary:pluginname::General Category > Specific Category +\endcode + +which a host may read and use to assign plugins a location within a +category tree for display to the user. The expectation is that +advanced users may also choose to set up their own preferred category +trees, which is why this information is not queried as part of the +Vamp plugin's API itself. The Vamp::HostExt::PluginLoader class also +provides support for plugin category lookup using this scheme. + +\section license License + +This plugin SDK is freely redistributable under a "new-style BSD" +licence. See the file COPYING for more details. In short, you may +modify and redistribute the SDK and example plugins within any +commercial or non-commercial, proprietary or open-source plugin or +application under almost any conditions, with no obligation to provide +source code, provided you retain the original copyright note. + + +*/ diff --git a/lib/vamp-2.6/src/vamp-hostsdk/Files.cpp b/lib/vamp-2.6/src/vamp-hostsdk/Files.cpp new file mode 100644 index 0000000000..8a04dab893 --- /dev/null +++ b/lib/vamp-2.6/src/vamp-hostsdk/Files.cpp @@ -0,0 +1,277 @@ +/* -*- 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-2015 Chris Cannam and QMUL. + + 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 <vamp-hostsdk/PluginHostAdapter.h> + +#include "Files.h" + +#include <cctype> // tolower + +#include <cstring> + +#ifdef _WIN32 + +#include <windows.h> +#include <tchar.h> +#define PLUGIN_SUFFIX "dll" + +#else /* ! _WIN32 */ + +#include <dirent.h> +#include <dlfcn.h> + +#ifdef __APPLE__ +#define PLUGIN_SUFFIX "dylib" +#else /* ! __APPLE__ */ +#define PLUGIN_SUFFIX "so" +#endif /* ! __APPLE__ */ + +#endif /* ! _WIN32 */ + +using namespace std; + +vector<string> +Files::listLibraryFiles() +{ + return listLibraryFilesMatching(""); +} + +vector<string> +Files::listLibraryFilesMatching(string libraryName) +{ + vector<string> path = Vamp::PluginHostAdapter::getPluginPath(); + vector<string> libraryFiles; + + // we match case-insensitively + for (size_t i = 0; i < libraryName.length(); ++i) { + libraryName[i] = tolower(libraryName[i]); + } + + for (size_t i = 0; i < path.size(); ++i) { + + vector<string> files = listFiles(path[i], PLUGIN_SUFFIX); + + for (vector<string>::iterator fi = files.begin(); + fi != files.end(); ++fi) { + + if (libraryName != "") { + // we match case-insensitively + string temp = *fi; + for (size_t i = 0; i < temp.length(); ++i) { + temp[i] = tolower(temp[i]); + } + // libraryName should be lacking an extension, as it + // is supposed to have come from the plugin key + string::size_type pi = temp.find('.'); + if (pi == string::npos) { + if (libraryName != temp) continue; + } else { + if (libraryName != temp.substr(0, pi)) continue; + } + } + + string fullPath = path[i]; + fullPath = splicePath(fullPath, *fi); + libraryFiles.push_back(fullPath); + } + } + + return libraryFiles; +} + +void * +Files::loadLibrary(string path) +{ + void *handle = 0; +#ifdef _WIN32 +#ifdef UNICODE + int len = path.length() + 1; // cannot be more wchars than length in bytes of utf8 string + wchar_t *buffer = new wchar_t[len]; + int rv = MultiByteToWideChar(CP_UTF8, 0, path.c_str(), len, buffer, len); + if (rv <= 0) { + cerr << "Vamp::HostExt: Unable to convert library path \"" + << path << "\" to wide characters " << endl; + delete[] buffer; + return handle; + } + handle = LoadLibrary(buffer); + delete[] buffer; +#else + handle = LoadLibrary(path.c_str()); +#endif + if (!handle) { + cerr << "Vamp::HostExt: Unable to load library \"" + << path << "\"" << endl; + } +#else + handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_LOCAL); + if (!handle) { + cerr << "Vamp::HostExt: Unable to load library \"" + << path << "\": " << dlerror() << endl; + } +#endif + return handle; +} + +void +Files::unloadLibrary(void *handle) +{ +#ifdef _WIN32 + FreeLibrary((HINSTANCE)handle); +#else + dlclose(handle); +#endif +} + +void * +Files::lookupInLibrary(void *handle, const char *symbol) +{ +#ifdef _WIN32 + return (void *)GetProcAddress((HINSTANCE)handle, symbol); +#else + return (void *)dlsym(handle, symbol); +#endif +} + +string +Files::lcBasename(string path) +{ + string basename(path); + + string::size_type li = basename.rfind('/'); + if (li != string::npos) basename = basename.substr(li + 1); + +#ifdef _WIN32 + li = basename.rfind('\\'); + if (li != string::npos) basename = basename.substr(li + 1); +#endif + + li = basename.find('.'); + if (li != string::npos) basename = basename.substr(0, li); + + for (size_t i = 0; i < basename.length(); ++i) { + basename[i] = tolower(basename[i]); + } + + return basename; +} + +string +Files::splicePath(string a, string b) +{ +#ifdef _WIN32 + return a + "\\" + b; +#else + return a + "/" + b; +#endif +} + +vector<string> +Files::listFiles(string dir, string extension) +{ + vector<string> files; + +#ifdef _WIN32 + string expression = dir + "\\*." + extension; +#ifdef UNICODE + int len = expression.length() + 1; // cannot be more wchars than length in bytes of utf8 string + wchar_t *buffer = new wchar_t[len]; + int rv = MultiByteToWideChar(CP_UTF8, 0, expression.c_str(), len, buffer, len); + if (rv <= 0) { + cerr << "Vamp::HostExt: Unable to convert wildcard path \"" + << expression << "\" to wide characters" << endl; + delete[] buffer; + return files; + } + WIN32_FIND_DATA data; + HANDLE fh = FindFirstFile(buffer, &data); + if (fh == INVALID_HANDLE_VALUE) { + delete[] buffer; + return files; + } + + bool ok = true; + while (ok) { + wchar_t *fn = data.cFileName; + int wlen = wcslen(fn) + 1; + int maxlen = wlen * 6; + char *conv = new char[maxlen]; + int rv = WideCharToMultiByte(CP_UTF8, 0, fn, wlen, conv, maxlen, 0, 0); + if (rv > 0) { + files.push_back(conv); + } + delete[] conv; + ok = FindNextFile(fh, &data); + } + + FindClose(fh); + delete[] buffer; +#else + WIN32_FIND_DATA data; + HANDLE fh = FindFirstFile(expression.c_str(), &data); + if (fh == INVALID_HANDLE_VALUE) return files; + + bool ok = true; + while (ok) { + files.push_back(data.cFileName); + ok = FindNextFile(fh, &data); + } + + FindClose(fh); +#endif +#else + + size_t extlen = extension.length(); + DIR *d = opendir(dir.c_str()); + if (!d) return files; + + struct dirent *e = 0; + while ((e = readdir(d))) { + + size_t len = strlen(e->d_name); + if (len < extlen + 2 || + e->d_name + len - extlen - 1 != "." + extension) { + continue; + } + + files.push_back(e->d_name); + } + + closedir(d); +#endif + + return files; +} diff --git a/lib/vamp-2.6/src/vamp-hostsdk/Files.h b/lib/vamp-2.6/src/vamp-hostsdk/Files.h new file mode 100644 index 0000000000..6e3fd37fe3 --- /dev/null +++ b/lib/vamp-2.6/src/vamp-hostsdk/Files.h @@ -0,0 +1,63 @@ +/* -*- 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-2015 Chris Cannam and QMUL. + + 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_FILES_H +#define VAMP_FILES_H + +#include <vector> +#include <string> + +/** + * This is a private implementation class for the Vamp Host SDK. + */ +class Files +{ +public: + static std::vector<std::string> listLibraryFiles(); + static std::vector<std::string> listLibraryFilesMatching(std::string libname); + + static void *loadLibrary(std::string filename); + static void unloadLibrary(void *); + static void *lookupInLibrary(void *, const char *symbol); + + static std::string lcBasename(std::string path); + static std::string splicePath(std::string a, std::string b); + static std::vector<std::string> listFiles(std::string dir, std::string ext); +}; + +#endif + + diff --git a/lib/vamp-2.3/src/vamp-hostsdk/PluginBufferingAdapter.cpp b/lib/vamp-2.6/src/vamp-hostsdk/PluginBufferingAdapter.cpp index 5d945e70f9..a8747435cb 100644 --- a/lib/vamp-2.3/src/vamp-hostsdk/PluginBufferingAdapter.cpp +++ b/lib/vamp-2.6/src/vamp-hostsdk/PluginBufferingAdapter.cpp @@ -244,8 +244,10 @@ protected: bool m_unrun; mutable OutputList m_outputs; mutable std::map<int, bool> m_rewriteOutputTimes; + std::map<int, int> m_fixedRateFeatureNos; // output no -> feature no void processBlock(FeatureSet& allFeatureSets); + void adjustFixedRateFeatureTime(int outputNo, Feature &); }; PluginBufferingAdapter::PluginBufferingAdapter(Plugin *plugin) : @@ -564,6 +566,8 @@ PluginBufferingAdapter::Impl::reset() m_queue[i]->reset(); } + m_fixedRateFeatureNos.clear(); + m_plugin->reset(); } @@ -607,6 +611,25 @@ PluginBufferingAdapter::Impl::process(const float *const *inputBuffers, return allFeatureSets; } +void +PluginBufferingAdapter::Impl::adjustFixedRateFeatureTime(int outputNo, + Feature &feature) +{ + if (feature.hasTimestamp) { + double secs = feature.timestamp.sec; + secs += feature.timestamp.nsec / 1e9; + m_fixedRateFeatureNos[outputNo] = + int(secs * double(m_outputs[outputNo].sampleRate) + 0.5); + } + + feature.timestamp = RealTime::fromSeconds + (m_fixedRateFeatureNos[outputNo] / double(m_outputs[outputNo].sampleRate)); + + feature.hasTimestamp = true; + + m_fixedRateFeatureNos[outputNo] = m_fixedRateFeatureNos[outputNo] + 1; +} + PluginBufferingAdapter::FeatureSet PluginBufferingAdapter::Impl::getRemainingFeatures() { @@ -631,9 +654,18 @@ PluginBufferingAdapter::Impl::getRemainingFeatures() for (map<int, FeatureList>::iterator iter = featureSet.begin(); iter != featureSet.end(); ++iter) { + + int outputNo = iter->first; FeatureList featureList = iter->second; + for (size_t i = 0; i < featureList.size(); ++i) { - allFeatureSets[iter->first].push_back(featureList[i]); + + if (m_outputs[outputNo].sampleType == + OutputDescriptor::FixedSampleRate) { + adjustFixedRateFeatureTime(outputNo, featureList[i]); + } + + allFeatureSets[outputNo].push_back(featureList[i]); } } @@ -681,15 +713,12 @@ PluginBufferingAdapter::Impl::processBlock(FeatureSet& allFeatureSets) break; case OutputDescriptor::FixedSampleRate: - // use our internal timestamp if feature lacks one - if (!featureList[i].hasTimestamp) { - featureList[i].timestamp = timestamp + adjustment; - featureList[i].hasTimestamp = true; - } + adjustFixedRateFeatureTime(outputNo, featureList[i]); break; case OutputDescriptor::VariableSampleRate: - break; // plugin must set timestamp + // plugin must set timestamp + break; default: break; diff --git a/lib/vamp-2.3/src/vamp-hostsdk/PluginChannelAdapter.cpp b/lib/vamp-2.6/src/vamp-hostsdk/PluginChannelAdapter.cpp index 8463a6e3b6..8463a6e3b6 100644 --- a/lib/vamp-2.3/src/vamp-hostsdk/PluginChannelAdapter.cpp +++ b/lib/vamp-2.6/src/vamp-hostsdk/PluginChannelAdapter.cpp diff --git a/lib/vamp-2.3/src/vamp-hostsdk/PluginHostAdapter.cpp b/lib/vamp-2.6/src/vamp-hostsdk/PluginHostAdapter.cpp index f5a9119c96..2cac617a6c 100644 --- a/lib/vamp-2.3/src/vamp-hostsdk/PluginHostAdapter.cpp +++ b/lib/vamp-2.6/src/vamp-hostsdk/PluginHostAdapter.cpp @@ -37,7 +37,7 @@ #include <vamp-hostsdk/PluginHostAdapter.h> #include <cstdlib> -#if ( VAMP_SDK_MAJOR_VERSION != 2 || VAMP_SDK_MINOR_VERSION != 3 ) +#if ( VAMP_SDK_MAJOR_VERSION != 2 || VAMP_SDK_MINOR_VERSION != 6 ) #error Unexpected version of Vamp SDK header included #endif @@ -265,7 +265,11 @@ PluginHostAdapter::getCurrentProgram() const if (!m_handle) return ""; int pn = m_descriptor->getCurrentProgram(m_handle); - return m_descriptor->programs[pn]; + if (pn < (int)m_descriptor->programCount) { + return m_descriptor->programs[pn]; + } else { + return ""; + } } void diff --git a/lib/vamp-2.3/src/vamp-hostsdk/PluginInputDomainAdapter.cpp b/lib/vamp-2.6/src/vamp-hostsdk/PluginInputDomainAdapter.cpp index 5429483ed2..2bf396eb76 100644 --- a/lib/vamp-2.3/src/vamp-hostsdk/PluginInputDomainAdapter.cpp +++ b/lib/vamp-2.6/src/vamp-hostsdk/PluginInputDomainAdapter.cpp @@ -39,8 +39,6 @@ #include <vamp-hostsdk/PluginInputDomainAdapter.h> -// http://msdn.microsoft.com/en-us/library/4hwaceh6(v=vs.80).aspx -#define _USE_MATH_DEFINES #include <cmath> #include "Window.h" @@ -71,6 +69,9 @@ */ #ifdef HAVE_FFTW3 #include <fftw3.h> +#warning "Compiling with FFTW3 support will result in a GPL binary" +#else +#include "../vamp-sdk/FFTimpl.cpp" #endif @@ -125,8 +126,6 @@ protected: #else double *m_ro; double *m_io; - void fft(unsigned int n, bool inverse, - double *ri, double *ii, double *ro, double *io); #endif FeatureSet processShiftingTimestamp(const float *const *inputBuffers, RealTime timestamp); @@ -293,10 +292,12 @@ PluginInputDomainAdapter::Impl::initialise(size_t channels, size_t stepSize, siz return false; } +#ifndef HAVE_FFTW3 if (blockSize & (blockSize-1)) { std::cerr << "ERROR: PluginInputDomainAdapter::initialise: non-power-of-two\nblocksize " << blockSize << " not supported" << std::endl; return false; } +#endif if (m_channels > 0) { for (int c = 0; c < m_channels; ++c) { @@ -507,7 +508,14 @@ PluginInputDomainAdapter::Impl::processShiftingTimestamp(const float *const *inp RealTime timestamp) { if (m_method == ShiftTimestamp) { + // we may need to add one nsec if timestamp + + // getTimestampAdjustment() rounds down timestamp = timestamp + getTimestampAdjustment(); + RealTime nsec(0, 1); + if (RealTime::realTime2Frame(timestamp, m_inputSampleRate) < |