48 #define isinf(x) (!finite(x)) 52 #define isnan(x) false 53 #define isinf(x) false 57 Plugin(inputSampleRate),
70 return "spectralcentroid";
76 return "Spectral Centroid";
82 return "Calculate the centroid frequency of the spectrum of the input signal";
88 return "Vamp SDK Example Plugins";
100 return "Freely redistributable (BSD license)";
127 d.
name =
"Log Frequency Centroid";
128 d.
description =
"Centroid of the log weighted frequency spectrum";
138 d.
name =
"Linear Frequency Centroid";
139 d.
description =
"Centroid of the linear frequency spectrum";
149 cerr <<
"ERROR: SpectralCentroid::process: " 150 <<
"SpectralCentroid has not been initialised" 155 double numLin = 0.0, numLog = 0.0, denom = 0.0;
159 double real = inputBuffers[0][i*2];
160 double imag = inputBuffers[0][i*2 + 1];
161 double scalemag = sqrt(real * real + imag * imag) / (
m_blockSize/2);
162 numLin += freq * scalemag;
163 numLog += log10f(freq) * scalemag;
170 float centroidLin = float(numLin / denom);
171 float centroidLog = powf(10,
float(numLog / denom));
176 if (!isnan(centroidLog) && !isinf(centroidLog)) {
177 feature.
values.push_back(centroidLog);
179 returnFeatures[0].push_back(feature);
182 if (!isnan(centroidLin) && !isinf(centroidLin)) {
183 feature.
values.push_back(centroidLin);
185 returnFeatures[1].push_back(feature);
188 return returnFeatures;
std::vector< OutputDescriptor > OutputList
Chris@6:
std::string getCopyright() const
Get the copyright statement or licensing summary for the plugin.
Chris@6:
OutputList getOutputDescriptors() const
Get the outputs of this plugin.
Chris@6:
Chris@6:
bool hasFixedBinCount
True if the output has the same number of values per sample for every output sample.
Chris@6:
std::vector< float > values
Results for a single sample of this feature.
Chris@6:
std::map< int, FeatureList > FeatureSet
Chris@6:
FeatureSet process(const float *const *inputBuffers, Vamp::RealTime timestamp)
Process a single block of input data.
Chris@6:
void reset()
Reset the plugin after use, to prepare it for another clean run.
Chris@6:
std::string description
A human-readable short text describing the output.
Chris@6:
std::string getName() const
Get a human-readable name or title of the plugin.
Chris@6:
std::string identifier
The name of the output, in computer-usable form.
Chris@6:
Chris@6:
Chris@6:
Chris@6:
int getPluginVersion() const
Get the version number of the plugin.
Chris@6:
Chris@6:
Chris@6:
std::string unit
The unit of the output, in human-readable form.
Chris@6:
virtual size_t getMinChannelCount() const
Get the minimum supported number of input channels.
Chris@6:
std::string name
The human-readable name of the output.
Chris@6:
virtual size_t getMaxChannelCount() const
Get the maximum supported number of input channels.
Chris@6:
RealTime represents time values to nanosecond precision with accurate arithmetic and frame-rate conve...
Chris@6:
bool hasTimestamp
True if an output feature has its own timestamp.
Chris@6:
std::string getMaker() const
Get the name of the author or vendor of the plugin in human-readable form.
Chris@6:
std::string getIdentifier() const
Get the computer-usable name of the plugin.
Chris@6:
SpectralCentroid(float inputSampleRate)
Chris@6:
std::string getDescription() const
Get a human-readable description for the plugin, typically a line of text that may optionally be disp...
Chris@6:
virtual ~SpectralCentroid()
Chris@6:
Results from each process() align with that call's block start.
Chris@6:
size_t binCount
The number of values per result of the output.
Chris@6:
bool isQuantized
True if the output values are quantized to a particular resolution.
Chris@6:
SampleType sampleType
Positioning in time of the output results.
Chris@6:
bool initialise(size_t channels, size_t stepSize, size_t blockSize)
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).
Chris@6:
bool hasKnownExtents
True if the results in each output bin fall within a fixed numeric range (minimum and maximum values)...
Chris@6:
FeatureSet getRemainingFeatures()
After all blocks have been processed, calculate and return any remaining features derived from the co...
Chris@6: