|
From: <sag...@us...> - 2015-01-11 18:21:48
|
Revision: 4713
http://sourceforge.net/p/modplug/code/4713
Author: saga-games
Date: 2015-01-11 18:21:36 +0000 (Sun, 11 Jan 2015)
Log Message:
-----------
[Fix] IT compatibility: Default sample and instrument panning should only be reset by notes, not instrument numbers.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-01-11 17:34:09 UTC (rev 4712)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-01-11 18:21:36 UTC (rev 4713)
@@ -1003,47 +1003,29 @@
if (pIns && ((!IsCompatibleMode(TRK_IMPULSETRACKER) && pSmp) || pIns->nMixPlug))
pChn->nNNA = pIns->nNNA;
- if (pSmp)
+ // Update volume
+ if (pIns)
{
- if (pIns)
+ pChn->nInsVol = pIns->nGlobalVol;
+ if(pSmp != nullptr)
{
- pChn->nInsVol = (pSmp->nGlobalVol * pIns->nGlobalVol) >> 6;
- // Default instrument panning
- if(pIns->dwFlags[INS_SETPANNING])
- {
- pChn->nPan = pIns->nPan;
- // IT compatibility: Sample and instrument panning overrides channel surround status.
- // Test case: SmpInsPanSurround.it
- if(IsCompatibleMode(TRK_IMPULSETRACKER) && !m_SongFlags[SONG_SURROUNDPAN])
- {
- pChn->dwFlags.reset(CHN_SURROUND);
- }
- }
- } else
- {
- pChn->nInsVol = pSmp->nGlobalVol;
+ pChn->nInsVol = (pSmp->nGlobalVol * pChn->nInsVol) >> 6;
}
+ } else if (pSmp != nullptr)
+ {
+ pChn->nInsVol = pSmp->nGlobalVol;
+ }
- // Default sample panning
- if(pSmp->uFlags[CHN_PANNING] && (bUpdVol || !(GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))))
- {
- // FT2 compatibility: Only reset panning on instrument numbers, not notes (bUpdVol condition)
- // Test case: PanMemory.xm
- pChn->nPan = pSmp->nPan;
-
- // IT compatibility: Sample and instrument panning overrides channel surround status.
- // Test case: SmpInsPanSurround.it
- if(IsCompatibleMode(TRK_IMPULSETRACKER) && !m_SongFlags[SONG_SURROUNDPAN])
- {
- pChn->dwFlags.reset(CHN_SURROUND);
- }
- }
- } else if(pIns && pIns->HasValidMIDIChannel())
+ // Update panning
+ // FT2 compatibility: Only reset panning on instrument numbers, not notes (bUpdVol condition)
+ // Test case: PanMemory.xm
+ // IT compatibility: Sample and instrument panning is only applied on note change, not instrument change
+ // Test case: PanReset.it
+ if((bUpdVol || !(GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))) && !IsCompatibleMode(TRK_IMPULSETRACKER))
{
- pChn->nInsVol = pIns->nGlobalVol;
+ ApplyInstrumentPanning(pChn, pIns, pSmp);
}
-
// Reset envelopes
if(bResetEnv)
{
@@ -1344,6 +1326,10 @@
UINT period = GetPeriodFromNote(note, pChn->nFineTune, pChn->nC5Speed);
pChn->nPanbrelloOffset = 0;
+ // IT compatibility: Sample and instrument panning is only applied on note change, not instrument change
+ // Test case: PanReset.it
+ if(IsCompatibleMode(TRK_IMPULSETRACKER)) ApplyInstrumentPanning(pChn, pIns, pSmp);
+
if(!pSmp) return;
if(period)
{
@@ -1562,7 +1548,38 @@
{
if (!bManual) pChn->nPeriod = 0;
}
+}
+
+// Apply sample or instrumernt panning
+void CSoundFile::ApplyInstrumentPanning(ModChannel *pChn, const ModInstrument *instr, const ModSample *smp) const
+//---------------------------------------------------------------------------------------------------------------
+{
+ int32_t newPan = int32_min;
+ if(instr != nullptr)
+ {
+ // Default instrument panning
+ if(instr->dwFlags[INS_SETPANNING])
+ {
+ newPan = instr->nPan;
+ }
+ }
+
+ // Default sample panning
+ if(smp != nullptr && smp->uFlags[CHN_PANNING])
+ {
+ newPan = smp->nPan;
+ }
+ if(newPan != int32_min)
+ {
+ pChn->nPan = newPan;
+ // IT compatibility: Sample and instrument panning overrides channel surround status.
+ // Test case: SmpInsPanSurround.it
+ if(IsCompatibleMode(TRK_IMPULSETRACKER) && !m_SongFlags[SONG_SURROUNDPAN])
+ {
+ pChn->dwFlags.reset(CHN_SURROUND);
+ }
+ }
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2015-01-11 17:34:09 UTC (rev 4712)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2015-01-11 18:21:36 UTC (rev 4713)
@@ -775,6 +775,7 @@
void CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut);
void NoteChange(ModChannel *pChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false) const;
void InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true) const;
+ void ApplyInstrumentPanning(ModChannel *pChn, const ModInstrument *instr, const ModSample *smp) const;
// Channel Effects
void KeyOff(ModChannel *pChn) const;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|