|
From: <sag...@us...> - 2009-10-12 22:04:47
|
Revision: 397
http://modplug.svn.sourceforge.net/modplug/?rev=397&view=rev
Author: saga-games
Date: 2009-10-12 22:04:33 +0000 (Mon, 12 Oct 2009)
Log Message:
-----------
[Fix] Improvements to the "Invert Loop" effect (was only applied on rows with EFx)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2009-10-12 00:44:56 UTC (rev 396)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2009-10-12 22:04:33 UTC (rev 397)
@@ -34,6 +34,7 @@
extern signed char retrigTable1[16];
extern signed char retrigTable2[16];
extern short int ModRandomTable[64];
+extern BYTE ModEFxTable[16];
////////////////////////////////////////////////////////////
@@ -1869,10 +1870,11 @@
break;
}
+ // MOD Effect (called every row)
+ InvertLoop(&Chn[nChn]);
+ } // for(...) end
- }
-
// Navigation Effects
if(m_dwSongFlags & SONG_FIRSTTICK)
{
@@ -2522,8 +2524,12 @@
case 0xC0: NoteCut(nChn, param); break;
// EDx: Note Delay
// EEx: Pattern Delay
- // EFx: MOD: Invert Loop / Funk Repeat, XM: Set Active Midi Macro
- case 0xF0: pChn->nActiveMacro = param; break;
+ case 0xF0:
+ if((m_nType & MOD_TYPE_MOD) != 0) // MOD: Invert Loop
+ pChn->nEFxSpeed = param;
+ else // XM: Set Active Midi Macro
+ pChn->nActiveMacro = param;
+ break;
}
}
@@ -2679,6 +2685,25 @@
}
+inline void CSoundFile::InvertLoop(MODCHANNEL *pChn)
+//--------------------------------------------------
+{
+ // EFx implementation for MOD files (PT 1.1A and up: Invert Loop)
+ // This effect trashes samples.
+ if((m_nType & MOD_TYPE_MOD) == 0 || pChn->nEFxSpeed == 0) return;
+
+ pChn->nEFxDelay += ModEFxTable[pChn->nEFxSpeed];
+ if(pChn->nEFxDelay < 0x80) return;
+ pChn->nEFxDelay = 0;
+ if (++pChn->nEFxOffset >= pChn->nLoopEnd - pChn->nLoopStart)
+ pChn->nEFxOffset = 0;
+
+ // TRASH IT!!! (Yes, the sample!)
+ if(pChn->pSample != nullptr && (pChn->dwFlags & CHN_LOOP))
+ pChn->pSample[pChn->nLoopStart + pChn->nEFxOffset] = ~pChn->pSample[pChn->nLoopStart + pChn->nEFxOffset];
+}
+
+
void CSoundFile::ProcessMidiMacro(UINT nChn, LPCSTR pszMidiMacro, UINT param)
//---------------------------------------------------------------------------
{
@@ -3797,6 +3822,3 @@
pChn->m_CalculateFreq = true;
}
-
-
-
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2009-10-12 00:44:56 UTC (rev 396)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2009-10-12 22:04:33 UTC (rev 397)
@@ -638,6 +638,7 @@
Chn[ich].dwFlags = ChnSettings[ich].dwFlags;
Chn[ich].nVolume = 256;
Chn[ich].nCutOff = 0x7F;
+ Chn[ich].nEFxSpeed = 0;
//IT compatibility 15. Retrigger
if(IsCompatibleMode(TRK_IMPULSETRACKER))
{
@@ -1467,6 +1468,7 @@
Chn[i].nRetrigCount = 0;
}
Chn[i].nTremorCount = 0;
+ Chn[i].nEFxSpeed = 0;
}
if(resetMask & 4)
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2009-10-12 00:44:56 UTC (rev 396)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2009-10-12 22:04:33 UTC (rev 397)
@@ -200,7 +200,7 @@
LONG nCutSwing, nResSwing;
LONG nRestorePanOnNewNote; //If > 0, nPan should be set to nRestorePanOnNewNote - 1 on new note. Used to recover from panswing.
UINT nOldGlobalVolSlide;
- DWORD nEFxOffset; // offset memory for either Funk Repeat or Invert Loop (EFx, .MOD only)
+ DWORD nEFxOffset; // offset memory for Invert Loop (EFx, .MOD only)
// 8-bit members
BYTE nRestoreResonanceOnNewNote; //Like above
BYTE nRestoreCutoffOnNewNote; //Like above
@@ -224,7 +224,7 @@
BYTE nRowCommand, nRowParam;
BYTE nLeftVU, nRightVU;
BYTE nActiveMacro, nFilterMode;
- BYTE nEFxDelay; // memory for either Funk Repeat or Invert Loop (EFx, .MOD only)
+ BYTE nEFxSpeed, nEFxDelay; // memory for Invert Loop (EFx, .MOD only)
uint16 m_RowPlugParam; //NOTE_PCs memory.
float m_nPlugParamValueStep; //rewbs.smoothVST
@@ -725,12 +725,12 @@
void WriteInstrumentPropertyForAllInstruments(__int32 code, __int16 size, FILE* f, MODINSTRUMENT* instruments[], UINT nInstruments);
void SaveExtendedInstrumentProperties(MODINSTRUMENT *instruments[], UINT nInstruments, FILE* f);
void SaveExtendedSongProperties(FILE* f);
- void LoadExtendedSongProperties(const MODTYPE modtype, LPCBYTE ptr, const LPCBYTE startpos, const size_t seachlimit, bool* pInterpretMptMade = NULL);
+ void LoadExtendedSongProperties(const MODTYPE modtype, LPCBYTE ptr, const LPCBYTE startpos, const size_t seachlimit, bool* pInterpretMptMade = false);
// Reads extended instrument properties(XM/IT/MPTM).
// If no errors occur and song extension tag is found, returns pointer to the beginning
// of the tag, else returns NULL.
- LPCBYTE LoadExtendedInstrumentProperties(const LPCBYTE pStart, const LPCBYTE pEnd, bool* pInterpretMptMade = NULL);
+ LPCBYTE LoadExtendedInstrumentProperties(const LPCBYTE pStart, const LPCBYTE pEnd, bool* pInterpretMptMade = false);
#endif // MODPLUG_NO_FILESAVE
// MOD Convert function
@@ -847,6 +847,7 @@
void ExtendedMODCommands(UINT nChn, UINT param);
void ExtendedS3MCommands(UINT nChn, UINT param);
void ExtendedChannelEffect(MODCHANNEL *, UINT param);
+ inline void InvertLoop(MODCHANNEL* pChn);
void ProcessMidiMacro(UINT nChn, LPCSTR pszMidiMacro, UINT param=0);
void ProcessSmoothMidiMacro(UINT nChn, LPCSTR pszMidiMacro, UINT param=0); //rewbs.smoothVST
void SetupChannelFilter(MODCHANNEL *pChn, bool bReset, int flt_modifier = 256) const;
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2009-10-12 00:44:56 UTC (rev 396)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2009-10-12 22:04:33 UTC (rev 397)
@@ -78,7 +78,6 @@
extern signed char ft2VibratoTable[256]; // -64 .. +64
extern int MixSoundBuffer[MIXBUFFERSIZE*4];
extern int MixRearBuffer[MIXBUFFERSIZE*2];
-extern BYTE ModEFxTable[16];
#ifndef NO_REVERB
extern UINT gnReverbSend;
@@ -1692,24 +1691,6 @@
}
}
- // .MOD EFx implementation
- if((m_nType & MOD_TYPE_MOD) && pChn->nRowCommand == CMD_MODCMDEX && (pChn->nRowParam & 0xF0) == 0xF0)
- {
- pChn->nEFxDelay += ModEFxTable[pChn->nRowParam & 0x0F];
- if((pChn->dwFlags & CHN_LOOP) && (pChn->nEFxDelay & 0x80))
- {
- // invert loop code (PT 1.1A and up)
- pChn->nEFxDelay = 0;
-
- if (++pChn->nEFxOffset >= pChn->nLoopEnd - pChn->nLoopStart)
- pChn->nEFxOffset = 0;
-
- // TRASH IT!!! (Yes, the sample!)
- pChn->pSample[pChn->nLoopStart + pChn->nEFxOffset] = ~pChn->pSample[pChn->nLoopStart + pChn->nEFxOffset];
- }
- }
-
-
#ifdef MODPLUG_PLAYER
// Limit CPU -> > 80% -> don't ramp
if ((gnCPUUsage >= 80) && (!pChn->nRealVolume))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|