Mercurial > audlegacy-plugins
diff src/paranormal/containers.c @ 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 | 0393aae79318 |
children | c9d736cdc93f |
line wrap: on
line diff
--- 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;