diff --git a/MicroDexed.ino b/MicroDexed.ino index 8f8a039..3525630 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -324,7 +324,7 @@ void setup() sgtl5000_1.unmuteLineout(); sgtl5000_1.autoVolumeDisable(); // turn off AGC sgtl5000_1.volume(0.5, 0.5); // Headphone volume - sgtl5000_1.lineOutLevel(SGTL5000_LINEOUT_LEVEL); + sgtl5000_1.lineOutLevel(sgtl5000_level); sgtl5000_1.audioPostProcessorEnable(); sgtl5000_1.autoVolumeControl(1, 1, 1, 0.9, 0.01, 0.05); sgtl5000_1.autoVolumeEnable(); @@ -1312,18 +1312,6 @@ void initial_values_from_eeprom(bool init) MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); } } - -#if defined(TEENSY_AUDIO_BOARD) - // Special handling for SGTL5000 volume setting - uint8_t sgtl5000_level = EEPROM[EEPROM_SGTL5000_LINEOUT_LEVEL_ADDRESS]; - if (sgtl5000_level >= SGTL5000_LINEOUT_LEVEL_MAX || sgtl5000_level <= SGTL5000_LINEOUT_LEVEL_MIN) - { - sgtl5000_level = SGTL5000_LINEOUT_LEVEL_DEFAULT; - EEPROM[EEPROM_SGTL5000_LINEOUT_LEVEL_ADDRESS] = SGTL5000_LINEOUT_LEVEL_DEFAULT; - } - Serial.print(F("SGTL5000 output level: ")); - Serial.println(sgtl5000_level); -#endif Serial.println(F("OK, loaded!")); master_mixer_r.gain(DEXED, 1.0); @@ -1336,6 +1324,11 @@ void initial_values_from_eeprom(bool init) master_mixer_l.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); set_volume(configuration.vol, configuration.mono); + +#if defined(TEENSY_AUDIO_BOARD) + EEPROM.get(EEPROM_SGTL5000_LINEOUT_LEVEL_ADDRESS, sgtl5000_level); + //sgtl5000_1.lineOutLevel(sgtl5000_level); +#endif } #ifdef DEBUG show_configuration(); @@ -1399,6 +1392,15 @@ void check_configuration(void) master_mixer_l.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); master_mixer_r.gain(REVERB, mapfloat(configuration.delay_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); master_mixer_l.gain(REVERB, mapfloat(configuration.delay_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); + +#if defined(TEENSY_AUDIO_ADAPTER) + // Special handling for SGTL5000 volume setting + if (sgtl5000_level > SGTL5000_LINEOUT_LEVEL_MAX || sgtl5000_level < SGTL5000_LINEOUT_LEVEL_MIN) + { + sgtl5000_level = SGTL5000_LINEOUT_LEVEL_DEFAULT; + EEPROM.put(EEPROM_SGTL5000_LINEOUT_LEVEL_ADDRESS, SGTL5000_LINEOUT_LEVEL_DEFAULT); + } +#endif } void init_configuration(void) @@ -1458,6 +1460,11 @@ void init_configuration(void) configuration.dexed[instance_id].op_enabled = OP_ENABLED_DEFAULT; } eeprom_update(); +#if defined(TEENSY_AUDIO_ADAPTER) + sgtl5000_level = SGTL5000_LINEOUT_LEVEL_DEFAULT; + EEPROM.put(EEPROM_SGTL5000_LINEOUT_LEVEL_ADDRESS, SGTL5000_LINEOUT_LEVEL_DEFAULT); + sgtl5000_1.lineOutLevel(sgtl5000_level); +#endif } void eeprom_write(void) @@ -1592,8 +1599,11 @@ void show_configuration(void) Serial.print(F("Delay Time ")); Serial.println(configuration.delay_time, DEC); Serial.print(F("Delay Feedback ")); Serial.println(configuration.delay_feedback, DEC); Serial.print(F("Delay Level ")); Serial.println(configuration.delay_level, DEC); - Serial.print(F("Soft MIDI Thr ")); Serial.println(configuration.soft_midi_thru, DEC); - Serial.flush(); + Serial.print(F("Soft MIDI Thru ")); Serial.println(configuration.soft_midi_thru, DEC); +#if defined(TEENSY_AUDIO_BOARD) + Serial.print(F("SGTL5000 level ")); Serial.println(sgtl5000_level, DEC); +#endif + for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { Serial.print(F("=== DEXED INSTANCE ")); @@ -1633,6 +1643,7 @@ void show_configuration(void) Serial.flush(); } Serial.println(); + Serial.flush(); } void show_patch(uint8_t instance_id)