comparison VampTestPlugin.cpp @ 4:6ece30ceb931

Output something on all outputs defined so far
author Chris Cannam
date Mon, 25 Mar 2013 22:46:17 +0000
parents 72c80798371e
children d83566810b96
comparison
equal deleted inserted replaced
3:72c80798371e 4:6ece30ceb931
190 d.identifier = "grid-oss"; 190 d.identifier = "grid-oss";
191 d.name = "Grid: OneSamplePerStep"; 191 d.name = "Grid: OneSamplePerStep";
192 d.description = "A fixed-height grid of values with one column per process block"; 192 d.description = "A fixed-height grid of values with one column per process block";
193 d.unit = ""; 193 d.unit = "";
194 d.hasFixedBinCount = true; 194 d.hasFixedBinCount = true;
195 d.binCount = 1; 195 d.binCount = 10;
196 d.hasKnownExtents = false; 196 d.hasKnownExtents = false;
197 d.isQuantized = false; 197 d.isQuantized = false;
198 d.sampleType = OutputDescriptor::VariableSampleRate; 198 d.sampleType = OutputDescriptor::OneSamplePerStep;
199 d.sampleRate = 0; 199 d.sampleRate = 0;
200 d.hasDuration = false; 200 d.hasDuration = false;
201 list.push_back(d); 201 list.push_back(d);
202 202
203 // 5 -> grid-fsr 203 // 5 -> grid-fsr
204 d.identifier = "grid-fsr"; 204 d.identifier = "grid-fsr";
205 d.name = "Grid: FixedSampleRate"; 205 d.name = "Grid: FixedSampleRate";
206 d.description = "A fixed-height grid of values with equally-spaced columns (independent of process step size)"; 206 d.description = "A fixed-height grid of values with equally-spaced columns (independent of process step size)";
207 d.unit = ""; 207 d.unit = "";
208 d.hasFixedBinCount = true; 208 d.hasFixedBinCount = true;
209 d.binCount = 1; 209 d.binCount = 10;
210 d.hasKnownExtents = false; 210 d.hasKnownExtents = false;
211 d.isQuantized = false; 211 d.isQuantized = false;
212 d.sampleType = OutputDescriptor::VariableSampleRate; 212 d.sampleType = OutputDescriptor::FixedSampleRate;
213 d.sampleRate = 0; 213 d.sampleRate = 2;
214 d.hasDuration = false; 214 d.hasDuration = false;
215 list.push_back(d); 215 list.push_back(d);
216 216
217 217
218 return list; 218 return list;
261 s << i+1 << " of " << n << ": " << v << " at " << r.toText(); 261 s << i+1 << " of " << n << ": " << v << " at " << r.toText();
262 f.label = s.str(); 262 f.label = s.str();
263 return f; 263 return f;
264 } 264 }
265 265
266 static Vamp::Plugin::Feature
267 timedCurveValue(RealTime r, int i, int n)
268 {
269 std::stringstream s;
270 Vamp::Plugin::Feature f;
271 f.hasTimestamp = true;
272 f.timestamp = r;
273 f.hasDuration = false;
274 float v = float(i) / float(n);
275 f.values.push_back(v);
276 s << i+1 << " of " << n << ": " << v << " at " << r.toText();
277 f.label = s.str();
278 return f;
279 }
280
281 static Vamp::Plugin::Feature
282 gridColumn(RealTime r, int i, int n)
283 {
284 std::stringstream s;
285 Vamp::Plugin::Feature f;
286 f.hasTimestamp = false;
287 f.hasDuration = false;
288 for (int j = 0; j < 10; ++j) {
289 float v = float(j + i + 2) / float(n + 10);
290 f.values.push_back(v);
291 }
292 s << i+1 << " of " << n << " at " << r.toText();
293 f.label = s.str();
294 return f;
295 }
296
266 VampTestPlugin::FeatureSet 297 VampTestPlugin::FeatureSet
267 VampTestPlugin::process(const float *const *inputBuffers, RealTime timestamp) 298 VampTestPlugin::process(const float *const *inputBuffers, RealTime timestamp)
268 { 299 {
269 FeatureSet fs; 300 FeatureSet fs;
270 301
274 for (int i = 0; i < (int)m_instants.size(); ++i) { 305 for (int i = 0; i < (int)m_instants.size(); ++i) {
275 if (m_instants[i] >= timestamp && m_instants[i] < endTime) { 306 if (m_instants[i] >= timestamp && m_instants[i] < endTime) {
276 // instants output 307 // instants output
277 fs[0].push_back(instant(m_instants[i], i, m_instants.size())); 308 fs[0].push_back(instant(m_instants[i], i, m_instants.size()));
278 } 309 }
310
311 RealTime variCurveTime = m_instants[i] / 2;
312 if (variCurveTime >= timestamp && variCurveTime < endTime) {
313 // curve-vsr output
314 fs[3].push_back(timedCurveValue(variCurveTime, i, m_instants.size()));
315 }
279 } 316 }
280 317
281 if (m_n < 20) { 318 if (m_n < 20) {
282 // curve-oss output 319 // curve-oss output
283 fs[1].push_back(untimedCurveValue(timestamp, m_n, 20)); 320 fs[1].push_back(untimedCurveValue(timestamp, m_n, 20));
286 if (m_n < 5) { 323 if (m_n < 5) {
287 // curve-fsr output 324 // curve-fsr output
288 fs[2].push_back(untimedCurveValue(RealTime::fromSeconds(m_n / 2.0), m_n, 10)); 325 fs[2].push_back(untimedCurveValue(RealTime::fromSeconds(m_n / 2.0), m_n, 10));
289 } 326 }
290 327
328 if (m_n < 20) {
329 // grid-oss output
330 fs[4].push_back(gridColumn(timestamp, m_n, 20));
331 }
332
291 m_lastTime = endTime; 333 m_lastTime = endTime;
292 m_n = m_n + 1; 334 m_n = m_n + 1;
293 return fs; 335 return fs;
294 } 336 }
295 337
298 { 340 {
299 FeatureSet fs; 341 FeatureSet fs;
300 342
301 for (int i = 0; i < (int)m_instants.size(); ++i) { 343 for (int i = 0; i < (int)m_instants.size(); ++i) {
302 if (m_instants[i] >= m_lastTime) { 344 if (m_instants[i] >= m_lastTime) {
345 // instants output
303 fs[0].push_back(instant(m_instants[i], i, m_instants.size())); 346 fs[0].push_back(instant(m_instants[i], i, m_instants.size()));
347 }
348
349 RealTime variCurveTime = m_instants[i] / 2;
350 if (variCurveTime >= m_lastTime) {
351 // curve-vsr output
352 fs[3].push_back(timedCurveValue(m_instants[i], i, m_instants.size()));
304 } 353 }
305 } 354 }
306 355
307 for (int i = (m_n > 5 ? 5 : m_n); i < 10; ++i) { 356 for (int i = (m_n > 5 ? 5 : m_n); i < 10; ++i) {
308 // curve-fsr output 357 // curve-fsr output
309 fs[2].push_back(untimedCurveValue(RealTime::fromSeconds(i / 2.0), i, 10)); 358 fs[2].push_back(untimedCurveValue(RealTime::fromSeconds(i / 2.0), i, 10));
310 } 359 }
311 360
361 for (int i = (m_n > 5 ? 5 : m_n); i < 10; ++i) {
362 // grid-fsr output
363 fs[5].push_back(gridColumn(RealTime::fromSeconds(i / 2.0), i, 10));
364 }
365
312 return fs; 366 return fs;
313 } 367 }
314 368