Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions lib/qm-dsp/dsp/tempotracking/TempoTrackV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ TempoTrackV2::filter_df(d_vec_t &df)
void
TempoTrackV2::calculateBeatPeriod(const vector<double> &df,
vector<double> &beat_period,
vector<double> &tempi,
double inputtempo, bool constraintempo)
{
// to follow matlab.. split into 512 sample frames with a 128 hop size
Expand Down Expand Up @@ -168,7 +167,7 @@ TempoTrackV2::calculateBeatPeriod(const vector<double> &df,
}

// now call viterbi decoding function
viterbi_decode(rcfmat,wv,beat_period,tempi);
viterbi_decode(rcfmat,wv,beat_period);
}


Expand Down Expand Up @@ -228,7 +227,7 @@ TempoTrackV2::get_rcf(const d_vec_t &dfframe_in, const d_vec_t &wv, d_vec_t &rcf
}

void
TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &beat_period, d_vec_t &tempi)
TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &beat_period)
{
// following Kevin Murphy's Viterbi decoding to get best path of
// beat periods through rfcmat
Expand Down Expand Up @@ -316,13 +315,8 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
}

i_vec_t bestpath(T);
d_vec_t tmp_vec(Q);
for (int i = 0; i < Q; i++) {
tmp_vec[i] = delta[T-1][i];
}

// find starting point - best beat period for "last" frame
bestpath[T-1] = get_max_ind(tmp_vec);
bestpath[T-1] = get_max_ind(delta[T-1]);

// backtrace through index of maximum values in psi
for (int t=T-2; t>0 ;t--) {
Expand All @@ -346,10 +340,6 @@ TempoTrackV2::viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &
for (int i = lastind; i < int(beat_period.size()); i++) {
beat_period[i] = beat_period[lastind];
}

for (int i = 0; i < int(beat_period.size()); i++) {
tempi.push_back((60. * m_rate / m_increment)/beat_period[i]);
}
}

double
Expand Down
9 changes: 3 additions & 6 deletions lib/qm-dsp/dsp/tempotracking/TempoTrackV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ class TempoTrackV2

// Returned beat periods are given in df increment units; inputtempo and tempi in bpm
void calculateBeatPeriod(const std::vector<double> &df,
std::vector<double> &beatPeriod,
std::vector<double> &tempi) {
calculateBeatPeriod(df, beatPeriod, tempi, 120.0, false);
std::vector<double> &beatPeriod) {
calculateBeatPeriod(df, beatPeriod, 120.0, false);
}

// Returned beat periods are given in df increment units; inputtempo and tempi in bpm
// MEPD 28/11/12 Expose inputtempo and constraintempo parameters
// Note, if inputtempo = 120 and constraintempo = false, then functionality is as it was before
void calculateBeatPeriod(const std::vector<double> &df,
std::vector<double> &beatPeriod,
std::vector<double> &tempi,
double inputtempo, bool constraintempo);

// Returned beat positions are given in df increment units
Expand Down Expand Up @@ -80,8 +78,7 @@ class TempoTrackV2
double mean_array(const d_vec_t &dfin, int start, int end);
void filter_df(d_vec_t &df);
void get_rcf(const d_vec_t &dfframe, const d_vec_t &wv, d_vec_t &rcf);
void viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv,
d_vec_t &bp, d_vec_t &tempi);
void viterbi_decode(const d_mat_t &rcfmat, const d_vec_t &wv, d_vec_t &bp);
double get_max_val(const d_vec_t &df);
int get_max_ind(const d_vec_t &df);
void normalise_vec(d_vec_t &df);
Expand Down
Loading
Loading