@@ -43,24 +43,24 @@ BeatDetect::BeatDetect(PCM *_pcm)
4343
4444 this ->vol_instant =0 ;
4545 this ->vol_history =0 ;
46- for (unsigned y=0 ;y<80 ;y++)
46+ for (unsigned y=0 ;y<BEAT_HISTORY_LENGTH ;y++)
4747 this ->vol_buffer [y]=0 ;
4848
4949 this ->beat_buffer_pos =0 ;
5050
5151 this ->bass_instant = 0 ;
5252 this ->bass_history = 0 ;
53- for (unsigned y=0 ;y<80 ;y++)
53+ for (unsigned y=0 ;y<BEAT_HISTORY_LENGTH ;y++)
5454 this ->bass_buffer [y]=0 ;
5555
5656 this ->mid_instant = 0 ;
5757 this ->mid_history = 0 ;
58- for (unsigned y=0 ;y<80 ;y++)
58+ for (unsigned y=0 ;y<BEAT_HISTORY_LENGTH ;y++)
5959 this ->mid_buffer [y]=0 ;
6060
6161 this ->treb_instant = 0 ;
6262 this ->treb_history = 0 ;
63- for (unsigned y=0 ;y<80 ;y++)
63+ for (unsigned y=0 ;y<BEAT_HISTORY_LENGTH ;y++)
6464 this ->treb_buffer [y]=0 ;
6565
6666 this ->treb = 0 ;
@@ -125,39 +125,39 @@ void BeatDetect::getBeatVals( float samplerate, unsigned fft_length, float *vdat
125125 bass_instant += (vdataL[i*2 ]*vdataL[i*2 ]) + (vdataR[i*2 ]*vdataR[i*2 ]);
126126 }
127127 bass_instant *= 100.0 /(ranges[1 ]-ranges[0 ]);
128- bass_history -= bass_buffer[beat_buffer_pos] *. 0125 ;
128+ bass_history -= bass_buffer[beat_buffer_pos] * ( 1.0 /BEAT_HISTORY_LENGTH) ;
129129 bass_buffer[beat_buffer_pos] = bass_instant;
130- bass_history += bass_instant *. 0125 ;
130+ bass_history += bass_instant * ( 1.0 /BEAT_HISTORY_LENGTH) ;
131131
132132 mid_instant = 0 ;
133133 for (unsigned i=ranges[1 ]+1 ; i<=ranges[2 ] ; i++)
134134 {
135135 mid_instant += (vdataL[i*2 ]*vdataL[i*2 ]) + (vdataR[i*2 ]*vdataR[i*2 ]);
136136 }
137137 mid_instant *= 100.0 /(ranges[2 ]-ranges[1 ]);
138- mid_history -= mid_buffer[beat_buffer_pos] *. 0125 ;
138+ mid_history -= mid_buffer[beat_buffer_pos] * ( 1.0 /BEAT_HISTORY_LENGTH) ;
139139 mid_buffer[beat_buffer_pos] = mid_instant;
140- mid_history += mid_instant *. 0125 ;
140+ mid_history += mid_instant * ( 1.0 /BEAT_HISTORY_LENGTH) ;
141141
142142 treb_instant = 0 ;
143143 for (unsigned i=ranges[2 ]+1 ; i<=ranges[3 ] ; i++)
144144 {
145145 treb_instant += (vdataL[i*2 ]*vdataL[i*2 ]) + (vdataR[i*2 ]*vdataR[i*2 ]);
146146 }
147147 treb_instant *= 90.0 /(ranges[3 ]-ranges[2 ]);
148- treb_history -= treb_buffer[beat_buffer_pos] *. 0125 ;
148+ treb_history -= treb_buffer[beat_buffer_pos] * ( 1.0 /BEAT_HISTORY_LENGTH) ;
149149 treb_buffer[beat_buffer_pos] = treb_instant;
150- treb_history += treb_instant *. 0125 ;
150+ treb_history += treb_instant * ( 1.0 /BEAT_HISTORY_LENGTH) ;
151151
152152 vol_instant = (bass_instant + mid_instant + treb_instant) / 3 .0f ;
153- vol_history -= (vol_buffer[beat_buffer_pos])*. 0125 ;
153+ vol_history -= (vol_buffer[beat_buffer_pos])* ( 1.0 /BEAT_HISTORY_LENGTH) ;
154154 vol_buffer[beat_buffer_pos] = vol_instant;
155- vol_history += ( vol_instant)*. 0125 ;
155+ vol_history += vol_instant * ( 1.0 /BEAT_HISTORY_LENGTH) ;
156156
157157// fprintf(stderr, "%6.3f %6.2f %6.3f\n", bass_history/vol_history, mid_history/vol_history, treb_history/vol_history);
158- bass = bass_instant / fmax (0.0001 , bass_history + 0.5 *vol_history);
159- mid = mid_instant / fmax (0.0001 , mid_history + 0.5 *vol_history);
160- treb = treb_instant / fmax (0.0001 , treb_history + 0.5 *vol_history);
158+ bass = bass_instant / fmax (0.0001 , 1.3 * bass_history + 0.2 *vol_history);
159+ mid = mid_instant / fmax (0.0001 , 1.3 * mid_history + 0.2 *vol_history);
160+ treb = treb_instant / fmax (0.0001 , 1.3 * treb_history + 0.2 *vol_history);
161161 vol = vol_instant / fmax (0.0001 , 1 .5f * vol_history);
162162
163163 if ( projectM_isnan ( treb ) ) {
0 commit comments