From 8f8db87ba78bf85cf4455cad8fbcee2250509a48 Mon Sep 17 00:00:00 2001 From: probonopd Date: Thu, 1 May 2025 07:29:12 +0200 Subject: [PATCH] Logarithmic mapping for Audio Output Level Attenuator --- src/mididevice.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 56c7500..58209d9 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -426,7 +426,9 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign { LOGNOTE("MIDI-SYSEX: Set Audio Output Level Attenuator %d to %d", nTG, val & 0x0F); // Example: F0 43 10 04 1A 00 F7 to F0 43 10 04 1A 07 F7 - unsigned newVolume = (unsigned)((val & 0x07) * 127 / 7); + // Apply logarithmic scaling for volume + unsigned attenVal = val & 0x07; + unsigned newVolume = (unsigned)(127.0 * pow(attenVal / 7.0, 2.0) + 0.5); // Logarithmic mapping m_pSynthesizer->SetVolume(newVolume, nTG); } break;