From 66dab0bdbdf7a97d89511be487dcfdf19ce55e37 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 28 Sep 2018 19:03:52 +0200 Subject: [PATCH] Trying to fix loudness... --- MicroDexed.ino | 13 ++++++++----- UI.cpp | 12 ++++++++++++ dexed_sysex.cpp | 1 - 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index ac16f1f..3bfa961 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -555,11 +555,12 @@ void set_volume(float v, float vr, float vl) vol_right = vr; vol_left = vl; +#ifndef I2C_DISPLAY EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, uint8_t(vol * UCHAR_MAX)); EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR, uint8_t(vol_right * UCHAR_MAX)); EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR, uint8_t(vol_left * UCHAR_MAX)); update_eeprom_checksum(); - +#endif #ifdef DEBUG uint8_t tmp; Serial.print(F("Setting volume: VOL=")); @@ -587,11 +588,13 @@ void set_volume(float v, float vr, float vl) #endif #ifdef TEENSY_AUDIO_BOARD - sgtl5000_1.dacVolume(log(vol * vol_left), log(vol * vol_right)); + //sgtl5000_1.dacVolume(log(vol * vol_left)+1, log(vol * vol_right)+1); // https://stackoverflow.com/questions/19472747/convert-linear-scale-to-logarithmic + sgtl5000_1.dacVolume(vol * vol_left, vol * vol_right); + #else - volume_master.gain(log(vol)); - volume_r.gain(log(vr)); - volume_l.gain(log(vl)); + volume_master.gain(lvol); + volume_r.gain(lvr); + volume_l.gain(vl); #endif } diff --git a/UI.cpp b/UI.cpp index fbce6c3..08613ee 100644 --- a/UI.cpp +++ b/UI.cpp @@ -24,6 +24,7 @@ */ #include +#include #include "config.h" #include "dexed.h" #include "dexed_sysex.h" @@ -36,7 +37,13 @@ elapsedMillis ui_back_to_main; void handle_ui(void) { if (ui_back_to_main >= UI_AUTO_BACK_MS && ui_state != UI_MAIN) + { ui_show_main(); + EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, uint8_t(vol * UCHAR_MAX)); + EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR, uint8_t(vol_right * UCHAR_MAX)); + EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR, uint8_t(vol_left * UCHAR_MAX)); + update_eeprom_checksum(); + } for (uint8_t i = 0; i < NUM_ENCODER; i++) { @@ -121,6 +128,11 @@ void handle_ui(void) break; case UI_MAIN_VOICE_SELECTED: ui_main_state = UI_MAIN_VOICE; + if (enc[i].read() <= 0) + enc[i].write(0); + else if (enc[i].read() >= MAX_VOICES) + enc[i].write(MAX_VOICES); + voice = enc[i].read(); break; } get_bank_voice_name(bank, voice); diff --git a/dexed_sysex.cpp b/dexed_sysex.cpp index 1da837f..db6b78d 100644 --- a/dexed_sysex.cpp +++ b/dexed_sysex.cpp @@ -129,7 +129,6 @@ bool load_sysex(uint8_t b, uint8_t v) { #ifdef DEBUG char n[11]; - bool r; strncpy(n, (char*)&data[118], 10); Serial.print("Loading sysex ");