MCPcopy Create free account
hub / github.com/adamstark/BTrack / complexSpectralDifference

Method complexSpectralDifference

src/OnsetDetectionFunction.cpp:481–517  ·  view source on GitHub ↗

=======================================================================

Source from the content-addressed store, hash-verified

479
480//=======================================================================
481double OnsetDetectionFunction::complexSpectralDifference()
482{
483 double phaseDeviation;
484 double sum;
485 double csd;
486
487 // perform the FFT
488 performFFT();
489
490 sum = 0; // initialise sum to zero
491
492 // compute phase values from fft output and sum deviations
493 for (int i = 0; i < frameSize; i++)
494 {
495 // calculate phase value
496 phase[i] = atan2 (complexOut[i][1], complexOut[i][0]);
497
498 // calculate magnitude value
499 magSpec[i] = sqrt (pow (complexOut[i][0],2) + pow(complexOut[i][1],2));
500
501 // phase deviation
502 phaseDeviation = phase[i] - (2 * prevPhase[i]) + prevPhase2[i];
503
504 // calculate complex spectral difference for the current spectral bin
505 csd = sqrt (pow (magSpec[i], 2) + pow (prevMagSpec[i], 2) - 2 * magSpec[i] * prevMagSpec[i] * cos (phaseDeviation));
506
507 // add to sum
508 sum = sum + csd;
509
510 // store values for next calculation
511 prevPhase2[i] = prevPhase[i];
512 prevPhase[i] = phase[i];
513 prevMagSpec[i] = magSpec[i];
514 }
515
516 return sum;
517}
518
519//=======================================================================
520double OnsetDetectionFunction::complexSpectralDifferenceHWR()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected