# HG changeset patch # User nenolod # Date 1162361344 28800 # Node ID a118245b88c7c9a85fbdf2345053277189143ad2 # Parent f57b76df3d96d9e168347a284f7372b5d6fb70f9 [svn] - use a quantized variance instead of a fast fft sum for beat detection with thresholding diff -r f57b76df3d96 -r a118245b88c7 ChangeLog --- 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 + 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 revision [328] - clean up about box diff -r f57b76df3d96 -r a118245b88c7 src/paranormal/containers.c --- 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;