|
|
@ -555,11 +555,12 @@ void set_volume(float v, float vr, float vl) |
|
|
|
vol_right = vr; |
|
|
|
vol_right = vr; |
|
|
|
vol_left = vl; |
|
|
|
vol_left = vl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef I2C_DISPLAY |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_MASTER_VOLUME_ADDR, uint8_t(vol * UCHAR_MAX)); |
|
|
|
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_RIGHT_ADDR, uint8_t(vol_right * UCHAR_MAX)); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR, uint8_t(vol_left * UCHAR_MAX)); |
|
|
|
EEPROM.update(EEPROM_OFFSET + EEPROM_VOLUME_LEFT_ADDR, uint8_t(vol_left * UCHAR_MAX)); |
|
|
|
update_eeprom_checksum(); |
|
|
|
update_eeprom_checksum(); |
|
|
|
|
|
|
|
#endif |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
uint8_t tmp; |
|
|
|
uint8_t tmp; |
|
|
|
Serial.print(F("Setting volume: VOL=")); |
|
|
|
Serial.print(F("Setting volume: VOL=")); |
|
|
@ -587,11 +588,13 @@ void set_volume(float v, float vr, float vl) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
#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 |
|
|
|
#else |
|
|
|
volume_master.gain(log(vol)); |
|
|
|
volume_master.gain(lvol); |
|
|
|
volume_r.gain(log(vr)); |
|
|
|
volume_r.gain(lvr); |
|
|
|
volume_l.gain(log(vl)); |
|
|
|
volume_l.gain(vl); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|