From 5cee620f4a8ffe7c92e57782e3c910bcb2670a3c Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 26 Jul 2018 12:57:03 +0200 Subject: [PATCH] Small fixes. --- MicroDexed.ino | 21 +++++++++++++-------- config.h | 2 +- dexed.cpp | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 7b5d343..4d33e6f 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -487,31 +487,35 @@ int8_t num_key_base_c(uint8_t midi_note) } #endif -void set_volume(float master_vol, float vol_right, float vol_left) +void set_volume(float v, float vr, float vl) { - EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, master_vol * UCHAR_MAX); - EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR, vol_right * UCHAR_MAX); - EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR, vol_left * UCHAR_MAX); + vol=v; + vol_right=vr; + vol_left=vl; + + 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(); #ifdef DEBUG uint8_t tmp; Serial.print(F("Setting volume: VOL=")); - Serial.print(master_vol, DEC); + Serial.print(v, DEC); Serial.print(F("[")); tmp = EEPROM.read(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR); Serial.print(tmp, DEC); Serial.print(F("/")); Serial.print(float(tmp) / UCHAR_MAX, DEC); Serial.print(F("] VOL_L=")); - Serial.print(vol_left, DEC); + Serial.print(vl, DEC); Serial.print(F("[")); tmp = EEPROM.read(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR); Serial.print(tmp, DEC); Serial.print(F("/")); Serial.print(float(tmp) / UCHAR_MAX, DEC); Serial.print(F("] VOL_R=")); - Serial.print(vol_right, DEC); + Serial.print(vr, DEC); Serial.print(F("[")); tmp = EEPROM.read(EEPROM_OFFSET + EEPROM_VOLUME_RIGHT_ADDR); Serial.print(tmp, DEC); @@ -519,7 +523,8 @@ void set_volume(float master_vol, float vol_right, float vol_left) Serial.print(float(tmp) / UCHAR_MAX, DEC); Serial.println(F("]")); #endif - sgtl5000_1.dacVolume(master_vol * vol_left, master_vol * vol_right); + + sgtl5000_1.dacVolume(vol * vol_left, vol * vol_right); } void handle_sysex_parameter(const uint8_t* sysex, uint8_t len) diff --git a/config.h b/config.h index 74516db..4dea1bc 100644 --- a/config.h +++ b/config.h @@ -59,7 +59,7 @@ // Some optimizations #define USE_TEENSY_DSP 1 #define SUM_UP_AS_INT 1 -#define REDUCE_LOUDNESS 0 +#define REDUCE_LOUDNESS 1 // Enable TEST_NOTE for adding code to drop some midi notes for testing without keyboard //#define TEST_NOTE MIDI_E2 diff --git a/dexed.cpp b/dexed.cpp index c369695..83ac62d 100644 --- a/dexed.cpp +++ b/dexed.cpp @@ -222,7 +222,7 @@ bool Dexed::processMidiMessage(uint8_t type, uint8_t data1, uint8_t data2) break; case 7: // Volume vol = float(value) / 0x7f; - sgtl5000_1.dacVolume(vol * vol_left, vol * vol_right); + set_volume(vol, vol_left, vol_right); break; case 10: // Pan if (value < 64)