Fixing writing to EEPROM only when no sound is active to avoid small drops in sound

calculation.
Removed some debug output.
pull/32/head
Holger Wirtz 5 years ago
parent f8a45bef03
commit b7d9921d3a
  1. 18
      MicroDexed.ino
  2. 81
      UI.hpp
  3. 2
      config.h
  4. 2
      dexed.cpp

@ -1452,13 +1452,21 @@ void eeprom_write(void)
void eeprom_update(void) void eeprom_update(void)
{ {
eeprom_update_flag = false; for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
configuration.checksum = crc32((byte*)&configuration + 4, sizeof(configuration) - 4); {
EEPROM.put(EEPROM_START_ADDRESS, configuration); if (active_voices[instance_id] > 0)
Serial.println(F("Updating EEPROM")); autostore = 0;
else
{
eeprom_update_flag = false;
configuration.checksum = crc32((byte*)&configuration + 4, sizeof(configuration) - 4);
EEPROM.put(EEPROM_START_ADDRESS, configuration);
Serial.println(F("Updating EEPROM"));
#ifdef DEBUG #ifdef DEBUG
show_configuration(); show_configuration();
#endif #endif
}
}
} }
uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https://www.arduino.cc/en/Tutorial/EEPROMCrc uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https://www.arduino.cc/en/Tutorial/EEPROMCrc

