Mercurial > audlegacy-plugins
annotate src/paranormal/beatdetect.c @ 1150:3506c611a802 trunk
[svn] - fix registration of lastfm session ID
author | nenolod |
---|---|
date | Mon, 28 May 2007 23:29:02 -0700 |
parents | 65c4d8591b4a |
children | 3b034150d31e |
rev | line source |
---|---|
170
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
1 #include "paranormal.h" |
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
2 |
281 | 3 /* |
4 * This algorithm is by Janusz Gregorcyzk, the implementation is | |
5 * mine, however. | |
6 * | |
7 * -- nenolod | |
8 */ | |
170
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
9 int |
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
10 pn_is_new_beat(void) |
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
11 { |
281 | 12 gint i; |
13 gint total = 0; | |
14 gboolean ret = FALSE; | |
15 static gint previous; | |
170
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
16 |
281 | 17 for (i = 1; i < 512; i++) |
18 { | |
19 total += abs (pn_sound_data->pcm_data[0][i] - | |
20 pn_sound_data->pcm_data[0][i - 1]); | |
21 } | |
22 | |
23 total /= 512; | |
24 | |
25 ret = (total > (2 * previous)); | |
26 | |
27 previous = total; | |
28 | |
29 return ret; | |
170
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
30 } |