Mercurial > hg > qm-dsp
comparison dsp/tempotracking/TempoTrack.cpp @ 6:a9bf0cfe9383
* Make tempo tracker return locked tempo as well as beats
author | cannam |
---|---|
date | Fri, 08 Dec 2006 18:05:36 +0000 |
parents | d7116e3183f8 |
children | 2e3f5d2d62c1 |
comparison
equal
deleted
inserted
replaced
5:1e6d89e4f441 | 6:a9bf0cfe9383 |
---|---|
10 | 10 |
11 #include "TempoTrack.h" | 11 #include "TempoTrack.h" |
12 | 12 |
13 #include "dsp/maths/MathAliases.h" | 13 #include "dsp/maths/MathAliases.h" |
14 #include "dsp/maths/MathUtilities.h" | 14 #include "dsp/maths/MathUtilities.h" |
15 | |
16 #include <iostream> | |
15 | 17 |
16 | 18 |
17 ////////////////////////////////////////////////////////////////////// | 19 ////////////////////////////////////////////////////////////////////// |
18 // Construction/Destruction | 20 // Construction/Destruction |
19 ////////////////////////////////////////////////////////////////////// | 21 ////////////////////////////////////////////////////////////////////// |
164 { | 166 { |
165 maxValRCF = m_tempoScratch[ i ]; | 167 maxValRCF = m_tempoScratch[ i ]; |
166 maxIndexRCF = i; | 168 maxIndexRCF = i; |
167 } | 169 } |
168 } | 170 } |
169 | 171 |
172 double locked = 5168.f / maxIndexRCF; | |
173 if (locked >= 30 && locked <= 180) { | |
174 m_lockedTempo = locked; | |
175 } | |
176 | |
170 if( tsig == 0 ) | 177 if( tsig == 0 ) |
171 tsig = 4; | 178 tsig = 4; |
172 | 179 |
173 | 180 |
174 if( tsig == 4 ) | 181 if( tsig == 4 ) |
632 | 639 |
633 | 640 |
634 | 641 |
635 | 642 |
636 | 643 |
637 vector<int> TempoTrack::process( vector <double> DF ) | 644 vector<int> TempoTrack::process( vector <double> DF, |
645 vector <double> *tempoReturn ) | |
638 { | 646 { |
639 m_dataLength = DF.size(); | 647 m_dataLength = DF.size(); |
640 | 648 |
649 m_lockedTempo = 0.0; | |
650 | |
641 double period = 0.0; | 651 double period = 0.0; |
642 int stepFlag = 0; | 652 int stepFlag = 0; |
643 int constFlag = 0; | 653 int constFlag = 0; |
644 int FSP = 0; | 654 int FSP = 0; |
645 int tsig = 0; | 655 int tsig = 0; |
756 | 766 |
757 lastBeat = beatPredict(FSP, alignment[ TTLoopIndex ], period, m_lagLength ); | 767 lastBeat = beatPredict(FSP, alignment[ TTLoopIndex ], period, m_lagLength ); |
758 | 768 |
759 FSP += (m_lagLength); | 769 FSP += (m_lagLength); |
760 | 770 |
771 if (tempoReturn) tempoReturn->push_back(m_lockedTempo); | |
772 | |
761 TTLoopIndex++; | 773 TTLoopIndex++; |
762 } | 774 } |
763 | 775 |
764 | 776 |
765 delete [] periodP; | 777 delete [] periodP; |