Revision 2:8056c637875b OfaVampPlugin.cpp
| OfaVampPlugin.cpp | ||
|---|---|---|
| 1 | 1 |
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
| 2 | 2 |
|
| 3 |
/* |
|
| 4 |
Vamp feature extraction plugins using MusicIP OFA library. |
|
| 5 |
|
|
| 6 |
Centre for Digital Music, Queen Mary, University of London. |
|
| 7 |
This file copyright 2007 QMUL. |
|
| 8 |
|
|
| 9 |
This program is free software; you can redistribute it and/or |
|
| 10 |
modify it under the terms of the GNU General Public License as |
|
| 11 |
published by the Free Software Foundation; either version 2 of the |
|
| 12 |
License, or (at your option) any later version. See the file |
|
| 13 |
COPYING included with this distribution for more information. |
|
| 14 |
*/ |
|
| 15 |
|
|
| 3 | 16 |
#include "OfaVampPlugin.h" |
| 4 | 17 |
|
| 5 | 18 |
#include <vamp/vamp.h> |
| ... | ... | |
| 17 | 30 |
|
| 18 | 31 |
using std::string; |
| 19 | 32 |
|
| 20 |
OfaVampPlugin::OfaVampPlugin(float inputSampleRate) : |
|
| 33 |
OfaVampPlugin::OfaVampPlugin(float inputSampleRate, Type type) :
|
|
| 21 | 34 |
Plugin(inputSampleRate), |
| 35 |
m_type(type), |
|
| 22 | 36 |
m_buffer(0), |
| 23 | 37 |
m_bufsiz(0), |
| 24 | 38 |
m_bufidx(0), |
| ... | ... | |
| 35 | 49 |
} |
| 36 | 50 |
|
| 37 | 51 |
string |
| 38 |
OfaVampPlugin::getIdentifier() const |
|
| 39 |
{
|
|
| 40 |
return "ofa"; |
|
| 41 |
} |
|
| 42 |
|
|
| 43 |
string |
|
| 44 |
OfaVampPlugin::getName() const |
|
| 45 |
{
|
|
| 46 |
return "MusicIP OFA Audio Fingerprinter"; |
|
| 47 |
} |
|
| 48 |
|
|
| 49 |
string |
|
| 50 |
OfaVampPlugin::getDescription() const |
|
| 51 |
{
|
|
| 52 |
return "Calculates an audio fingerprint using the MusicIP fingerprinting library"; |
|
| 53 |
} |
|
| 54 |
|
|
| 55 |
string |
|
| 56 | 52 |
OfaVampPlugin::getMaker() const |
| 57 | 53 |
{
|
| 58 |
return "Chris Cannam"; |
|
| 54 |
return "Chris Cannam, using MusicIP OFA library";
|
|
| 59 | 55 |
} |
| 60 | 56 |
|
| 61 | 57 |
int |
| ... | ... | |
| 67 | 63 |
string |
| 68 | 64 |
OfaVampPlugin::getCopyright() const |
| 69 | 65 |
{
|
| 70 |
return ""; //!!!
|
|
| 66 |
return "GPL";
|
|
| 71 | 67 |
} |
| 72 | 68 |
|
| 73 | 69 |
OfaVampPlugin::ParameterList |
| ... | ... | |
| 134 | 130 |
OutputList list; |
| 135 | 131 |
|
| 136 | 132 |
OutputDescriptor desc; |
| 137 |
desc.identifier = "fingerprint"; |
|
| 138 |
desc.name = "Fingerprint"; |
|
| 139 |
desc.description = "Single result containing the audio fingerprint as its label"; |
|
| 140 |
desc.unit = ""; |
|
| 141 |
desc.hasFixedBinCount = true; |
|
| 142 |
desc.binCount = 0; |
|
| 143 |
desc.hasKnownExtents = false; |
|
| 144 |
desc.isQuantized = false; |
|
| 145 |
desc.sampleType = OutputDescriptor::VariableSampleRate; |
|
| 146 |
desc.sampleRate = m_inputSampleRate; |
|
| 147 |
list.push_back(desc); |
|
| 148 | 133 |
|
| 149 |
desc.identifier = "puid"; |
|
| 150 |
desc.name = "PUID"; |
|
| 151 |
desc.description = "Single result containing the MusicIP online PUID for this audio track, if available"; |
|
| 152 |
desc.unit = ""; |
|
| 153 |
desc.hasFixedBinCount = true; |
|
| 154 |
desc.binCount = 0; |
|
| 155 |
desc.hasKnownExtents = false; |
|
| 156 |
desc.isQuantized = false; |
|
| 157 |
desc.sampleType = OutputDescriptor::VariableSampleRate; |
|
| 158 |
desc.sampleRate = m_inputSampleRate; |
|
| 159 |
list.push_back(desc); |
|
| 134 |
m_fingerprintResultIndex = -1; |
|
| 135 |
m_puidResultIndex = -1; |
|
| 136 |
int index = 0; |
|
| 137 |
|
|
| 138 |
if (m_type == TypeFingerprint || m_type == TypeBoth) {
|
|
| 139 |
|
|
| 140 |
desc.identifier = "fingerprint"; |
|
| 141 |
desc.name = "Fingerprint"; |
|
| 142 |
desc.description = "Single result containing the audio fingerprint as its label"; |
|
| 143 |
desc.unit = ""; |
|
| 144 |
desc.hasFixedBinCount = true; |
|
| 145 |
desc.binCount = 0; |
|
| 146 |
desc.hasKnownExtents = false; |
|
| 147 |
desc.isQuantized = false; |
|
| 148 |
desc.sampleType = OutputDescriptor::VariableSampleRate; |
|
| 149 |
desc.sampleRate = m_inputSampleRate; |
|
| 150 |
list.push_back(desc); |
|
| 151 |
|
|
| 152 |
m_fingerprintResultIndex = index; |
|
| 153 |
++index; |
|
| 154 |
} |
|
| 155 |
|
|
| 156 |
if (m_type == TypePUID || m_type == TypeBoth) {
|
|
| 157 |
|
|
| 158 |
desc.identifier = "puid"; |
|
| 159 |
desc.name = "PUID"; |
|
| 160 |
desc.description = "Single result containing the MusicIP online PUID for this audio track, if available"; |
|
| 161 |
desc.unit = ""; |
|
| 162 |
desc.hasFixedBinCount = true; |
|
| 163 |
desc.binCount = 0; |
|
| 164 |
desc.hasKnownExtents = false; |
|
| 165 |
desc.isQuantized = false; |
|
| 166 |
desc.sampleType = OutputDescriptor::VariableSampleRate; |
|
| 167 |
desc.sampleRate = m_inputSampleRate; |
|
| 168 |
list.push_back(desc); |
|
| 169 |
|
|
| 170 |
m_puidResultIndex = index; |
|
| 171 |
++index; |
|
| 172 |
} |
|
| 160 | 173 |
|
| 161 | 174 |
return list; |
| 162 | 175 |
} |
| ... | ... | |
| 220 | 233 |
|
| 221 | 234 |
m_print = print; |
| 222 | 235 |
|
| 223 |
Feature feature; |
|
| 224 |
feature.hasTimestamp = true; |
|
| 225 |
feature.timestamp = Vamp::RealTime::zeroTime; |
|
| 226 |
feature.label = m_print; |
|
| 227 |
fset[0].push_back(feature); |
|
| 228 |
return fset; |
|
| 236 |
if (m_fingerprintResultIndex >= 0) {
|
|
| 237 |
|
|
| 238 |
Feature feature; |
|
| 239 |
feature.hasTimestamp = true; |
|
| 240 |
feature.timestamp = Vamp::RealTime::zeroTime; |
|
| 241 |
feature.label = m_print; |
|
| 242 |
fset[m_fingerprintResultIndex].push_back(feature); |
|
| 243 |
return fset; |
|
| 244 |
} |
|
| 229 | 245 |
} |
| 230 | 246 |
|
| 231 | 247 |
return FeatureSet(); |
| ... | ... | |
| 236 | 252 |
{
|
| 237 | 253 |
FeatureSet fset; |
| 238 | 254 |
|
| 239 |
if (m_print == "") return fset; |
|
| 255 |
if (m_print == "" || m_puidResultIndex < 0) return fset;
|
|
| 240 | 256 |
|
| 241 | 257 |
Feature feature; |
| 242 | 258 |
feature.hasTimestamp = true; |
| ... | ... | |
| 272 | 288 |
std::cerr << "Fingerprint was: " << m_print << std::endl; |
| 273 | 289 |
} else {
|
| 274 | 290 |
feature.label = info->getPUID(); |
| 275 |
fset[1].push_back(feature);
|
|
| 291 |
fset[m_puidResultIndex].push_back(feature);
|
|
| 276 | 292 |
} |
| 277 | 293 |
|
| 278 | 294 |
return fset; |
| 279 | 295 |
} |
| 280 | 296 |
|
| 281 |
static Vamp::PluginAdapter<OfaVampPlugin> ofaAdapter; |
|
| 297 |
static Vamp::PluginAdapter<OfaFingerprintPlugin> ofaFingerprintAdapter; |
|
| 298 |
static Vamp::PluginAdapter<OfaPUIDPlugin> ofaPUIDAdapter; |
|
| 282 | 299 |
|
| 283 | 300 |
const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int version, |
| 284 | 301 |
unsigned int index) |
| ... | ... | |
| 286 | 303 |
if (version < 1) return 0; |
| 287 | 304 |
|
| 288 | 305 |
switch (index) {
|
| 289 |
case 0: return ofaAdapter.getDescriptor(); |
|
| 306 |
case 0: return ofaFingerprintAdapter.getDescriptor(); |
|
| 307 |
case 1: return ofaPUIDAdapter.getDescriptor(); |
|
| 290 | 308 |
default: return 0; |
| 291 | 309 |
} |
| 292 | 310 |
} |
Also available in: Unified diff