1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-13 08:05:52 +01:00

Move library tree where it belongs

This commit is contained in:
ra
2010-01-24 09:19:39 +00:00
parent e74978ba77
commit 58caf78a86
6020 changed files with 2790154 additions and 0 deletions

View File

@@ -0,0 +1,441 @@
/* -*- 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_SDK_PLUGIN_H_
#define _VAMP_SDK_PLUGIN_H_
#include <string>
#include <vector>
#include <map>
#include "PluginBase.h"
#include "RealTime.h"
#include "plugguard.h"
_VAMP_SDK_PLUGSPACE_BEGIN(Plugin.h)
namespace Vamp {
/**
* \class Plugin Plugin.h <vamp-sdk/Plugin.h>
*
* Vamp::Plugin is a base class for plugin instance classes
* that provide feature extraction from audio or related data.
*
* In most cases, the input will be audio and the output will be a
* stream of derived data at a lower sampling resolution than the
* input.
*
* Note that this class inherits several abstract methods from
* PluginBase. These must be implemented by the subclass.
*
*
* PLUGIN LIFECYCLE
*
* Feature extraction plugins are managed differently from real-time
* plugins (such as VST effects). The main difference is that the
* parameters for a feature extraction plugin are configured before
* the plugin is used, and do not change during use.
*
* 1. Host constructs the plugin, passing it the input sample rate.
* The plugin may do basic initialisation, but should not do anything
* computationally expensive at this point. You must make sure your
* plugin is cheap to construct, otherwise you'll seriously affect the
* startup performance of almost all hosts. If you have serious
* initialisation to do, the proper place is in initialise() (step 5).
*
* 2. Host may query the plugin's available outputs.
*
* 3. Host queries programs and parameter descriptors, and may set
* some or all of them. Parameters that are not explicitly set should
* take their default values as specified in the parameter descriptor.
* When a program is set, the parameter values may change and the host
* will re-query them to check.
*
* 4. Host queries the preferred step size, block size and number of
* channels. These may all vary depending on the parameter values.
* (Note however that you cannot make the number of distinct outputs
* dependent on parameter values.)
*
* 5. Plugin is properly initialised with a call to initialise. This
* fixes the step size, block size, and number of channels, as well as
* all of the parameter and program settings. If the values passed in
* to initialise do not match the plugin's advertised preferred values
* from step 4, the plugin may refuse to initialise and return false
* (although if possible it should accept the new values). Any
* computationally expensive setup code should take place here.
*
* 6. Host finally checks the number of values, resolution, extents
* etc per output (which may vary depending on the number of channels,
* step size and block size as well as the parameter values).
*
* 7. Host will repeatedly call the process method to pass in blocks
* of input data. This method may return features extracted from that
* data (if the plugin is causal).
*
* 8. Host will call getRemainingFeatures exactly once, after all the
* input data has been processed. This may return any non-causal or
* leftover features.
*
* 9. At any point after initialise was called, the host may
* optionally call the reset method and restart processing. (This
* does not mean it can change the parameters, which are fixed from
* initialise until destruction.)
*
* A plugin does not need to handle the case where setParameter or
* selectProgram is called after initialise has been called. It's the
* host's responsibility not to do that. Similarly, the plugin may
* safely assume that initialise is called no more than once.
*/
class Plugin : public PluginBase
{
public:
virtual ~Plugin() { }
/**
* Initialise a plugin to prepare it for use with the given number
* of input channels, step size (window increment, in sample
* frames) and block size (window size, in sample frames).
*
* The input sample rate should have been already specified at
* construction time.
*
* Return true for successful initialisation, false if the number
* of input channels, step size and/or block size cannot be
* supported.
*/
virtual bool initialise(size_t inputChannels,
size_t stepSize,
size_t blockSize) = 0;
/**
* Reset the plugin after use, to prepare it for another clean
* run. Not called for the first initialisation (i.e. initialise
* must also do a reset).
*/
virtual void reset() = 0;
enum InputDomain { TimeDomain, FrequencyDomain };
/**
* Get the plugin's required input domain. If this is TimeDomain,
* the samples provided to the process() function (below) will be
* in the time domain, as for a traditional audio processing
* plugin. If this is FrequencyDomain, the host will carry out a
* windowed FFT of size equal to the negotiated block size on the
* data before passing the frequency bin data in to process().
* The plugin does not get to choose the window type -- the host
* will either let the user do so, or will use a Hanning window.
*/
virtual InputDomain getInputDomain() const = 0;
/**
* Get the preferred block size (window size -- the number of
* sample frames passed in each block to the process() function).
* This should be called before initialise().
*
* A plugin that can handle any block size may return 0. The
* final block size will be set in the initialise() call.
*/
virtual size_t getPreferredBlockSize() const { return 0; }
/**
* Get the preferred step size (window increment -- the distance
* in sample frames between the start frames of consecutive blocks
* passed to the process() function) for the plugin. This should
* be called before initialise().
*
* A plugin may return 0 if it has no particular interest in the
* step size. In this case, the host should make the step size
* equal to the block size if the plugin is accepting input in the
* time domain. If the plugin is accepting input in the frequency
* domain, the host may use any step size. The final step size
* will be set in the initialise() call.
*/
virtual size_t getPreferredStepSize() const { return 0; }
/**
* Get the minimum supported number of input channels.
*/
virtual size_t getMinChannelCount() const { return 1; }
/**
* Get the maximum supported number of input channels.
*/
virtual size_t getMaxChannelCount() const { return 1; }
struct OutputDescriptor
{
/**
* The name of the output, in computer-usable form. Should be
* reasonably short and without whitespace or punctuation, using
* the characters [a-zA-Z0-9_-] only.
* Example: "zero_crossing_count"
*/
std::string identifier;
/**
* The human-readable name of the output.
* Example: "Zero Crossing Counts"
*/
std::string name;
/**
* A human-readable short text describing the output. May be
* empty if the name has said it all already.
* Example: "The number of zero crossing points per processing block"
*/
std::string description;
/**
* The unit of the output, in human-readable form.
*/
std::string unit;
/**
* True if the output has the same number of values per sample
* for every output sample. Outputs for which this is false
* are unlikely to be very useful in a general-purpose host.
*/
bool hasFixedBinCount;
/**
* The number of values per result of the output. Undefined
* if hasFixedBinCount is false. If this is zero, the output
* is point data (i.e. only the time of each output is of
* interest, the value list will be empty).
*/
size_t binCount;
/**
* The (human-readable) names of each of the bins, if
* appropriate. This is always optional.
*/
std::vector<std::string> binNames;
/**
* True if the results in each output bin fall within a fixed
* numeric range (minimum and maximum values). Undefined if
* binCount is zero.
*/
bool hasKnownExtents;
/**
* Minimum value of the results in the output. Undefined if
* hasKnownExtents is false or binCount is zero.
*/
float minValue;
/**
* Maximum value of the results in the output. Undefined if
* hasKnownExtents is false or binCount is zero.
*/
float maxValue;
/**
* True if the output values are quantized to a particular
* resolution. Undefined if binCount is zero.
*/
bool isQuantized;
/**
* Quantization resolution of the output values (e.g. 1.0 if
* they are all integers). Undefined if isQuantized is false
* or binCount is zero.
*/
float quantizeStep;
enum SampleType {
/// Results from each process() align with that call's block start
OneSamplePerStep,
/// Results are evenly spaced in time (sampleRate specified below)
FixedSampleRate,
/// Results are unevenly spaced and have individual timestamps
VariableSampleRate
};
/**
* Positioning in time of the output results.
*/
SampleType sampleType;
/**
* Sample rate of the output results, as samples per second.
* Undefined if sampleType is OneSamplePerStep.
*
* If sampleType is VariableSampleRate and this value is
* non-zero, then it may be used to calculate a resolution for
* the output (i.e. the "duration" of each sample, in time,
* will be 1/sampleRate seconds). It's recommended to set
* this to zero if that behaviour is not desired.
*/
float sampleRate;
/**
* True if the returned results for this output are known to
* have a duration field.
*/
bool hasDuration;
OutputDescriptor() : // defaults for mandatory non-class-type members
hasFixedBinCount(false), hasKnownExtents(false), isQuantized(false),
sampleType(OneSamplePerStep), hasDuration(false) { }
};
typedef std::vector<OutputDescriptor> OutputList;
/**
* Get the outputs of this plugin. An output's index in this list
* is used as its numeric index when looking it up in the
* FeatureSet returned from the process() call.
*/
virtual OutputList getOutputDescriptors() const = 0;
struct Feature
{
/**
* True if an output feature has its own timestamp. This is
* mandatory if the output has VariableSampleRate, optional if
* the output has FixedSampleRate, and unused if the output
* has OneSamplePerStep.
*/
bool hasTimestamp;
/**
* Timestamp of the output feature. This is mandatory if the
* output has VariableSampleRate or if the output has
* FixedSampleRate and hasTimestamp is true, and unused
* otherwise.
*/
RealTime timestamp;
/**
* True if an output feature has a specified duration. This
* is optional if the output has VariableSampleRate or
* FixedSampleRate, and and unused if the output has
* OneSamplePerStep.
*/
bool hasDuration;
/**
* Duration of the output feature. This is mandatory if the
* output has VariableSampleRate or FixedSampleRate and
* hasDuration is true, and unused otherwise.
*/
RealTime duration;
/**
* Results for a single sample of this feature. If the output
* hasFixedBinCount, there must be the same number of values
* as the output's binCount count.
*/
std::vector<float> values;
/**
* Label for the sample of this feature.
*/
std::string label;
Feature() : // defaults for mandatory non-class-type members
hasTimestamp(false), hasDuration(false) { }
};
typedef std::vector<Feature> FeatureList;
typedef std::map<int, FeatureList> FeatureSet; // key is output no
/**
* Process a single block of input data.
*
* If the plugin's inputDomain is TimeDomain, inputBuffers will
* point to one array of floats per input channel, and each of
* these arrays will contain blockSize consecutive audio samples
* (the host will zero-pad as necessary). The timestamp in this
* case will be the real time in seconds of the start of the
* supplied block of samples.
*
* If the plugin's inputDomain is FrequencyDomain, inputBuffers
* will point to one array of floats per input channel, and each
* of these arrays will contain blockSize/2+1 consecutive pairs of
* real and imaginary component floats corresponding to bins
* 0..(blockSize/2) of the FFT output. That is, bin 0 (the first
* pair of floats) contains the DC output, up to bin blockSize/2
* which contains the Nyquist-frequency output. There will
* therefore be blockSize+2 floats per channel in total. The
* timestamp will be the real time in seconds of the centre of the
* FFT input window (i.e. the very first block passed to process
* might contain the FFT of half a block of zero samples and the
* first half-block of the actual data, with a timestamp of zero).
*
* Return any features that have become available after this
* process call. (These do not necessarily have to fall within
* the process block, except for OneSamplePerStep outputs.)
*/
virtual FeatureSet process(const float *const *inputBuffers,
RealTime timestamp) = 0;
/**
* After all blocks have been processed, calculate and return any
* remaining features derived from the complete input.
*/
virtual FeatureSet getRemainingFeatures() = 0;
/**
* Used to distinguish between Vamp::Plugin and other potential
* sibling subclasses of PluginBase. Do not reimplement this
* function in your subclass.
*/
virtual std::string getType() const { return "Feature Extraction Plugin"; }
protected:
Plugin(float inputSampleRate) :
m_inputSampleRate(inputSampleRate) { }
float m_inputSampleRate;
};
}
_VAMP_SDK_PLUGSPACE_END(Plugin.h)
#endif

