From 03a44e6b189f8ac34ff79cb62fbf9a67f7bdb9e1 Mon Sep 17 00:00:00 2001 From: Johannes Schultz Date: Thu, 19 Sep 2024 14:01:47 +0000 Subject: [PATCH] Merged revision(s) 21414-21415 from trunk/OpenMPT: [Fix] Result of CMD_VOLUME was never sent to plugins, because it was processed after ProcessMidiOut was called. In particular this means that MOD to MIDI export didn't export volumes. ........ [Fix] Velocity was halved in previous commit. ........ git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.31@21627 56274372-70c3-4bfc-bfc3-4c3a0b034d27 --- soundlib/Sndmix.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/soundlib/Sndmix.cpp b/soundlib/Sndmix.cpp index b3561e4cd6..4e4b2d04bf 100644 --- a/soundlib/Sndmix.cpp +++ b/soundlib/Sndmix.cpp @@ -2641,11 +2641,11 @@ void CSoundFile::ProcessMidiOut(CHANNELINDEX nChn) // Check for volume commands uint8 vol = 0xFF; if(chn.rowCommand.volcmd == VOLCMD_VOLUME) - vol = std::min(chn.rowCommand.vol, uint8(64)); + vol = std::min(chn.rowCommand.vol, uint8(64)) * 2u; else if(chn.rowCommand.command == CMD_VOLUME) - vol = std::min(chn.rowCommand.param, uint8(64)); + vol = std::min(chn.rowCommand.param, uint8(64)) * 2u; else if(chn.rowCommand.command == CMD_VOLUME8) - vol = static_cast((chn.rowCommand.param + 3u) / 4u); + vol = static_cast((chn.rowCommand.param + 1u) / 2u); const bool hasVolCommand = (vol != 0xFF); @@ -2659,7 +2659,7 @@ void CSoundFile::ProcessMidiOut(CHANNELINDEX nChn) SendMIDINote(nChn, realNote, static_cast(chn.nVolume)); } else if(hasVolCommand) { - pPlugin->MidiCC(MIDIEvents::MIDICC_Volume_Fine, vol, nChn); + pPlugin->MidiCC(MIDIEvents::MIDICC_Volume_Fine, vol / 2u, nChn); } return; } @@ -2673,7 +2673,7 @@ void CSoundFile::ProcessMidiOut(CHANNELINDEX nChn) switch(pIns->pluginVelocityHandling) { case PLUGIN_VELOCITYHANDLING_CHANNEL: - velocity = chn.nVolume; + velocity = hasVolCommand ? vol * 2 : chn.nVolume; break; default: break; @@ -2701,11 +2701,11 @@ void CSoundFile::ProcessMidiOut(CHANNELINDEX nChn) switch(pIns->pluginVolumeHandling) { case PLUGIN_VOLUMEHANDLING_DRYWET: - if(hasVolCommand) pPlugin->SetDryRatio(1.0f - (2 * vol) / 127.0f); + if(hasVolCommand) pPlugin->SetDryRatio(1.0f - vol / 127.0f); else pPlugin->SetDryRatio(1.0f - (2 * defaultVolume) / 127.0f); break; case PLUGIN_VOLUMEHANDLING_MIDI: - if(hasVolCommand) pPlugin->MidiCC(MIDIEvents::MIDICC_Volume_Coarse, std::min(uint8(127), static_cast(2 * vol)), nChn); + if(hasVolCommand) pPlugin->MidiCC(MIDIEvents::MIDICC_Volume_Coarse, std::min(uint8(127), vol), nChn); else pPlugin->MidiCC(MIDIEvents::MIDICC_Volume_Coarse, static_cast(std::min(uint32(127), static_cast(2 * defaultVolume))), nChn); break; default: