Mercurial > audlegacy-plugins
annotate src/paranormal/beatdetect.c @ 679:c8dc00a58f0d trunk
[svn] - remove a bunch of pointless code. we don't do ID3 for raw AAC files at this time.
| author | nenolod |
|---|---|
| date | Tue, 20 Feb 2007 04:13:46 -0800 |
| 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 } |
