Mercurial > audlegacy-plugins
annotate src/rovascope/beatdetect.c @ 1257:574ee15195f3
- Fixes for flac_is_our_fd
author | Ralf Ertzinger <ralf@skytale.net> |
---|---|
date | Fri, 13 Jul 2007 13:28:18 +0200 |
parents | 290588854a9d |
children |
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 } |