From: <sag...@us...> - 2011-09-20 01:01:05
|
Revision: 1048 http://modplug.svn.sourceforge.net/modplug/?rev=1048&view=rev Author: saga-games Date: 2011-09-20 01:00:58 +0000 (Tue, 20 Sep 2011) Log Message: ----------- [Fix] More Swing fixage. Old files using the 0...64 volswing range are now upgraded automatically, so that internal algorithms don't need all that case switching anymore. [Fix] Panswing range is 0...64, not 0...100 (yay consistency) [Mod] OpenMPT: Version is now 1.20.00.26 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2011-09-20 01:00:58 UTC (rev 1048) @@ -958,7 +958,7 @@ // Vol/Pan Swing m_SliderVolSwing.SetRange(0, 100); - m_SliderPanSwing.SetRange(0, 100); + m_SliderPanSwing.SetRange(0, 64); m_SliderCutSwing.SetRange(0, 64); m_SliderResSwing.SetRange(0, 64); // Filter @@ -2375,7 +2375,7 @@ else if (pSlider==&m_SliderPanSwing) { n = m_SliderPanSwing.GetPos(); - if ((n >= 0) && (n <= 100) && (n != (int)pIns->nPanSwing)) + if ((n >= 0) && (n <= 64) && (n != (int)pIns->nPanSwing)) { pIns->nPanSwing = (BYTE)n; SetInstrumentModified(true); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-09-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/mptrack/version.h 2011-09-20 01:00:58 UTC (rev 1048) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 25 +#define VER_MINORMINOR 26 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2011-09-20 01:00:58 UTC (rev 1048) @@ -457,7 +457,7 @@ pIns->nIFC = pis->ifc; pIns->nIFR = pis->ifr; pIns->nVolSwing = min(pis->rv, 100); - pIns->nPanSwing = min(pis->rp, 100); + pIns->nPanSwing = min(pis->rp, 64); pIns->nPan = (pis->dfp & 0x7F) << 2; if (pIns->nPan > 256) pIns->nPan = 128; if (pis->dfp < 0x80) pIns->dwFlags |= INS_SETPANNING; @@ -1249,6 +1249,15 @@ SetModFlag(MSF_OLDVOLSWING, true); } + if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)) + { + // Previously, volume swing values ranged from 0 to 64. They should reach from 0 to 100 instead. + for(INSTRUMENTINDEX i = 1; i <= GetNumInstruments(); i++) if(Instruments[i] != nullptr) + { + Instruments[i]->nVolSwing = min(Instruments[i]->nVolSwing * 100 / 64, 100); + } + } + if(GetType() == MOD_TYPE_IT) { // Set appropriate mod flags if the file was not made with MPT. @@ -1622,7 +1631,7 @@ iti.dfp = (BYTE)(pIns->nPan >> 2); if (!(pIns->dwFlags & INS_SETPANNING)) iti.dfp |= 0x80; iti.rv = min(pIns->nVolSwing, 100); - iti.rp = min(pIns->nPanSwing, 100); + iti.rp = min(pIns->nPanSwing, 64); iti.ifc = pIns->nIFC; iti.ifr = pIns->nIFR; iti.nos = 0; Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-09-20 01:00:58 UTC (rev 1048) @@ -959,29 +959,16 @@ // Volume Swing if (pIns->nVolSwing) { - // IT compatibility: MPT has a weird vol swing algorithm.... - if(IsCompatibleMode(TRK_IMPULSETRACKER)) - { - double d = 2 * (((double) rand()) / RAND_MAX) - 1; - pChn->nVolSwing = std::floor(d * pChn->nInsVol * pIns->nVolSwing / 100.0); - } else - { - int d = ((LONG)pIns->nVolSwing * (LONG)((rand() & 0xFF) - 0x7F)) / 128; - pChn->nVolSwing = (signed short)((d * pChn->nVolume + 1) / 128); - } + const double delta = 2 * (((double) rand()) / RAND_MAX) - 1; + pChn->nVolSwing = (LONG)std::floor(delta * (IsCompatibleMode(TRK_IMPULSETRACKER) ? pChn->nInsVol : (pChn->nVolume + 1)) * pIns->nVolSwing / 100.0); } // Pan Swing if (pIns->nPanSwing) { - // IT compatibility: MPT has a weird pan swing algorithm.... - if(IsCompatibleMode(TRK_IMPULSETRACKER)) + const double delta = 2 * (((double) rand()) / RAND_MAX) - 1; + pChn->nPanSwing = (LONG)std::floor(delta * (IsCompatibleMode(TRK_IMPULSETRACKER) ? 4 : 1) * pIns->nPanSwing); + if(!IsCompatibleMode(TRK_IMPULSETRACKER)) { - double d = 2 * (((double) rand()) / RAND_MAX) - 1; - pChn->nPanSwing = std::floor(d * pIns->nPanSwing * 4); - } else - { - int d = ((LONG)pIns->nPanSwing * (LONG)((rand() & 0xFF) - 0x7F)) / 128; - pChn->nPanSwing = (signed short)d; pChn->nRestorePanOnNewNote = pChn->nPan + 1; } } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-09-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-09-20 01:00:58 UTC (rev 1048) @@ -118,10 +118,10 @@ BYTE nNNA; // New note action BYTE nDCT; // Duplicate check type (i.e. which condition will trigger the duplicate note action) BYTE nDNA; // Duplicate note action - BYTE nPanSwing; // Random panning factor - BYTE nVolSwing; // Random volume factor - BYTE nIFC; // Default filter cutoff (00...7F). Used if the high bit is set - BYTE nIFR; // Default filter resonance (00...7F). Used if the high bit is set + BYTE nPanSwing; // Random panning factor (0...64) + BYTE nVolSwing; // Random volume factor (0...100) + BYTE nIFC; // Default filter cutoff (0...127). Used if the high bit is set + BYTE nIFR; // Default filter resonance (0...127). Used if the high bit is set WORD wMidiBank; // MIDI bank BYTE nMidiProgram; // MIDI program @@ -134,8 +134,8 @@ PLUGINDEX nMixPlug; // Plugin assigned to this instrument uint16 nVolRampUp; // Default sample ramping up UINT nResampling; // Resampling mode - BYTE nCutSwing; // Random cutoff factor - BYTE nResSwing; // Random resonance factor + BYTE nCutSwing; // Random cutoff factor (0...64) + BYTE nResSwing; // Random resonance factor (0...64) BYTE nFilterMode; // Default filter mode WORD wPitchToTempoLock; // BPM at which the samples assigned to this instrument loop correctly BYTE nPluginVelocityHandling; // How to deal with plugin velocity Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-20 00:10:15 UTC (rev 1047) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-09-20 01:00:58 UTC (rev 1048) @@ -942,8 +942,17 @@ void CSoundFile::ProcessPanningSwing(MODCHANNEL *pChn) //---------------------------------------------------- { - pChn->nRealPan = pChn->nPan + pChn->nPanSwing; - pChn->nRealPan = CLAMP(pChn->nRealPan, 0, 256); + if(IsCompatibleMode(TRK_IMPULSETRACKER) || GetModFlag(MSF_OLDVOLSWING)) + { + pChn->nRealPan = pChn->nPan + pChn->nPanSwing; + } else + { + pChn->nPan += pChn->nPanSwing; + Limit(pChn->nPan, 0, 256); + pChn->nPanSwing = 0; + pChn->nRealPan = pChn->nPan; + } + Limit(pChn->nRealPan, 0, 256); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |