From: <sag...@us...> - 2014-10-10 19:41:09
|
Revision: 4411 http://sourceforge.net/p/modplug/code/4411 Author: saga-games Date: 2014-10-10 19:40:50 +0000 (Fri, 10 Oct 2014) Log Message: ----------- [New] Added support for a MOD variant introduced by SoundTracker 2.6 and Ice Tracker [Fix] XM: FT2 panning scheme was also applied to XMs made with trackers that most definitely don't use square root panning law. [Mod] OpenMPT: Version is now 1.24.00.08 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Load_mod.cpp trunk/OpenMPT/soundlib/Load_xm.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-10-10 17:34:53 UTC (rev 4410) +++ trunk/OpenMPT/common/versionNumber.h 2014-10-10 19:40:50 UTC (rev 4411) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 07 +#define VER_MINORMINOR 08 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/soundlib/Load_mod.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-10 17:34:53 UTC (rev 4410) +++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-10-10 19:40:50 UTC (rev 4411) @@ -1,7 +1,7 @@ /* * Load_mod.cpp * ------------ - * Purpose: MOD / NST (ProTracker / NoiseTracker) and M15 / STK (Ultimate Soundtracker / Soundtracker) module loader / saver + * Purpose: MOD / NST (ProTracker / NoiseTracker), M15 / STK (Ultimate Soundtracker / Soundtracker) and ST26 (SoundTracker 2.6 / Ice Tracker) module loader / saver * Notes : (currently none) * Authors: Olivier Lapicque * OpenMPT Devs @@ -280,7 +280,7 @@ } } - // Convert OpenMPT's internal sample header to an MOD sample header. + // Convert OpenMPT's internal sample header to a MOD sample header. SmpLength ConvertToMOD(const ModSample &mptSmp) { SmpLength writeLength = mptSmp.pSample != nullptr ? mptSmp.nLength : 0; @@ -1134,6 +1134,122 @@ } +// SoundTracker 2.6 / Ice Tracker variation of the MOD format +// The only real difference to other SoundTracker formats is the way patterns are stored: +// Every pattern consists of four independent, re-usable tracks. +bool CSoundFile::ReadICE(FileReader &file, ModLoadingFlags loadFlags) +//------------------------------------------------------------------- +{ + char magic[4]; + if(!file.Seek(1464) || !file.ReadArray(magic)) + { + return false; + } + + InitializeGlobals(); + + if(IsMagic(magic, "MTN\0")) + madeWithTracker = "SoundTracker 2.6"; + else if(IsMagic(magic, "IT10")) + madeWithTracker = "Ice Tracker 1.0 / 1.1"; + else + return false; + + // Reading song title + file.Seek(0); + file.ReadString<mpt::String::spacePadded>(songName, 20); + + // Load Samples + m_nSamples = 31; + for(SAMPLEINDEX smp = 1; smp <= 31; smp++) + { + MODSampleHeader sampleHeader; + ReadSample(file, sampleHeader, Samples[smp], m_szNames[smp]); + } + + const uint8 numOrders = file.ReadUint8(); + const uint8 numTracks = file.ReadUint8(); + if(numOrders > 128) + return false; + + uint8 tracks[128 * 4]; + file.ReadArray(tracks); + for(size_t i = 0; i < CountOf(tracks); i++) + { + if(tracks[i] > numTracks) + return false; + } + + if(loadFlags == onlyVerifyHeader) + return true; + + // Now we can be pretty sure that this is a valid MOD file. Set up default song settings. + m_nType = MOD_TYPE_MOD; + m_nChannels = 4; + m_nInstruments = 0; + m_nDefaultSpeed = 6; + m_nDefaultTempo = 125; + m_nMinPeriod = 14 * 4; + m_nMaxPeriod = 3424 * 4; + m_nSamplePreAmp = 64; + m_SongFlags = SONG_PT1XMODE; + + // Setup channel pan positions and volume + SetupMODPanning(); + + // Reading patterns + Order.resize(numOrders); + for(PATTERNINDEX pat = 0; pat < numOrders; pat++) + { + Order[pat] = pat; + if(Patterns.Insert(pat, 64)) + continue; + + for(CHANNELINDEX chn = 0; chn < 4; chn++) + { + file.Seek(1468 + tracks[pat * 4 + chn] * 64u * 4u); + ModCommand *m = Patterns[pat].GetpModCommand(0, chn); + + for(ROWINDEX row = 0; row < 64; row++, m += 4) + { + ReadMODPatternEntry(file, *m); + + if((m->command || m->param) + && !(m->command == 0x0E && m->param >= 0x10) // Exx only sets filter + && !(m->command >= 0x05 && m->command <= 0x09)) // These don't exist in ST2.6 + { + ConvertModCommand(*m); + if(m->command == CMD_TEMPO) + { + m->command = CMD_SPEED; + } + } else + { + m->command = CMD_NONE; + } + } + } + } + + // Reading samples + if(loadFlags & loadSampleData) + { + file.Seek(1468 + numTracks * 64u * 4u); + for(SAMPLEINDEX smp = 1; smp <= 31; smp++) if(Samples[smp].nLength) + { + SampleIO( + SampleIO::_8bit, + SampleIO::mono, + SampleIO::littleEndian, + SampleIO::signedPCM) + .ReadSample(Samples[smp], file); + } + } + + return true; +} + + #ifndef MODPLUG_NO_FILESAVE bool CSoundFile::SaveMod(const mpt::PathString &filename) const Modified: trunk/OpenMPT/soundlib/Load_xm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_xm.cpp 2014-10-10 17:34:53 UTC (rev 4410) +++ trunk/OpenMPT/soundlib/Load_xm.cpp 2014-10-10 19:40:50 UTC (rev 4411) @@ -283,7 +283,7 @@ InitializeGlobals(); InitializeChannels(); ChangeModTypeTo(MOD_TYPE_XM); - m_nMixLevels = mixLevels_compatible_FT2; + m_nMixLevels = mixLevels_compatible; FlagSet<TrackerVersions> madeWith(verUnknown); @@ -583,6 +583,11 @@ mpt::String::SetNullTerminator(mptVersion); m_dwLastSavedWithVersion = MptVersion::ToNum(mptVersion); madeWith = verOpenMPT | verConfirmed; + + if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 19)) + m_nMixLevels = mixLevels_compatible; + else + m_nMixLevels = mixLevels_compatible_FT2; } if(m_dwLastSavedWithVersion != 0 && !madeWith[verOpenMPT]) @@ -591,23 +596,27 @@ SetModFlag(MSF_COMPATIBLE_PLAY, false); } - if(madeWith[verFT2Generic] && !m_SongFlags[SONG_EMBEDMIDICFG]) + if(madeWith[verFT2Generic]) { - // FT2 allows typing in arbitrary unsupported effect letters such as Zxx. - // Prevent these commands from being interpreted as filter commands by erasing the default MIDI Config. - MemsetZero(m_MidiCfg.szMidiSFXExt); - MemsetZero(m_MidiCfg.szMidiZXXExt); - } + m_nMixLevels = mixLevels_compatible_FT2; - if(madeWith[verFT2Generic] - && fileHeader.version >= 0x0104 // Old versions of FT2 didn't have (smooth) ramping. Disable it for those versions where we can be sure that there should be no ramping. + if(!m_SongFlags[SONG_EMBEDMIDICFG]) + { + // FT2 allows typing in arbitrary unsupported effect letters such as Zxx. + // Prevent these commands from being interpreted as filter commands by erasing the default MIDI Config. + MemsetZero(m_MidiCfg.szMidiSFXExt); + MemsetZero(m_MidiCfg.szMidiZXXExt); + } + + if(fileHeader.version >= 0x0104 // Old versions of FT2 didn't have (smooth) ramping. Disable it for those versions where we can be sure that there should be no ramping. #ifdef MODPLUG_TRACKER - && TrackerSettings::Instance().autoApplySmoothFT2Ramping + && TrackerSettings::Instance().autoApplySmoothFT2Ramping #endif // MODPLUG_TRACKER - ) - { - // apply FT2-style super-soft volume ramping - SetModFlag(MSF_VOLRAMP, true); + ) + { + // apply FT2-style super-soft volume ramping + SetModFlag(MSF_VOLRAMP, true); + } } if(madeWithTracker.empty()) @@ -688,7 +697,7 @@ memcpy(fileHeader.signature, "Extended Module: ", 17); mpt::String::Write<mpt::String::spacePadded>(fileHeader.songName, songName); fileHeader.eof = 0x1A; - std::string openMptTrackerName = MptVersion::GetOpenMPTVersionStr(); + const std::string openMptTrackerName = MptVersion::GetOpenMPTVersionStr(); mpt::String::Write<mpt::String::spacePadded>(fileHeader.trackerName, openMptTrackerName); // Writing song header Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-10 17:34:53 UTC (rev 4410) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-10 19:40:50 UTC (rev 4411) @@ -817,6 +817,7 @@ && !ReadJ2B(file, loadFlags) && !ReadMO3(file, loadFlags) && !ReadMod(file, loadFlags) + && !ReadICE(file, loadFlags) && !ReadM15(file, loadFlags)) { m_nType = MOD_TYPE_NONE; @@ -2394,11 +2395,7 @@ // Starting from OpenMPT 1.23.01.04, FT2-style panning has its own mix mode instead. if(GetType() == MOD_TYPE_XM) { - if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 19) - && GetMixLevels() == mixLevels_compatible_FT2) - { - SetMixLevels(mixLevels_compatible); - } else if(m_dwLastSavedWithVersion >= MAKE_VERSION_NUMERIC(1, 22, 07, 19) + if(m_dwLastSavedWithVersion >= MAKE_VERSION_NUMERIC(1, 22, 07, 19) && m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 23, 01, 04) && GetMixLevels() == mixLevels_compatible) { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-10-10 17:34:53 UTC (rev 4410) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-10-10 19:40:50 UTC (rev 4411) @@ -623,6 +623,7 @@ bool ReadS3M(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadMod(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadM15(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); + bool ReadICE(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadMed(const uint8 *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadMTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); bool ReadSTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |