static void MaxAcf (mrs_real& max, mrs_real& mean, const realvec& beatHistogram, realvec& res,mrs_natural startSearchAt, mrs_natural stopSearchAt) { mrs_natural k,len = beatHistogram.getCols (); res.setval(0.); // compute ACF for (k = startSearchAt; k < stopSearchAt; k++) // this can be optimized { mrs_real val = 0; for (mrs_natural i = k; i < len; i++) { val += beatHistogram(i) * beatHistogram(i-k); } res(k) = val / (len-k); } //pkr_->process(in, pkres_); max = res.maxval (); mean = 1e6*res.mean (); }
void Peak2Rms::myProcess(realvec& in, realvec& out) { mrs_real peak = in.maxval(); mrs_real rms = 0.0; mrs_natural t; for (t = 0; t < inSamples_; t++) { rms += in(0,t) * in(0,t); } rms /= inSamples_; rms = sqrt(rms); out(0) = peak/rms; }