annotate src/rovascope/beatdetect.c @ 989:84bef123b22e trunk

[svn] - provide full metadata from the file's tuple when performing the transcode
author nenolod
date Mon, 30 Apr 2007 22:03:19 -0700
parents 290588854a9d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
3 /*
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
4 * This algorithm is by Janusz Gregorcyzk, the implementation is
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
5 * mine, however.
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
6 *
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
7 * -- nenolod
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
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
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
12 gint i;
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
13 gint total = 0;
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
14 gboolean ret = FALSE;
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
15 static gint previous;
170
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
16
281
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
17 for (i = 1; i < 512; i++)
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
18 {
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
19 total += abs (pn_sound_data->pcm_data[0][i] -
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
20 pn_sound_data->pcm_data[0][i - 1]);
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
21 }
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
22
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
23 total /= 512;
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
24
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
25 ret = (total > (2 * previous));
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
26
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
27 previous = total;
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
28
65c4d8591b4a [svn] - pinch xvs's beat detection algorithm.
nenolod
parents: 170
diff changeset
29 return ret;
170
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
30 }