View File

@@ -0,0 +1,121 @@
/* -*- 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_ADAPTER_H_
#define _VAMP_PLUGIN_ADAPTER_H_
#include <map>
#include <vamp/vamp.h>
#include "Plugin.h"
#include "plugguard.h"
_VAMP_SDK_PLUGSPACE_BEGIN(PluginAdapter.h)
namespace Vamp {
/**
* \class PluginAdapterBase PluginAdapter.h <vamp-sdk/PluginAdapter.h>
*
* PluginAdapter and PluginAdapterBase provide a wrapper class that a
* plugin library can use to make its C++ Vamp::Plugin objects
* available through the Vamp C API.
*
* Almost all Vamp plugin libraries will want to make use of this. To
* do so, all they need to do is declare a PluginAdapter<T> for each
* plugin class T in their library. It's very simple, and you need to
* know absolutely nothing about how it works in order to use it.
* Just cut and paste from an existing plugin's discovery function.
* \see vampGetPluginDescriptor
*/
class PluginAdapterBase
{
public:
virtual ~PluginAdapterBase();
/**
* Return a VampPluginDescriptor describing the plugin that is
* wrapped by this adapter.
*/
const VampPluginDescriptor *getDescriptor();
protected:
PluginAdapterBase();
virtual Plugin *createPlugin(float inputSampleRate) = 0;
class Impl;
Impl *m_impl;
};
/**
* \class PluginAdapter PluginAdapter.h <vamp-sdk/PluginAdapter.h>
*
* PluginAdapter turns a PluginAdapterBase into a specific wrapper for
* a particular plugin implementation.
*
* See PluginAdapterBase.
*/
template <typename P>
class PluginAdapter : public PluginAdapterBase
{
public:
PluginAdapter() : PluginAdapterBase() { }
virtual ~PluginAdapter() { }
protected:
Plugin *createPlugin(float inputSampleRate) {
P *p = new P(inputSampleRate);
Plugin *plugin = dynamic_cast<Plugin *>(p);
if (!plugin) {
std::cerr << "ERROR: PluginAdapter::createPlugin: "
<< "Template type is not a plugin!"
<< std::endl;
delete p;
return 0;
}
return plugin;
}
};
}
_VAMP_SDK_PLUGSPACE_END(PluginAdapter.h)
#endif

