comparison dsp/tempotracking/TempoTrack.cpp @ 414:7e8d1f26b098

Fix compiler warnings with -Wall -Wextra
author Chris Cannam <c.cannam@qmul.ac.uk>
date Mon, 28 Sep 2015 12:33:17 +0100
parents c5e1b25d5177
children 7e52c034cf62
comparison
equal deleted inserted replaced
413:ec7318974497 414:7e8d1f26b098
67 m_rawDFFrame = new double[ m_winLength ]; 67 m_rawDFFrame = new double[ m_winLength ];
68 m_smoothDFFrame = new double[ m_winLength ]; 68 m_smoothDFFrame = new double[ m_winLength ];
69 m_frameACF = new double[ m_winLength ]; 69 m_frameACF = new double[ m_winLength ];
70 m_tempoScratch = new double[ m_lagLength ]; 70 m_tempoScratch = new double[ m_lagLength ];
71 m_smoothRCF = new double[ m_lagLength ]; 71 m_smoothRCF = new double[ m_lagLength ];
72
73
74 unsigned int winPre = Params.WinT.pre;
75 unsigned int winPost = Params.WinT.post;
76 72
77 m_DFFramer.configure( m_winLength, m_lagLength ); 73 m_DFFramer.configure( m_winLength, m_lagLength );
78 74
79 m_DFPParams.length = m_winLength; 75 m_DFPParams.length = m_winLength;
80 m_DFPParams.AlphaNormParam = Params.alpha; 76 m_DFPParams.AlphaNormParam = Params.alpha;
118 114
119 delete m_RCFConditioning; 115 delete m_RCFConditioning;
120 116
121 } 117 }
122 118
123 void TempoTrack::createCombFilter(double* Filter, unsigned int winLength, unsigned int TSig, double beatLag) 119 void TempoTrack::createCombFilter(double* Filter, int winLength, int /* TSig */, double beatLag)
124 { 120 {
125 unsigned int i; 121 int i;
126 122
127 if( beatLag == 0 ) 123 if( beatLag == 0 )
128 { 124 {
129 for( i = 0; i < winLength; i++ ) 125 for( i = 0; i < winLength; i++ )
130 { 126 {
145 double TempoTrack::tempoMM(double* ACF, double* weight, int tsig) 141 double TempoTrack::tempoMM(double* ACF, double* weight, int tsig)
146 { 142 {
147 143
148 double period = 0; 144 double period = 0;
149 double maxValRCF = 0.0; 145 double maxValRCF = 0.0;
150 unsigned int maxIndexRCF = 0; 146 int maxIndexRCF = 0;
151 147
152 double* pdPeaks; 148 double* pdPeaks;
153 149
154 unsigned int maxIndexTemp; 150 int maxIndexTemp;
155 double maxValTemp; 151 double maxValTemp;
156 unsigned int count; 152 int count;
157 153
158 unsigned int numelem,i,j; 154 int numelem,i,j;
159 int a, b; 155 int a, b;
160 156
161 for( i = 0; i < m_lagLength; i++ ) 157 for( i = 0; i < m_lagLength; i++ )
162 m_tempoScratch[ i ] = 0.0; 158 m_tempoScratch[ i ] = 0.0;
163 159
474 { 470 {
475 *flag = 0; 471 *flag = 0;
476 } 472 }
477 } 473 }
478 474
479 int TempoTrack::findMeter(double *ACF, unsigned int len, double period) 475 int TempoTrack::findMeter(double *ACF, int len, double period)
480 { 476 {
481 int i; 477 int i;
482 int p = (int)MathUtilities::round( period ); 478 int p = (int)MathUtilities::round( period );
483 int tsig; 479 int tsig;
484 480
489 double temp3B = 0.0; 485 double temp3B = 0.0;
490 double temp4A = 0.0; 486 double temp4A = 0.0;
491 double temp4B = 0.0; 487 double temp4B = 0.0;
492 488
493 double* dbf = new double[ len ]; int t = 0; 489 double* dbf = new double[ len ]; int t = 0;
494 for( unsigned int u = 0; u < len; u++ ){ dbf[ u ] = 0.0; } 490 for( int u = 0; u < len; u++ ){ dbf[ u ] = 0.0; }
495 491
496 if( (double)len < 6 * p + 2 ) 492 if( (double)len < 6 * p + 2 )
497 { 493 {
498 for( i = ( 3 * p - 2 ); i < ( 3 * p + 2 ) + 1; i++ ) 494 for( i = ( 3 * p - 2 ); i < ( 3 * p + 2 ) + 1; i++ )
499 { 495 {
546 542
547 543
548 return tsig; 544 return tsig;
549 } 545 }
550 546
551 void TempoTrack::createPhaseExtractor(double *Filter, unsigned int winLength, double period, unsigned int fsp, unsigned int lastBeat) 547 void TempoTrack::createPhaseExtractor(double *Filter, int /* winLength */, double period, int fsp, int lastBeat)
552 { 548 {
553 int p = (int)MathUtilities::round( period ); 549 int p = (int)MathUtilities::round( period );
554 int predictedOffset = 0; 550 int predictedOffset = 0;
555 551
556 #ifdef DEBUG_TEMPO_TRACK 552 #ifdef DEBUG_TEMPO_TRACK
582 { 578 {
583 int mu = p; 579 int mu = p;
584 double sigma = (double)p/8; 580 double sigma = (double)p/8;
585 double PhaseMin = 0.0; 581 double PhaseMin = 0.0;
586 double PhaseMax = 0.0; 582 double PhaseMax = 0.0;
587 unsigned int scratchLength = p*2; 583 int scratchLength = p*2;
588 double temp = 0.0; 584 double temp = 0.0;
589 585
590 for( int i = 0; i < scratchLength; i++ ) 586 for( int i = 0; i < scratchLength; i++ )
591 { 587 {
592 phaseScratch[ i ] = exp( -0.5 * pow( ( i - mu ) / sigma, 2 ) ) / ( sqrt( 2*PI ) *sigma ); 588 phaseScratch[ i ] = exp( -0.5 * pow( ( i - mu ) / sigma, 2 ) ) / ( sqrt( 2*PI ) *sigma );
602 598
603 #ifdef DEBUG_TEMPO_TRACK 599 #ifdef DEBUG_TEMPO_TRACK
604 std::cerr << "predictedOffset = " << predictedOffset << std::endl; 600 std::cerr << "predictedOffset = " << predictedOffset << std::endl;
605 #endif 601 #endif
606 602
607 unsigned int index = 0; 603 int index = 0;
608 for (int i = p - ( predictedOffset - 1); i < p + ( p - predictedOffset) + 1; i++) 604 for (int i = p - ( predictedOffset - 1); i < p + ( p - predictedOffset) + 1; i++)
609 { 605 {
610 #ifdef DEBUG_TEMPO_TRACK 606 #ifdef DEBUG_TEMPO_TRACK
611 std::cerr << "assigning to filter index " << index << " (size = " << p*2 << ")" << " value " << phaseScratch[i] << " from scratch index " << i << std::endl; 607 std::cerr << "assigning to filter index " << index << " (size = " << p*2 << ")" << " value " << phaseScratch[i] << " from scratch index " << i << std::endl;
612 #endif 608 #endif
622 } 618 }
623 619
624 delete [] phaseScratch; 620 delete [] phaseScratch;
625 } 621 }
626 622
627 int TempoTrack::phaseMM(double *DF, double *weighting, unsigned int winLength, double period) 623 int TempoTrack::phaseMM(double *DF, double *weighting, int winLength, double period)
628 { 624 {
629 int alignment = 0; 625 int alignment = 0;
630 int p = (int)MathUtilities::round( period ); 626 int p = (int)MathUtilities::round( period );
631 627
632 double temp = 0.0; 628 double temp = 0.0;
665 delete [] align; 661 delete [] align;
666 662
667 return alignment; 663 return alignment;
668 } 664 }
669 665
670 int TempoTrack::beatPredict(unsigned int FSP0, double alignment, double period, unsigned int step ) 666 int TempoTrack::beatPredict(int FSP0, double alignment, double period, int step )
671 { 667 {
672 int beat = 0; 668 int beat = 0;
673 669
674 int p = (int)MathUtilities::round( period ); 670 int p = (int)MathUtilities::round( period );
675 int align = (int)MathUtilities::round( alignment ); 671 int align = (int)MathUtilities::round( alignment );
710 vector <double> causalDF; 706 vector <double> causalDF;
711 707
712 causalDF = DF; 708 causalDF = DF;
713 709
714 //Prepare Causal Extension DFData 710 //Prepare Causal Extension DFData
715 unsigned int DFCLength = m_dataLength + m_winLength; 711 // int DFCLength = m_dataLength + m_winLength;
716 712
717 for( unsigned int j = 0; j < m_winLength; j++ ) 713 for( int j = 0; j < m_winLength; j++ )
718 { 714 {
719 causalDF.push_back( 0 ); 715 causalDF.push_back( 0 );
720 } 716 }
721 717
722 718
723 double* RW = new double[ m_lagLength ]; 719 double* RW = new double[ m_lagLength ];
724 for( unsigned int clear = 0; clear < m_lagLength; clear++){ RW[ clear ] = 0.0;} 720 for (int clear = 0; clear < m_lagLength; clear++){ RW[ clear ] = 0.0;}
725 721
726 double* GW = new double[ m_lagLength ]; 722 double* GW = new double[ m_lagLength ];
727 for(unsigned int clear = 0; clear < m_lagLength; clear++){ GW[ clear ] = 0.0;} 723 for (int clear = 0; clear < m_lagLength; clear++){ GW[ clear ] = 0.0;}
728 724
729 double* PW = new double[ m_lagLength ]; 725 double* PW = new double[ m_lagLength ];
730 for(unsigned clear = 0; clear < m_lagLength; clear++){ PW[ clear ] = 0.0;} 726 for(int clear = 0; clear < m_lagLength; clear++){ PW[ clear ] = 0.0;}
731 727
732 m_DFFramer.setSource( &causalDF[0], m_dataLength ); 728 m_DFFramer.setSource( &causalDF[0], m_dataLength );
733 729
734 unsigned int TTFrames = m_DFFramer.getMaxNoFrames(); 730 int TTFrames = m_DFFramer.getMaxNoFrames();
735 731
736 #ifdef DEBUG_TEMPO_TRACK 732 #ifdef DEBUG_TEMPO_TRACK
737 std::cerr << "TTFrames = " << TTFrames << std::endl; 733 std::cerr << "TTFrames = " << TTFrames << std::endl;
738 #endif 734 #endif
739 735
740 double* periodP = new double[ TTFrames ]; 736 double* periodP = new double[ TTFrames ];
741 for(unsigned clear = 0; clear < TTFrames; clear++){ periodP[ clear ] = 0.0;} 737 for(int clear = 0; clear < TTFrames; clear++){ periodP[ clear ] = 0.0;}
742 738
743 double* periodG = new double[ TTFrames ]; 739 double* periodG = new double[ TTFrames ];
744 for(unsigned clear = 0; clear < TTFrames; clear++){ periodG[ clear ] = 0.0;} 740 for(int clear = 0; clear < TTFrames; clear++){ periodG[ clear ] = 0.0;}
745 741
746 double* alignment = new double[ TTFrames ]; 742 double* alignment = new double[ TTFrames ];
747 for(unsigned clear = 0; clear < TTFrames; clear++){ alignment[ clear ] = 0.0;} 743 for(int clear = 0; clear < TTFrames; clear++){ alignment[ clear ] = 0.0;}
748 744
749 m_beats.clear(); 745 m_beats.clear();
750 746
751 createCombFilter( RW, m_lagLength, 0, 0 ); 747 createCombFilter( RW, m_lagLength, 0, 0 );
752 748
753 int TTLoopIndex = 0; 749 int TTLoopIndex = 0;
754 750
755 for( unsigned int i = 0; i < TTFrames; i++ ) 751 for( int i = 0; i < TTFrames; i++ )
756 { 752 {
757 m_DFFramer.getFrame( m_rawDFFrame ); 753 m_DFFramer.getFrame( m_rawDFFrame );
758 754
759 m_DFConditioning->process( m_rawDFFrame, m_smoothDFFrame ); 755 m_DFConditioning->process( m_rawDFFrame, m_smoothDFFrame );
760 756