From: <sv...@op...> - 2024-08-05 21:59:36
|
Author: sagamusix Date: Mon Aug 5 23:59:24 2024 New Revision: 21335 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21335 Log: Merged revision(s) 21334 from trunk/OpenMPT: [Fix] SFX: Last arpeggio note is held at end of row, and a peculiar 0-1-2-0-2-1 arpeggio table is used. Fixes Bassbomb/ok.sfx (https://www.un4seen.com/forum/?topic=15448.msg143414#msg143414). [Fix] SFX: Ignore unused data at end of oneshot samples which sometimes caused clicky noises (https://www.un4seen.com/forum/?topic=15448.msg143414#msg143414). ........ Modified: branches/OpenMPT-1.31/ (props changed) branches/OpenMPT-1.31/soundlib/Load_sfx.cpp branches/OpenMPT-1.31/soundlib/Sndmix.cpp Modified: branches/OpenMPT-1.31/soundlib/Load_sfx.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Load_sfx.cpp Mon Aug 5 23:59:00 2024 (r21334) +++ branches/OpenMPT-1.31/soundlib/Load_sfx.cpp Mon Aug 5 23:59:24 2024 (r21335) @@ -54,7 +54,7 @@ struct SFXSampleHeader { char name[22]; - char dummy[2]; // Supposedly sample length, but almost always incorrect + uint16be oneshotLength; // For unlooped samples, this is quite frequently 2 bytes shorter than the sample data length (and the last two samples would cause a click to be heard) uint8be finetune; uint8be volume; uint16be loopStart; @@ -64,7 +64,7 @@ void ConvertToMPT(ModSample &mptSmp, uint32 length) const { mptSmp.Initialize(MOD_TYPE_MOD); - mptSmp.nLength = length; + mptSmp.nLength = (loopLength > 1) ? length : (oneshotLength * 2u); mptSmp.nFineTune = MOD2XMFineTune(finetune); mptSmp.nVolume = 4u * std::min(volume.get(), uint8(64)); @@ -434,14 +434,18 @@ // Reading samples if(loadFlags & loadSampleData) { - for(SAMPLEINDEX smp = 1; smp <= m_nSamples; smp++) if(Samples[smp].nLength) + for(SAMPLEINDEX smp = 1; smp <= m_nSamples; smp++) { + if(!sampleLen[smp - 1]) + continue; + + FileReader chunk = file.ReadChunk(sampleLen[smp - 1]); SampleIO( SampleIO::_8bit, SampleIO::mono, SampleIO::littleEndian, SampleIO::signedPCM) - .ReadSample(Samples[smp], file); + .ReadSample(Samples[smp], chunk); } } Modified: branches/OpenMPT-1.31/soundlib/Sndmix.cpp ============================================================================== --- branches/OpenMPT-1.31/soundlib/Sndmix.cpp Mon Aug 5 23:59:00 2024 (r21334) +++ branches/OpenMPT-1.31/soundlib/Sndmix.cpp Mon Aug 5 23:59:24 2024 (r21335) @@ -1592,6 +1592,11 @@ uint8 note = (GetType() != MOD_TYPE_MOD) ? chn.nNote : static_cast<uint8>(GetNoteFromPeriod(period, chn.nFineTune, chn.nC5Speed)); if(GetType() & (MOD_TYPE_DBM | MOD_TYPE_DIGI)) tick += 2; + + // SFX uses a 0-1-2-0-2-1 pattern (fixed at 6 ticks per row) + if(GetType() == MOD_TYPE_SFX && tick > 3) + tick ^= 3; + switch(tick % 3) { case 1: note += (chn.nArpeggio >> 4); break; @@ -1614,7 +1619,7 @@ } period = GetPeriodFromNote(note, chn.nFineTune, chn.nC5Speed); - if(GetType() & (MOD_TYPE_DBM | MOD_TYPE_DIGI | MOD_TYPE_PSM | MOD_TYPE_STM | MOD_TYPE_OKT)) + if(GetType() & (MOD_TYPE_DBM | MOD_TYPE_DIGI | MOD_TYPE_PSM | MOD_TYPE_STM | MOD_TYPE_OKT | MOD_TYPE_SFX)) { // The arpeggio note offset remains effective after the end of the current row in ScreamTracker 2. // This fixes the flute lead in MORPH.STM by Skaven, pattern 27. |