Revision 1:d7ef749300ed Test.cpp

View differences:

Test.cpp
44 44
using namespace Vamp;
45 45
using namespace Vamp::HostExt;
46 46

  
47
#include <cmath>
48

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

  
......
54 56
        (key, rate, PluginLoader::ADAPT_ALL);
55 57
}
56 58

  
59
float **
60
Test::createBlock(size_t channels, size_t blocksize)
61
{
62
    float **b = new float *[channels];
63
    for (size_t c = 0; c < channels; ++c) {
64
        b[c] = new float[blocksize];
65
    }
66
    return b;
67
}
68

  
69
void
70
Test::destroyBlock(float **blocks, size_t channels)
71
{
72
    for (size_t c = 0; c < channels; ++c) {
73
        delete[] blocks[c];
74
    }
75
    delete[] blocks;
76
}
77

  
78
bool
79
Test::initDefaults(Plugin *p, size_t &channels, size_t &step, size_t &block,
80
                   Results &r)
81
{
82
    channels = p->getMinChannelCount();
83
    block = p->getPreferredBlockSize();
84
    step = p->getPreferredStepSize();
85
    if (block == 0) block = 1024;
86
    if (step == 0) {
87
        if (p->getInputDomain() == Plugin::FrequencyDomain) step = block/2;
88
        else step = block;
89
    }
90
    if (!p->initialise(channels, step, block)) {
91
        r.push_back(error("initialisation with default values failed"));
92
        return false;
93
    }
94
    return true;
95
}
96

  
57 97
void
58 98
Test::appendFeatures(Plugin::FeatureSet &a, const Plugin::FeatureSet &b)
59 99
{
......
68 108
}
69 109

  
70 110
bool
111
Test::allFeaturesValid(const Plugin::FeatureSet &b)
112
{
113
    for (Plugin::FeatureSet::const_iterator i = b.begin(); i != b.end(); ++i) {
114
        for (int j = 0; j < (int)i->second.size(); ++j) {
115
            if (i->second[j].values.empty()) continue;
116
            for (int k = 0; k < (int)i->second[j].values.size(); ++k) {
117
                if (isnan(i->second[j].values[k]) ||
118
                    isinf(i->second[j].values[k])) {
119
                    return false;
120
                }
121
            }
122
        }
123
    }
124
    return true;
125
}
126

  
127
bool
71 128
operator==(const Plugin::FeatureSet &a, const Plugin::FeatureSet &b)
72 129
{
73 130
    if (a.size() != b.size()) return false;

Also available in: Unified diff