Skip to content

Commit

Permalink
Merged revision(s) 22199 from trunk/OpenMPT:
Browse files Browse the repository at this point in the history
[Fix] MED: Another attempt at getting volume commands right. If MED Soundstudio for Windows behaviour is to be believed, 7-bit volume should only be applied if the pattern has valid block info. Otherwise it multiplies volume command parameters by 2. Fixes drain from hyperland! (d.f.h).med (https://www.un4seen.com/forum/?topic=15448.msg144105#msg144105)
........


git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.31@22200 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Nov 16, 2024
1 parent ca0886a commit fbd96ca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions soundlib/Load_med.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ struct TranslateMEDPatternContext
const bool softwareMixing : 1;
const bool bpmMode : 1;
const bool volHex : 1;
const bool vol7bit : 1;
};


Expand All @@ -426,7 +427,7 @@ static std::pair<EffectCommand, ModCommand::PARAM> ConvertMEDEffect(ModCommand &
case 0x0C: // Set Volume (note: parameters >= 0x80 (only in hex mode?) should set the default instrument volume, which we don't support)
if(!ctx.volHex && param < 0x99)
m.SetEffectCommand(CMD_VOLUME, static_cast<ModCommand::PARAM>((param >> 4) * 10 + (param & 0x0F)));
else if(ctx.volHex && ctx.version < 3)
else if(ctx.volHex && !ctx.vol7bit)
m.SetEffectCommand(CMD_VOLUME, static_cast<ModCommand::PARAM>(std::min(param & 0x7F, 64)));
else if(ctx.volHex)
m.SetEffectCommand(CMD_VOLUME, static_cast<ModCommand::PARAM>(((param & 0x7F) + 1) / 2));
Expand Down Expand Up @@ -1389,6 +1390,7 @@ bool CSoundFile::ReadMED(FileReader &file, ModLoadingFlags loadFlags)
int16 transpose = NOTE_MIN + 47 + songHeader.playTranspose;
uint16 numPages = 0;
FileReader cmdExt, commandPages;
bool vol7bit = false;

if(version < 1)
{
Expand All @@ -1406,6 +1408,7 @@ bool CSoundFile::ReadMED(FileReader &file, ModLoadingFlags loadFlags)
numRows = patHeader.numRows + 1;
if(patHeader.blockInfoOffset)
{
vol7bit = true;
auto offset = file.GetPosition();
file.Seek(patHeader.blockInfoOffset);
MMDBlockInfo blockInfo;
Expand Down Expand Up @@ -1444,7 +1447,7 @@ bool CSoundFile::ReadMED(FileReader &file, ModLoadingFlags loadFlags)
pattern.SetName(patName);
LimitMax(numTracks, m_nChannels);

TranslateMEDPatternContext context{transpose, numTracks, version, rowsPerBeat, is8Ch, softwareMixing, bpmMode, volHex};
TranslateMEDPatternContext context{transpose, numTracks, version, rowsPerBeat, is8Ch, softwareMixing, bpmMode, volHex, vol7bit};
needInstruments |= TranslateMEDPattern(file, cmdExt, pattern, context, false);

for(uint16 page = 0; page < numPages; page++)
Expand Down

0 comments on commit fbd96ca

Please sign in to comment.