First test for sequencer-sync towards the audio interrupt.

pull/65/head
Holger Wirtz 4 years ago
parent e8772102b1
commit 09ff0cb755
  1. 30
      MicroDexed.ino
  2. 3
      sequencer.cpp
  3. 39
      sequencer_timer.cpp
  4. 27
      sequencer_timer.h

@ -36,6 +36,7 @@
#include "effect_modulated_delay.h" #include "effect_modulated_delay.h"
#include "effect_stereo_mono.h" #include "effect_stereo_mono.h"
#include "effect_mono_stereo.h" #include "effect_mono_stereo.h"
#include "sequencer_timer.h"
#ifdef USE_PLATEREVERB #ifdef USE_PLATEREVERB
#include "effect_platervbstereo.h" #include "effect_platervbstereo.h"
#else #else
@ -251,6 +252,9 @@ AudioConnection patchCord22(drum_mixer_l, 0, master_mixer_l, 2);
#endif #endif
#endif #endif
AudioSequencerTimer sequencer_timer;
AudioConnection patchCord25(reverb_mixer_r, sequencer_timer);
// //
// Dynamic patching of MicroDexed objects // Dynamic patching of MicroDexed objects
// //
@ -400,6 +404,29 @@ extern LCDMenuLib2 LCDML;
extern void getNoteName(char* noteName, uint8_t noteNumber); extern void getNoteName(char* noteName, uint8_t noteNumber);
void testfunc(void)
{
static int8_t takt;
switch (takt % 4)
{
case 0:
Serial.println("EINS!");
break;
case 1:
Serial.println("ZWEI!");
break;
case 2:
Serial.println("DREI!");
break;
case 3:
Serial.println("VIER!");
takt = -1;
break;
}
takt++;
}
/*********************************************************************** /***********************************************************************
SETUP SETUP
***********************************************************************/ ***********************************************************************/
@ -665,6 +692,9 @@ void setup()
audio_thru_mixer_l.gain(3, 0.0); audio_thru_mixer_l.gain(3, 0.0);
#endif #endif
sequencer_timer.set_bpm(60);
sequencer_timer.step_function(&testfunc);
#ifdef DEBUG #ifdef DEBUG
Serial.println(F("<setup end>")); Serial.println(F("<setup end>"));
#endif #endif

@ -12,6 +12,9 @@ extern void handleNoteOff(byte , byte , byte );
extern void UI_func_sequencer(uint8_t); extern void UI_func_sequencer(uint8_t);
extern const char* seq_find_shortname(uint8_t); extern const char* seq_find_shortname(uint8_t);
void sequencer(void) void sequencer(void)
{ {

@ -0,0 +1,39 @@
#include <Audio.h>
#include "config.h"
#include "sequencer_timer.h"
void AudioSequencerTimer::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 AudioSequencerTimer::get_tick(void)
{
return (tick);
}
void AudioSequencerTimer::set_bpm(uint8_t b)
{
bpm = b;
}
void AudioSequencerTimer::step_function(void(*func)())
{
if (func != NULL)
sequencer_step_function = func;
else
sequencer_step_function = NULL;
}

@ -0,0 +1,27 @@
#ifndef _SEQUENCER_TIMER_H_
#define _SEQUENCER_TIMER_H_
class AudioSequencerTimer : public AudioStream
{
public:
AudioSequencerTimer(void):
AudioStream(1, inputQueueArray)
{
tick = 0;
bpm = 60;
sequencer_step_function = NULL;
}
virtual uint32_t get_tick(void);
virtual void set_bpm(uint8_t b);
virtual void step_function(void(*func)());
virtual void update(void);
private:
audio_block_t *inputQueueArray[1];
uint8_t bpm;
void (*sequencer_step_function)();
volatile uint32_t tick;
const float beat = AUDIO_SAMPLE_RATE_EXACT / float(AUDIO_BLOCK_SAMPLES) / 60.0;
};
#endif
Loading…
Cancel
Save