|
|
@ -220,13 +220,12 @@ void create_audio_engine_chain(uint8_t instance_id) |
|
|
|
uint8_t sd_card = 0; |
|
|
|
uint8_t sd_card = 0; |
|
|
|
Sd2Card card; |
|
|
|
Sd2Card card; |
|
|
|
SdVolume volume; |
|
|
|
SdVolume volume; |
|
|
|
uint8_t midi_ticks[10] = {0, 6, 9, 12, 18, 24, 36, 48, 72, 96}; |
|
|
|
float midi_ticks_factor[10] = {0.0, 0.0625, 0.09375, 0.125, 0.1875, 0.25, 0.375, 0.5, 0.75 , 1.0}; |
|
|
|
uint8_t midi_bpm_counter = 0; |
|
|
|
uint8_t midi_bpm_counter = 0; |
|
|
|
elapsedMillis midi_bpm; |
|
|
|
uint8_t midi_bpm = 0; |
|
|
|
#ifdef USE_FX |
|
|
|
int16_t _midi_bpm = -1; |
|
|
|
uint8_t midi_timing_counter[NUM_DEXED] = {0, 0}; |
|
|
|
bool midi_clock_running = false; |
|
|
|
elapsedMillis midi_timing_timer[NUM_DEXED]; |
|
|
|
elapsedMillis midi_bpm_timer; |
|
|
|
#endif |
|
|
|
|
|
|
|
elapsedMillis long_button_pressed; |
|
|
|
elapsedMillis long_button_pressed; |
|
|
|
elapsedMillis control_rate; |
|
|
|
elapsedMillis control_rate; |
|
|
|
uint8_t active_voices[NUM_DEXED]; |
|
|
|
uint8_t active_voices[NUM_DEXED]; |
|
|
@ -1374,71 +1373,75 @@ void handleTuneRequest(void) |
|
|
|
|
|
|
|
|
|
|
|
void handleClock(void) |
|
|
|
void handleClock(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
if (midi_clock_running != true) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (midi_bpm_counter % 24 == 0) |
|
|
|
if (midi_bpm_counter % 24 == 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
midi_bpm = (60000.0f / float(midi_bpm_timer) + 0.5); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_midi_bpm > -1 && _midi_bpm != midi_bpm) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("MIDI Clock: ")); |
|
|
|
Serial.print(F("MIDI Clock: ")); |
|
|
|
Serial.print(60000.0f / midi_bpm, 2); |
|
|
|
Serial.print(midi_bpm); |
|
|
|
Serial.print(F(" bpm (")); |
|
|
|
Serial.print(F(" bpm (")); |
|
|
|
Serial.print(midi_bpm, DEC); |
|
|
|
Serial.print(midi_bpm_timer, DEC); |
|
|
|
Serial.println(F("ms per quarter)")); |
|
|
|
Serial.println(F("ms per quarter)")); |
|
|
|
midi_bpm = 0; |
|
|
|
|
|
|
|
midi_bpm_counter = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
midi_bpm_counter++; |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef USE_FX |
|
|
|
#ifdef USE_FX |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (midi_ticks[configuration.fx.delay_sync[instance_id]] > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
1 1/16 = 6 ticks |
|
|
|
1 1/16 = 6 ticks / 0.0625 |
|
|
|
2 1/16T = 9 ticks |
|
|
|
2 1/16T = 9 ticks / 0.09375 |
|
|
|
3 1/8 = 12 ticks |
|
|
|
3 1/8 = 12 ticks / 0.125 |
|
|
|
4 1/8T = 18 ticks |
|
|
|
4 1/8T = 18 ticks / 0.1875 |
|
|
|
5 1/4 = 24 ticks |
|
|
|
5 1/4 = 24 ticks / 0.25 |
|
|
|
6 1/4T = 36 ticks |
|
|
|
6 1/4T = 36 ticks / 0.375 |
|
|
|
7 1/2 = 48 ticks |
|
|
|
7 1/2 = 48 ticks / 0.5 |
|
|
|
8 1/2T = 72 ticks |
|
|
|
8 1/2T = 72 ticks / 0.75 |
|
|
|
9 1/1 = 96 ticks |
|
|
|
9 1/1 = 96 ticks / 1.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (midi_timing_counter[instance_id] % midi_ticks[configuration.fx.delay_sync[instance_id]] == 0) |
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int32_t t = midi_timing_timer[instance_id]; |
|
|
|
if (configuration.fx.delay_sync[instance_id] > 0) |
|
|
|
delay_fx[instance_id]->delay(0, constrain(t*10, DELAY_TIME_MIN*10, DELAY_TIME_MAX*10)); |
|
|
|
{ |
|
|
|
|
|
|
|
uint16_t t = uint16_t(60.0 / float(midi_bpm) * 1000.0 * midi_ticks_factor[configuration.fx.delay_sync[instance_id]] + 0.5); |
|
|
|
|
|
|
|
delay_fx[instance_id]->delay(0, constrain(t, DELAY_TIME_MIN * 10, DELAY_TIME_MAX * 10)); |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Delay-Sync to ")); |
|
|
|
Serial.print(F("Setting Delay-Sync to ")); |
|
|
|
Serial.print(constrain(t, DELAY_TIME_MIN, DELAY_TIME_MAX), DEC); |
|
|
|
Serial.print(constrain(t, DELAY_TIME_MIN * 10, DELAY_TIME_MAX * 10), DEC); |
|
|
|
Serial.print(F(" ms / ")); |
|
|
|
Serial.println(F(" ms")); |
|
|
|
Serial.print(midi_timing_counter[instance_id], DEC); |
|
|
|
|
|
|
|
Serial.println(F(" ticks")); |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
midi_timing_counter[instance_id] = 0; |
|
|
|
|
|
|
|
midi_timing_timer[instance_id] = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
midi_timing_counter[instance_id]++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#else |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_midi_bpm = midi_bpm; |
|
|
|
|
|
|
|
midi_bpm_counter = 0; |
|
|
|
|
|
|
|
midi_bpm_timer = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
midi_bpm_counter++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleStart(void) |
|
|
|
void handleStart(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
; |
|
|
|
midi_clock_running = true; |
|
|
|
|
|
|
|
midi_bpm_timer = 0; |
|
|
|
|
|
|
|
midi_bpm_counter = 0; |
|
|
|
|
|
|
|
_midi_bpm = -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleContinue(void) |
|
|
|
void handleContinue(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
; |
|
|
|
midi_clock_running = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleStop(void) |
|
|
|
void handleStop(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
; |
|
|
|
midi_clock_running = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handleActiveSensing(void) |
|
|
|
void handleActiveSensing(void) |
|
|
|