From: <sag...@us...> - 2015-02-27 22:14:31
|
Revision: 4796 http://sourceforge.net/p/modplug/code/4796 Author: saga-games Date: 2015-02-27 22:14:25 +0000 (Fri, 27 Feb 2015) Log Message: ----------- [Fix] S3M compatibility: Properly limit periods in S3M files and cut period when sliding too high (test case: PeriodLimit.s3m and channel 4 in shell shock (tmnt 3) by virt) Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Load_s3m.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/common/versionNumber.h 2015-02-27 22:14:25 UTC (rev 4796) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 02 -#define VER_MINORMINOR 02 +#define VER_MINORMINOR 03 //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_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2015-02-27 22:14:25 UTC (rev 4796) @@ -654,8 +654,8 @@ } m_nSamples = std::max(SAMPLEINDEX(1), GetNumSamples()); - m_nMinPeriod = 8; - m_nMaxPeriod = 0xF000; + m_nMinPeriod = 0; + m_nMaxPeriod = int32_max; PATTERNINDEX numPats = std::min(static_cast<PATTERNINDEX>(patPos.size()), GetModSpecifications().patternsMax); Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_s3m.cpp 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2015-02-27 22:14:25 UTC (rev 4796) @@ -316,7 +316,7 @@ } // Bit 8 = Stereo (we always use stereo) - m_nSamplePreAmp = Clamp(fileHeader.masterVolume & 0x7F, 0x10, 0x7F); + m_nSamplePreAmp = std::max(fileHeader.masterVolume & 0x7F, 0x10); // Channel setup m_nChannels = 4; @@ -324,22 +324,18 @@ { ChnSettings[i].Reset(); - if(fileHeader.channels[i] == 0xFF) + if(fileHeader.channels[i] != 0xFF) { - ChnSettings[i].nPan = 128; - ChnSettings[i].dwFlags = CHN_MUTE; - } else - { m_nChannels = i + 1; ChnSettings[i].nPan = (fileHeader.channels[i] & 8) ? 0xCC : 0x33; // 200 : 56 - if(fileHeader.channels[i] & 0x80) - { - ChnSettings[i].dwFlags = CHN_MUTE; - // Detect Adlib channels here (except for OpenMPT 1.19 and older, which would write wrong channel types for PCM channels 16-32): - // c = channels[i] ^ 0x80; - // if(c >= 16 && c < 32) adlibChannel = true; - } } + if(fileHeader.channels[i] & 0x80) + { + ChnSettings[i].dwFlags = CHN_MUTE; + // Detect Adlib channels here (except for OpenMPT 1.19 and older, which would write wrong channel types for PCM channels 16-32): + // c = channels[i] ^ 0x80; + // if(c >= 16 && c < 32) adlibChannel = true; + } } if(m_nChannels < 1) { Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2015-02-27 22:14:25 UTC (rev 4796) @@ -56,9 +56,6 @@ const CHANNELINDEX MAX_BASECHANNELS = 127; // Max pattern channels. const CHANNELINDEX MAX_CHANNELS = 256; //200 // Maximum number of mixing channels. -#define MIN_PERIOD 0x0020 // Note: Period is an Amiga metric that is inverse to frequency. -#define MAX_PERIOD 0xFFFF // Periods in MPT are 4 times as fine as Amiga periods because of extra fine frequency slides. - #define FREQ_FRACBITS 4 // Number of fractional bits in return value of CSoundFile::GetFreqFromPeriod() // String lengths (including trailing null char) Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-02-27 22:14:25 UTC (rev 4796) @@ -3195,7 +3195,15 @@ } else { pChn->nPeriod -= (int)(param * 4); - if (pChn->nPeriod < 1) pChn->nPeriod = 1; + if (pChn->nPeriod < 1) + { + pChn->nPeriod = 1; + if(GetType() == MOD_TYPE_S3M) + { + pChn->nFadeOutVol = 0; + pChn->dwFlags.set(CHN_NOTEFADE | CHN_FASTVOLRAMP); + } + } } } } @@ -3259,7 +3267,15 @@ } else { pChn->nPeriod -= (int)(param); - if (pChn->nPeriod < 1) pChn->nPeriod = 1; + if (pChn->nPeriod < 1) + { + pChn->nPeriod = 1; + if(GetType() == MOD_TYPE_S3M) + { + pChn->nFadeOutVol = 0; + pChn->dwFlags.set(CHN_NOTEFADE | CHN_FASTVOLRAMP); + } + } } } } @@ -4720,7 +4736,15 @@ { pChn->nPeriod += nFreqSlide; } - if(pChn->nPeriod < 1) pChn->nPeriod = 1; + if (pChn->nPeriod < 1) + { + pChn->nPeriod = 1; + if(GetType() == MOD_TYPE_S3M) + { + pChn->nFadeOutVol = 0; + pChn->dwFlags.set(CHN_NOTEFADE | CHN_FASTVOLRAMP); + } + } } Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2015-02-27 22:14:25 UTC (rev 4796) @@ -1,4 +1,5 @@ -/* +in_p + /* * Sndfile.cpp * ----------- * Purpose: Core class of the playback engine. Every song is represented by a CSoundFile object. @@ -557,7 +558,7 @@ #ifndef MODPLUG_TRACKER m_nFreqFactor = m_nTempoFactor = 65536; #endif - m_nMinPeriod = MIN_PERIOD; + m_nMinPeriod = 32; m_nMaxPeriod = 0x7FFF; m_nRepeatCount = 0; m_PlayState.m_nSeqOverride = ORDERINDEX_INVALID; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Sndfile.h 2015-02-27 22:14:25 UTC (rev 4796) @@ -425,7 +425,12 @@ UINT m_nFreqFactor; // Pitch shift factor (65536 = no pitch shifting). Only used in libopenmpt (openmpt::ext::interactive::set_pitch_factor) UINT m_nTempoFactor; // Tempo factor (65536 = no tempo adjustment). Only used in libopenmpt (openmpt::ext::interactive::set_tempo_factor) #endif - int32 m_nMinPeriod, m_nMaxPeriod; // min period = highest possible frequency, max period = lowest possible frequency + + // Min Period = highest possible frequency, Max Period = lowest possible frequency for current format + // Note: Period is an Amiga metric that is inverse to frequency. + // Periods in MPT are 4 times as fine as Amiga periods because of extra fine frequency slides (introduced in the S3M format). + int32 m_nMinPeriod, m_nMaxPeriod; + int32 m_nRepeatCount; // -1 means repeat infinitely. ORDERINDEX m_nMaxOrderPosition; ModChannelSettings ChnSettings[MAX_BASECHANNELS]; // Initial channels settings Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2015-02-27 11:22:19 UTC (rev 4795) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2015-02-27 22:14:25 UTC (rev 4796) @@ -1915,7 +1915,9 @@ pChn->nCalcVolume = vol; // Update calculated volume for MIDI macros - if (pChn->nPeriod < m_nMinPeriod) pChn->nPeriod = m_nMinPeriod; + // ST3 only clamps the final output period, but never the channel's internal period. + // Test case: PeriodLimit.s3m + if (pChn->nPeriod < m_nMinPeriod && GetType() != MOD_TYPE_S3M) pChn->nPeriod = m_nMinPeriod; if(IsCompatibleMode(TRK_FASTTRACKER2)) Clamp(pChn->nPeriod, 1, 31999); period = pChn->nPeriod; @@ -1980,25 +1982,12 @@ ProcessSampleAutoVibrato(pChn, period, vibratoFactor, nPeriodFrac); // Final Period + // ST3 only clamps the final output period, but never the channel's internal period. + // Test case: PeriodLimit.s3m if (period <= m_nMinPeriod) { - // ST3 simply stops playback if frequency is too high. - // Test case: FreqLimits.s3m - if (GetType() & MOD_TYPE_S3M) pChn->nLength = 0; period = m_nMinPeriod; } - //rewbs: temporarily commenting out block to allow notes below A-0. - /*if (period > m_nMaxPeriod) - { - if ((m_nType & MOD_TYPE_IT) || (period >= 0x100000)) - { - pChn->nFadeOutVol = 0; - pChn->dwFlags |= CHN_NOTEFADE; - pChn->nRealVolume = 0; - } - period = m_nMaxPeriod; - nPeriodFrac = 0; - }*/ if(GetType() == MOD_TYPE_MPT && pIns != nullptr && pIns->pTuning != nullptr) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |