Revision 2:8056c637875b

View differences:

Makefile
1 1

  
2
CXXFLAGS	:= -I../vamp-plugin-sdk -O3 -Wall -march=pentium4 -msse -msse2 -fomit-frame-pointer -ffast-math
2
CXXFLAGS	:= -I../vamp-plugin-sdk -O2 -Wall
3

  
4
#CXXFLAGS	:= -I../vamp-plugin-sdk -O3 -Wall -march=pentium4 -msse -msse2 -fomit-frame-pointer -ffast-math
3 5

  
4 6
ofa-vamp-plugin.so:	OfaVampPlugin.o protocol.o
5 7
	g++ -shared $^ -o $@ -L../vamp-plugin-sdk/vamp-sdk -Wl,-Bstatic -lvamp-sdk -Wl,-Bdynamic -lofa -lcurl -lexpat
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
}
OfaVampPlugin.h
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
#ifndef _OFA_VAMP_PLUGIN_H_
4 17
#define _OFA_VAMP_PLUGIN_H_
5 18

  
6 19
#include <vamp-sdk/Plugin.h>
7 20

  
8
#include <pthread.h>
9

  
10 21
class OfaVampPlugin : public Vamp::Plugin
11 22
{
12 23
public:
13
    OfaVampPlugin(float inputSampleRate);
24
    enum Type { TypeFingerprint, TypePUID, TypeBoth };
25
    OfaVampPlugin(float inputSampleRate, Type type);
14 26
    virtual ~OfaVampPlugin();
15 27

  
16 28
    bool initialise(size_t channels, size_t stepSize, size_t blockSize);
......
24 36
    size_t getMinChannelCount() const { return 1; }
25 37
    size_t getMaxChannelCount() const { return 2; }
26 38

  
27
    std::string getIdentifier() const;
28
    std::string getName() const;
29
    std::string getDescription() const;
30 39
    std::string getMaker() const;
31 40
    int getPluginVersion() const;
32 41
    std::string getCopyright() const;
......
43 52
    FeatureSet getRemainingFeatures();
44 53

  
45 54
protected:
55
    Type m_type;
56
    mutable int m_fingerprintResultIndex;
57
    mutable int m_puidResultIndex;
46 58
    int16_t *m_buffer;
47 59
    size_t m_bufsiz;
48 60
    size_t m_bufidx;
......
53 65
    bool m_enough;
54 66
};
55 67

  
68
class OfaFingerprintPlugin : public OfaVampPlugin
69
{
70
public:
71
    OfaFingerprintPlugin(float inputSampleRate) :
72
        OfaVampPlugin(inputSampleRate, TypeFingerprint) { }
73

  
74
    std::string getName() const { 
75
        return "MusicIP Audio Fingerprinter";
76
    }
77

  
78
    std::string getDescription() const { 
79
        return "Calculates an audio fingerprint using the MusicIP OFA fingerprinting library";
80
    }
81

  
82
    std::string getIdentifier() const {
83
        return "ofa_fingerprint";
84
    }
85
};
86

  
87
class OfaPUIDPlugin : public OfaVampPlugin
88
{
89
public:
90
    OfaPUIDPlugin(float inputSampleRate) :
91
        OfaVampPlugin(inputSampleRate, TypePUID) { }
92

  
93
    std::string getName() const { 
94
        return "MusicIP PUID Lookup";
95
    }
96

  
97
    std::string getDescription() const { 
98
        return "Calculates an audio fingerprint using the MusicIP OFA fingerprinting library and uses it to look up a MusicDNS PUID";
99
    }
100

  
101
    std::string getIdentifier() const {
102
        return "ofa_puid";
103
    }
104
};
105

  
106
class OfaBothPlugin : public OfaVampPlugin
107
{
108
public:
109
    OfaBothPlugin(float inputSampleRate) :
110
        OfaVampPlugin(inputSampleRate, TypeBoth) { }
111

  
112
    std::string getName() const { 
113
        return "MusicIP Fingerprinter and PUID";
114
    }
115

  
116
    std::string getDescription() const { 
117
        return "Calculates an audio fingerprint and PUID using the MusicIP OFA library";
118
    }
119

  
120
    std::string getIdentifier() const {
121
        return "ofa_both";
122
    }
123
};
124

  
56 125

  
57 126
#endif
ofa-vamp-plugin.cat
1
vamp:ofa-vamp-plugin:ofa::Fingerprinting
1
vamp:ofa-vamp-plugin:ofa_fingerprint::Fingerprinting
2
vamp:ofa-vamp-plugin:ofa_puid::Fingerprinting
3
vamp:ofa-vamp-plugin:ofa_both::Fingerprinting

Also available in: Unified diff