View File

@@ -0,0 +1,262 @@
/* -*- 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_SDK_PLUGIN_BASE_H_
#define _VAMP_SDK_PLUGIN_BASE_H_
#include <string>
#include <vector>
#define VAMP_SDK_VERSION "2.0"
#define VAMP_SDK_MAJOR_VERSION 2
#define VAMP_SDK_MINOR_VERSION 0
#include "plugguard.h"
_VAMP_SDK_PLUGSPACE_BEGIN(PluginBase.h)
namespace Vamp {
/**
* A base class for plugins with optional configurable parameters,
* programs, etc. The Vamp::Plugin is derived from this, and
* individual Vamp plugins should derive from that.
*
* This class does not provide the necessary interfaces to instantiate
* or run a plugin. It only specifies an interface for retrieving
* those controls that the host may wish to show to the user for
* editing. It could meaningfully be subclassed by real-time plugins
* or other sorts of plugin as well as Vamp plugins.
*/
class PluginBase
{
public:
virtual ~PluginBase() { }
/**
* Get the Vamp API compatibility level of the plugin.
*/
virtual unsigned int getVampApiVersion() const { return 2; }
/**
* Get the computer-usable name of the plugin. This should be
* reasonably short and contain no whitespace or punctuation
* characters. It may only contain the characters [a-zA-Z0-9_-].
* This is the authoritative way for a program to identify a
* plugin within a given library.
*
* This text may be visible to the user, but it should not be the
* main text used to identify a plugin to the user (that will be
* the name, below).
*
* Example: "zero_crossings"
*/
virtual std::string getIdentifier() const = 0;
/**
* Get a human-readable name or title of the plugin. This
* should be brief and self-contained, as it may be used to
* identify the plugin to the user in isolation (i.e. without also
* showing the plugin's "identifier").
*
* Example: "Zero Crossings"
*/
virtual std::string getName() const = 0;
/**
* Get a human-readable description for the plugin, typically
* a line of text that may optionally be displayed in addition
* to the plugin's "name". May be empty if the name has said
* it all already.
*
* Example: "Detect and count zero crossing points"
*/
virtual std::string getDescription() const = 0;
/**
* Get the name of the author or vendor of the plugin in
* human-readable form. This should be a short identifying text,
* as it may be used to label plugins from the same source in a
* menu or similar.
*/
virtual std::string getMaker() const = 0;
/**
* Get the copyright statement or licensing summary for the
* plugin. This can be an informative text, without the same
* presentation constraints as mentioned for getMaker above.
*/
virtual std::string getCopyright() const = 0;
/**
* Get the version number of the plugin.
*/
virtual int getPluginVersion() const = 0;
struct ParameterDescriptor
{
/**
* The name of the parameter, in computer-usable form. Should
* be reasonably short, and may only contain the characters
* [a-zA-Z0-9_-].
*/
std::string identifier;
/**
* The human-readable name of the parameter.
*/
std::string name;
/**
* A human-readable short text describing the parameter. May be
* empty if the name has said it all already.
*/
std::string description;
/**
* The unit of the parameter, in human-readable form.
*/
std::string unit;
/**
* The minimum value of the parameter.
*/
float minValue;
/**
* The maximum value of the parameter.
*/
float maxValue;
/**
* The default value of the parameter. The plugin should
* ensure that parameters have this value on initialisation
* (i.e. the host is not required to explicitly set parameters
* if it wants to use their default values).
*/
float defaultValue;
/**
* True if the parameter values are quantized to a particular
* resolution.
*/
bool isQuantized;
/**
* Quantization resolution of the parameter values (e.g. 1.0
* if they are all integers). Undefined if isQuantized is
* false.
*/
float quantizeStep;
/**
* Names for the quantized values. If isQuantized is true,
* this may either be empty or contain one string for each of
* the quantize steps from minValue up to maxValue inclusive.
* Undefined if isQuantized is false.
*
* If these names are provided, they should be shown to the
* user in preference to the values themselves. The user may
* never see the actual numeric values unless they are also
* encoded in the names.
*/
std::vector<std::string> valueNames;
ParameterDescriptor() : // the defaults are invalid: you must set them
minValue(0), maxValue(0), defaultValue(0), isQuantized(false) { }
};
typedef std::vector<ParameterDescriptor> ParameterList;
/**
* Get the controllable parameters of this plugin.
*/
virtual ParameterList getParameterDescriptors() const {
return ParameterList();
}
/**
* Get the value of a named parameter. The argument is the identifier
* field from that parameter's descriptor.
*/
virtual float getParameter(std::string) const { return 0.0; }
/**
* Set a named parameter. The first argument is the identifier field
* from that parameter's descriptor.
*/
virtual void setParameter(std::string, float) { }
typedef std::vector<std::string> ProgramList;
/**
* Get the program settings available in this plugin. A program
* is a named shorthand for a set of parameter values; changing
* the program may cause the plugin to alter the values of its
* published parameters (and/or non-public internal processing
* parameters). The host should re-read the plugin's parameter
* values after setting a new program.
*
* The programs must have unique names.
*/
virtual ProgramList getPrograms() const { return ProgramList(); }
/**
* Get the current program.
*/
virtual std::string getCurrentProgram() const { return ""; }
/**
* Select a program. (If the given program name is not one of the
* available programs, do nothing.)
*/
virtual void selectProgram(std::string) { }
/**
* Get the type of plugin. This is to be implemented by the
* immediate subclass, not by actual plugins. Do not attempt to
* implement this in plugin code.
*/
virtual std::string getType() const = 0;
};
}
_VAMP_SDK_PLUGSPACE_END(PluginBase.h)
#endif

