=======================================================================
| 479 | |
| 480 | //======================================================================= |
| 481 | double 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 | //======================================================================= |
| 520 | double OnsetDetectionFunction::complexSpectralDifferenceHWR() |
nothing calls this directly
no outgoing calls
no test coverage detected