~mr-unwell2006/mixxx/mixxx

« back to all changes in this revision

Viewing changes to mixxx/src/beattools.cpp

  • Committer: Vittorio
  • Date: 2012-01-07 14:06:53 UTC
  • Revision ID: l0rdt@gmx.it-20120107140653-14yf1d45b2m8kr75
*beattools.cpp: Fix for tracks with less than 8 beats

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
     */
58
58
    int max_frequency = 0;
59
59
    double most_freq_bpm = 0;
 
60
    double avg_bpm = 0;
60
61
    for(int i=N; i < beats.size(); i+=N){
61
62
        //get start and end sample of the beats
62
63
        double start_sample = beats.at(i-N);
64
65
 
65
66
        //Time needed to count a bar (4 beats)
66
67
        double time = (end_sample - start_sample)/(SampleRate);
67
 
        double avg_bpm = 60*N / time;
 
68
        avg_bpm = 60*N / time;
68
69
 
69
70
        if(avg_bpm < min_bpm)
70
71
        {
105
106
     * see http://en.wikipedia.org/wiki/Median#The_sample_median
106
107
     */
107
108
    double median = 0;
 
109
    if(average_bpm_list.size()==0)
 
110
        return avg_bpm;
108
111
    if(average_bpm_list.size() % 2 == 0){
109
112
        //build avg of {(n)/2} and {(n)/2}+1 in the sorted list
110
113
        int item_position = (average_bpm_list.size())/2;