comparison plugins/BeatTrack.cpp @ 153:38502a1595ff

Update for new DetectionFunction api
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 21 Oct 2013 12:02:51 +0100
parents 87c13eccd52e
children f96ea0e4b475
comparison
equal deleted inserted replaced
152:979281679a39 153:38502a1595ff
365 << "BeatTracker has not been initialised" 365 << "BeatTracker has not been initialised"
366 << endl; 366 << endl;
367 return FeatureSet(); 367 return FeatureSet();
368 } 368 }
369 369
370 size_t len = m_d->dfConfig.frameLength / 2; 370 size_t len = m_d->dfConfig.frameLength / 2 + 1;
371 371
372 double *magnitudes = new double[len]; 372 double *reals = new double[len];
373 double *phases = new double[len]; 373 double *imags = new double[len];
374 374
375 // We only support a single input channel 375 // We only support a single input channel
376 376
377 for (size_t i = 0; i < len; ++i) { 377 for (size_t i = 0; i < len; ++i) {
378 378 reals[i] = inputBuffers[0][i*2];
379 magnitudes[i] = sqrt(inputBuffers[0][i*2 ] * inputBuffers[0][i*2 ] + 379 imags[i] = inputBuffers[0][i*2+1];
380 inputBuffers[0][i*2+1] * inputBuffers[0][i*2+1]); 380 }
381 381
382 phases[i] = atan2(-inputBuffers[0][i*2+1], inputBuffers[0][i*2]); 382 double output = m_d->df->processFrequencyDomain(reals, imags);
383 } 383
384 384 delete[] reals;
385 double output = m_d->df->process(magnitudes, phases); 385 delete[] imags;
386
387 delete[] magnitudes;
388 delete[] phases;
389 386
390 if (m_d->dfOutput.empty()) m_d->origin = timestamp; 387 if (m_d->dfOutput.empty()) m_d->origin = timestamp;
391 388
392 m_d->dfOutput.push_back(output); 389 m_d->dfOutput.push_back(output);
393 390