From: <sv...@op...> - 2024-11-07 22:48:55
|
Author: sagamusix Date: Thu Nov 7 23:48:41 2024 New Revision: 22107 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22107 Log: [Fix] MED: Apparently in MED SoundStudio, when using 1-64ch software mixing mode, tempos 1-10 in SPD mode behave strangely (first 8 values all result in ~157 BPM, 8 upwards results in "normal" tempo). Fixes "K-SaveMe" (https://www.un4seen.com/forum/?topic=15448.msg144080#msg144080). Modified: trunk/OpenMPT/soundlib/Load_med.cpp Modified: trunk/OpenMPT/soundlib/Load_med.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Load_med.cpp Thu Nov 7 22:11:52 2024 (r22106) +++ trunk/OpenMPT/soundlib/Load_med.cpp Thu Nov 7 23:48:41 2024 (r22107) @@ -391,7 +391,7 @@ MPT_BINARY_STRUCT(MMDDump, 10) -static TEMPO MMDTempoToBPM(uint32 tempo, bool is8Ch, bool bpmMode, uint8 rowsPerBeat) +static TEMPO MMDTempoToBPM(uint32 tempo, bool is8Ch, bool softwareMixing, bool bpmMode, uint8 rowsPerBeat) { if(bpmMode && !is8Ch) { @@ -405,10 +405,14 @@ // MED Soundstudio uses these tempos when importing old files static constexpr uint8 tempos[10] = {179, 164, 152, 141, 131, 123, 116, 110, 104, 99}; return TEMPO(tempos[tempo - 1], 0); - } else if(tempo > 0 && tempo <= 10) + } else if(!softwareMixing && tempo > 0 && tempo <= 10) { // SoundTracker compatible tempo return TEMPO((6.0 * 1773447.0 / 14500.0) / tempo); + } else if(softwareMixing && tempo < 8) + { + // Observed in MED SoundStudio 1.03 with 1-64ch mixing mode and SPD tempo mode (bug?) + return TEMPO(157.86); } return TEMPO(tempo / 0.264); @@ -421,8 +425,8 @@ const CHANNELINDEX numTracks; const uint8 version; const uint8 rowsPerBeat; - const bool hardwareMixSamples : 1; const bool is8Ch : 1; + const bool softwareMixing : 1; const bool bpmMode : 1; const bool volHex : 1; }; @@ -469,7 +473,7 @@ m.param = 0x70; } else { - uint16 tempo = mpt::saturate_round<uint16>(MMDTempoToBPM(param, ctx.is8Ch, ctx.bpmMode, ctx.rowsPerBeat).ToDouble()); + uint16 tempo = mpt::saturate_round<uint16>(MMDTempoToBPM(param, ctx.is8Ch, ctx.softwareMixing, ctx.bpmMode, ctx.rowsPerBeat).ToDouble()); if(tempo <= Util::MaxValueOfType(m.param)) { m.param = static_cast<ModCommand::PARAM>(tempo); @@ -1448,8 +1452,9 @@ const bool volHex = (songHeader.flags & MMDSong::FLAG_VOLHEX) != 0; const bool is8Ch = (songHeader.flags & MMDSong::FLAG_8CHANNEL) != 0; const bool bpmMode = (songHeader.flags2 & MMDSong::FLAG2_BPM) != 0; + const bool softwareMixing = (songHeader.flags2 & MMDSong::FLAG2_MIX) != 0; const uint8 rowsPerBeat = 1 + (songHeader.flags2 & MMDSong::FLAG2_BMASK); - order.SetDefaultTempo(MMDTempoToBPM(songHeader.defaultTempo, is8Ch, bpmMode, rowsPerBeat)); + order.SetDefaultTempo(MMDTempoToBPM(songHeader.defaultTempo, is8Ch, softwareMixing, bpmMode, rowsPerBeat)); order.SetDefaultSpeed(Clamp<uint8, uint8>(songHeader.tempo2, 1, 32)); if(bpmMode) { @@ -1625,7 +1630,7 @@ pattern.SetName(patName); LimitMax(numTracks, GetNumChannels()); - TranslateMEDPatternContext context{transpose, numTracks, version, rowsPerBeat, hardwareMixSamples, is8Ch, bpmMode, volHex}; + TranslateMEDPatternContext context{transpose, numTracks, version, rowsPerBeat, is8Ch, softwareMixing, bpmMode, volHex}; needInstruments |= TranslateMEDPattern(file, cmdExt, pattern, context, false); for(uint16 page = 0; page < numPages; page++) |