From: <sv...@op...> - 2024-11-01 22:47:54
|
Author: sagamusix Date: Fri Nov 1 23:47:42 2024 New Revision: 22058 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22058 Log: Merged revision(s) 22055-22056 from trunk/OpenMPT: [Fix] MOD: Also enable ProTracker-compatible tremolo ramp waveform for M!K! modules. ........ [Imp] Warn when Startrekker AM companion file for synthesized instruments is most likely missing. ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Load_mod.cpp Modified: branches/OpenMPT-1.31/soundlib/Load_mod.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_mod.cpp Fri Nov 1 23:42:41 2024 (r22057) +++ branches/OpenMPT-1.31/soundlib/Load_mod.cpp Fri Nov 1 23:47:42 2024 (r22058) @@ -1072,6 +1072,7 @@ // Reading patterns Patterns.ResizeArray(numPatterns); + std::bitset<32> referencedSamples; for(PATTERNINDEX pat = 0; pat < numPatterns; pat++) { ModCommand *rowBase = nullptr; @@ -1179,6 +1180,8 @@ if(m.instr != 0) { lastInstrument[chn] = m.instr; + if(isStartrekker) + referencedSamples.set(m.instr & 0x1F); } } if(hasSpeedOnRow && hasTempoOnRow) @@ -1215,7 +1218,7 @@ { m_SongFlags.set(SONG_ISAMIGA); } - if(isGenericMultiChannel || isMdKd) + if(isGenericMultiChannel || isMdKd || IsMagic(magic, "M!K!")) { m_playBehaviour.set(kFT2MODTremoloRampWaveform); } @@ -1316,7 +1319,7 @@ m_nInstruments = 31; #endif - for(SAMPLEINDEX smp = 1; smp <= m_nInstruments; smp++) + for(SAMPLEINDEX smp = 1; smp <= GetNumInstruments(); smp++) { // For Startrekker AM synthesis, we need instrument envelopes. ModInstrument *ins = AllocateInstrument(smp, smp); @@ -1336,6 +1339,28 @@ // This extra padding is probably present to have identical block sizes for AM and FM instruments. amData.Skip(120 - sizeof(AMInstrument)); } + + if(!m_nInstruments) + { + uint8 emptySampleReferences = 0; + for(SAMPLEINDEX smp = 1; smp <= 31; smp++) + { + if(referencedSamples[smp] && !Samples[smp].nLength) + { + if(++emptySampleReferences > 1) + { + mpt::ustring filenameHint; + if(file.GetOptionalFileName()) + { + const auto filename = file.GetOptionalFileName()->GetFilename().ToUnicode(); + filenameHint = MPT_UFORMAT(" ({}.nt or {}.as)")(filename, filename); + } + AddToLog(LogWarning, MPT_UFORMAT("This Startrekker AM file is most likely missing its companion file{}. Synthesized instruments will not play.")(filenameHint)); + break; + } + } + } + } } #endif // MPT_EXTERNAL_SAMPLES || MPT_BUILD_FUZZER |