Skip to content

Commit

Permalink
Merged revision(s) 22056, 22377 from trunk/OpenMPT:
Browse files Browse the repository at this point in the history
[Imp] Warn when Startrekker AM companion file for synthesized instruments is most likely missing.
........
[Imp] Allow Startrekker AM external sample check to also work for libopenmpt.
........


git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.30@22379 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Dec 1, 2024
1 parent b65dc0f commit e5d1255
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion soundlib/Load_mod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ bool CSoundFile::ReadMOD(FileReader &file, ModLoadingFlags loadFlags)

// Reading patterns
Patterns.ResizeArray(numPatterns);
std::bitset<32> referencedSamples;
for(PATTERNINDEX pat = 0; pat < numPatterns; pat++)
{
ModCommand *rowBase = nullptr;
Expand Down Expand Up @@ -1148,6 +1149,8 @@ bool CSoundFile::ReadMOD(FileReader &file, ModLoadingFlags loadFlags)
if(m.instr != 0)
{
lastInstrument[chn] = m.instr;
if(isStartrekker)
referencedSamples.set(m.instr & 0x1F);
}
}
if(hasSpeedOnRow && hasTempoOnRow)
Expand Down Expand Up @@ -1278,7 +1281,7 @@ bool CSoundFile::ReadMOD(FileReader &file, ModLoadingFlags loadFlags)
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);
Expand All @@ -1301,6 +1304,32 @@ bool CSoundFile::ReadMOD(FileReader &file, ModLoadingFlags loadFlags)
}
#endif // MPT_EXTERNAL_SAMPLES || MPT_BUILD_FUZZER

if((loadFlags & loadSampleData) && isStartrekker && !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);
}
#ifdef MPT_EXTERNAL_SAMPLES
AddToLog(LogWarning, MPT_UFORMAT("This Startrekker AM file is most likely missing its companion file{}. Synthesized instruments will not play.")(filenameHint));
#else
AddToLog(LogWarning, U_("This appears to be a Startrekker AM file with external synthesizes instruments. External instruments are currently not supported."));
#endif // MPT_EXTERNAL_SAMPLES
break;
}
}
}
}

// Fix VBlank MODs. Arbitrary threshold: 8 minutes (enough for "frame of mind" by Dascon...).
// Basically, this just converts all tempo commands into speed commands
// for MODs which are supposed to have VBlank timing (instead of CIA timing).
Expand Down

0 comments on commit e5d1255

Please sign in to comment.