Mercurial > hg > multitrack-audio-matcher
comparison bayesianArraySrc/DynamicVector.cpp @ 20:4f6006cac9de
added evaluation of recorded tempo, holding of this data, drawing of recorded and playing tempo estimates
author | Andrew N Robertson <andrew.robertson@eecs.qmul.ac.uk> |
---|---|
date | Sun, 12 Feb 2012 00:48:07 +0000 |
parents | 780def3a1f36 |
children | eb43b2a007ea |
comparison
equal
deleted
inserted
replaced
19:1a62561bd72d | 20:4f6006cac9de |
---|---|
173 } | 173 } |
174 | 174 |
175 | 175 |
176 | 176 |
177 void DynamicVector::addGaussianShapeFromRealTime(const double& actualTime, const double& StdDev, double factor){ | 177 void DynamicVector::addGaussianShapeFromRealTime(const double& actualTime, const double& StdDev, double factor){ |
178 | 178 //could be further optimised |
179 double mean = getRealTermsAsIndex(actualTime); | 179 double mean = getRealTermsAsIndex(actualTime); |
180 // printf("Gaussian realtime %f at index %f\n", actualTime, mean); | 180 double standardDeviation = StdDev / scalar;//in vector indices from real time (ms) |
181 int i; | 181 //printf("Gaussian realtime %f at index %f std dev %f vec indices %f\n", actualTime, mean, StdDev, standardDeviation ); |
182 double std_dev_factor = (2*StdDev*StdDev); | 182 int i; |
183 factor *= (1/(StdDev*sqrt(2*PI))); | 183 double std_dev_factor = (2*standardDeviation*standardDeviation); |
184 int maxVal = min((int) array.size(), (int)(mean + 4.8*StdDev)); | 184 factor *= (1/(standardDeviation*sqrt(2*PI))); |
185 int minVal = max(0, (int)(mean - 4.8*StdDev)); | 185 int maxVal = min((int) array.size(), (int)(mean + 4.8*standardDeviation)); |
186 int minVal = max(0, (int)(mean - 4.8*standardDeviation)); | |
186 | 187 |
187 for (i=minVal;i < maxVal;i++){ | 188 for (i=minVal;i < maxVal;i++){ |
188 array[i] += factor*exp(-1*(i-mean)*(i-mean)/(std_dev_factor)); | 189 array[i] += factor*exp(-1*(i-mean)*(i-mean)/(std_dev_factor)); |
189 } | 190 } |
190 | 191 |