From c10258cafde75a4ea3e8f27142aa3ee2f5d21be4 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sun, 30 Sep 2018 16:09:26 +0200 Subject: [PATCH] Fixed volume (loudness) calculation. --- MicroDexed.ino | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 3bfa961..7107cb5 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -588,13 +588,12 @@ void set_volume(float v, float vr, float vl) #endif #ifdef TEENSY_AUDIO_BOARD - //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); - + //sgtl5000_1.dacVolume(log(vol * vol_left)+1, log(vol * vol_right)+1); + sgtl5000_1.dacVolume(1 - pow((1 - vol * vol_left), 2.7), (1 - pow((1 - vol * vol_right), 2.7))); #else - volume_master.gain(lvol); - volume_r.gain(lvr); - volume_l.gain(vl); + volume_master.gain(1 - pow(1 - lvol, 2.7)); + volume_r.gain(1 - pow(1 - vr, 2.7)); + volume_l.gain(1 - pow(1 - vl, 2.7)); #endif }