@ -789,11 +789,6 @@ void UI_func_reverb_roomsize(uint8_t param)
// setup function // setup function
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Reverb Roomsize")); lcd.print(F("Reverb Roomsize"));
#ifdef DEBUG
Serial.println(F("Entering UI_func_reverb_roomsize()"));
Serial.print(F("configuration.roomsize="));
Serial.println(configuration.reverb_roomsize, DEC);
#endif
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -829,11 +824,6 @@ void UI_func_reverb_roomsize(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
{ {
#ifdef DEBUG
Serial.println(F("Leaving UI_func_reverb_roomsize()"));
Serial.print(F("reverb_roomsize="));
Serial.println(configuration.reverb_roomsize, DEC);
#endif
eeprom_write(); eeprom_write();
} }
} }
@ -845,11 +835,6 @@ void UI_func_reverb_damping(uint8_t param)
// setup function // setup function
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Reverb Damping")); lcd.print(F("Reverb Damping"));
#ifdef DEBUG
Serial.println(F("Entering UI_func_reverb_damping()"));
Serial.print(F("reverb_damping="));
Serial.println(configuration.reverb_damping, DEC);
#endif
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -885,11 +870,6 @@ void UI_func_reverb_damping(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
{ {
#ifdef DEBUG
Serial.println(F("Leaving UI_func_reverb_damping()"));
Serial.print(F("configuration.reverb_damping="));
Serial.println(configuration.reverb_damping, DEC);
#endif
eeprom_write(); eeprom_write();
} }
} }
@ -906,13 +886,6 @@ void UI_func_reverb_send(uint8_t param)
// setup function // setup function
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Reverb Send")); lcd.print(F("Reverb Send"));
#ifdef DEBUG
Serial.println(F("Entering UI_func_reverb_send()"));
Serial.print(F("configuration.dexed["));
Serial.print(instance_id, DEC);
Serial.print(F("].reverb_send="));
Serial.println(configuration.dexed[instance_id].reverb_send, DEC);
#endif
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -949,13 +922,6 @@ void UI_func_reverb_send(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
{ {
#ifdef DEBUG
Serial.println(F("Leaving UI_func_reverb_send()"));
Serial.print(F("configuration.dexed["));
Serial.print(instance_id, DEC);
Serial.print(F("].reverb_send="));
Serial.println(configuration.dexed[instance_id].reverb_send, DEC);
#endif
eeprom_write(); eeprom_write();
} }
} }
@ -967,11 +933,6 @@ void UI_func_reverb_level(uint8_t param)
// setup function // setup function
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Reverb Level")); lcd.print(F("Reverb Level"));
#ifdef DEBUG
Serial.println(F("Entering UI_func_reverb_level()"));
Serial.print(F("reverb_level="));
Serial.println(configuration.reverb_level, DEC);
#endif
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -1007,11 +968,6 @@ void UI_func_reverb_level(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
{ {
#ifdef DEBUG
Serial.println(F("Leaving UI_func_reverb_level()"));
Serial.print(F("configuration.reverb_levelg="));
Serial.println(configuration.reverb_level, DEC);
#endif
eeprom_write(); eeprom_write();
} }
} }
@ -1023,11 +979,6 @@ void UI_func_chorus_frequency(uint8_t param)
// setup function // setup function
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Chorus Frequency")); lcd.print(F("Chorus Frequency"));
#ifdef DEBUG
Serial.println(F("Entering UI_func_chorus_frequency()"));
Serial.print(F("configuration.chorus_frequency="));
Serial.println(configuration.chorus_frequency, DEC);
#endif
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -1063,11 +1014,6 @@ void UI_func_chorus_frequency(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
{ {
#ifdef DEBUG
Serial.println(F("Leaving UI_func_chorus_frequency()"));
Serial.print(F("configuration.chorus_frequency="));
Serial.println(configuration.chorus_frequency, DEC);
#endif
eeprom_write(); eeprom_write();
} }
} }
@ -1232,11 +1178,6 @@ void UI_func_chorus_level(uint8_t param)
// setup function // setup function
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Chorus Level")); lcd.print(F("Chorus Level"));
#ifdef DEBUG
Serial.println(F("Entering UI_func_chorus_level()"));
Serial.print(F("chorus_level="));
Serial.println(configuration.chorus_level, DEC);
#endif
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -1272,11 +1213,6 @@ void UI_func_chorus_level(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
{ {
#ifdef DEBUG
Serial.println(F("Leaving UI_func_chorus_level()"));
Serial.print(F("configuration.chorus_level="));
Serial.println(configuration.chorus_level, DEC);
#endif
eeprom_write(); eeprom_write();
} }
} }
@ -1436,11 +1372,6 @@ void UI_func_delay_level(uint8_t param)
// setup function // setup function
lcd.setCursor(0, 0); lcd.setCursor(0, 0);
lcd.print(F("Delay Level")); lcd.print(F("Delay Level"));
#ifdef DEBUG
Serial.println(F("Entering UI_func_delay_level()"));
Serial.print(F("delay_level="));
Serial.println(configuration.delay_level, DEC);
#endif
} }
if (LCDML.FUNC_loop()) // ****** LOOP ********* if (LCDML.FUNC_loop()) // ****** LOOP *********
@ -1476,11 +1407,6 @@ void UI_func_delay_level(uint8_t param)
if (LCDML.FUNC_close()) // ****** STABLE END ********* if (LCDML.FUNC_close()) // ****** STABLE END *********
{ {
#ifdef DEBUG
Serial.println(F("Leaving UI_func_delay_level()"));
Serial.print(F("configuration.delay_levelg="));
Serial.println(configuration.delay_level, DEC);
#endif
eeprom_write(); eeprom_write();
} }
} }
@ -3379,15 +3305,10 @@ void lcd_display_bar_int(const char* title, uint32_t value, uint32_t min_value,
uint8_t vf = uint8_t(modff(_v, &_vi) * 10.0 + 0.5); uint8_t vf = uint8_t(modff(_v, &_vi) * 10.0 + 0.5);
uint8_t vi = uint8_t(_vi + 0.5); uint8_t vi = uint8_t(_vi + 0.5);
Serial.println(value, DEC);
Serial.println(_v, 5);
Serial.println(vf, DEC);
Serial.println(vi, DEC);
if (init == true) if (init == true)
{ {
// show initial title, value and bar // show initial title, value and bar
lcd.clear(); LCDML.DISP_clear();
lcd.show(0, 0, LCD_cols - 1, title); lcd.show(0, 0, LCD_cols - 1, title);
lcd.setCursor(LCD_cols - (size + 1) + 1, 0); lcd.setCursor(LCD_cols - (size + 1) + 1, 0);
lcd_display_int(value, size, zeros, brackets, sign); lcd_display_int(value, size, zeros, brackets, sign);

@ -244,6 +244,8 @@ enum { DEXED, CHORUS, DELAY, REVERB};
#endif #endif
#define TRANSPOSE_FIX 24 #define TRANSPOSE_FIX 24
//#define VOICE_SILENCE_LEVEL 1069
#define VOICE_SILENCE_LEVEL 4000
// Audio // Audio
#ifdef TGA_AUDIO_BOARD #ifdef TGA_AUDIO_BOARD

@ -444,7 +444,7 @@ uint8_t Dexed::getNumNotesPlaying(void)
{ {
// this voice is a carrier! // this voice is a carrier!
op_carrier_num++; op_carrier_num++;
if (voiceStatus.amp[op] <= 1069 && voiceStatus.ampStep[op] == 4) if (voiceStatus.amp[op] <= VOICE_SILENCE_LEVEL && voiceStatus.ampStep[op] == 4)
{ {
// this voice produces no audio output // this voice produces no audio output
op_amp++; op_amp++;

Loading…
Cancel
Save