To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / Test.cpp @ 0:f89128a316e7

History | View | Annotate | Download (3.6 KB)

1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2

    
3
/*
4
    Vamp Plugin Fuzz Tester
5
    Chris Cannam, cannam@all-day-breakfast.com
6
    Centre for Digital Music, Queen Mary, University of London.
7
    Copyright 2009 QMUL.
8

9
    This program loads a Vamp plugin and tests its susceptibility to a
10
    number of common pitfalls, including handling of extremes of input
11
    data.  If you can think of any additional useful tests that are
12
    easily added, please send them to me.
13
  
14
    Permission is hereby granted, free of charge, to any person
15
    obtaining a copy of this software and associated documentation
16
    files (the "Software"), to deal in the Software without
17
    restriction, including without limitation the rights to use, copy,
18
    modify, merge, publish, distribute, sublicense, and/or sell copies
19
    of the Software, and to permit persons to whom the Software is
20
    furnished to do so, subject to the following conditions:
21

22
    The above copyright notice and this permission notice shall be
23
    included in all copies or substantial portions of the Software.
24

25
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
29
    ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
30
    CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32

33
    Except as contained in this notice, the names of the Centre for
34
    Digital Music; Queen Mary, University of London; and Chris Cannam
35
    shall not be used in advertising or otherwise to promote the sale,
36
    use or other dealings in this Software without prior written
37
    authorization.
38
*/
39

    
40
#include "Test.h"
41

    
42
#include <vamp-hostsdk/PluginLoader.h>
43

    
44
using namespace Vamp;
45
using namespace Vamp::HostExt;
46

    
47
Test::Test() { }
48
Test::~Test() { }
49

    
50
Plugin *
51
Test::load(std::string key, float rate)
52
{
53
    return PluginLoader::getInstance()->loadPlugin
54
        (key, rate, PluginLoader::ADAPT_ALL);
55
}
56

    
57
void
58
Test::appendFeatures(Plugin::FeatureSet &a, const Plugin::FeatureSet &b)
59
{
60
    for (Plugin::FeatureSet::const_iterator i = b.begin(); i != b.end(); ++i) {
61
        int output = i->first;
62
        const Plugin::FeatureList &fl = i->second;
63
        Plugin::FeatureList &target = a[output];
64
        for (Plugin::FeatureList::const_iterator j = fl.begin(); j != fl.end(); ++j) {
65
            target.push_back(*j);
66
        }
67
    }
68
}
69

    
70
bool
71
operator==(const Plugin::FeatureSet &a, const Plugin::FeatureSet &b)
72
{
73
    if (a.size() != b.size()) return false;
74
    for (Plugin::FeatureSet::const_iterator ai = a.begin();
75
         ai != a.end(); ++ai) {
76
        int output = ai->first;
77
        Plugin::FeatureSet::const_iterator bi = b.find(output);
78
        if (bi == b.end()) return false;
79
        if (!(ai->second == bi->second)) return false;
80
    }
81
    return true;
82
}
83

    
84
bool
85
operator==(const Plugin::FeatureList &a, const Plugin::FeatureList &b)
86
{
87
    if (a.size() != b.size()) return false;
88
    for (int i = 0; i < (int)a.size(); ++i) {
89
        if (!(a[i] == b[i])) return false;
90
    }
91
    return true;
92
}
93

    
94
bool
95
operator==(const Plugin::Feature &a, const Plugin::Feature &b)
96
{
97
    if (a.hasTimestamp != b.hasTimestamp) return false;
98
    if (a.hasTimestamp && (a.timestamp != b.timestamp)) return false;
99
    if (a.hasDuration != b.hasDuration) return false;
100
    if (a.hasDuration && (a.duration != b.duration)) return false;
101
    if (a.values != b.values) return false;
102
    if (a.label != b.label) return false;
103
    return true;
104
}
105