From: <sv...@op...> - 2024-09-22 22:37:36
|
Author: sagamusix Date: Mon Sep 23 00:37:23 2024 New Revision: 21687 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21687 Log: Merged revision(s) 21685-21686 from trunk/OpenMPT: [Fix] OKT: Disable loop on type "B" samples if they're used on a mixed channel. Fixes sinfonia.okta (https://www.un4seen.com/forum/?topic=15448.msg143764#msg143764). ........ [Fix] PTM: Polytracker is another one of those trackers where offset command strength is halved by using 16-bit samples... fixes leveled.ptm (https://www.un4seen.com/forum/?topic=15448.msg143764#msg143764). ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Load_okt.cpp branches/OpenMPT-1.31/soundlib/Load_ptm.cpp branches/OpenMPT-1.31/soundlib/Snd_fx.cpp Modified: branches/OpenMPT-1.31/soundlib/Load_okt.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_okt.cpp Mon Sep 23 00:36:58 2024 (r21686) +++ branches/OpenMPT-1.31/soundlib/Load_okt.cpp Mon Sep 23 00:37:23 2024 (r21687) @@ -30,7 +30,7 @@ }; uint32be signature; // IFF chunk name - uint32be chunksize; // chunk size without header + uint32be chunkSize; // Chunk size without header }; MPT_BINARY_STRUCT(OktIffChunk, 8) @@ -38,11 +38,11 @@ struct OktSample { char name[20]; - uint32be length; // length in bytes + uint32be length; // Length in bytes uint16be loopStart; // *2 for real value uint16be loopLength; // ditto - uint16be volume; // default volume - uint16be type; // 7-/8-bit sample + uint16be volume; // Default volume + uint16be type; // 7-/8-bit sample (0: 7-bit, only usable on paired channels ["8" in GUI], 1: 8-bit, only usable on unpaired channels ["4" in GUI], 2: 7-bit, usable on all channels ["B" in GUI]) }; MPT_BINARY_STRUCT(OktSample, 32) @@ -124,20 +124,26 @@ if(note > 0 && note <= 36) { m.note = note + (NOTE_MIDDLEC - 13); + if(pairedChn[chn] && m.note >= NOTE_MIDDLEC + 22) + m.note = NOTE_MIDDLEC + 21; + m.instr = instr + 1; if(m.instr > 0 && m.instr <= sndFile.GetNumSamples()) { - const auto &sample = sndFile.GetSample(m.instr); + auto &sample = sndFile.GetSample(m.instr); // Default volume only works on raw Paula channels if(pairedChn[chn] && sample.nVolume < 256) - { m.SetVolumeCommand(VOLCMD_VOLUME, 64); - } + // Type "B" samples (can play on both paired and unpaired channels) can have loop information, + // which can only be used on unpaired channels. The correct fix would be to have a looped and unlooped variant of this sample, + // but it is probably quite unlikely that any module relies on this behaviour. + // On the other hand, sinfonia.okta has a type "B" sample with loop points set, and it only uses paired channels. + if(pairedChn[chn] && sample.uFlags[CHN_SUSTAINLOOP]) + sample.uFlags.reset(CHN_SUSTAINLOOP); + // If channel and sample type don't match, stop this channel (add 100 to the instrument number to make it understandable what happened during import) if((sample.cues[0] == 1 && pairedChn[chn] != 0) || (sample.cues[0] == 0 && pairedChn[chn] == 0)) - { m.instr += 100; - } } } @@ -330,7 +336,7 @@ if(!file.ReadStruct(iffHead)) break; - FileReader chunk = file.ReadChunk(iffHead.chunksize); + FileReader chunk = file.ReadChunk(iffHead.chunkSize); if(!chunk.IsValid()) continue; Modified: branches/OpenMPT-1.31/soundlib/Load_ptm.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_ptm.cpp Mon Sep 23 00:36:58 2024 (r21686) +++ branches/OpenMPT-1.31/soundlib/Load_ptm.cpp Mon Sep 23 00:37:23 2024 (r21687) @@ -273,6 +273,13 @@ case CMD_GLOBALVOLUME: m.param = std::min(m.param, uint8(0x40)) * 2u; break; +#ifdef MODPLUG_TRACKER + case CMD_OFFSET: + case CMD_REVERSEOFFSET: + if(m.instr && m.instr <= GetNumSamples() && Samples[m.instr].uFlags[CHN_16BIT]) + m.param /= 2; + break; +#endif // MODPLUG_TRACKER default: break; } Modified: branches/OpenMPT-1.31/soundlib/Snd_fx.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Snd_fx.cpp Mon Sep 23 00:36:58 2024 (r21686) +++ branches/OpenMPT-1.31/soundlib/Snd_fx.cpp Mon Sep 23 00:37:23 2024 (r21687) @@ -5451,9 +5451,9 @@ param = (param - chn.nLoopStart) % (chn.nLoopEnd - chn.nLoopStart) + chn.nLoopStart; } - if(GetType() == MOD_TYPE_MDL && chn.dwFlags[CHN_16BIT]) + if((GetType() & (MOD_TYPE_MDL | MOD_TYPE_PTM)) && chn.dwFlags[CHN_16BIT]) { - // Digitrakker really uses byte offsets, not sample offsets. WTF! + // Digitrakker and Polytracker use byte offsets, not sample offsets. param /= 2u; } @@ -5526,7 +5526,10 @@ chn.dwFlags.set(CHN_PINGPONGFLAG); chn.dwFlags.reset(CHN_LOOP); chn.nLength = chn.pModSample->nLength; // If there was a loop, extend sample to whole length. - chn.position.Set((chn.nLength - 1) - std::min(SmpLength(param) << 8, chn.nLength - SmpLength(1)), 0); + SmpLength offset = param << 8; + if(GetType() == MOD_TYPE_PTM && chn.dwFlags[CHN_16BIT]) + offset /= 2; + chn.position.Set((chn.nLength - 1) - std::min(offset, chn.nLength - SmpLength(1)), 0); } } |