From fbd96caf039aa877603e410444fd2aa900f531e7 Mon Sep 17 00:00:00 2001 From: Johannes Schultz Date: Sat, 16 Nov 2024 00:42:07 +0000 Subject: [PATCH] Merged revision(s) 22199 from trunk/OpenMPT: [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 --- soundlib/Load_med.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/soundlib/Load_med.cpp b/soundlib/Load_med.cpp index 46828c4a7e8..18656dce42e 100644 --- a/soundlib/Load_med.cpp +++ b/soundlib/Load_med.cpp @@ -406,6 +406,7 @@ struct TranslateMEDPatternContext const bool softwareMixing : 1; const bool bpmMode : 1; const bool volHex : 1; + const bool vol7bit : 1; }; @@ -426,7 +427,7 @@ static std::pair 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((param >> 4) * 10 + (param & 0x0F))); - else if(ctx.volHex && ctx.version < 3) + else if(ctx.volHex && !ctx.vol7bit) m.SetEffectCommand(CMD_VOLUME, static_cast(std::min(param & 0x7F, 64))); else if(ctx.volHex) m.SetEffectCommand(CMD_VOLUME, static_cast(((param & 0x7F) + 1) / 2)); @@ -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) { @@ -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; @@ -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++)