|
From: <sag...@us...> - 2012-12-16 14:44:06
|
Revision: 1465
http://sourceforge.net/p/modplug/code/1465
Author: saga-games
Date: 2012-12-16 14:44:01 +0000 (Sun, 16 Dec 2012)
Log Message:
-----------
[Fix] Getting a bit closer to IT's macro idiosyncrasies... Zxx is now only applied on first tick, before any other effects, \xx remains "sane". Also, volume 0 seems to be clamped to MIDI value 1 instead of 0.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2012-12-16 01:05:01 UTC (rev 1464)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2012-12-16 14:44:01 UTC (rev 1465)
@@ -1517,7 +1517,7 @@
// -> DESC="add extended parameter mechanism to pattern effects"
ModCommand *m = nullptr;
// -! NEW_FEATURE#0010
- for (CHANNELINDEX nChn = 0; nChn < m_nChannels; nChn++, pChn++)
+ for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)
{
UINT instr = pChn->rowCommand.instr;
UINT volcmd = pChn->rowCommand.volcmd;
@@ -1951,6 +1951,15 @@
if((GetType() == MOD_TYPE_S3M) && ChnSettings[nChn].dwFlags[CHN_MUTE]) // not even effects are processed on muted S3M channels
continue;
+ if(cmd == CMD_MIDI && m_SongFlags[SONG_FIRSTTICK])
+ {
+ // MIDI macro (Smooth MIDI macros are processed later, when we know all the volumes, panning, etc.)
+ if(param < 0x80)
+ ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], param);
+ else
+ ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiZXXExt[(param & 0x7F)], 0);
+ }
+
// Volume Column Effect (except volume & panning)
/* A few notes, paraphrased from ITTECH.TXT by Storlek (creator of schismtracker):
Ex/Fx/Gx are shared with Exx/Fxx/Gxx; Ex/Fx are 4x the 'normal' slide value
@@ -1962,7 +1971,7 @@
so... hxx = (hx | (oldhxx & 0xf0)) ???
TODO is this done correctly?
*/
- if ((volcmd > VOLCMD_PANNING) && (m_nTickCount >= nStartTick))
+ if((volcmd > VOLCMD_PANNING) && (m_nTickCount >= nStartTick))
{
if (volcmd == VOLCMD_TONEPORTAMENTO)
{
@@ -2078,18 +2087,13 @@
}
// Effects
- if (cmd) switch (cmd)
+ if(cmd != CMD_NONE) switch (cmd)
{
-// -> CODE#0010
-// -> DESC="add extended parameter mechanism to pattern effects"
- case CMD_XPARAM:
- break;
-// -> NEW_FEATURE#0010
// Set Volume
case CMD_VOLUME:
if(m_SongFlags[SONG_FIRSTTICK])
{
- pChn->nVolume = (param < 64) ? param*4 : 256;
+ pChn->nVolume = (param < 64) ? param * 4 : 256;
pChn->dwFlags.set(CHN_FASTVOLRAMP);
}
break;
@@ -2440,10 +2444,10 @@
nPosJump = param;
if(m_SongFlags[SONG_PATTERNLOOP] && m_nSeqOverride == ORDERINDEX_INVALID)
{
- m_nSeqOverride = param;
- //Releasing pattern loop after position jump could cause
- //instant jumps - modifying behavior so that now position jumps
- //occurs also when pattern loop is enabled.
+ m_nSeqOverride = param;
+ //Releasing pattern loop after position jump could cause
+ //instant jumps - modifying behavior so that now position jumps
+ //occurs also when pattern loop is enabled.
}
// see http://forum.openmpt.org/index.php?topic=2769.0 - FastTracker resets Dxx if Bxx is called _after_ Dxx
@@ -3622,20 +3626,20 @@
// This is "almost" how IT does it - apparently, IT seems to lag one row behind on global volume or channel volume changes.
const int swing = (IsCompatibleMode(TRK_IMPULSETRACKER) || GetModFlag(MSF_OLDVOLSWING)) ? pChn->nVolSwing : 0;
const int vol = _muldiv((pChn->nVolume + swing) * m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 20);
- data = (unsigned char)Util::Min(vol / 2, 127);
+ data = (unsigned char)Clamp(vol / 2, 1, 127);
//data = (unsigned char)min((pChn->nVolume * pChn->nGlobalVol * m_nGlobalVolume) >> (1 + 6 + 8), 127);
} else if(macro[pos] == 'u') // u: volume (calculated)
{
// Same note as with velocity applies here, but apparently also for instrument / sample volumes?
const int vol = _muldiv(pChn->nCalcVolume * m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 26);
- data = (unsigned char)Util::Min(vol / 2, 127);
+ data = (unsigned char)Clamp(vol / 2, 1, 127);
//data = (unsigned char)min((pChn->nCalcVolume * pChn->nGlobalVol * m_nGlobalVolume) >> (7 + 6 + 8), 127);
} else if(macro[pos] == 'x') // x: pan set
{
- data = (unsigned char)min(pChn->nPan / 2, 127);
+ data = (unsigned char)Util::Min(pChn->nPan / 2, 127);
} else if(macro[pos] == 'y') // y: calculated pan
{
- data = (unsigned char)min(pChn->nRealPan / 2, 127);
+ data = (unsigned char)Util::Min(pChn->nRealPan / 2, 127);
} else if(macro[pos] == 'a') // a: high byte of bank select
{
if(pIns && pIns->wMidiBank)
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2012-12-16 01:05:01 UTC (rev 1464)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2012-12-16 14:44:01 UTC (rev 1465)
@@ -1900,7 +1900,7 @@
} else
#endif // MODPLUG_TRACKER
{
- if (!ProcessRow())
+ if(!ProcessRow())
return FALSE;
}
////////////////////////////////////////////////////////////////////////////////////
@@ -2400,19 +2400,18 @@
//-------------------------------------------------------
{
ModChannel *pChn = &Chn[nChn];
- if(nChn < m_nChannels)
+ if(nChn < GetNumChannels())
{
// TODO evaluate per-plugin macros here
//ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_PAN]);
//ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_VOLUME]);
- if(pChn->rowCommand.command == CMD_MIDI || pChn->rowCommand.command == CMD_SMOOTHMIDI)
+ if(pChn->rowCommand.command == CMD_SMOOTHMIDI)
{
- // Also non-smooth MIDI Macros are processed on every row to update macros with volume or panning variables.
if(pChn->rowCommand.param < 0x80)
- ProcessMIDIMacro(nChn, (pChn->rowCommand.command == CMD_SMOOTHMIDI), m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], pChn->rowCommand.param);
+ ProcessMIDIMacro(nChn, true, m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], pChn->rowCommand.param);
else
- ProcessMIDIMacro(nChn, (pChn->rowCommand.command == CMD_SMOOTHMIDI), m_MidiCfg.szMidiZXXExt[(pChn->rowCommand.param & 0x7F)], 0);
+ ProcessMIDIMacro(nChn, true, m_MidiCfg.szMidiZXXExt[(pChn->rowCommand.param & 0x7F)], 0);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|