Mercurial > audlegacy-plugins
annotate src/paranormal/beatdetect.c @ 3161:6dd886b5c72b
revive stdio plugin for now. gio cannot write id3 tags.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Mon, 13 Jul 2009 23:53:41 +0900 |
parents | f1b6f1b2cdb3 |
children |
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 |
2835 | 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
1892
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 } |