comparison src/BTrack.cpp @ 15:2b94d3d2fb9d develop

Reformatted comments, removed the OnsetDetectionFunction constructor with no arguments, removed a number of unused variables and made changes to the python module to fix some casting problems and removed some unused variables there also. Still getting the same results, so no overall changes to the algorithm.
author Adam <adamstark.uk@gmail.com>
date Wed, 22 Jan 2014 01:13:45 +0000
parents 18fc3c248436
children 73c64ca0ed23
comparison
equal deleted inserted replaced
14:18fc3c248436 15:2b94d3d2fb9d
17 * You should have received a copy of the GNU General Public License 17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */ 19 */
20 //======================================================================= 20 //=======================================================================
21 21
22 #include <iostream>
23 #include <cmath> 22 #include <cmath>
23 #include <algorithm>
24 #include "BTrack.h" 24 #include "BTrack.h"
25 #include "samplerate.h" 25 #include "samplerate.h"
26 using namespace std;
27
28
29 26
30 27
31 //======================================================================= 28 //=======================================================================
32 BTrack :: BTrack() 29 BTrack :: BTrack()
33 { 30 {
379 float x_thresh[N]; 376 float x_thresh[N];
380 377
381 int p_post = 7; 378 int p_post = 7;
382 int p_pre = 8; 379 int p_pre = 8;
383 380
384 t = min(N,p_post); // what is smaller, p_post of df size. This is to avoid accessing outside of arrays 381 t = std::min(N,p_post); // what is smaller, p_post of df size. This is to avoid accessing outside of arrays
385 382
386 // find threshold for first 't' samples, where a full average cannot be computed yet 383 // find threshold for first 't' samples, where a full average cannot be computed yet
387 for (i = 0;i <= t;i++) 384 for (i = 0;i <= t;i++)
388 { 385 {
389 k = min((i+p_pre),N); 386 k = std::min((i+p_pre),N);
390 x_thresh[i] = mean_array(x,1,k); 387 x_thresh[i] = mean_array(x,1,k);
391 } 388 }
392 // find threshold for bulk of samples across a moving average from [i-p_pre,i+p_post] 389 // find threshold for bulk of samples across a moving average from [i-p_pre,i+p_post]
393 for (i = t+1;i < N-p_post;i++) 390 for (i = t+1;i < N-p_post;i++)
394 { 391 {
395 x_thresh[i] = mean_array(x,i-p_pre,i+p_post); 392 x_thresh[i] = mean_array(x,i-p_pre,i+p_post);
396 } 393 }
397 // for last few samples calculate threshold, again, not enough samples to do as above 394 // for last few samples calculate threshold, again, not enough samples to do as above
398 for (i = N-p_post;i < N;i++) 395 for (i = N-p_post;i < N;i++)
399 { 396 {
400 k = max((i-p_post),1); 397 k = std::max((i-p_post),1);
401 x_thresh[i] = mean_array(x,k,N); 398 x_thresh[i] = mean_array(x,k,N);
402 } 399 }
403 400
404 // subtract the threshold from the detection function and check that it is not less than 0 401 // subtract the threshold from the detection function and check that it is not less than 0
405 for (i = 0;i < N;i++) 402 for (i = 0;i < N;i++)