View File

@@ -0,0 +1,167 @@
/* -*- 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.
*/
/*
This is a modified version of a source file from the
Rosegarden MIDI and audio sequencer and notation editor.
This file copyright 2000-2006 Chris Cannam.
Relicensed by the author as detailed above.
*/
#ifndef _VAMP_REAL_TIME_H_
#define _VAMP_REAL_TIME_H_
#include <iostream>
#include <string>
#ifndef _WIN32
struct timeval;
#endif
#include "plugguard.h"
_VAMP_SDK_PLUGSPACE_BEGIN(RealTime.h)
namespace Vamp {
/**
* \class RealTime RealTime.h <vamp-sdk/RealTime.h>
*
* RealTime represents time values to nanosecond precision
* with accurate arithmetic and frame-rate conversion functions.
*/
struct RealTime
{
int sec;
int nsec;
int usec() const { return nsec / 1000; }
int msec() const { return nsec / 1000000; }
RealTime(): sec(0), nsec(0) {}
RealTime(int s, int n);
RealTime(const RealTime &r) :
sec(r.sec), nsec(r.nsec) { }
static RealTime fromSeconds(double sec);
static RealTime fromMilliseconds(int msec);
#ifndef _WIN32
static RealTime fromTimeval(const struct timeval &);
#endif
RealTime &operator=(const RealTime &r) {
sec = r.sec; nsec = r.nsec; return *this;
}
RealTime operator+(const RealTime &r) const {
return RealTime(sec + r.sec, nsec + r.nsec);
}
RealTime operator-(const RealTime &r) const {
return RealTime(sec - r.sec, nsec - r.nsec);
}
RealTime operator-() const {
return RealTime(-sec, -nsec);
}
bool operator <(const RealTime &r) const {
if (sec == r.sec) return nsec < r.nsec;
else return sec < r.sec;
}
bool operator >(const RealTime &r) const {
if (sec == r.sec) return nsec > r.nsec;
else return sec > r.sec;
}
bool operator==(const RealTime &r) const {
return (sec == r.sec && nsec == r.nsec);
}
bool operator!=(const RealTime &r) const {
return !(r == *this);
}
bool operator>=(const RealTime &r) const {
if (sec == r.sec) return nsec >= r.nsec;
else return sec >= r.sec;
}
bool operator<=(const RealTime &r) const {
if (sec == r.sec) return nsec <= r.nsec;
else return sec <= r.sec;
}
RealTime operator/(int d) const;
/**
* Return the ratio of two times.
*/
double operator/(const RealTime &r) const;
/**
* Return a human-readable debug-type string to full precision
* (probably not a format to show to a user directly)
*/
std::string toString() const;
/**
* Return a user-readable string to the nearest millisecond
* in a form like HH:MM:SS.mmm
*/
std::string toText(bool fixedDp = false) const;
/**
* Convert a RealTime into a sample frame at the given sample rate.
*/
static long realTime2Frame(const RealTime &r, unsigned int sampleRate);
/**
* Convert a sample frame at the given sample rate into a RealTime.
*/
static RealTime frame2RealTime(long frame, unsigned int sampleRate);
static const RealTime zeroTime;
};
std::ostream &operator<<(std::ostream &out, const RealTime &rt);
}
_VAMP_SDK_PLUGSPACE_END(RealTime.h)
#endif

