You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
MicroDexed/audio_timer.cpp

43 lines
637 B

#include <Audio.h>
#include "config.h"
#include "audio_timer.h"
void AudioTimer::update(void)
{
audio_block_t *in;
in = receiveReadOnly(0);
if (in)
release(in);
tick++;
if (tick >= float(beat)*float(bpm) + 0.5)
{
if (sequencer_step_function != NULL)
(*sequencer_step_function)();
tick = 0;
}
}
uint32_t AudioTimer::get_tick(void)
{
return (tick);
}
void AudioTimer::set_bpm(uint8_t b)
{
bpm = b;
}
void AudioTimer::function(uint8_t steps, void(*func)())
{
if (func != NULL)
{
sequencer_step_function = func;
steps = bpm * steps / 4;
}
else
sequencer_step_function = NULL;
}