# HG changeset patch # User nenolod # Date 1162365229 28800 # Node ID 13955c70fbec44cbf3c8dbd141bf1c7575fcc676 # Parent c99b7428082704ddbfda7ccd278d1cace3d907f1 [svn] - split out beat detection code into beatdetect.c diff -r c99b74280827 -r 13955c70fbec ChangeLog --- a/ChangeLog Tue Oct 31 22:55:20 2006 -0800 +++ b/ChangeLog Tue Oct 31 23:13:49 2006 -0800 @@ -1,3 +1,12 @@ +2006-11-01 06:55:20 +0000 William Pitcock + revision [338] + - another example preset showing the true power of on-beat branched execution + + trunk/src/paranormal/presets/Makefile | 3 + trunk/src/paranormal/presets/nenolod_-_beatscope.pnv | 71 +++++++++++++++++++ + 2 files changed, 73 insertions(+), 1 deletion(-) + + 2006-11-01 06:42:55 +0000 William Pitcock revision [336] - support lookup of actuator templates by their display name diff -r c99b74280827 -r 13955c70fbec src/paranormal/Makefile --- a/src/paranormal/Makefile Tue Oct 31 22:55:20 2006 -0800 +++ b/src/paranormal/Makefile Tue Oct 31 23:13:49 2006 -0800 @@ -11,6 +11,7 @@ SOURCES = \ actuators.c \ + beatdetect.c \ builtins.c \ cfg.c \ cmaps.c \ diff -r c99b74280827 -r 13955c70fbec src/paranormal/beatdetect.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/paranormal/beatdetect.c Tue Oct 31 23:13:49 2006 -0800 @@ -0,0 +1,15 @@ +#include "paranormal.h" + +int +pn_is_new_beat(void) +{ + /* quantize the average energy of the pcm_data for beat detection. */ + int fftsum = + ((pn_sound_data->pcm_data[0][0] + pn_sound_data->pcm_data[1][0]) >> 6); + + /* + * if the energy's quantization is within this, trigger as a detected + * beat, otherwise don't. + */ + return (fftsum >= 300 && fftsum <= 600) ? 1 : 0; +} diff -r c99b74280827 -r 13955c70fbec src/paranormal/containers.c --- a/src/paranormal/containers.c Tue Oct 31 22:55:20 2006 -0800 +++ b/src/paranormal/containers.c Tue Oct 31 23:13:49 2006 -0800 @@ -175,16 +175,7 @@ { struct container_cycle_data *cdata = (struct container_cycle_data*)data; int now; - - /* quantize the average energy of the pcm_data for beat detection. */ - int fftsum = - ((pn_sound_data->pcm_data[0][0] + pn_sound_data->pcm_data[1][0]) >> 6); - - /* - * if the energy's quantization is within this, trigger as a detected - * beat. - */ - int new_beat = (fftsum >= 300 && fftsum <= 600) ? 1 : 0; + int new_beat = pn_is_new_beat(); /* * Change branch if all of the requirements are met for the branch to change. diff -r c99b74280827 -r 13955c70fbec src/paranormal/paranormal.h --- a/src/paranormal/paranormal.h Tue Oct 31 22:55:20 2006 -0800 +++ b/src/paranormal/paranormal.h Tue Oct 31 23:13:49 2006 -0800 @@ -50,4 +50,7 @@ extern float sin_val[360]; extern float cos_val[360]; +/* beat detection */ +int pn_is_new_beat(void); + #endif /* _PARANORMAL_H */