changeset 166:a118245b88c7 trunk

[svn] - use a quantized variance instead of a fast fft sum for beat detection with thresholding
author nenolod
date Tue, 31 Oct 2006 22:09:04 -0800
parents f57b76df3d96
children c9d736cdc93f
files ChangeLog src/paranormal/containers.c
diffstat 2 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Oct 31 21:33:37 2006 -0800
+++ b/ChangeLog	Tue Oct 31 22:09:04 2006 -0800
@@ -1,3 +1,11 @@
+2006-11-01 05:33:37 +0000  William Pitcock <nenolod@nenolod.net>
+  revision [330]
+  - update this preset for the new version of the branching container.
+  
+  trunk/src/paranormal/presets/nenolod_-_quakingscope.pnv |    2 +-
+  1 file changed, 1 insertion(+), 1 deletion(-)
+
+
 2006-11-01 05:28:30 +0000  William Pitcock <nenolod@nenolod.net>
   revision [328]
   - clean up about box
--- a/src/paranormal/containers.c	Tue Oct 31 21:33:37 2006 -0800
+++ b/src/paranormal/containers.c	Tue Oct 31 22:09:04 2006 -0800
@@ -154,7 +154,6 @@
   GSList *children;
   GSList *current;
   int last_change;
-  int last_beat;
 };
 
 static void
@@ -176,12 +175,21 @@
 {
   struct container_cycle_data *cdata = (struct container_cycle_data*)data;
   int now;
-  int new_beat = ((pn_sound_data->pcm_data[0][0]+pn_sound_data->pcm_data[1][0]) >> 7) >= 80 ? 1 : 0;
+
+  /* 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 >= 350 && fftsum <= 600) ? 1 : 0;
 
   /*
    * Change branch if all of the requirements are met for the branch to change.
    */
-  if ((opts[1].val.bval == TRUE && new_beat != cdata->last_beat) || opts[1].val.bval == FALSE)
+  if ((opts[1].val.bval == TRUE && new_beat != 0) || opts[1].val.bval == FALSE)
     {
        now = SDL_GetTicks();	
 
@@ -196,9 +204,6 @@
          }
     }
 
-  /* reset the tracking for on-beat branch changing. */
-  cdata->last_beat = new_beat;  
-
   if (! cdata->current)
     cdata->current = cdata->children;