view src/rovascope/beatdetect.c @ 1153:b391fddc35b2 trunk

[svn] Fix handling of SPC efb register when echo instruction has been called. Shift right of 14 is too high of a modifier and does not match the response of the FIR filter in the SPC700. Shift right of 16 delivers a more accurate result.
author nenolod
date Tue, 29 May 2007 21:57:06 -0700
parents 290588854a9d
children
line wrap: on
line source

#include "paranormal.h"

/*
 * This algorithm is by Janusz Gregorcyzk, the implementation is
 * mine, however.
 *
 *   -- nenolod
 */
int
pn_is_new_beat(void)
{
  gint i;
  gint total = 0;
  gboolean ret = FALSE;
  static gint previous;

  for (i = 1; i < 512; i++)
    {
       total += abs (pn_sound_data->pcm_data[0][i] -
		     pn_sound_data->pcm_data[0][i - 1]);
    }

  total /= 512;

  ret = (total > (2 * previous));

  previous = total;

  return ret;
}