beat_detect: use get_sample()
Signed-off-by: Thomas Schmid <tom@lfence.de>
This commit is contained in:
parent
b3ce3e0169
commit
ea9aa04022
@ -35,8 +35,6 @@ static float angle2;
|
|||||||
|
|
||||||
static float pos_target = NUM_LEDS / 2;
|
static float pos_target = NUM_LEDS / 2;
|
||||||
static float pos_target_filtered = NUM_LEDS / 2;
|
static float pos_target_filtered = NUM_LEDS / 2;
|
||||||
|
|
||||||
static float microphone_offset = 1900;
|
|
||||||
static long initial_time;
|
static long initial_time;
|
||||||
|
|
||||||
static int active = 15;
|
static int active = 15;
|
||||||
@ -85,17 +83,13 @@ void setup()
|
|||||||
}
|
}
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
float sample = get_sample();
|
||||||
int sample = int(analogRead(MIC_PIN) - microphone_offset);
|
energy += std::abs(sample) * std::abs(sample);
|
||||||
energy += abs(sample) * abs(sample);
|
|
||||||
n_samples++;
|
n_samples++;
|
||||||
|
|
||||||
if (micros() - last_us_bp > sampling_period_bp)
|
if (micros() - last_us_bp > sampling_period_bp)
|
||||||
{
|
{
|
||||||
Serial.println(n_samples);
|
|
||||||
n_samples = 0;
|
n_samples = 0;
|
||||||
|
|
||||||
microphone_offset += (analogRead(MIC_PIN) - microphone_offset) * 0.001;
|
|
||||||
last_us_bp += sampling_period_bp;
|
last_us_bp += sampling_period_bp;
|
||||||
//energy_fil += (energy - energy_fil) * 0.01;
|
//energy_fil += (energy - energy_fil) * 0.01;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user