Revision 3:0f65bb22172b Test.cpp

View differences:

Test.cpp
75 75
    delete[] blocks;
76 76
}
77 77

  
78
float **
79
Test::createTestAudio(size_t channels, size_t blocksize, size_t blocks)
80
{
81
    float **b = new float *[channels];
82
    for (size_t c = 0; c < channels; ++c) {
83
        b[c] = new float[blocksize * blocks];
84
        for (int i = 0; i < int(blocksize * blocks); ++i) {
85
            b[c][i] = sinf(float(i) / 10.f);
86
            if (i == 5005 || i == 20002) {
87
                b[c][i-2] = 0;
88
                b[c][i-1] = -1;
89
                b[c][i] = 1;
90
            }
91
        }
92
    }
93
    return b;
94
}
95

  
96
void
97
Test::destroyTestAudio(float **b, size_t channels)
98
{
99
    for (size_t c = 0; c < channels; ++c) {
100
        delete[] b[c];
101
    }
102
    delete[] b;
103
}
104

  
78 105
bool
79 106
Test::initDefaults(Plugin *p, size_t &channels, size_t &step, size_t &block,
80 107
                   Results &r)
......
94 121
    return true;
95 122
}
96 123

  
124
bool
125
Test::initAdapted(Plugin *p, size_t &channels, size_t step, size_t block,
126
                  Results &r)
127
{
128
    channels = p->getMinChannelCount();
129
    if (!p->initialise(channels, step, block)) {
130
        r.push_back(error("initialisation failed"));
131
        return false;
132
    }
133
    return true;
134
}
135

  
97 136
void
98 137
Test::appendFeatures(Plugin::FeatureSet &a, const Plugin::FeatureSet &b)
99 138
{
......
124 163
    return true;
125 164
}
126 165

  
166
void
167
Test::dump(const Plugin::FeatureSet &fs)
168
{
169
    for (Plugin::FeatureSet::const_iterator fsi = fs.begin();
170
         fsi != fs.end(); ++fsi) {
171
        int output = fsi->first;
172
        std::cerr << "Output " << output << ":" << std::endl;
173
        const Plugin::FeatureList &fl = fsi->second;
174
        for (int i = 0; i < (int)fl.size(); ++i) {
175
            std::cerr << "  Feature " << i << ":" << std::endl;
176
            const Plugin::Feature &f = fl[i];
177
            std::cerr << "    Timestamp: " << (f.hasTimestamp ? "(none)" : f.timestamp.toText()) << std::endl;
178
            std::cerr << "    Duration: " << (f.hasDuration ? "(none)" : f.duration.toText()) << std::endl;
179
            std::cerr << "    Label: " << (f.label == "" ? "(none)" : f.label) << std::endl;
180
            std::cerr << "    Value: " << (f.values.empty() ? "(none)" : "");
181
            for (int j = 0; j < (int)f.values.size(); ++j) {
182
                std::cerr << f.values[j] << " ";
183
            }
184
            std::cerr << std::endl;
185
        }
186
    }
187
}
188

  
189
void
190
Test::dump(const Result &r,
191
           const Plugin::FeatureSet &a,
192
           const Plugin::FeatureSet &b)
193
{
194
    std::cerr << r.message() << std::endl;
195
    std::cerr << "\nFirst result set:" << std::endl;
196
    dump(a);
197
    std::cerr << "\nSecond result set:" << std::endl;
198
    dump(b);
199
    std::cerr << std::endl;
200
}
201

  
127 202
bool
128 203
operator==(const Plugin::FeatureSet &a, const Plugin::FeatureSet &b)
129 204
{

Also available in: Unified diff