Mercurial > audlegacy-plugins
annotate src/paranormal-ng/beatdetect.c @ 2202:f76e846d53d9
updating TLEN frame returned
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Mon, 03 Dec 2007 01:26:57 +0300 |
parents | 1fa3c8cd366a |
children | f1b6f1b2cdb3 |
rev | line source |
---|---|
2078
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
1 /* |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
2 * paranormal: iterated pipeline-driven visualization plugin |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
3 * Copyright (c) 2006, 2007 William Pitcock <nenolod@dereferenced.org> |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
4 * Portions copyright (c) 2001 Jamie Gennis <jgennis@mindspring.com> |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
5 * |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
8 * the Free Software Foundation; under version 2 of the License. |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
9 * |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
13 * GNU General Public License for more details. |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
14 * |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
18 */ |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
19 |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
20 #include "paranormal.h" |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
21 |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
22 /* |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
23 * This algorithm is by Janusz Gregorcyzk, the implementation is |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
24 * mine, however. |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
25 * |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
26 * -- nenolod |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
27 */ |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
28 int |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
29 pn_is_new_beat(void) |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
30 { |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
31 gint i; |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
32 gint total = 0; |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
33 gboolean ret = FALSE; |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
34 static gint previous; |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
35 |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
36 for (i = 1; i < 512; i++) |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
37 { |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
38 total += abs (pn_sound_data->pcm_data[0][i] - |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
39 pn_sound_data->pcm_data[0][i - 1]); |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
40 } |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
41 |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
42 total /= 512; |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
43 |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
44 ret = (total > (2 * previous)); |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
45 |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
46 previous = total; |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
47 |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
48 return ret; |
1fa3c8cd366a
paranormal-ng: a GL visualiser. lots to do, most stuff won't work, but hey, this will do cool stuff too soon
William Pitcock <nenolod@atheme.org>
parents:
diff
changeset
|
49 } |