From: <sv...@op...> - 2024-11-24 13:05:27
|
Author: sagamusix Date: Sun Nov 24 14:05:15 2024 New Revision: 22290 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22290 Log: Merged revision(s) 22251 from trunk/OpenMPT: [Imp] DBM / IMF / MED: When merging pattern commands, allow to move offset to volume column at the expense of a lower offset resolution. Slightly improves playback of ShowMeLove.med (https://www.un4seen.com/forum/?topic=15448.msg144136#msg144136). ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Load_dbm.cpp branches/OpenMPT-1.31/soundlib/Load_imf.cpp branches/OpenMPT-1.31/soundlib/Load_med.cpp branches/OpenMPT-1.31/soundlib/ModSample.cpp branches/OpenMPT-1.31/soundlib/modcommand.cpp branches/OpenMPT-1.31/soundlib/modcommand.h Modified: branches/OpenMPT-1.31/soundlib/Load_dbm.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_dbm.cpp Sun Nov 24 14:03:24 2024 (r22289) +++ branches/OpenMPT-1.31/soundlib/Load_dbm.cpp Sun Nov 24 14:05:15 2024 (r22290) @@ -109,7 +109,7 @@ void ConvertToMPT(ModSample &mptSmp) const { - mptSmp.Initialize(); + mptSmp.Initialize(MOD_TYPE_DBM); mptSmp.nVolume = std::min(static_cast<uint16>(volume), uint16(64)) * 4u; mptSmp.nC5Speed = Util::muldivr(sampleRate, 8303, 8363); @@ -583,7 +583,7 @@ cmd1 = CMD_NONE; } - const auto lostCommand = m.FillInTwoCommands(cmd1, param1, cmd2, param2); + const auto lostCommand = m.FillInTwoCommands(cmd1, param1, cmd2, param2, true); if(ModCommand::IsGlobalCommand(lostCommand.first, lostCommand.second)) lostGlobalCommands.insert(lostGlobalCommands.begin(), lostCommand); // Insert at front so that the last command of same type "wins" Modified: branches/OpenMPT-1.31/soundlib/Load_imf.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_imf.cpp Sun Nov 24 14:03:24 2024 (r22289) +++ branches/OpenMPT-1.31/soundlib/Load_imf.cpp Sun Nov 24 14:05:15 2024 (r22290) @@ -177,7 +177,7 @@ // Convert an IMFSample to OpenMPT's internal sample representation. void ConvertToMPT(ModSample &mptSmp) const { - mptSmp.Initialize(); + mptSmp.Initialize(MOD_TYPE_IMF); mptSmp.filename = mpt::String::ReadBuf(mpt::String::nullTerminated, filename); mptSmp.nLength = length; @@ -556,7 +556,7 @@ const auto [e1c, e1d, e2c, e2d] = patternChunk.ReadArray<uint8, 4>(); // Command 1, Data 1, Command 2, Data 2 const auto [command1, param1] = TranslateIMFEffect(e1c, e1d); const auto [command2, param2] = TranslateIMFEffect(e2c, e2d); - m.FillInTwoCommands(command1, param1, command2, param2); + m.FillInTwoCommands(command1, param1, command2, param2, true); } else if(mask & 0xC0) { // There's one effect, just stick it in the effect column (unless it's a volume command) Modified: branches/OpenMPT-1.31/soundlib/Load_med.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_med.cpp Sun Nov 24 14:03:24 2024 (r22289) +++ branches/OpenMPT-1.31/soundlib/Load_med.cpp Sun Nov 24 14:05:15 2024 (r22290) @@ -641,7 +641,7 @@ if(oldCmd.first != CMD_NONE && m->command != oldCmd.first) { if(!ModCommand::CombineEffects(m->command, m->param, oldCmd.first, oldCmd.second) && m->volcmd == VOLCMD_NONE) - m->FillInTwoCommands(m->command, m->param, oldCmd.first, oldCmd.second); + m->FillInTwoCommands(m->command, m->param, oldCmd.first, oldCmd.second, true); // Reset X-Param to 8-bit value if this cell was overwritten with a "useful" effect if(row > 0 && oldCmd.first == CMD_XPARAM && m->command != CMD_XPARAM) pattern.GetpModCommand(row - 1, chn)->param = Util::MaxValueOfType(m->param); Modified: branches/OpenMPT-1.31/soundlib/ModSample.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/ModSample.cpp Sun Nov 24 14:03:24 2024 (r22289) +++ branches/OpenMPT-1.31/soundlib/ModSample.cpp Sun Nov 24 14:05:15 2024 (r22290) @@ -154,7 +154,16 @@ rootNote = 0; filename = ""; - RemoveAllCuePoints(); + if(type & (MOD_TYPE_DBM | MOD_TYPE_IMF | MOD_TYPE_MED)) + { + for(SmpLength i = 1; i < 10; i++) + { + cues[i - 1] = Util::muldiv_unsigned(i, 255 * 256, 9); + } + } else + { + RemoveAllCuePoints(); + } } Modified: branches/OpenMPT-1.31/soundlib/modcommand.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/modcommand.cpp Sun Nov 24 14:03:24 2024 (r22289) +++ branches/OpenMPT-1.31/soundlib/modcommand.cpp Sun Nov 24 14:05:15 2024 (r22290) @@ -1346,7 +1346,7 @@ } -std::pair<EffectCommand, ModCommand::PARAM> ModCommand::FillInTwoCommands(EffectCommand effect1, uint8 param1, EffectCommand effect2, uint8 param2) +std::pair<EffectCommand, ModCommand::PARAM> ModCommand::FillInTwoCommands(EffectCommand effect1, uint8 param1, EffectCommand effect2, uint8 param2, bool allowLowResOffset) { if(effect1 == effect2) { @@ -1401,6 +1401,12 @@ std::swap(effect1, effect2); std::swap(param1, param2); } + if(effect2 == CMD_OFFSET && (allowLowResOffset || param2 == 0)) + { + SetVolumeCommand(VOLCMD_OFFSET, static_cast<ModCommand::VOL>(param2 ? std::max(param2 * 9 / 255, 1) : 0)); + SetEffectCommand(effect1, param1); + return {CMD_NONE, ModCommand::PARAM(0)}; + } SetVolumeCommand(VOLCMD_NONE, 0); SetEffectCommand(effect2, param2); return {effect1, param1}; Modified: branches/OpenMPT-1.31/soundlib/modcommand.h ============================================================================== --- branches/OpenMPT-1.31/soundlib/modcommand.h Sun Nov 24 14:03:24 2024 (r22289) +++ branches/OpenMPT-1.31/soundlib/modcommand.h Sun Nov 24 14:05:15 2024 (r22290) @@ -230,7 +230,7 @@ // Try to convert a an effect into a volume column effect. Returns converted effect on success. [[nodiscard]] static std::pair<VolumeCommand, VOL> ConvertToVolCommand(const EffectCommand effect, PARAM param, bool force); // Takes two "normal" effect commands and converts them to volume column + effect column commands. Returns the dropped command + param (CMD_NONE if nothing had to be dropped). - std::pair<EffectCommand, PARAM> FillInTwoCommands(EffectCommand effect1, uint8 param1, EffectCommand effect2, uint8 param2); + std::pair<EffectCommand, PARAM> FillInTwoCommands(EffectCommand effect1, uint8 param1, EffectCommand effect2, uint8 param2, bool allowLowResOffset = false); // Try to combine two commands into one. Returns true on success and the combined command is placed in eff1 / param1. static bool CombineEffects(EffectCommand &eff1, uint8 ¶m1, EffectCommand &eff2, uint8 ¶m2); |