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.
43 lines
637 B
43 lines
637 B
3 years ago
|
#include <Audio.h>
|
||
|
#include "config.h"
|
||
3 years ago
|
#include "audio_timer.h"
|
||
3 years ago
|
|
||
3 years ago
|
void AudioTimer::update(void)
|
||
3 years ago
|
{
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
uint32_t AudioTimer::get_tick(void)
|
||
3 years ago
|
{
|
||
|
return (tick);
|
||
|
}
|
||
|
|
||
3 years ago
|
void AudioTimer::set_bpm(uint8_t b)
|
||
3 years ago
|
{
|
||
|
bpm = b;
|
||
|
}
|
||
|
|
||
3 years ago
|
void AudioTimer::function(uint8_t steps, void(*func)())
|
||
3 years ago
|
{
|
||
|
if (func != NULL)
|
||
3 years ago
|
{
|
||
3 years ago
|
sequencer_step_function = func;
|
||
3 years ago
|
steps = bpm * steps / 4;
|
||
|
}
|
||
3 years ago
|
else
|
||
|
sequencer_step_function = NULL;
|
||
|
}
|