Skip to content

Commit

Permalink
Merged revision(s) 21414-21415 from trunk/OpenMPT:
Browse files Browse the repository at this point in the history
[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
  • Loading branch information
sagamusix committed Sep 19, 2024
1 parent 1377508 commit 03a44e6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions soundlib/Sndmix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint8>((chn.rowCommand.param + 3u) / 4u);
vol = static_cast<uint8>((chn.rowCommand.param + 1u) / 2u);

const bool hasVolCommand = (vol != 0xFF);

Expand All @@ -2659,7 +2659,7 @@ void CSoundFile::ProcessMidiOut(CHANNELINDEX nChn)
SendMIDINote(nChn, realNote, static_cast<uint16>(chn.nVolume));
} else if(hasVolCommand)
{
pPlugin->MidiCC(MIDIEvents::MIDICC_Volume_Fine, vol, nChn);
pPlugin->MidiCC(MIDIEvents::MIDICC_Volume_Fine, vol / 2u, nChn);
}
return;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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<uint8>(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<uint8>(std::min(uint32(127), static_cast<uint32>(2 * defaultVolume))), nChn);
break;
default:
Expand Down

0 comments on commit 03a44e6

Please sign in to comment.