# HG changeset patch # User nenolod # Date 1164056768 28800 # Node ID 65c4d8591b4a0dbf5e7396e0c3e827592d977c16 # Parent 3b5878a7c62fc749612f21ae0be85a2282dac7a3 [svn] - pinch xvs's beat detection algorithm. diff -r 3b5878a7c62f -r 65c4d8591b4a ChangeLog --- a/ChangeLog Mon Nov 20 09:06:45 2006 -0800 +++ b/ChangeLog Mon Nov 20 13:06:08 2006 -0800 @@ -1,3 +1,11 @@ +2006-11-20 17:06:45 +0000 Derek Pomery + revision [594] + typo + + trunk/m4/libFLAC.m4 | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + + 2006-11-20 06:54:10 +0000 Yoshiki Yazawa revision [586] build fixes: diff -r 3b5878a7c62f -r 65c4d8591b4a src/paranormal/beatdetect.c --- a/src/paranormal/beatdetect.c Mon Nov 20 09:06:45 2006 -0800 +++ b/src/paranormal/beatdetect.c Mon Nov 20 13:06:08 2006 -0800 @@ -1,15 +1,30 @@ #include "paranormal.h" +/* + * This algorithm is by Janusz Gregorcyzk, the implementation is + * mine, however. + * + * -- nenolod + */ int pn_is_new_beat(void) { - /* quantize the average energy of the pcm_data for beat detection. */ - int fftsum = - ((pn_sound_data->pcm_data[0][0] + pn_sound_data->pcm_data[1][0]) >> 6); + gint i; + gint total = 0; + gboolean ret = FALSE; + static gint previous; - /* - * if the energy's quantization is within this, trigger as a detected - * beat, otherwise don't. - */ - return (fftsum >= 300 && fftsum <= 600) ? 1 : 0; + for (i = 1; i < 512; i++) + { + total += abs (pn_sound_data->pcm_data[0][i] - + pn_sound_data->pcm_data[0][i - 1]); + } + + total /= 512; + + ret = (total > (2 * previous)); + + previous = total; + + return ret; }