View File

@@ -0,0 +1,98 @@
/* -*- 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_SDK_PLUGGUARD_H_
#define _VAMP_SDK_PLUGGUARD_H_
/**
* Normal usage should be:
*
* - Plugins include vamp-sdk/Plugin.h or vamp-sdk/PluginBase.h.
* These files include this header, which specifies an appropriate
* namespace for the plugin classes to avoid any risk of conflict
* with non-plugin class implementations in the host on load.
*
* - Hosts include vamp-hostsdk/Plugin.h, vamp-hostsdk/PluginBase.h,
* vamp-hostsdk/PluginHostAdapter, vamp-hostsdk/PluginLoader.h etc.
* These files include vamp-hostsdk/hostguard.h, which makes a note
* that we are in a host. A file such as vamp-hostsdk/Plugin.h
* then simply includes vamp-sdk/Plugin.h, and this guard header
* takes notice of the fact that it has been included from a host
* and leaves the plugin namespace unset.
*
* Problems will occur when a host includes files directly from the
* vamp-sdk directory. There are two reasons this might happen:
* mistake, perhaps owing to ignorance of the fact that this isn't
* allowed (particularly since it was the normal mechanism in v1 of
* the SDK); and a wish to incorporate plugin code directly into the
* host rather than having to load it.
*
* What if the host does include a vamp-sdk header by mistake? We can
* catch it if it's included before something from vamp-hostsdk. If
* it's included after something from vamp-hostsdk, it will work OK
* anyway. The remaining problem case is where nothing from
* vamp-hostsdk is included in the same file. We can't catch that.
*/
#ifndef _VAMP_IN_HOSTSDK
#define _VAMP_IN_PLUGINSDK 1
#ifdef _VAMP_NO_PLUGIN_NAMESPACE
#define _VAMP_SDK_PLUGSPACE_BEGIN(h)
#define _VAMP_SDK_PLUGSPACE_END(h)
#else
#ifdef _VAMP_PLUGIN_IN_HOST_NAMESPACE
#define _VAMP_SDK_PLUGSPACE_BEGIN(h) \
namespace _VampHost {
#define _VAMP_SDK_PLUGSPACE_END(h) \
} \
using namespace _VampHost;
#else
#define _VAMP_SDK_PLUGSPACE_BEGIN(h) \
namespace _VampPlugin {
#define _VAMP_SDK_PLUGSPACE_END(h) \
} \
using namespace _VampPlugin;
#endif
#endif
#endif
#endif

View File

@@ -0,0 +1,46 @@
/* -*- 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_SDK_SINGLE_INCLUDE_H_
#define _VAMP_SDK_SINGLE_INCLUDE_H_
#include "PluginBase.h"
#include "Plugin.h"
#include "RealTime.h"
#endif