comparison src/BTrack.cpp @ 111:8fb1610c9192

Code style updates
author Adam Stark <adamstark.uk@gmail.com>
date Thu, 17 Aug 2023 09:31:30 +0200
parents a6701b3f636f
children 54c657d621dd
comparison
equal deleted inserted replaced
110:0fdaf082ad1a 111:8fb1610c9192
34 } 34 }
35 35
36 //======================================================================= 36 //=======================================================================
37 BTrack::BTrack (int hop) 37 BTrack::BTrack (int hop)
38 : odf (hop, 2 * hop, ComplexSpectralDifferenceHWR, HanningWindow) 38 : odf (hop, 2 * hop, ComplexSpectralDifferenceHWR, HanningWindow)
39 { 39 {
40 initialise (hop); 40 initialise (hop);
41 } 41 }
42 42
43 //======================================================================= 43 //=======================================================================
44 BTrack::BTrack (int hop, int frame) 44 BTrack::BTrack (int hop, int frame)
108 double t_mu = 41/2; 108 double t_mu = 41/2;
109 double m_sig; 109 double m_sig;
110 double x; 110 double x;
111 // create tempo transition matrix 111 // create tempo transition matrix
112 m_sig = 41/8; 112 m_sig = 41/8;
113 for (int i = 0;i < 41;i++) 113
114 { 114 for (int i = 0; i < 41; i++)
115 for (int j = 0;j < 41;j++) 115 {
116 { 116 for (int j = 0; j < 41; j++)
117 x = j+1; 117 {
118 t_mu = i+1; 118 x = j + 1;
119 tempoTransitionMatrix[i][j] = (1 / (m_sig * sqrt (2 * M_PI))) * exp( (-1*pow((x-t_mu),2)) / (2*pow(m_sig,2)) ); 119 t_mu = i + 1;
120 tempoTransitionMatrix[i][j] = (1 / (m_sig * sqrt (2 * M_PI))) * exp((-1 * pow ((x - t_mu), 2)) / (2 * pow (m_sig, 2)) );
120 } 121 }
121 } 122 }
122 123
123 // tempo is not fixed 124 // tempo is not fixed
124 tempoFixed = false; 125 tempoFixed = false;
501 { 502 {
502 int onsetDetectionFunctionLength = 512; 503 int onsetDetectionFunctionLength = 512;
503 504
504 #ifdef USE_FFTW 505 #ifdef USE_FFTW
505 // copy into complex array and zero pad 506 // copy into complex array and zero pad
506 for (int i = 0;i < FFTLengthForACFCalculation;i++) 507 for (int i = 0; i < FFTLengthForACFCalculation; i++)
507 { 508 {
508 if (i < onsetDetectionFunctionLength) 509 if (i < onsetDetectionFunctionLength)
509 { 510 {
510 complexIn[i][0] = onsetDetectionFunction[i]; 511 complexIn[i][0] = onsetDetectionFunction[i];
511 complexIn[i][1] = 0.0; 512 complexIn[i][1] = 0.0;
521 fftw_execute (acfForwardFFT); 522 fftw_execute (acfForwardFFT);
522 523
523 // multiply by complex conjugate 524 // multiply by complex conjugate
524 for (int i = 0;i < FFTLengthForACFCalculation;i++) 525 for (int i = 0;i < FFTLengthForACFCalculation;i++)
525 { 526 {
526 complexOut[i][0] = complexOut[i][0]*complexOut[i][0] + complexOut[i][1]*complexOut[i][1]; 527 complexOut[i][0] = complexOut[i][0] * complexOut[i][0] + complexOut[i][1] * complexOut[i][1];
527 complexOut[i][1] = 0.0; 528 complexOut[i][1] = 0.0;
528 } 529 }
529 530
530 // perform the ifft 531 // perform the ifft
531 fftw_execute (acfBackwardFFT); 532 fftw_execute (acfBackwardFFT);
532 533
533 #endif 534 #endif
534 535
535 #ifdef USE_KISS_FFT 536 #ifdef USE_KISS_FFT
536 // copy into complex array and zero pad 537 // copy into complex array and zero pad
537 for (int i = 0;i < FFTLengthForACFCalculation;i++) 538 for (int i = 0; i < FFTLengthForACFCalculation; i++)
538 { 539 {
539 if (i < onsetDetectionFunctionLength) 540 if (i < onsetDetectionFunctionLength)
540 { 541 {
541 fftIn[i].r = onsetDetectionFunction[i]; 542 fftIn[i].r = onsetDetectionFunction[i];
542 fftIn[i].i = 0.0; 543 fftIn[i].i = 0.0;
567 568
568 for (int i = 0; i < 512; i++) 569 for (int i = 0; i < 512; i++)
569 { 570 {
570 #ifdef USE_FFTW 571 #ifdef USE_FFTW
571 // calculate absolute value of result 572 // calculate absolute value of result
572 double absValue = sqrt (complexIn[i][0]*complexIn[i][0] + complexIn[i][1]*complexIn[i][1]); 573 double absValue = sqrt (complexIn[i][0] * complexIn[i][0] + complexIn[i][1] * complexIn[i][1]);
573 #endif 574 #endif
574 575
575 #ifdef USE_KISS_FFT 576 #ifdef USE_KISS_FFT
576 // calculate absolute value of result 577 // calculate absolute value of result
577 double absValue = sqrt (fftIn[i].r * fftIn[i].r + fftIn[i].i * fftIn[i].i); 578 double absValue = sqrt (fftIn[i].r * fftIn[i].r + fftIn[i].i * fftIn[i].i);