Logarithmic mapping for volume

tx812-performance
probonopd 1 week ago committed by GitHub
parent af2c8dcee2
commit 66eb4481ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      src/mididevice.cpp

@ -426,9 +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); 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 // Example: F0 43 10 04 1A 00 F7 to F0 43 10 04 1A 07 F7
// Exponential mapping like on the TX816: 7=127, 6=63, 5=31, ... 0=0 // Logarithmic mapping for volume
unsigned attenVal = val & 0x07; unsigned attenVal = val & 0x07;
unsigned newVolume = (attenVal == 0) ? 0 : (127 >> (7 - attenVal)); unsigned newVolume = (unsigned)(127.0 * pow(attenVal / 7.0, 2.0) + 0.5);
m_pSynthesizer->SetVolume(newVolume, nTG); m_pSynthesizer->SetVolume(newVolume, nTG);
} }
break; break;

Loading…
Cancel
Save