annotate src/paranormal/beatdetect.c @ 188:0d826917c56f trunk

[svn] - 64-bit safety (pass 1 of 2)
author nenolod
date Thu, 02 Nov 2006 18:22:02 -0800
parents 13955c70fbec
children 65c4d8591b4a
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
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
3 int
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
4 pn_is_new_beat(void)
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
5 {
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
6 /* quantize the average energy of the pcm_data for beat detection. */
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
7 int fftsum =
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
8 ((pn_sound_data->pcm_data[0][0] + pn_sound_data->pcm_data[1][0]) >> 6);
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
9
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
10 /*
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
11 * if the energy's quantization is within this, trigger as a detected
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
12 * beat, otherwise don't.
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
13 */
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
14 return (fftsum >= 300 && fftsum <= 600) ? 1 : 0;
13955c70fbec [svn] - split out beat detection code into beatdetect.c
nenolod
parents:
diff changeset
15 }