From: <sv...@op...> - 2024-11-09 23:38:20
|
Author: sagamusix Date: Sun Nov 10 00:38:13 2024 New Revision: 22131 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22131 Log: [Mod] S3M: Don't clamp out-of-range notes to minimum note. [Imp] Add more tests for S3M / XM out-of-range note saving. Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp Sun Nov 10 00:30:29 2024 (r22130) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp Sun Nov 10 00:38:13 2024 (r22131) @@ -973,13 +973,9 @@ { // Note Cut note = s3mNoteOff; - } else if(note >= NOTE_MIN && note < NOTE_MIN + 12) + } else if(note >= NOTE_MIN + 12 && note <= NOTE_MIN + 107) { - // Too low - note = 0; - } else if(note >= NOTE_MIN && note <= NOTE_MIN + 107) - { - note -= (12 + NOTE_MIN); + note -= NOTE_MIN + 12; note = static_cast<uint8>((note % 12) + ((note / 12) << 4)); } else { Modified: trunk/OpenMPT/test/test.cpp ============================================================================== --- trunk/OpenMPT/test/test.cpp Sun Nov 10 00:30:29 2024 (r22130) +++ trunk/OpenMPT/test/test.cpp Sun Nov 10 00:38:13 2024 (r22131) @@ -2866,7 +2866,8 @@ VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(0, 1)->note, NOTE_MIN + 12); VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(1, 1)->note, NOTE_MIN + 12 + 95); VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(2, 1)->note, NOTE_KEYOFF); - VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 0)->IsEmpty(), true); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(30, 0)->IsEmpty(), true); // Test for resaved out-of-range note + VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 0)->IsEmpty(), true); // Test for resaved out-of-range note VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->IsEmpty(), false); VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->IsPcNote(), false); VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetpModCommand(31, 1)->note, NOTE_MIDDLEC + 12); @@ -3412,7 +3413,8 @@ VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(3, 0)->IsEmpty(), false); VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(3, 0)->note, NOTE_NONE); VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(3, 0)->instr, 99); - VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(4, 0)->IsEmpty(), true); + VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(4, 0)->IsEmpty(), true); // Test for resaved out-of-range note + VERIFY_EQUAL_NONCONT(sndFile.Patterns[0].GetpModCommand(5, 0)->IsEmpty(), true); // Test for resaved out-of-range note VERIFY_EQUAL_NONCONT(sndFile.Patterns[1].GetNumRows(), 64); VERIFY_EQUAL_NONCONT(sndFile.Patterns.IsPatternEmpty(1), false); @@ -3714,6 +3716,8 @@ // file still works. GetSoundFile(sndFileContainer).m_nSamples++; GetSoundFile(sndFileContainer).Instruments[1]->Keyboard[110] = GetSoundFile(sndFileContainer).GetNumSamples(); + GetSoundFile(sndFileContainer).Patterns[1].GetpModCommand(30, 0)->note = NOTE_MIN; // Should not be saved to file + GetSoundFile(sndFileContainer).Patterns[1].GetpModCommand(31, 0)->note = NOTE_MIN + 108; // Ditto #ifndef MODPLUG_NO_FILESAVE // Test file saving @@ -3774,6 +3778,8 @@ #ifndef MODPLUG_NO_FILESAVE // Test file saving sndFile.ChnSettings[1].dwFlags.set(CHN_MUTE); + sndFile.Patterns[0].GetpModCommand(4, 0)->note = NOTE_MIN; // Should not be saved to file + sndFile.Patterns[0].GetpModCommand(5, 0)->note = NOTE_MIN + 108; // Ditto sndFile.m_dwLastSavedWithVersion = Version::Current(); #if MPT_OS_DJGPP SaveS3M(sndFileContainer, filenameBase + P_("ss3")); |