Several fixes.

pull/65/head
Holger Wirtz 3 years ago
parent 0c922276c2
commit 857a73dcf6
  1. 2
      MicroDexed.ino
  2. 15
      audio_timer.cpp
  3. 10
      audio_timer.h

@ -718,7 +718,7 @@ void setup()
#endif
audio_timer.set_bpm(60);
audio_timer.function(4, &testfunc);
audio_timer.function(8, &testfunc); // 60 bpm with 1/8 pulses
#ifdef DEBUG
Serial.println(F("<setup end>"));

@ -12,10 +12,10 @@ void AudioTimer::update(void)
tick++;
if (tick >= float(beat)*float(bpm) + 0.5)
if (tick >= _steps)
{
if (sequencer_step_function != NULL)
(*sequencer_step_function)();
if (step_function != NULL)
(*step_function)();
tick = 0;
}
}
@ -30,13 +30,14 @@ void AudioTimer::set_bpm(uint8_t b)
bpm = b;
}
void AudioTimer::function(uint8_t steps, void(*func)())
void AudioTimer::function(uint8_t stepping, void(*func)())
{
steps = stepping;
if (func != NULL)
{
sequencer_step_function = func;
steps = bpm * steps / 4;
step_function = func;
_steps = beat * float(bpm) * 4.0 / float(stepping) + 0.5;
}
else
sequencer_step_function = NULL;
step_function = NULL;
}

@ -9,19 +9,21 @@ class AudioTimer : public AudioStream
{
tick = 0;
bpm = 60;
sequencer_step_function = NULL;
steps = 4;
step_function = NULL;
}
virtual uint32_t get_tick(void);
virtual void set_bpm(uint8_t b);
virtual void function(uint8_t steps, void(*func)());
virtual void function(uint8_t stepping, void(*func)());
virtual void update(void);
private:
audio_block_t *inputQueueArray[1];
uint8_t bpm;
uint16_t steps;
void (*sequencer_step_function)();
uint8_t steps;
uint16_t _steps;
void (*step_function)();
volatile uint32_t tick;
const float beat = AUDIO_SAMPLE_RATE_EXACT / float(AUDIO_BLOCK_SAMPLES) / 60.0;
};

Loading…
Cancel
Save