Mercurial > audlegacy-plugins
annotate src/paranormal/beatdetect.c @ 2499:4d6045c20cc5
Include cleanups, part #4.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 31 Mar 2008 15:18:05 +0300 |
parents | 3b034150d31e |
children | f1b6f1b2cdb3 |
rev | line source |
---|---|
1892
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
1 /* |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
2 * paranormal: iterated pipeline-driven visualization plugin |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
3 * Copyright (c) 2006, 2007 William Pitcock <nenolod@dereferenced.org> |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
4 * Portions copyright (c) 2001 Jamie Gennis <jgennis@mindspring.com> |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
5 * |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
8 * the Free Software Foundation; under version 2 of the License. |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
9 * |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
13 * GNU General Public License for more details. |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
14 * |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
18 */ |
3b034150d31e
Add GPL2 boilerplate text.
William Pitcock <nenolod@atheme.org>
parents:
281
diff
changeset
|
19 |
170
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
20 #include "paranormal.h" |
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
21 |
281 | 22 /* |
23 * This algorithm is by Janusz Gregorcyzk, the implementation is | |
24 * mine, however. | |
25 * | |
26 * -- nenolod | |
27 */ | |
170
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
28 int |
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
29 pn_is_new_beat(void) |
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
30 { |
281 | 31 gint i; |
32 gint total = 0; | |
33 gboolean ret = FALSE; | |
34 static gint previous; | |
170
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
35 |
281 | 36 for (i = 1; i < 512; i++) |
37 { | |
38 total += abs (pn_sound_data->pcm_data[0][i] - | |
39 pn_sound_data->pcm_data[0][i - 1]); | |
40 } | |
41 | |
42 total /= 512; | |
43 | |
44 ret = (total > (2 * previous)); | |
45 | |
46 previous = total; | |
47 | |
48 return ret; | |
170
13955c70fbec
[svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff
changeset
|
49 } |