Fixes for synced delay calculation.

pull/46/head
Holger Wirtz 3 years ago
parent a91798ed9f
commit 66b872db96
  1. 21
      MicroDexed.ino
  2. 4
      UI.hpp
  3. 5
      third-party/Synth_Dexed/tools/sysex2c.py

@ -222,11 +222,12 @@ void create_audio_engine_chain(uint8_t instance_id)
uint8_t sd_card = 0;
Sd2Card card;
SdVolume volume;
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};
//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};
float midi_ticks_factor[10] = {0.0, 0.25, 0.375, 0.5, 0.75, 1.0, 1.5, 2.0, 3.0 , 4.0};
uint8_t midi_bpm_counter = 0;
uint8_t midi_bpm = 0;
int16_t _midi_bpm = -1;
bool midi_clock_running = false;
//midi_bpmbool midi_clock_running = false;
elapsedMillis midi_bpm_timer;
elapsedMillis long_button_pressed;
elapsedMillis control_rate;
@ -1370,8 +1371,8 @@ void handleTuneRequest(void)
void handleClock(void)
{
if (midi_clock_running != true)
return;
//if (midi_clock_running != true)
// return;
if (midi_bpm_counter % 24 == 0)
{
@ -1403,10 +1404,12 @@ void handleClock(void)
{
if (configuration.fx.delay_sync[instance_id] > 0)
{
uint16_t midi_sync_delay_time = uint16_t(60.0 / float(midi_bpm) * 1000.0 * midi_ticks_factor[configuration.fx.delay_sync[instance_id]] + 0.5);
uint16_t midi_sync_delay_time = uint16_t(60000.0 * midi_ticks_factor[configuration.fx.delay_sync[instance_id]] / float(midi_bpm) + 0.5);
delay_fx[instance_id]->delay(0, constrain(midi_sync_delay_time, DELAY_TIME_MIN * 10, DELAY_TIME_MAX * 10));
#ifdef DEBUG
Serial.print(F("Setting Delay-Sync to "));
Serial.print(F("Setting Delay-Sync of instance "));
Serial.print(instance_id);
Serial.print(F(" to "));
Serial.print(constrain(midi_sync_delay_time, DELAY_TIME_MIN * 10, DELAY_TIME_MAX * 10), DEC);
Serial.println(F(" ms"));
#endif
@ -1425,7 +1428,7 @@ void handleClock(void)
void handleStart(void)
{
midi_clock_running = true;
//midi_clock_running = true;
midi_bpm_timer = 0;
midi_bpm_counter = 0;
_midi_bpm = -1;
@ -1433,12 +1436,12 @@ void handleStart(void)
void handleContinue(void)
{
midi_clock_running = true;
//midi_clock_running = true;
}
void handleStop(void)
{
midi_clock_running = false;
//midi_clock_running = false;
}
void handleActiveSensing(void)

@ -6068,12 +6068,12 @@ void lcd_display_delay_sync(uint8_t sync)
break;
}
uint16_t midi_sync_delay_time = uint16_t(1000.0 * midi_bpm * midi_ticks_factor[sync] / 60.0 + 0.5);
uint16_t midi_sync_delay_time = uint16_t(60000.0 * midi_ticks_factor[sync] / midi_bpm + 0.5);
if (midi_sync_delay_time > DELAY_MAX_TIME)
{
#ifdef DEBUG
Serial.println(F("Calculated MIDI-Sync delay: "));
Serial.print(round(1000.0 * midi_bpm * midi_ticks_factor[sync] / 60.0), DEC);
Serial.print(round(60000.0 * midi_ticks_factor[sync] / midi_bpm), DEC);
Serial.println(F("ms"));
Serial.println(F("MIDI-Sync delay: midi_sync_delay_time"));
Serial.print(midi_sync_delay_time, DEC);

@ -93,6 +93,8 @@ print("""
//
// File generated with sysex2c.py
//
#pragma once
""")
if(decode==True):
print("uint8_t progmem_bank[%d][32][156] PROGMEM =\n{" % int(len(sys.argv)))
@ -132,7 +134,8 @@ for sysex in sys.argv:
for v in range(1,33):
data=f.read(128)
print("\t\t{\t// %d: %s" % (v, data[118:128].decode('ascii')))
patchname=str(data[118:128].decode('ascii')).upper().replace('\\','')
print("\t\t{\t// %d: %s" % (v, patchname))
if(decode==True):
print_header_data(unpack_packed_patch(data))
else:

Loading…
Cancel
Save