|
From: <sag...@us...> - 2010-06-15 21:08:49
|
Revision: 625
http://modplug.svn.sourceforge.net/modplug/?rev=625&view=rev
Author: saga-games
Date: 2010-06-15 21:08:42 +0000 (Tue, 15 Jun 2010)
Log Message:
-----------
[Fix] XM Compatibility: Prevent notes to be stopped after a fadeout. This way, a portamento effect can pick up a faded instrument which is long enough. This occours for example in the bassline (channel 11) of jt_burn.xm. Not tested with many XMs yet, I hope this won't break anything else...
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 2010-06-15 18:40:15 UTC (rev 624)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-06-15 21:08:42 UTC (rev 625)
@@ -740,7 +740,7 @@
if(!bPorta && pSmp && IsCompatibleMode(TRK_IMPULSETRACKER)) pChn->nC5Speed = pSmp->nC5Speed;
// XM Compatibility: Ignore notes with portamento if there was no note playing.
- if(bPorta && (pChn->pCurrentSample == nullptr) && IsCompatibleMode(TRK_FASTTRACKER2))
+ if(bPorta && (pChn->nInc == 0) && IsCompatibleMode(TRK_FASTTRACKER2))
{
pChn->nPeriod = 0;
return;
@@ -3540,7 +3540,7 @@
//--------------------------------
{
MODCHANNEL *pChn = &Chn[nChn];
- BOOL bKeyOn = (pChn->dwFlags & CHN_KEYOFF) ? FALSE : TRUE;
+ const bool bKeyOn = (pChn->dwFlags & CHN_KEYOFF) ? false : true;
pChn->dwFlags |= CHN_KEYOFF;
//if ((!pChn->pModInstrument) || (!(pChn->dwFlags & CHN_VOLENV)))
if ((pChn->pModInstrument) && (!(pChn->dwFlags & CHN_VOLENV)))
@@ -3550,34 +3550,35 @@
if (!pChn->nLength) return;
if ((pChn->dwFlags & CHN_SUSTAINLOOP) && (pChn->pModSample) && (bKeyOn))
{
- MODSAMPLE *psmp = pChn->pModSample;
- if (psmp->uFlags & CHN_LOOP)
+ const MODSAMPLE *pSmp = pChn->pModSample;
+ if (pSmp->uFlags & CHN_LOOP)
{
- if (psmp->uFlags & CHN_PINGPONGLOOP)
+ if (pSmp->uFlags & CHN_PINGPONGLOOP)
pChn->dwFlags |= CHN_PINGPONGLOOP;
else
pChn->dwFlags &= ~(CHN_PINGPONGLOOP|CHN_PINGPONGFLAG);
pChn->dwFlags |= CHN_LOOP;
- pChn->nLength = psmp->nLength;
- pChn->nLoopStart = psmp->nLoopStart;
- pChn->nLoopEnd = psmp->nLoopEnd;
+ pChn->nLength = pSmp->nLength;
+ pChn->nLoopStart = pSmp->nLoopStart;
+ pChn->nLoopEnd = pSmp->nLoopEnd;
if (pChn->nLength > pChn->nLoopEnd) pChn->nLength = pChn->nLoopEnd;
} else
{
pChn->dwFlags &= ~(CHN_LOOP|CHN_PINGPONGLOOP|CHN_PINGPONGFLAG);
- pChn->nLength = psmp->nLength;
+ pChn->nLength = pSmp->nLength;
}
}
if (pChn->pModInstrument)
{
MODINSTRUMENT *pIns = pChn->pModInstrument;
- if (((pIns->VolEnv.dwFlags & ENV_LOOP) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) && (pIns->nFadeOut)) {
+ if (((pIns->VolEnv.dwFlags & ENV_LOOP) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) && (pIns->nFadeOut))
+ {
pChn->dwFlags |= CHN_NOTEFADE;
}
- if (pIns->VolEnv.nReleaseNode != ENV_RELEASE_NODE_UNSET) {
- pChn->nVolEnvValueAtReleaseJump=getVolEnvValueFromPosition(pChn->nVolEnvPosition, pIns);
- pChn->nVolEnvPosition= pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode];
+ if (pIns->VolEnv.nReleaseNode != ENV_RELEASE_NODE_UNSET)
+ {
+ pChn->nVolEnvValueAtReleaseJump = getVolEnvValueFromPosition(pChn->nVolEnvPosition, pIns); pChn->nVolEnvPosition= pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode];
}
}
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2010-06-15 18:40:15 UTC (rev 624)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2010-06-15 21:08:42 UTC (rev 625)
@@ -930,7 +930,10 @@
MODINSTRUMENT *pIns = pChn->pModInstrument;
- if ((pChn->dwFlags & CHN_NOTEFADE) && (!(pChn->nFadeOutVol|pChn->nRightVol|pChn->nLeftVol)))
+ // XM Compatibility: Prevent notes to be stopped after a fadeout. This way, a portamento effect can pick up a faded instrument which is long enough.
+ // This occours for example in the bassline (channel 11) of jt_burn.xm. I hope this won't break anything else...
+ // I also suppose this could decrease mixing performance a bit, but hey, which CPU can't handle 32 muted channels these days... :-)
+ if ((pChn->dwFlags & CHN_NOTEFADE) && (!(pChn->nFadeOutVol|pChn->nRightVol|pChn->nLeftVol)) && (!IsCompatibleMode(TRK_FASTTRACKER2)))
{
pChn->nLength = 0;
pChn->nROfs = pChn->nLOfs = 0;
@@ -1672,7 +1675,7 @@
// Volume Sustain ?
if ((pIns->VolEnv.dwFlags & ENV_SUSTAIN) && (!(pChn->dwFlags & CHN_KEYOFF)))
{
- if (pChn->nVolEnvPosition == (UINT)pIns->VolEnv.Ticks[pIns->VolEnv.nSustainEnd]+1)
+ if (pChn->nVolEnvPosition == (UINT)pIns->VolEnv.Ticks[pIns->VolEnv.nSustainEnd] + 1)
pChn->nVolEnvPosition = pIns->VolEnv.Ticks[pIns->VolEnv.nSustainStart];
} else
// End of Envelope ?
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-10 18:30:16
|
Revision: 640
http://modplug.svn.sourceforge.net/modplug/?rev=640&view=rev
Author: saga-games
Date: 2010-07-10 18:30:08 +0000 (Sat, 10 Jul 2010)
Log Message:
-----------
[Ref] Added more const modifiers to the loader functions.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/LOAD_AMF.CPP
trunk/OpenMPT/soundlib/LOAD_DBM.CPP
trunk/OpenMPT/soundlib/LOAD_DMF.CPP
trunk/OpenMPT/soundlib/LOAD_DSM.CPP
trunk/OpenMPT/soundlib/Load_669.cpp
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Load_far.cpp
trunk/OpenMPT/soundlib/Load_imf.cpp
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_mdl.cpp
trunk/OpenMPT/soundlib/Load_med.cpp
trunk/OpenMPT/soundlib/Load_ptm.cpp
trunk/OpenMPT/soundlib/Load_s3m.cpp
trunk/OpenMPT/soundlib/Load_stm.cpp
trunk/OpenMPT/soundlib/Load_ult.cpp
trunk/OpenMPT/soundlib/Load_umx.cpp
trunk/OpenMPT/soundlib/Load_wav.cpp
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/LOAD_AMF.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2010-07-10 18:30:08 UTC (rev 640)
@@ -171,8 +171,8 @@
-bool CSoundFile::ReadAMF(LPCBYTE lpStream, const DWORD dwMemLength)
-//-----------------------------------------------------------
+bool CSoundFile::ReadAMF(const LPCBYTE lpStream, const DWORD dwMemLength)
+//-----------------------------------------------------------------------
{
const AMFFILEHEADER *pfh = (AMFFILEHEADER *)lpStream;
DWORD dwMemPos;
Modified: trunk/OpenMPT/soundlib/LOAD_DBM.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/LOAD_DBM.CPP 2010-07-10 18:30:08 UTC (rev 640)
@@ -107,7 +107,7 @@
void ConvertDBMEffect(uint8 *command, uint8 *param)
-//----------------------------------
+//-------------------------------------------------
{
if(*command < ARRAYELEMCOUNT(dbm_efftrans))
*command = dbm_efftrans[*command];
@@ -176,8 +176,8 @@
}
-bool CSoundFile::ReadDBM(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadDBM(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
const DBMFILEHEADER *pfh = (DBMFILEHEADER *)lpStream;
DWORD dwMemPos;
Modified: trunk/OpenMPT/soundlib/LOAD_DMF.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/LOAD_DMF.CPP 2010-07-10 18:30:08 UTC (rev 640)
@@ -86,8 +86,8 @@
#endif
-bool CSoundFile::ReadDMF(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadDMF(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
const DMFHEADER *pfh = (DMFHEADER *)lpStream;
DMFINFO *psi;
Modified: trunk/OpenMPT/soundlib/LOAD_DSM.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2010-07-10 18:30:08 UTC (rev 640)
@@ -85,8 +85,8 @@
#pragma pack()
-bool CSoundFile::ReadDSM(LPCBYTE lpStream, DWORD dwMemLength)
-//-----------------------------------------------------------
+bool CSoundFile::ReadDSM(const LPCBYTE lpStream, const DWORD dwMemLength)
+//-----------------------------------------------------------------------
{
DSMFILEHEADER *pfh = (DSMFILEHEADER *)lpStream;
DSMSONG *psong;
Modified: trunk/OpenMPT/soundlib/Load_669.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_669.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_669.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -39,8 +39,8 @@
} SAMPLE669;
-bool CSoundFile::Read669(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::Read669(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
BOOL b669Ext;
const FILEHEADER669 *pfh = (const FILEHEADER669 *)lpStream;
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -45,8 +45,8 @@
-bool CSoundFile::ReadAMS(LPCBYTE lpStream, DWORD dwMemLength)
-//-----------------------------------------------------------
+bool CSoundFile::ReadAMS(const LPCBYTE lpStream, const DWORD dwMemLength)
+//-----------------------------------------------------------------------
{
BYTE pkinf[MAX_SAMPLES];
AMSFILEHEADER *pfh = (AMSFILEHEADER *)lpStream;
Modified: trunk/OpenMPT/soundlib/Load_far.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_far.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_far.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -58,8 +58,8 @@
#pragma pack()
-bool CSoundFile::ReadFAR(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadFAR(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
if(dwMemLength < sizeof(FARHEADER1))
return false;
Modified: trunk/OpenMPT/soundlib/Load_imf.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_imf.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_imf.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -239,11 +239,11 @@
}
}
-static void load_imf_envelope(INSTRUMENTENVELOPE *env, IMFINSTRUMENT *imfins, int e)
-//----------------------------------------------------------------------------------
+static void load_imf_envelope(INSTRUMENTENVELOPE *env, const IMFINSTRUMENT *imfins, const int e)
+//----------------------------------------------------------------------------------------------
{
UINT min = 0; // minimum tick value for next node
- int shift = (e == IMF_ENV_VOL) ? 0 : 2;
+ const int shift = (e == IMF_ENV_VOL) ? 0 : 2;
env->dwFlags = ((imfins->env[e].flags & 1) ? ENV_ENABLED : 0) | ((imfins->env[e].flags & 2) ? ENV_SUSTAIN : 0) | ((imfins->env[e].flags & 4) ? ENV_LOOP : 0);
env->nNodes = CLAMP(imfins->env[e].points, 2, 25);
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -287,7 +287,7 @@
//BOOL CSoundFile::ITInstrToMPT(const void *p, MODINSTRUMENT *pIns, UINT trkvers)
long CSoundFile::ITInstrToMPT(const void *p, MODINSTRUMENT *pIns, UINT trkvers) //rewbs.modularInstData
-//--------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
{
// Envelope point count. Limited to 25 in IT format.
const int iEnvMax = (m_nType & MOD_TYPE_MPT) ? MAX_ENVPOINTS : 25;
@@ -457,7 +457,7 @@
// -> CODE#0023
// -> DESC="IT project files (.itp)"
bool CSoundFile::ReadITProject(LPCBYTE lpStream, const DWORD dwMemLength)
-//-----------------------------------------------------------------
+//-----------------------------------------------------------------------
{
UINT i,n,nsmp;
DWORD id,len,size;
Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mdl.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -226,8 +226,8 @@
-bool CSoundFile::ReadMDL(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadMDL(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
DWORD dwMemPos, dwPos, blocklen, dwTrackPos;
const MDLSONGHEADER *pmsh = (const MDLSONGHEADER *)lpStream;
Modified: trunk/OpenMPT/soundlib/Load_med.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_med.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_med.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -474,8 +474,8 @@
}
-bool CSoundFile::ReadMed(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadMed(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
const MEDMODULEHEADER *pmmh;
const MMD0SONGHEADER *pmsh;
Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ptm.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -62,8 +62,8 @@
#pragma pack()
-bool CSoundFile::ReadPTM(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadPTM(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
if(lpStream == nullptr || dwMemLength < sizeof(PTMFILEHEADER))
return false;
Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -217,8 +217,8 @@
}
-bool CSoundFile::ReadS3M(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadS3M(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
if ((!lpStream) || (dwMemLength <= sizeof(S3MFILEHEADER) + 64)) return false;
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -59,8 +59,8 @@
-bool CSoundFile::ReadSTM(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadSTM(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
STMHEADER *phdr = (STMHEADER *)lpStream;
DWORD dwMemPos = 0;
Modified: trunk/OpenMPT/soundlib/Load_ult.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ult.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_ult.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -303,8 +303,8 @@
};
-bool CSoundFile::ReadUlt(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadUlt(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
DWORD dwMemPos = 0;
uint8 ult_version;
Modified: trunk/OpenMPT/soundlib/Load_umx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_umx.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_umx.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -12,8 +12,8 @@
#define MODMAGIC_OFFSET (20+31*30+130)
-bool CSoundFile::ReadUMX(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadUMX(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
if ((!lpStream) || (dwMemLength < 0x800)) return false;
// Rip Mods from UMX
Modified: trunk/OpenMPT/soundlib/Load_wav.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_wav.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_wav.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -17,8 +17,8 @@
/////////////////////////////////////////////////////////////
// WAV file support
-bool CSoundFile::ReadWav(const BYTE *lpStream, DWORD dwMemLength)
-//---------------------------------------------------------------
+bool CSoundFile::ReadWav(const BYTE *lpStream, const DWORD dwMemLength)
+//---------------------------------------------------------------------
{
DWORD dwMemPos = 0;
WAVEFILEHEADER *phdr = (WAVEFILEHEADER *)lpStream;
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-10 18:30:08 UTC (rev 640)
@@ -235,8 +235,8 @@
return dwMemPos;
}
-bool CSoundFile::ReadXM(const BYTE *lpStream, DWORD dwMemLength)
-//--------------------------------------------------------------
+bool CSoundFile::ReadXM(const BYTE *lpStream, const DWORD dwMemLength)
+//--------------------------------------------------------------------
{
XMFILEHEADER xmheader;
XMSAMPLEHEADER xmsh;
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-10 17:35:43 UTC (rev 639)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-10 18:30:08 UTC (rev 640)
@@ -660,7 +660,7 @@
void SetRepeatCount(int n) { m_nRepeatCount = n; }
int GetRepeatCount() const { return m_nRepeatCount; }
- BOOL IsPaused() const { return (m_dwSongFlags & SONG_PAUSED) ? TRUE : FALSE; }
+ bool IsPaused() const { return (m_dwSongFlags & SONG_PAUSED) ? true : false; }
void LoopPattern(PATTERNINDEX nPat, ROWINDEX nRow = 0);
void CheckCPUUsage(UINT nCPU);
BOOL SetPatternName(PATTERNINDEX nPat, LPCSTR lpszName);
@@ -672,38 +672,38 @@
void ResetChannelState(CHANNELINDEX chn, BYTE resetStyle);
// Module Loaders
- bool ReadXM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadS3M(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadMod(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadMed(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadMTM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadSTM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadIT(LPCBYTE lpStream, const DWORD dwMemLength);
- //bool ReadMPT(LPCBYTE lpStream, const DWORD dwMemLength);
- bool ReadITProject(LPCBYTE lpStream, const DWORD dwMemLength); // -> CODE#0023 -> DESC="IT project files (.itp)" -! NEW_FEATURE#0023
- bool Read669(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadUlt(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadWav(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadDSM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadFAR(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadAMS(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadAMS2(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadMDL(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadOKT(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadDMF(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadPTM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadDBM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadAMF(LPCBYTE lpStream, const DWORD dwMemLength);
- bool ReadMT2(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadPSM(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadPSM16(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadUMX(LPCBYTE lpStream, DWORD dwMemLength);
- bool ReadMO3(LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadXM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadS3M(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMod(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMed(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMTM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadSTM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadIT(const LPCBYTE lpStream, const DWORD dwMemLength);
+ //bool ReadMPT(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadITProject(const LPCBYTE lpStream, const DWORD dwMemLength); // -> CODE#0023 -> DESC="IT project files (.itp)" -! NEW_FEATURE#0023
+ bool Read669(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadUlt(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadWav(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadDSM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadFAR(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadAMS(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadAMS2(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMDL(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadOKT(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadDMF(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadPTM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadDBM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadAMF(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMT2(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadPSM(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadPSM16(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadUMX(const LPCBYTE lpStream, const DWORD dwMemLength);
+ bool ReadMO3(const LPCBYTE lpStream, const DWORD dwMemLength);
bool ReadGDM(const LPCBYTE lpStream, const DWORD dwMemLength);
bool ReadIMF(const LPCBYTE lpStream, const DWORD dwMemLength);
bool ReadAM(const LPCBYTE lpStream, const DWORD dwMemLength);
bool ReadJ2B(const LPCBYTE lpStream, const DWORD dwMemLength);
- bool ReadMID(LPCBYTE lpStream, DWORD dwMemLength);
+ bool ReadMID(const LPCBYTE lpStream, DWORD dwMemLength);
// Save Functions
#ifndef MODPLUG_NO_FILESAVE
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-16 19:20:29
|
Revision: 648
http://modplug.svn.sourceforge.net/modplug/?rev=648&view=rev
Author: saga-games
Date: 2010-07-16 19:20:22 +0000 (Fri, 16 Jul 2010)
Log Message:
-----------
[Ref] Message reading: It's now possible to specify a callback function for converting characters. The AMS loader makes use of this.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Message.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2010-07-15 23:55:10 UTC (rev 647)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2010-07-16 19:20:22 UTC (rev 648)
@@ -5,6 +5,12 @@
*
* Authors: Olivier Lapicque <oli...@jp...>
* OpenMPT dev(s) (miscellaneous modifications)
+ * Notes : Extreme was renamed to Velvet Development at some point,
+ * and thus they also renamed their tracker from
+ * "Extreme's Tracker" to "Velvet Studio".
+ * While the two programs look rather similiar, the structure of both
+ * programs' "AMS" format is significantly different - Velvet Studio is a
+ * rather advanced tracker in comparison to Extreme's Tracker.
*/
//////////////////////////////////////////////
@@ -44,7 +50,28 @@
#pragma pack()
+// Callback function for reading text
+void Convert_AMS_Text_Chars(char &c)
+//----------------------------------
+{
+ switch((unsigned char)c)
+ {
+ case 0x00:
+ case 0x81: c = ' '; break;
+ case 0x14: c = '\xF6'; break;
+ case 0x19: c = '\xD6'; break;
+ case 0x04: c = '\xE4'; break;
+ case 0x0E: c = '\xC4'; break;
+ case 0x06: c = '\xE5'; break;
+ case 0x0F: c = '\xC5'; break;
+ default:
+ if((unsigned char)c > 0x81)
+ c = '\r';
+ break;
+ }
+}
+
bool CSoundFile::ReadAMS(const LPCBYTE lpStream, const DWORD dwMemLength)
//-----------------------------------------------------------------------
{
@@ -136,29 +163,9 @@
tmp = *((WORD *)(lpStream+dwMemPos));
dwMemPos += 2;
if (dwMemPos + tmp >= dwMemLength) return true;
- if (tmp && AllocateMessage(tmp))
+ if (tmp)
{
- // Translate that weird text format...
- for(size_t i = 0; i < tmp; i++)
- {
- switch(lpStream[dwMemPos + i])
- {
- case 0x00:
- case 0x81: m_lpszSongComments[i] = ' '; break;
- case 0x14: m_lpszSongComments[i] = '\xF6'; break;
- case 0x19: m_lpszSongComments[i] = '\xD6'; break;
- case 0x04: m_lpszSongComments[i] = '\xE4'; break;
- case 0x0E: m_lpszSongComments[i] = '\xC4'; break;
- case 0x06: m_lpszSongComments[i] = '\xE5'; break;
- case 0x0F: m_lpszSongComments[i] = '\xC5'; break;
- default:
- if(lpStream[dwMemPos + i] > 0x81)
- m_lpszSongComments[i] = '\r';
- else
- m_lpszSongComments[i] = lpStream[dwMemPos + i];
- break;
- }
- }
+ ReadMessage(lpStream + dwMemPos, tmp, leCR, &Convert_AMS_Text_Chars);
}
dwMemPos += tmp;
@@ -352,11 +359,11 @@
BYTE packedsamples[MAX_SAMPLES];
if ((pfh->dwHdr1 != 0x68534D41) || (pfh->wHdr2 != 0x7264)
- || (pfh->b1A != 0x1A) || (pfh->titlelen > 30)) return FALSE;
+ || (pfh->b1A != 0x1A) || (pfh->titlelen > 30)) return false;
dwMemPos = pfh->titlelen + 8;
psh = (AMS2SONGHEADER *)(lpStream + dwMemPos);
if (((psh->version & 0xFF00) != 0x0200) || (!psh->instruments)
- || (psh->instruments > MAX_INSTRUMENTS) || (!psh->patterns) || (!psh->orders)) return FALSE;
+ || (psh->instruments > MAX_INSTRUMENTS) || (!psh->patterns) || (!psh->orders)) return false;
dwMemPos += sizeof(AMS2SONGHEADER);
if (pfh->titlelen)
{
@@ -461,7 +468,7 @@
dwMemPos += sizeof(AMS2SAMPLE);
}
}
- if (dwMemPos + 256 >= dwMemLength) return TRUE;
+ if (dwMemPos + 256 >= dwMemLength) return true;
// Comments
{
UINT composernamelen = lpStream[dwMemPos];
@@ -480,16 +487,16 @@
SpaceToNullStringFixed(ChnSettings[i].szName, chnnamlen);
}
dwMemPos += chnnamlen + 1;
- if (dwMemPos + chnnamlen + 256 >= dwMemLength) return TRUE;
+ if (dwMemPos + chnnamlen + 256 >= dwMemLength) return true;
}
// packed comments (ignored)
UINT songtextlen = *((LPDWORD)(lpStream+dwMemPos));
dwMemPos += songtextlen;
- if (dwMemPos + 256 >= dwMemLength) return TRUE;
+ if (dwMemPos + 256 >= dwMemLength) return true;
}
// Order List
{
- if ((dwMemPos + 2 * psh->orders) >= dwMemLength) return TRUE;
+ if ((dwMemPos + 2 * psh->orders) >= dwMemLength) return true;
Order.resize(psh->orders, Order.GetInvalidPatIndex());
for (UINT iOrd = 0; iOrd < psh->orders; iOrd++)
{
@@ -500,7 +507,7 @@
// Pattern Data
for (UINT ipat=0; ipat<psh->patterns; ipat++)
{
- if (dwMemPos+8 >= dwMemLength) return TRUE;
+ if (dwMemPos+8 >= dwMemLength) return true;
UINT packedlen = *((LPDWORD)(lpStream+dwMemPos));
UINT numrows = 1 + (UINT)(lpStream[dwMemPos+4]);
//UINT patchn = 1 + (UINT)(lpStream[dwMemPos+5] & 0x1F);
@@ -516,7 +523,7 @@
SpaceToNullStringFixed(s, patnamlen);
SetPatternName(ipat, s);
}
- if(Patterns.Insert(ipat, numrows)) return TRUE;
+ if(Patterns.Insert(ipat, numrows)) return true;
// Unpack Pattern Data
LPCBYTE psrc = lpStream + dwMemPos;
UINT pos = 3 + patnamlen;
@@ -570,7 +577,7 @@
// Read Samples
for (UINT iSmp=1; iSmp<=m_nSamples; iSmp++) if (Samples[iSmp].nLength)
{
- if (dwMemPos >= dwMemLength - 9) return TRUE;
+ if (dwMemPos >= dwMemLength - 9) return true;
UINT flags;
if (packedsamples[iSmp] & 0x03)
{
@@ -581,7 +588,7 @@
}
dwMemPos += ReadSample(&Samples[iSmp], flags, (LPSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos);
}
- return TRUE;
+ return true;
}
Modified: trunk/OpenMPT/soundlib/Message.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Message.cpp 2010-07-15 23:55:10 UTC (rev 647)
+++ trunk/OpenMPT/soundlib/Message.cpp 2010-07-16 19:20:22 UTC (rev 648)
@@ -51,21 +51,30 @@
// [in] data: pointer to the data in memory that is going to be read
// [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
// [in] lineEnding: line ending formatting of the text in memory.
+// [in] pTextConverter: Pointer to a callback function which can be used to pre-process the read characters, if necessary (nullptr otherwise).
// [out] returns true on success.
-bool CSoundFile::ReadMessage(const BYTE *data, const size_t length, enmLineEndings lineEnding)
-//--------------------------------------------------------------------------------------------
+bool CSoundFile::ReadMessage(const BYTE *data, const size_t length, enmLineEndings lineEnding, void (*pTextConverter)(char &))
+//----------------------------------------------------------------------------------------------------------------------------
{
+ char c;
+
// Simple line-ending detection algorithm. VERY simple.
if(lineEnding == leAutodetect)
{
+ char cprev = 0;
size_t nCR = 0, nLF = 0, nCRLF = 0;
// find CRs, LFs and CRLFs
for(size_t i = 0; i < length; i++)
- {
- if(data[i] == '\r') nCR++;
- else if(data[i] == '\n') nLF++;
+ {
+ c = data[i];
+ if(pTextConverter != nullptr)
+ pTextConverter(c);
- if(i && data[i - 1] == '\r' && data[i] == '\n') nCRLF++;
+ if(c == '\r') nCR++;
+ else if(c == '\n') nLF++;
+
+ if(i && cprev == '\r' && c == '\n') nCRLF++;
+ cprev = c;
}
// evaluate findings
if(nCR == nLF && nCR == nCRLF)
@@ -82,7 +91,11 @@
// calculate the final amount of characters to be allocated.
for(size_t i = 0; i < length; i++)
{
- switch(data[i])
+ c = data[i];
+ if(pTextConverter != nullptr)
+ pTextConverter(c);
+
+ switch(c)
{
case '\r':
if(lineEnding != leLF) final_length++;
@@ -102,7 +115,11 @@
size_t cpos = 0;
for(size_t i = 0; i < length; i++, cpos++)
{
- switch(data[i])
+ c = data[i];
+ if(pTextConverter != nullptr)
+ pTextConverter(c);
+
+ switch(c)
{
case '\r':
if(lineEnding != leLF)
@@ -121,7 +138,7 @@
m_lpszSongComments[cpos] = ' ';
break;
default:
- m_lpszSongComments[cpos] = data[i];
+ m_lpszSongComments[cpos] = c;
break;
}
}
@@ -135,9 +152,10 @@
// [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
// [in] lineLength: The fixed length of a line.
// [in] lineEndingLength: The padding space between two fikxed lines. (there could for example be a null char after every line)
+// [in] pTextConverter: Pointer to a callback function which can be used to pre-process the read characters, if necessary (nullptr otherwise).
// [out] returns true on success.
-bool CSoundFile::ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength)
-//----------------------------------------------------------------------------------------------------------------------------------------
+bool CSoundFile::ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength, void (*pTextConverter)(char &))
+//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{
if(lineLength == 0)
return false;
@@ -155,6 +173,9 @@
// fix weird chars
for(size_t lpos = 0; lpos < lineLength; lpos++)
{
+ // Pre-process text
+ if(pTextConverter != nullptr) pTextConverter(m_lpszSongComments[cpos + lpos]);
+
switch(m_lpszSongComments[cpos + lpos])
{
case '\0':
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-15 23:55:10 UTC (rev 647)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-16 19:20:22 UTC (rev 648)
@@ -964,16 +964,18 @@
// [in] data: pointer to the data in memory that is going to be read
// [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
// [in] lineEnding: line ending formatting of the text in memory.
+ // [in] pTextConverter: Pointer to a callback function which can be used to pre-process the read characters, if necessary (nullptr otherwise).
// [out] returns true on success.
- bool ReadMessage(const BYTE *data, const size_t length, enmLineEndings lineEnding);
+ bool ReadMessage(const BYTE *data, const size_t length, enmLineEndings lineEnding, void (*pTextConverter)(char &) = nullptr);
// Read comments with fixed line length from a mapped file.
// [in] data: pointer to the data in memory that is going to be read
// [in] length: number of characters that should be read, not including a possible trailing null terminator (it is automatically appended).
// [in] lineLength: The fixed length of a line.
// [in] lineEndingLength: The padding space between two fikxed lines. (there could for example be a null char after every line)
+ // [in] pTextConverter: Pointer to a callback function which can be used to pre-process the read characters, if necessary (nullptr otherwise).
// [out] returns true on success.
- bool ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength);
+ bool ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength, void (*pTextConverter)(char &) = nullptr);
// Currently unused (and the code doesn't look very nice :)
UINT GetSongMessage(LPSTR s, UINT cbsize, UINT linesize=32);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-16 23:18:47
|
Revision: 651
http://modplug.svn.sourceforge.net/modplug/?rev=651&view=rev
Author: saga-games
Date: 2010-07-16 23:18:40 +0000 (Fri, 16 Jul 2010)
Log Message:
-----------
[Imp] Small improvements to PSM loader.
[Mod] Added new formats to GetPeriodFromNote(). (Since they are automatically converted to something usesable, this doesn't change anything in OpenMPT).
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_psm.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/Load_psm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_psm.cpp 2010-07-16 21:46:18 UTC (rev 650)
+++ trunk/OpenMPT/soundlib/Load_psm.cpp 2010-07-16 23:18:40 UTC (rev 651)
@@ -7,7 +7,7 @@
* gave me a few clues. :)
*
* What's playing?
- * - Epic Pinball - Perfect! (I don't have an old version with the PSM16 tunes to compare, though - some of them differ from the new PSM tunes)
+ * - Epic Pinball - Perfect! (menu and order song are pitched up a bit in the PSM16 format for unknown reasons, but that shouldn't bother anyone)
* - Extreme Pinball - Perfect! (subtunes included!)
* - Jazz Jackrabbit - Perfect!
* - One Must Fall! - Perfect! (it helped a lot to have the original MTM files...)
@@ -31,7 +31,22 @@
// New PSM support starts here. PSM16 structs are below.
//
+// 32-Bit PSM header identifiers
+#define PSM16HEAD_PSM_ 0xFE4D5350
+#define PSMHEAD_PSM_ 0x204D5350
+#define PSMHEAD_FILE 0x454C4946
+// 32-Bit chunk identifiers
+#define PSMCHUNKID_TITL 0x4C544954
+#define PSMCHUNKID_SDFT 0x54464453
+#define PSMCHUNKID_PBOD 0x444F4250
+#define PSMCHUNKID_SONG 0x474E4F53
+#define PSMCHUNKID_DATE 0x45544144
+#define PSMCHUNKID_OPLH 0x484C504F
+#define PSMCHUNKID_PPAN 0x4E415050
+#define PSMCHUNKID_PATT 0x54544150
+#define PSMCHUNKID_DSAM 0x4D415344
+#define PSMCHUNKID_DSMP 0x504D5344
struct PSMNEWHEADER
{
@@ -126,17 +141,18 @@
ASSERT_CAN_READ(sizeof(PSMNEWHEADER));
PSMNEWHEADER *shdr = (PSMNEWHEADER *)lpStream;
- if(LittleEndian(shdr->formatID) == 0xFE4D5350) // "PSM\xFE" - PSM16 format
+ if(LittleEndian(shdr->formatID) == PSM16HEAD_PSM_) // "PSM\xFE" - PSM16 format
return ReadPSM16(lpStream, dwMemLength);
// Check header
- if(LittleEndian(shdr->formatID) != 0x204D5350 // "PSM "
+ if(LittleEndian(shdr->formatID) != PSMHEAD_PSM_ // "PSM "
|| LittleEndian(shdr->fileSize) != dwMemLength - 12
- || LittleEndian(shdr->fileInfoID) != 0x454C4946 // "FILE"
+ || LittleEndian(shdr->fileInfoID) != PSMHEAD_FILE // "FILE"
) return false;
// Yep, this seems to be a valid file.
m_nType = MOD_TYPE_PSM;
+ m_dwSongFlags = SONG_ITOLDEFFECTS | SONG_ITCOMPATMODE;
SetModFlag(MSF_COMPATIBLE_PLAY, true);
m_nChannels = 0;
@@ -171,16 +187,16 @@
switch(chunkID)
{
- case 0x4C544954: // "TITL" - Song Title
+ case PSMCHUNKID_TITL: // "TITL" - Song Title
memcpy(m_szNames[0], lpStream + dwMemPos, (chunkSize < 31) ? chunkSize : 31);
SpaceToNullStringFixed(m_szNames[0], 31);
break;
- case 0x54464453: // "SDFT" - Format info (song data starts here)
+ case PSMCHUNKID_SDFT: // "SDFT" - Format info (song data starts here)
if(chunkSize != 8 || memcmp(lpStream + dwMemPos, "MAINSONG", 8)) return false;
break;
- case 0x444F4250: // "PBOD" - Pattern data of a single pattern
+ case PSMCHUNKID_PBOD: // "PBOD" - Pattern data of a single pattern
if(chunkSize < 8 || chunkSize != LittleEndian(*(uint32 *)(lpStream + dwMemPos))) return false; // same value twice
// Pattern ID (something like "P0 " or "P13 ", or "PATT0 " in Sinaria) follows
@@ -197,7 +213,7 @@
// Convert later as we have to know how many channels there are.
break;
- case 0x474E4F53: // "SONG" - Subsong information (channel count etc)
+ case PSMCHUNKID_SONG: // "SONG" - Subsong information (channel count etc)
{
if(chunkSize < sizeof(PSMSONGHEADER)) return false;
PSMSONGHEADER *pSong = (PSMSONGHEADER *)(lpStream + dwMemPos);
@@ -220,7 +236,7 @@
switch(subChunkID)
{
- case 0x45544144: // "DATE" - Conversion date (YYMMDD)
+ case PSMCHUNKID_DATE: // "DATE" - Conversion date (YYMMDD)
if(subChunkSize != 6) break;
{
@@ -235,11 +251,11 @@
}
break;
- case 0x484C504F: // "OPLH" - Order list, channel + module settings
+ case PSMCHUNKID_OPLH: // "OPLH" - Order list, channel + module settings
{
if(subChunkSize < 9) return false;
// First two bytes = Number of chunks that follow
- //WORD nTotalChunks = LittleEndian(*(WORD *)(lpStream + dwChunkPos));
+ //uint16 nTotalChunks = LittleEndian(*(uint16 *)(lpStream + dwChunkPos));
// Now, the interesting part begins!
DWORD dwSettingsOffset = dwChunkPos + 2;
@@ -292,7 +308,6 @@
ORDERINDEX nRestartPosition = 0;
if(nRestartChunk >= nFirstOrderChunk) nRestartPosition = (ORDERINDEX)(nRestartChunk - nFirstOrderChunk);
subsong.restartPos += nRestartPosition;
- m_nRestartPos = subsong.restartPos;
}
dwSettingsOffset += 3;
break;
@@ -363,11 +378,6 @@
break;
default: // How the hell should this happen? I've listened through almost all existing (original) PSM files. :)
-#ifdef MODPLUG_TRACKER
- CString s;
- s.Format("Report to the OpenMPT team: Unknown chunk %d found at position %d (in the OPLH chunk of this PSM file)", lpStream[dwSettingsOffset], dwSettingsOffset);
- if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
-#endif // MODPLUG_TRACKER
// anyway, in such cases, we have to quit as we don't know how big the chunk really is.
return false;
break;
@@ -381,7 +391,7 @@
}
break;
- case 0x4E415050: // PPAN - Channel panning table (used in Sinaria)
+ case PSMCHUNKID_PPAN: // PPAN - Channel panning table (used in Sinaria)
if(subChunkSize & 1) return false;
for(uint32 i = 0; i < subChunkSize; i += 2)
{
@@ -407,11 +417,11 @@
}
break;
- case 0x54544150: // PATT - Pattern list
+ case PSMCHUNKID_PATT: // PATT - Pattern list
// We don't really need this.
break;
- case 0x4D415344: // DSAM - Sample list
+ case PSMCHUNKID_DSAM: // DSAM - Sample list
// We don't need this either.
break;
@@ -429,7 +439,7 @@
break;
- case 0x504D5344: // DSMP - Samples
+ case PSMCHUNKID_DSMP: // DSMP - Samples
if(!bNewFormat)
{
// original header
@@ -792,14 +802,13 @@
ROWINDEX lastRow = Patterns[endPattern].GetNumRows() - 1;
MODCOMMAND *row_data;
row_data = Patterns[endPattern];
- for(uint32 nCell = 0; nCell < m_nChannels * Patterns[endPattern].GetNumRows(); nCell++)
+ for(uint32 nCell = 0; nCell < m_nChannels * Patterns[endPattern].GetNumRows(); nCell++, row_data++)
{
if(row_data->command == CMD_PATTERNBREAK || row_data->command == CMD_POSITIONJUMP)
{
lastRow = nCell / m_nChannels;
break;
}
- row_data++;
}
TryWriteEffect(endPattern, lastRow, CMD_POSITIONJUMP, (BYTE)subsongs[i].restartPos, false, CHANNELINDEX_INVALID, false, true);
}
@@ -882,7 +891,7 @@
PSM16HEADER *shdr = (PSM16HEADER *)lpStream;
// Check header
- if((LittleEndian(shdr->formatID) != 0xFE4D5350) // "PSM\xFE"
+ if((LittleEndian(shdr->formatID) != PSM16HEAD_PSM_) // "PSM\xFE"
|| (shdr->lineEnd != 0x1A)
|| (shdr->formatVersion != 0x10 && shdr->formatVersion != 0x01) // why is this sometimes 0x01?
|| (shdr->patternVersion != 0) // 255ch pattern version not supported (did anyone use this?)
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-07-16 21:46:18 UTC (rev 650)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-07-16 23:18:40 UTC (rev 651)
@@ -3850,7 +3850,7 @@
{
if ((!note) || (note >= NOTE_MIN_SPECIAL)) return 0;
if (m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT|MOD_TYPE_S3M|MOD_TYPE_STM|MOD_TYPE_MDL|MOD_TYPE_ULT|MOD_TYPE_WAV
- |MOD_TYPE_FAR|MOD_TYPE_DMF|MOD_TYPE_PTM|MOD_TYPE_AMS|MOD_TYPE_DBM|MOD_TYPE_AMF|MOD_TYPE_PSM))
+ |MOD_TYPE_FAR|MOD_TYPE_DMF|MOD_TYPE_PTM|MOD_TYPE_AMS|MOD_TYPE_DBM|MOD_TYPE_AMF|MOD_TYPE_PSM|MOD_TYPE_J2B|MOD_TYPE_IMF))
{
note--;
if (m_dwSongFlags & SONG_LINEARSLIDES)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-07-23 23:57:52
|
Revision: 659
http://modplug.svn.sourceforge.net/modplug/?rev=659&view=rev
Author: saga-games
Date: 2010-07-23 23:57:46 +0000 (Fri, 23 Jul 2010)
Log Message:
-----------
[Fix] IT/MPTM Loaders: Mod flags were not imported properly if all of them were 0 (was broken since revision 650)
[Mod] IT/MPTM/XM Loaders/Savers: Also using the logging mechanism instead of message boxes here. Removed some warning messages from some other loaders.
Revision Links:
--------------
http://modplug.svn.sourceforge.net/modplug/?rev=650&view=rev
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_gdm.cpp
trunk/OpenMPT/soundlib/Load_imf.cpp
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_psm.cpp
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_gdm.cpp 2010-07-23 22:44:37 UTC (rev 658)
+++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2010-07-23 23:57:46 UTC (rev 659)
@@ -256,14 +256,7 @@
if(iPatternLength > dwMemLength || iPatternsOffset > dwMemLength - iPatternLength) break;
if(Patterns.Insert(iPat, 64))
- {
-#ifdef MODPLUG_TRACKER
- CString s;
- s.Format(TEXT("Allocating patterns failed starting from pattern %u"), iPat);
- if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
-#endif // MODPLUG_TRACKER
break;
- }
// position in THIS pattern
DWORD iPatternPos = iPatternsOffset + 2;
Modified: trunk/OpenMPT/soundlib/Load_imf.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_imf.cpp 2010-07-23 22:44:37 UTC (rev 658)
+++ trunk/OpenMPT/soundlib/Load_imf.cpp 2010-07-23 23:57:46 UTC (rev 659)
@@ -367,14 +367,8 @@
dwMemPos += 4;
if(Patterns.Insert(nPat, nrows))
- {
-#ifdef MODPLUG_TRACKER
- CString s;
- s.Format(TEXT("Allocating patterns failed starting from pattern %u"), nPat);
- if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
-#endif // MODPLUG_TRACKER
break;
- }
+
row_data = Patterns[nPat];
row = 0;
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2010-07-23 22:44:37 UTC (rev 658)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2010-07-23 23:57:46 UTC (rev 659)
@@ -23,13 +23,12 @@
#include <list>
#include "../mptrack/version.h"
-#define str_MBtitle (GetStrI18N((_TEXT("Saving IT"))))
#define str_tooMuchPatternData (GetStrI18N((_TEXT("Warning: File format limit was reached. Some pattern data may not get written to file."))))
#define str_pattern (GetStrI18N((_TEXT("pattern"))))
-#define str_PatternSetTruncationNote (GetStrI18N((_TEXT("The module contains %u patterns but only %u patterns can be loaded in this OpenMPT version."))))
-#define str_SequenceTruncationNote (GetStrI18N((_TEXT("Module has sequence of length %u; it will be truncated to maximum supported length, %u."))))
-#define str_LoadingIncompatibleVersion TEXT("The file informed that it is incompatible with this version of OpenMPT. Loading was terminated.")
-#define str_LoadingMoreRecentVersion TEXT("The loaded file was made with a more recent OpenMPT version and this version may not be able to load all the features or play the file correctly.")
+#define str_PatternSetTruncationNote (GetStrI18N((_TEXT("The module contains %u patterns but only %u patterns can be loaded in this OpenMPT version.\n"))))
+#define str_SequenceTruncationNote (GetStrI18N((_TEXT("Module has sequence of length %u; it will be truncated to maximum supported length, %u.\n"))))
+#define str_LoadingIncompatibleVersion TEXT("The file informed that it is incompatible with this version of OpenMPT. Loading was terminated.\n")
+#define str_LoadingMoreRecentVersion TEXT("The loaded file was made with a more recent OpenMPT version and this version may not be able to load all the features or play the file correctly.\n")
const uint16 verMptFileVer = 0x890;
const uint16 verMptFileVerLoadLimit = 0x1000; // If cwtv-field is greater or equal to this value,
@@ -113,7 +112,10 @@
TNTS_MAP_ITER iter = tNameToShort_Map.find(sf.Instruments[i]->pTuning);
if(iter == tNameToShort_Map.end()) //Should never happen
{
- MessageBox(0, "Error: 210807_1", 0, MB_ICONERROR);
+#ifdef MODPLUG_TRACKER
+ if(sf.GetpModDoc())
+ sf.GetpModDoc()->AddToLog(_T("Error: 210807_1\n"));
+#endif // MODPLUG_TRACKER
return;
}
srlztn::Binarywrite(oStrm, iter->second);
@@ -200,7 +202,7 @@
#ifdef MODPLUG_TRACKER
if(csf.GetpModDoc() != nullptr)
{
- string erm = string("Tuning ") + str + string(" used by the module was not found.");
+ string erm = string("Tuning ") + str + string(" used by the module was not found.\n");
csf.GetpModDoc()->AddToLog(erm.c_str());
csf.GetpModDoc()->SetModified(); //The tuning is changed so the modified flag is set.
}
@@ -885,6 +887,7 @@
if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 2, 50))
{
+ SetModFlag(MSF_COMPATIBLE_PLAY, false);
SetModFlag(MSF_MIDICC_BUGEMULATION, true);
SetModFlag(MSF_OLDVOLSWING, true);
}
@@ -1350,7 +1353,7 @@
{
#ifdef MODPLUG_TRACKER
CString s;
- s.Format(TEXT("Allocating patterns failed starting from pattern %u"), npat);
+ s.Format(TEXT("Allocating patterns failed starting from pattern %u\n"), npat);
if(GetpModDoc() != nullptr) GetpModDoc()->AddToLog(s);
#endif // MODPLUG_TRACKER
break;
@@ -1539,7 +1542,7 @@
if (ssb.m_Status & srlztn::SNT_FAILURE)
{
#ifdef MODPLUG_TRACKER
- if(GetpModDoc() != nullptr) GetpModDoc()->AddToLog(_T("Unknown error occured while deserializing file."));
+ if(GetpModDoc() != nullptr) GetpModDoc()->AddToLog(_T("Unknown error occured while deserializing file.\n"));
#endif // MODPLUG_TRACKER
}
}
@@ -1548,7 +1551,7 @@
if(GetTuneSpecificTunings().Deserialize(iStrm))
{
#ifdef MODPLUG_TRACKER
- if(GetpModDoc() != nullptr) GetpModDoc()->AddToLog(_T("Error occured - loading failed while trying to load tune specific tunings."));
+ if(GetpModDoc() != nullptr) GetpModDoc()->AddToLog(_T("Error occured - loading failed while trying to load tune specific tunings.\n"));
#endif // MODPLUG_TRACKER
}
else
@@ -2298,8 +2301,14 @@
buf[len++] = 0;
if(patinfo[0] > uint16_max - len)
{
- CString str; str.Format("%s (%s %u)", str_tooMuchPatternData, str_pattern, npat);
- MessageBox(0, str, str_MBtitle, MB_ICONWARNING);
+#ifdef MODPLUG_TRACKER
+ if(GetpModDoc())
+ {
+ CString str;
+ str.Format("%s (%s %u)\n", str_tooMuchPatternData, str_pattern, npat);
+ GetpModDoc()->AddToLog(str);
+ }
+#endif // MODPLUG_TRACKER
break;
}
else
@@ -2426,7 +2435,12 @@
ssb.FinishWrite();
if (ssb.m_Status & srlztn::SNT_FAILURE)
- AfxMessageBox("Error occured in writing MPTM extensions.", MB_ICONERROR);
+ {
+#ifdef MODPLUG_TRACKER
+ if(GetpModDoc())
+ GetpModDoc()->AddToLog("Error occured in writing MPTM extensions.\n");
+#endif // MODPLUG_TRACKER
+ }
//Last 4 bytes should tell where the hack mpt things begin.
if(!fout.good())
@@ -3611,7 +3625,12 @@
{
const size_t objectsize = GetMIDIMapper().GetSerializationSize();
if(objectsize > size_t(int16_max))
- MessageBox(NULL, "Datafield overflow with MIDI to plugparam mappings; data won't be written.", NULL, MB_ICONERROR);
+ {
+#ifdef MODPLUG_TRACKER
+ if(GetpModDoc())
+ GetpModDoc()->AddToLog("Datafield overflow with MIDI to plugparam mappings; data won't be written.\n");
+#endif // MODPLUG_TRACKER
+ }
else
{
code = 'MIMA';
@@ -3700,6 +3719,8 @@
if(pInterpretMptMade != NULL)
*pInterpretMptMade = true;
+ // HACK: Reset mod flags to default values here, as they are not always written.
+ m_ModFlags = 0;
// Case macros.
#define CASE(id, data) \
Modified: trunk/OpenMPT/soundlib/Load_psm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_psm.cpp 2010-07-23 22:44:37 UTC (rev 658)
+++ trunk/OpenMPT/soundlib/Load_psm.cpp 2010-07-23 23:57:46 UTC (rev 659)
@@ -529,14 +529,7 @@
dwPatternOffset += 2;
if(Patterns.Insert(nPat, patternSize))
- {
-#ifdef MODPLUG_TRACKER
- CString s;
- s.Format(TEXT("Allocating patterns failed starting from pattern %u"), nPat);
- if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
-#endif // MODPLUG_TRACKER
break;
- }
// Read pattern.
MODCOMMAND *row_data;
@@ -1016,14 +1009,7 @@
dwMemPos += sizeof(PSM16PATHEADER);
if(Patterns.Insert(nPat, phdr->numRows))
- {
-#ifdef MODPLUG_TRACKER
- CString s;
- s.Format(TEXT("Allocating patterns failed starting from pattern %u"), nPat);
- if(m_pModDoc != nullptr) m_pModDoc->AddToLog(s);
-#endif // MODPLUG_TRACKER
break;
- }
MODCOMMAND *row_data;
ROWINDEX iRow = 0;
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-23 22:44:37 UTC (rev 658)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2010-07-23 23:57:46 UTC (rev 659)
@@ -16,7 +16,6 @@
#pragma warning(disable:4244) //conversion from 'type1' to 'type2', possible loss of data
-#define str_MBtitle (GetStrI18N((_TEXT("Saving XM"))))
#define str_tooMuchPatternData (GetStrI18N((_TEXT("Warning: File format limit was reached. Some pattern data may not get written to file."))))
#define str_pattern (GetStrI18N((_TEXT("pattern"))))
@@ -723,6 +722,7 @@
#ifndef MODPLUG_NO_FILESAVE
+#include "../mptrack/Moddoc.h" // for logging errors
bool CSoundFile::SaveXM(LPCSTR lpszFileName, UINT nPacking, const bool bCompatibilityExport)
//------------------------------------------------------------------------------------------
@@ -731,10 +731,10 @@
if(len > s.size() - x) /*Buffer running out? Make it larger.*/ \
s.resize(s.size() + 10*1024, 0); \
\
- if(len > uint16_max - (UINT)x) /*Reaching the limits of file format?*/ \
+ if((len > uint16_max - (UINT)x) && GetpModDoc()) /*Reaching the limits of file format?*/ \
{ \
- CString str; str.Format("%s (%s %u)", str_tooMuchPatternData, str_pattern, i); \
- MessageBox(0, str, str_MBtitle, MB_ICONWARNING); \
+ CString str; str.Format("%s (%s %u)\n", str_tooMuchPatternData, str_pattern, i); \
+ GetpModDoc()->AddToLog(str); \
break; \
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2010-07-23 22:44:37 UTC (rev 658)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2010-07-23 23:57:46 UTC (rev 659)
@@ -622,12 +622,12 @@
BOOL Create(LPCBYTE lpStream, CModDoc *pModDoc, DWORD dwMemLength=0);
BOOL Destroy();
MODTYPE GetType() const { return m_nType; }
- inline bool TypeIsIT_MPT() const {return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) != 0;}
- inline bool TypeIsIT_MPT_XM() const {return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM)) != 0;}
- inline bool TypeIsS3M_IT_MPT() const {return (m_nType & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0;}
- inline bool TypeIsXM_MOD() const {return (m_nType & (MOD_TYPE_XM | MOD_TYPE_MOD)) != 0;}
- inline bool TypeIsMOD_S3M() const {return (m_nType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) != 0;}
- CModDoc* GetpModDoc() {return m_pModDoc;}
+ inline bool TypeIsIT_MPT() const { return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; }
+ inline bool TypeIsIT_MPT_XM() const { return (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM)) != 0; }
+ inline bool TypeIsS3M_IT_MPT() const { return (m_nType & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT)) != 0; }
+ inline bool TypeIsXM_MOD() const { return (m_nType & (MOD_TYPE_XM | MOD_TYPE_MOD)) != 0; }
+ inline bool TypeIsMOD_S3M() const { return (m_nType & (MOD_TYPE_MOD | MOD_TYPE_S3M)) != 0; }
+ CModDoc* GetpModDoc() const { return m_pModDoc; }
void SetMasterVolume(UINT vol, bool adjustAGC = false);
UINT GetMasterVolume() const { return m_nMasterVolume; }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-08-12 12:39:58
|
Revision: 685
http://modplug.svn.sourceforge.net/modplug/?rev=685&view=rev
Author: saga-games
Date: 2010-08-12 12:39:51 +0000 (Thu, 12 Aug 2010)
Log Message:
-----------
[Mod] IT Saving: Sane values are used again for the cwtv and cmwt fields; in fact the same values as in compatibility export. To be able to distinguish between raped and compatiblity-exported IT files, "OMPT" is written in the "reserved" header field.
[Ref] Related refactoring (replaced hex numbers by macros)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/IT_DEFS.H
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_itp.cpp
trunk/OpenMPT/soundlib/Sampleio.cpp
Modified: trunk/OpenMPT/soundlib/IT_DEFS.H
===================================================================
--- trunk/OpenMPT/soundlib/IT_DEFS.H 2010-08-11 20:37:26 UTC (rev 684)
+++ trunk/OpenMPT/soundlib/IT_DEFS.H 2010-08-12 12:39:51 UTC (rev 685)
@@ -13,19 +13,19 @@
WORD insnum;
WORD smpnum;
WORD patnum;
- WORD cwtv;
- WORD cmwt;
+ WORD cwtv; // "made with" tracker
+ WORD cmwt; // "compatible with" tracker
WORD flags;
WORD special;
BYTE globalvol;
- BYTE mv;
+ BYTE mv; // master volume
BYTE speed;
BYTE tempo;
- BYTE sep; // panning separation (0...128)
- BYTE pwd; // pitch wheel depth
+ BYTE sep; // panning separation (0...128)
+ BYTE pwd; // pitch wheel depth
WORD msglength;
DWORD msgoffset;
- DWORD reserved; // ChibiTracker writes "CHBI" here.
+ DWORD reserved; // ChibiTracker writes "CHBI" here. OpenMPT writes "OMPT" here in some cases, see Load_it.cpp
BYTE chnpan[64];
BYTE chnvol[64];
} ITFILEHEADER;
@@ -140,6 +140,14 @@
extern BYTE autovibit2xm[8];
extern BYTE autovibxm2it[8];
+// Impulse Tracker identifcators
+#define IT_IMPM 0x4D504D49 // "IMPM" IT header magic bytes
+#define IT_IMPS 0x53504D49 // "IMPS" IT sample header magic bytes
+#define IT_IMPI 0x49504D49 // "IMPI" IT instrument header magic bytes
+
+// Identificators by other trackers
+#define IT_MPTM 0x2E6D7074 // "tpm." old MPTM header magic bytes
+#define IT_OMPT 0x54504D4F // "OMPT" magic bytes for non-standard OpenMPT IT files
#define IT_CHBI 0x49424843 // "CHBI" magic bytes in the IT header to identify ChibiTracker
enum IT_ReaderBitMasks
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2010-08-11 20:37:26 UTC (rev 684)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2010-08-12 12:39:51 UTC (rev 685)
@@ -30,7 +30,7 @@
// the MPTM file will not be loaded.
/*
-MPTM version history for cwtv-field in IT header:
+MPTM version history for cwtv-field in "IT" header (only for MPTM files!):
0x890(1.18.02.00) -> 0x891(1.19.00.00): Pattern-specific time signatures
0x88F(1.18.01.00) -> 0x890(1.18.02.00): Removed volume command velocity :xy, added delay-cut command :xy.
0x88E(1.17.02.50) -> 0x88F(1.18.01.00): Numerous changes
@@ -473,7 +473,7 @@
bool hasModplugExtensions = false;
if ((!lpStream) || (dwMemLength < 0xC0)) return false;
- if ((pifh->id != 0x4D504D49 && pifh->id != 0x2e6D7074) || (pifh->insnum > 0xFF)
+ if ((pifh->id != LittleEndian(IT_IMPM) && pifh->id != LittleEndian(IT_MPTM)) || (pifh->insnum > 0xFF)
|| (pifh->smpnum >= MAX_SAMPLES) || (!pifh->ordnum)) return false;
if (dwMemPos + pifh->ordnum + pifh->insnum*4
+ pifh->smpnum*4 + pifh->patnum*4 > dwMemLength) return false;
@@ -484,7 +484,7 @@
if(mptStartPos >= dwMemLength || mptStartPos < 0x100)
mptStartPos = dwMemLength;
- if(pifh->id == 0x2e6D7074)
+ if(pifh->id == LittleEndian(IT_MPTM))
{
ChangeModTypeTo(MOD_TYPE_MPT);
}
@@ -503,22 +503,29 @@
if(GetType() == MOD_TYPE_IT)
{
// Which tracker was used to made this?
- if(pifh->cmwt == 0x888 || pifh->cwtv == 0x888)
+ if((pifh->cwtv & 0xF000) == 0x5000)
{
- // OpenMPT
+ // OpenMPT Version number (Major.Minor)
+ // This will only be interpreted as "made with modplug" (i.e. disable compatible playback etc) if the "reserved" field is set to "OMPT" - else, compatibility was used.
+ m_dwLastSavedWithVersion = (pifh->cwtv & 0x0FFF) << 16;
+ if(pifh->reserved == LittleEndian(IT_OMPT))
+ interpretModplugmade = true;
+ } else if(pifh->cmwt == 0x888 || pifh->cwtv == 0x888)
+ {
+ // OpenMPT 1.17 and 1.18 (raped IT format)
interpretModplugmade = true;
- } else if(pifh->cwtv == 0x217 && pifh->cmwt == 0x200 && pifh->reserved == 0)
+ } else if(pifh->cwtv == 0x0217 && pifh->cmwt == 0x0200 && pifh->reserved == 0)
{
- // Modplug Tracker 1.16
+ // Modplug Tracker 1.16 (semi-raped IT format)
m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 16, 00, 00);
interpretModplugmade = true;
- } else if(pifh->cwtv == 0x214 && pifh->cmwt == 0x202 && pifh->reserved == 0)
+ } else if(pifh->cwtv == 0x0214 && pifh->cmwt == 0x0202 && pifh->reserved == 0)
{
// Modplug Tracker b3.3 - 1.09, instruments 557 bytes apart
m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 09, 00, 00);
interpretModplugmade = true;
}
- else if(pifh->cwtv == 0x214 && pifh->cmwt == 0x200 && pifh->reserved == 0)
+ else if(pifh->cwtv == 0x0214 && pifh->cmwt == 0x0200 && pifh->reserved == 0)
{
// Modplug Tracker 1.00a5, instruments 560 bytes apart
m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 00, 00, 00);
@@ -554,12 +561,6 @@
}
}
- if((pifh->cwtv & 0xF000) == 0x5000) // OpenMPT Version number (Major.Minor) - we won't interpret this as "made with modplug" as this is used by compatibility export
- {
- m_dwLastSavedWithVersion = (pifh->cwtv & 0x0FFF) << 16;
- //interpretModplugmade = true;
- }
-
if (pifh->flags & 0x08) m_dwSongFlags |= SONG_LINEARSLIDES;
if (pifh->flags & 0x10) m_dwSongFlags |= SONG_ITOLDEFFECTS;
if (pifh->flags & 0x20) m_dwSongFlags |= SONG_ITCOMPATMODE;
@@ -592,7 +593,7 @@
if ((pifh->special & 0x01) && (pifh->msglength) && (pifh->msglength <= dwMemLength) && (pifh->msgoffset < dwMemLength - pifh->msglength))
{
// Generally, IT files should use CR for line endings. However, ChibiTracker uses LF. One could do...
- // if(pifh->cwtv == 0x0214 && pifh->cmwt == 0x0214 && LittleEndian(pifh->reserved) == IT_CHBI) --> Chibi detected.
+ // if(pifh->cwtv == 0x0214 && pifh->cmwt == 0x0214 && pifh->reserved == LittleEndian(IT_CHBI)) --> Chibi detected.
// But we'll just use autodetection here:
ReadMessage(lpStream + pifh->msgoffset, pifh->msglength, leAutodetect);
}
@@ -827,7 +828,7 @@
for (UINT nsmp=0; nsmp<pifh->smpnum; nsmp++) if ((smppos[nsmp]) && (smppos[nsmp] <= dwMemLength - sizeof(ITSAMPLESTRUCT)))
{
ITSAMPLESTRUCT *pis = (ITSAMPLESTRUCT *)(lpStream+smppos[nsmp]);
- if (pis->id == 0x53504D49)
+ if (pis->id == LittleEndian(IT_IMPS))
{
MODSAMPLE *pSmp = &Samples[nsmp+1];
memcpy(pSmp->filename, pis->filename, 12);
@@ -1169,7 +1170,7 @@
memset(&header, 0, sizeof(header));
dwPatNamLen = 0;
dwChnNamLen = 0;
- header.id = 0x4D504D49;
+ header.id = LittleEndian(IT_IMPM);
lstrcpyn(header.songname, m_szNames[0], 26);
header.highlight_minor = (BYTE)(m_nDefaultRowsPerBeat & 0xFF);
@@ -1190,12 +1191,11 @@
if(header.ordnum < 2) header.ordnum = 2;
}
-
header.insnum = m_nInstruments;
header.smpnum = m_nSamples;
header.patnum = (GetType() == MOD_TYPE_MPT) ? Patterns.Size() : MAX_PATTERNS;
if(Patterns.Size() < header.patnum) Patterns.ResizeArray(header.patnum);
- while ((header.patnum > 0) && (!Patterns[header.patnum-1])) header.patnum--;
+ while ((header.patnum > 0) && (!Patterns[header.patnum - 1])) header.patnum--;
patpos.resize(header.patnum, 0);
@@ -1207,8 +1207,20 @@
}
else //IT
{
- header.cwtv = 0x888; //
- header.cmwt = 0x888; // Might come up as "Impulse Tracker 8" file in XMPlay. :)
+ MptVersion::VersionNum vVersion = MptVersion::num;
+ header.cwtv = LittleEndianW(0x5000 | (WORD)((vVersion >> 16) & 0x0FFF)); // format: txyy (t = tracker ID, x = version major, yy = version minor), e.g. 0x5117 (OpenMPT = 5, 117 = v1.17)
+ header.cmwt = LittleEndianW(0x0214); // Common compatible tracker :)
+ // hack from schism tracker:
+ for(INSTRUMENTINDEX nIns = 1; nIns <= GetNumInstruments(); nIns++)
+ {
+ if(Instruments[nIns] && Instruments[nIns]->PitchEnv.dwFlags & ENV_FILTER)
+ {
+ header.cmwt = LittleEndianW(0x0217);
+ break;
+ }
+ }
+ // This way, we indicate that the file will most likely contain OpenMPT hacks. Compatibility export puts 0 here.
+ header.reserved = LittleEndian(IT_OMPT);
}
header.flags = 0x0001;
@@ -1334,7 +1346,7 @@
BYTE keyboardex[NOTE_MAX];
memset(&iti, 0, sizeof(iti));
- iti.id = 0x49504D49; // "IMPI"
+ iti.id = LittleEndian(IT_IMPI); // "IMPI"
//iti.trkvers = 0x211;
iti.trkvers = 0x220; //rewbs.itVersion
if (Instruments[nins])
@@ -1645,7 +1657,7 @@
memset(&itss, 0, sizeof(itss));
memcpy(itss.filename, psmp->filename, 12);
memcpy(itss.name, m_szNames[nsmp], 26);
- itss.id = 0x53504D49;
+ itss.id = LittleEndian(IT_IMPS);
itss.gvl = (BYTE)psmp->nGlobalVol;
UINT flags = RS_PCM8S;
@@ -1813,7 +1825,7 @@
memset(&header, 0, sizeof(header));
dwPatNamLen = 0;
dwChnNamLen = 0;
- header.id = 0x4D504D49;
+ header.id = LittleEndian(IT_IMPM);
lstrcpyn(header.songname, m_szNames[0], 26);
header.highlight_minor = (BYTE)(m_nDefaultRowsPerBeat & 0xFF);
@@ -1966,7 +1978,7 @@
BYTE keyboardex[NOTE_MAX];
memset(&iti, 0, sizeof(iti));
- iti.id = 0x49504D49; // "IMPI"
+ iti.id = LittleEndian(IT_IMPI); // "IMPI"
iti.trkvers = 0x0214;
if (Instruments[nins])
{
@@ -2250,7 +2262,7 @@
memcpy(itss.filename, psmp->filename, 12);
memcpy(itss.name, m_szNames[nsmp], 26);
SetNullTerminator(itss.name);
- itss.id = 0x53504D49;
+ itss.id = LittleEndian(IT_IMPS);
itss.gvl = (BYTE)psmp->nGlobalVol;
UINT flags = RS_PCM8S;
@@ -3120,4 +3132,3 @@
#undef CASE_NOTXM
}
-
Modified: trunk/OpenMPT/soundlib/Load_itp.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_itp.cpp 2010-08-11 20:37:26 UTC (rev 684)
+++ trunk/OpenMPT/soundlib/Load_itp.cpp 2010-08-12 12:39:51 UTC (rev 685)
@@ -325,7 +325,7 @@
if(dwMemPos >= dwMemLength || len > dwMemLength - dwMemPos) return false;
// Copy sample struct data
- if(pis.id == 0x53504D49)
+ if(pis.id == LittleEndian(IT_IMPS))
{
MODSAMPLE *pSmp = &Samples[nsmp];
memcpy(pSmp->filename, pis.filename, 12);
@@ -648,7 +648,7 @@
memcpy(itss.filename, psmp->filename, 12);
memcpy(itss.name, m_szNames[nsmp], 26);
- itss.id = 0x53504D49;
+ itss.id = LittleEndian(IT_IMPS);
itss.gvl = (BYTE)psmp->nGlobalVol;
itss.flags = 0x00;
@@ -720,3 +720,4 @@
}
#endif
+
Modified: trunk/OpenMPT/soundlib/Sampleio.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sampleio.cpp 2010-08-11 20:37:26 UTC (rev 684)
+++ trunk/OpenMPT/soundlib/Sampleio.cpp 2010-08-12 12:39:51 UTC (rev 685)
@@ -54,7 +54,7 @@
|| (psig[76/4] == LittleEndian(0x53524353)) // S3I signature
|| ((psig[0] == LittleEndian(0x4D524F46)) && (psig[2] == LittleEndian(0x46464941))) // AIFF signature
|| ((psig[0] == LittleEndian(0x4D524F46)) && (psig[2] == LittleEndian(0x58565338))) // 8SVX signature
- || (psig[0] == LittleEndian(0x53504D49)) // ITS signature
+ || (psig[0] == LittleEndian(LittleEndian(IT_IMPS))) // ITS signature
)
{
// Loading Instrument
@@ -1615,9 +1615,9 @@
// -> CODE#0027
// -> DESC="per-instrument volume ramping setup (refered as attack)"
// if ((!lpMemFile) || (dwFileLength < sizeof(ITSAMPLESTRUCT))
-// || (pis->id != 0x53504D49) || (((DWORD)pis->samplepointer) >= dwFileLength + dwOffset)) return FALSE;
+// || (pis->id != LittleEndian(IT_IMPS)) || (((DWORD)pis->samplepointer) >= dwFileLength + dwOffset)) return FALSE;
if ((!lpMemFile) || (dwFileLength < sizeof(ITSAMPLESTRUCT))
- || (pis->id != 0x53504D49) || (((DWORD)pis->samplepointer) >= dwFileLength + dwOffset)) return 0;
+ || (pis->id != LittleEndian(IT_IMPS)) || (((DWORD)pis->samplepointer) >= dwFileLength + dwOffset)) return 0;
// -! NEW_FEATURE#0027
DestroySample(nSample);
dwMemPos = pis->samplepointer - dwOffset;
@@ -1692,7 +1692,7 @@
UINT nsmp, nsamples;
if ((!lpMemFile) || (dwFileLength < sizeof(ITINSTRUMENT))
- || (pinstr->id != 0x49504D49)) return false;
+ || (pinstr->id != LittleEndian(IT_IMPI))) return false;
if (nInstr > m_nInstruments) m_nInstruments = nInstr;
// -> CODE#0003
// -> DESC="remove instrument's samples"
@@ -1787,7 +1787,7 @@
memset(smpcount, 0, sizeof(smpcount));
memset(smptable, 0, sizeof(smptable));
memset(smpmap, 0, sizeof(smpmap));
- iti->id = 0x49504D49; // "IMPI"
+ iti->id = LittleEndian(IT_IMPI); // "IMPI"
memcpy(iti->filename, pIns->filename, 12);
memcpy(iti->name, pIns->name, 26);
SetNullTerminator(iti->name);
@@ -1882,7 +1882,7 @@
UINT nsmp = smptable[j];
memset(&itss, 0, sizeof(itss));
MODSAMPLE *psmp = &Samples[nsmp];
- itss.id = 0x53504D49;
+ itss.id = LittleEndian(IT_IMPS);
memcpy(itss.filename, psmp->filename, 12);
memcpy(itss.name, m_szNames[nsmp], 26);
itss.gvl = (BYTE)psmp->nGlobalVol;
@@ -2158,7 +2158,3 @@
return true;
}
-
-
-
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-09-04 15:19:56
|
Revision: 699
http://modplug.svn.sourceforge.net/modplug/?rev=699&view=rev
Author: saga-games
Date: 2010-09-04 15:19:49 +0000 (Sat, 04 Sep 2010)
Log Message:
-----------
[Imp] Further improvements to VBlank MOD detection and playback (high speed values were simply ignored)
[Fix] MOD Specs: Max speed was off by one (31 instead of 32).
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/mod_specifications.h
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2010-09-02 23:45:48 UTC (rev 698)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2010-09-04 15:19:49 UTC (rev 699)
@@ -40,7 +40,7 @@
case 0x0C: command = CMD_VOLUME; break;
case 0x0D: command = CMD_PATTERNBREAK; param = ((param >> 4) * 10) + (param & 0x0F); break;
case 0x0E: command = CMD_MODCMDEX; break;
- case 0x0F: command = (param <= (UINT)((m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2)) ? 0x1F : 0x20)) ? CMD_SPEED : CMD_TEMPO;
+ case 0x0F: command = (param <= ((m_nType & (MOD_TYPE_MOD)) ? 0x20 : 0x1F)) ? CMD_SPEED : CMD_TEMPO;
if ((param == 0xFF) && (m_nSamples == 15) && (m_nType & MOD_TYPE_MOD)) command = 0; break; //<rewbs> what the hell is this?! :) //<jojo> it's the "stop tune" command! :-P
// Extension for XM extended effects
case 'G' - 55: command = CMD_GLOBALVOLUME; break; //16
@@ -262,7 +262,11 @@
if ((s[0]=='T') && (s[1]=='D') && (s[2]=='Z') && (s[3]>='4') && (s[3]<='9')) m_nChannels = s[3] - '0'; else
if (IsMagic(s,"16CN")) m_nChannels = 16; else
if (IsMagic(s,"32CN")) m_nChannels = 32; else m_nSamples = 15;
+ // Startrekker 8 channel mod (needs special treatment, see below)
bool bFLT8 = IsMagic(s, "FLT8") ? true : false;
+ // Only apply VBlank tests to M.K. (ProTracker) modules.
+ const bool bMdKd = IsMagic(s, "M.K.") ? true : false;
+
// Load Samples
nErr = 0;
dwTotalSampleLen = 0;
@@ -471,8 +475,10 @@
// (as this would indicate that f.e. a F30 command was really meant to set
// the ticks per row to 48, and not the tempo to 48 BPM).
// In the pattern loader above, a second condition is used: Only tempo commands
- // below 100 BPM are taken into account.
- if(bHasTempoCommands && GetSongTime() >= 10 * 60)
+ // below 100 BPM are taken into account. Furthermore, only M.K. (ProTracker)
+ // modules are checked.
+ // The same check is also applied to original NoiseTracker 15 sample mods.
+ if((bMdKd && bHasTempoCommands && GetSongTime() >= 10 * 60) || m_nSamples == 15)
{
Patterns.ForEachModCommand(FixVBlankMODs());
}
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-09-02 23:45:48 UTC (rev 698)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-09-04 15:19:49 UTC (rev 699)
@@ -243,11 +243,11 @@
nNextPatStartRow = 0; // FT2 E60 bug
if (nRow < Patterns[nPattern].GetNumRows() - 1)
{
- nextRow = Patterns[nPattern] + (nRow+1) * m_nChannels + nChn;
+ nextRow = Patterns[nPattern] + (nRow + 1) * m_nChannels + nChn;
}
if (nextRow && nextRow->command == CMD_XPARAM)
{
- nNextRow = (param<<8) + nextRow->param;
+ nNextRow = (param << 8) + nextRow->param;
} else
{
nNextRow = param;
@@ -266,9 +266,10 @@
// Set Speed
case CMD_SPEED:
if (!param) break;
- if ((param <= 0x20) || (m_nType != MOD_TYPE_MOD))
+ // Allow high speed values here for VBlank MODs. (Maybe it would be better to have a "VBlank MOD" flag somewhere? Is it worth the effort?)
+ if ((param <= GetModSpecifications().speedMax) || (m_nType & MOD_TYPE_MOD))
{
- if (param < 128) nMusicSpeed = param;
+ nMusicSpeed = param;
}
break;
// Set Tempo
@@ -3610,7 +3611,8 @@
#endif // FASTSOUNDLIB
#endif // MODPLUG_TRACKER
//if ((m_nType & MOD_TYPE_S3M) && (param > 0x80)) param -= 0x80;
- if ((param) && (param <= GetModSpecifications().speedMax)) m_nMusicSpeed = param;
+ // Allow high speed values here for VBlank MODs. (Maybe it would be better to have a "VBlank MOD" flag somewhere? Is it worth the effort?)
+ if ((param) && (param <= GetModSpecifications().speedMax || (m_nType & MOD_TYPE_MOD))) m_nMusicSpeed = param;
}
Modified: trunk/OpenMPT/soundlib/mod_specifications.h
===================================================================
--- trunk/OpenMPT/soundlib/mod_specifications.h 2010-09-02 23:45:48 UTC (rev 698)
+++ trunk/OpenMPT/soundlib/mod_specifications.h 2010-09-04 15:19:49 UTC (rev 699)
@@ -129,7 +129,7 @@
mixLevels_original, // defaultMixLevels
0, // Max MIDI mapping directives
1, // Min Speed
- 31, // Max Speed
+ 32, // Max Speed
false, // No song comments
0, // No instrument envelopes
false, // No envelope release node
@@ -169,7 +169,7 @@
mixLevels_original, // defaultMixLevels
0, // Max MIDI mapping directives
1, // Min Speed
- 31, // Max Speed
+ 32, // Max Speed
false, // No song comments
0, // No instrument envelopes
false, // No envelope release node
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-09-27 12:01:42
|
Revision: 722
http://modplug.svn.sourceforge.net/modplug/?rev=722&view=rev
Author: saga-games
Date: 2010-09-27 12:01:36 +0000 (Mon, 27 Sep 2010)
Log Message:
-----------
[Imp] It's now possible to create MOD files with more than 64 patterns. Just like in ProTracker, such MOD files are identified by the "M!K!" signature (instead of M.K.)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/mod_specifications.h
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2010-09-27 00:15:39 UTC (rev 721)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2010-09-27 12:01:36 UTC (rev 722)
@@ -617,7 +617,7 @@
norders = iord;
break;
}
- if ((Order[iord] < 0x80) && (nbp<=Order[iord])) nbp = Order[iord]+1;
+ if ((Order[iord] < 0x80) && (nbp <= Order[iord])) nbp = Order[iord] + 1;
}
bTab[0] = norders;
bTab[1] = m_nRestartPos;
@@ -628,9 +628,15 @@
fwrite(ord, 128, 1, f);
// Writing signature
if (m_nChannels == 4)
- lstrcpy((LPSTR)&bTab, "M.K.");
- else
- wsprintf((LPSTR)&bTab, "%luCHN", m_nChannels);
+ {
+ if(nbp < 64)
+ lstrcpy((LPSTR)&bTab, "M.K.");
+ else // more than 64 patterns
+ lstrcpy((LPSTR)&bTab, "M!K!");
+ } else
+ {
+ sprintf((LPSTR)&bTab, "%luCHN", m_nChannels);
+ }
fwrite(bTab, 4, 1, f);
// Writing patterns
for (UINT ipat=0; ipat<nbp; ipat++) { //for all patterns
Modified: trunk/OpenMPT/soundlib/mod_specifications.h
===================================================================
--- trunk/OpenMPT/soundlib/mod_specifications.h 2010-09-27 00:15:39 UTC (rev 721)
+++ trunk/OpenMPT/soundlib/mod_specifications.h 2010-09-27 12:01:36 UTC (rev 722)
@@ -111,7 +111,7 @@
false, // No notecut.
false, // No noteoff.
false, // No notefade.
- 64, // Pattern max.
+ 128, // Pattern max.
128, // Order max.
4, // Channel min
32, // Channel max
@@ -151,7 +151,7 @@
false, // No notecut.
false, // No noteoff.
false, // No notefade.
- 64, // Pattern max.
+ 128, // Pattern max.
128, // Order max.
4, // Channel min
32, // Channel max
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-10-04 17:44:33
|
Revision: 733
http://modplug.svn.sourceforge.net/modplug/?rev=733&view=rev
Author: saga-games
Date: 2010-10-04 17:44:27 +0000 (Mon, 04 Oct 2010)
Log Message:
-----------
[Mod] S3M Loader: Changed some code that should only affect really broken S3M files which every player handles different anyway (at least my broken version of aa-polym.s3m sounds better now)
[Fix] Mod Conversion: E9x is now converted to Q0x, not Q8x.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_s3m.cpp
trunk/OpenMPT/soundlib/modcommand.cpp
Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-10-03 21:22:48 UTC (rev 732)
+++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2010-10-04 17:44:27 UTC (rev 733)
@@ -377,9 +377,7 @@
if (c5Speed < 1024) c5Speed = 1024;
Samples[iSmp].nC5Speed = c5Speed;
- insfile[iSmp] = ((DWORD)LittleEndianW(*((LPWORD)(s+0x0E)))) << 4;
- insfile[iSmp] += ((DWORD)(BYTE)s[0x0D]) << 20;
- if (insfile[iSmp] > dwMemLength) insfile[iSmp] &= 0xFFFF; // wtf? whose idea was this?
+ insfile[iSmp - 1] = (s[0x0E] << 4) | (s[0x0F] << 12) | (s[0x0D] << 20);
if(Samples[iSmp].nLoopEnd < 2)
Samples[iSmp].nLoopStart = Samples[iSmp].nLoopEnd = 0;
@@ -499,23 +497,29 @@
}
// Reading samples
- for (UINT iRaw = 1; iRaw <= insnum; iRaw++) if ((Samples[iRaw].nLength) && (insfile[iRaw]))
+ for (UINT iRaw = 1; iRaw <= insnum; iRaw++) if ((Samples[iRaw].nLength) && (insfile[iRaw - 1]))
{
UINT flags = (psfh.version == 1) ? RS_PCM8S : RS_PCM8U;
if (insflags[iRaw-1] & 4) flags += 5;
if (insflags[iRaw-1] & 2) flags |= RSF_STEREO;
if (inspack[iRaw-1] == 4) flags = RS_ADPCM4;
- dwMemPos = insfile[iRaw];
- dwMemPos += ReadSample(&Samples[iRaw], flags, (LPSTR)(lpStream + dwMemPos), dwMemLength - dwMemPos);
+ if(insfile[iRaw - 1] < dwMemLength)
+ {
+ dwMemPos = insfile[iRaw - 1];
+ }
+ if(dwMemPos < dwMemLength)
+ {
+ dwMemPos += ReadSample(&Samples[iRaw], flags, (LPSTR)(lpStream + dwMemPos), dwMemLength - dwMemPos);
+ }
}
m_nMinPeriod = 64;
m_nMaxPeriod = 32767;
if (psfh.flags & 0x10) m_dwSongFlags |= SONG_AMIGALIMITS;
#ifdef MODPLUG_TRACKER
- if(bHasAdlibPatches && m_pModDoc != nullptr)
+ if(bHasAdlibPatches && GetpModDoc() != nullptr)
{
- m_pModDoc->AddToLog("This track uses Adlib instruments, which are not supported by OpenMPT.");
+ GetpModDoc()->AddToLog("This track uses Adlib instruments, which are not supported by OpenMPT.");
}
#endif // MODPLUG_TRACKER
Modified: trunk/OpenMPT/soundlib/modcommand.cpp
===================================================================
--- trunk/OpenMPT/soundlib/modcommand.cpp 2010-10-03 21:22:48 UTC (rev 732)
+++ trunk/OpenMPT/soundlib/modcommand.cpp 2010-10-04 17:44:27 UTC (rev 733)
@@ -27,7 +27,7 @@
case 0x50: m->param = (m->param & 0x0F) | 0x20; break;
case 0x60: m->param = (m->param & 0x0F) | 0xB0; break;
case 0x70: m->param = (m->param & 0x03) | 0x40; break;
- case 0x90: m->command = CMD_RETRIG; m->param = 0x80 | (m->param & 0x0F); break;
+ case 0x90: m->command = CMD_RETRIG; m->param = (m->param & 0x0F); break;
case 0xA0: if (m->param & 0x0F) { m->command = CMD_VOLUMESLIDE; m->param = (m->param << 4) | 0x0F; } else m->command = 0; break;
case 0xB0: if (m->param & 0x0F) { m->command = CMD_VOLUMESLIDE; m->param |= 0xF0; } else m->command = 0; break;
case 0xC0: if (m->param == 0xC0) { m->command = CMD_NONE; m->note = NOTE_NOTECUT; } // this does different things in IT and ST3
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-10-08 14:40:51
|
Revision: 735
http://modplug.svn.sourceforge.net/modplug/?rev=735&view=rev
Author: saga-games
Date: 2010-10-08 14:40:44 +0000 (Fri, 08 Oct 2010)
Log Message:
-----------
[Fix] STM Loader: Some fix from Schism which makes sense.
[Fix] Mod Specifications: Octave 8 was allowed in S3M files, that's a bit much of course (it wasn't even saved)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_stm.cpp
trunk/OpenMPT/soundlib/mod_specifications.h
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2010-10-05 16:55:20 UTC (rev 734)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2010-10-08 14:40:44 UTC (rev 735)
@@ -108,7 +108,11 @@
if ((pIns->nLength < 4) || (!pIns->nVolume)) pIns->nLength = 0;
pIns->nLoopStart = LittleEndianW(pStm->loopbeg);
pIns->nLoopEnd = LittleEndianW(pStm->loopend);
- if ((pIns->nLoopEnd > pIns->nLoopStart) && (pIns->nLoopEnd != 0xFFFF)) pIns->uFlags |= CHN_LOOP;
+ if ((pIns->nLoopEnd > pIns->nLoopStart) && (pIns->nLoopEnd != 0xFFFF))
+ {
+ pIns->uFlags |= CHN_LOOP;
+ pIns->nLoopEnd = min(pIns->nLoopEnd, pIns->nLength);
+ }
}
dwMemPos = sizeof(STMHEADER);
for (UINT nOrd = 0; nOrd < 128; nOrd++) if (Order[nOrd] >= 99) Order[nOrd] = Order.GetInvalidPatIndex();
Modified: trunk/OpenMPT/soundlib/mod_specifications.h
===================================================================
--- trunk/OpenMPT/soundlib/mod_specifications.h 2010-10-05 16:55:20 UTC (rev 734)
+++ trunk/OpenMPT/soundlib/mod_specifications.h 2010-10-08 14:40:44 UTC (rev 735)
@@ -265,7 +265,7 @@
// TODO: Set correct values.
"s3m", // File extension
13, // Minimum note index
- 120, // Maximum note index
+ 108, // Maximum note index
true, // Has notecut.
false, // No noteoff.
false, // No notefade.
@@ -305,7 +305,7 @@
// TODO: Set correct values.
"s3m", // File extension
13, // Minimum note index
- NOTE_MAX, // Maximum note index
+ 108, // Maximum note index
true, // Has notecut.
false, // No noteoff.
false, // No notefade.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-10-22 14:25:36
|
Revision: 746
http://modplug.svn.sourceforge.net/modplug/?rev=746&view=rev
Author: saga-games
Date: 2010-10-22 14:25:30 +0000 (Fri, 22 Oct 2010)
Log Message:
-----------
[Fix] XM Loader: Fixed handling of instruments with no samples, so that instruments assigned to VST plugins work correctly.
[Imp] PTM Loader: Improved handling of the note cut effect a bit.
[Ref] J2B Loader: Replaced some numbers by their #defined macros
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_ptm.cpp
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/load_j2b.cpp
Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ptm.cpp 2010-10-22 14:24:48 UTC (rev 745)
+++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2010-10-22 14:25:30 UTC (rev 746)
@@ -177,6 +177,15 @@
{
ConvertModCommand(&m[nChn]);
MODExx2S3MSxx(&m[nChn]);
+ // Note cut does just mute the sample, not cut it. We have to fix that, if possible.
+ if(m[nChn].command == CMD_S3MCMDEX && (m[nChn].param & 0xF0) == 0xC0 && m[nChn].volcmd == VOLCMD_NONE)
+ {
+ // SCx => v00 + SDx
+ // This is a pretty dumb solution because many (?) PTM files make usage of the volume column + note cut at the same time.
+ m[nChn].param = 0xD0 | (m[nChn].param & 0x0F);
+ m[nChn].volcmd = VOLCMD_VOLUME;
+ m[nChn].vol = 0;
+ }
} else
{
switch(m[nChn].command)
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2010-10-22 14:24:48 UTC (rev 745)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2010-10-22 14:25:30 UTC (rev 746)
@@ -327,6 +327,8 @@
memcpy(Instruments[iIns]->name, pih.name, 22);
SpaceToNullStringFixed(Instruments[iIns]->name, 22);
+ memset(&xmsh, 0, sizeof(XMSAMPLEHEADER));
+
if ((nsamples = pih.samples) > 0)
{
/* we have samples, so let's read the rest of this instrument
@@ -336,7 +338,6 @@
if (dwMemPos + ihsize >= dwMemLength)
return true;
- memset(&xmsh, 0, sizeof(XMSAMPLEHEADER));
memcpy(&xmsh,
lpStream + dwMemPos + sizeof(XMINSTRUMENTHEADER),
min(ihsize - sizeof(XMINSTRUMENTHEADER), sizeof(XMSAMPLEHEADER)));
@@ -355,15 +356,11 @@
if(xmsh.midichannel != 0 || xmsh.midienabled != 0 || xmsh.midiprogram != 0 || xmsh.mutecomputer != 0 || xmsh.pitchwheelrange != 0)
bIsFT2 = true; // definitely not MPT. (or any other tracker)
- dwMemPos += LittleEndian(pih.size);
- } else
- {
- if (LittleEndian(pih.size))
- dwMemPos += LittleEndian(pih.size);
- else
- dwMemPos += sizeof(XMINSTRUMENTHEADER);
- continue;
}
+ if (LittleEndian(pih.size))
+ dwMemPos += LittleEndian(pih.size);
+ else
+ dwMemPos += sizeof(XMINSTRUMENTHEADER);
memset(samplemap, 0, sizeof(samplemap));
if (nsamples > 32) return true;
Modified: trunk/OpenMPT/soundlib/load_j2b.cpp
===================================================================
--- trunk/OpenMPT/soundlib/load_j2b.cpp 2010-10-22 14:24:48 UTC (rev 745)
+++ trunk/OpenMPT/soundlib/load_j2b.cpp 2010-10-22 14:25:30 UTC (rev 746)
@@ -478,7 +478,7 @@
{
case AMCHUNKID_MAIN: // "MAIN" - Song info (AMFF)
case AMCHUNKID_INIT: // "INIT" - Song info (AM)
- if((LittleEndian(chunkheader->signature) == 0x4E49414D && !bIsAM) || (LittleEndian(chunkheader->signature) == 0x54494E49 && bIsAM))
+ if((LittleEndian(chunkheader->signature) == AMCHUNKID_MAIN && !bIsAM) || (LittleEndian(chunkheader->signature) == AMCHUNKID_INIT && bIsAM))
{
ASSERT_CAN_READ_CHUNK(sizeof(AMFFCHUNK_MAIN));
AMFFCHUNK_MAIN *mainchunk = (AMFFCHUNK_MAIN *)(lpStream + dwMemPos);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2010-11-13 13:49:15
|
Revision: 760
http://modplug.svn.sourceforge.net/modplug/?rev=760&view=rev
Author: saga-games
Date: 2010-11-13 13:49:04 +0000 (Sat, 13 Nov 2010)
Log Message:
-----------
[Fix] Pattern jumps to the same row+pattern as the jump command are not ignored anymore. (http://forum.openmpt.org/index.php?topic=1810.0)
[Fix] MOD Loader: Tentative fix for MODs with short loops at the sample start that were most likely not intended.
[Mod] IT Loader: MIDI macros are now cleared when loading IT files made with old Impulse Tracker versions (<2.14), so that Zxx commands won't break the songs anymore (fixes denonde.it, fix from Schism Tracker).
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2010-11-07 16:37:22 UTC (rev 759)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2010-11-13 13:49:04 UTC (rev 760)
@@ -775,6 +775,13 @@
dwMemPos += sizeof(MODMIDICFG);
}
}
+ // Ignore MIDI data. Fixes some files like denonde.it that were made with old versions of Impulse Tracker (which didn't support Zxx filters) and have Zxx effects in the patterns.
+ if (pifh->cwtv < 0x0214)
+ {
+ MemsetZero(m_MidiCfg);
+ m_dwSongFlags |= SONG_EMBEDMIDICFG;
+ }
+
// Read pattern names: "PNAM"
if ((dwMemPos + 8 < dwMemLength) && (*((DWORD *)(lpStream+dwMemPos)) == 0x4d414e50))
{
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2010-11-07 16:37:22 UTC (rev 759)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2010-11-13 13:49:04 UTC (rev 760)
@@ -275,7 +275,7 @@
// Check Mod Magic
memcpy(s, pMagic->Magic, 4);
if ((IsMagic(s, "M.K.")) || (IsMagic(s, "M!K!"))
- || (IsMagic(s, "M&K!")) || (IsMagic(s, "N.T."))) m_nChannels = 4; else
+ || (IsMagic(s, "M&K!")) || (IsMagic(s, "N.T.")) || (IsMagic(s, "FEST"))) m_nChannels = 4; else
if ((IsMagic(s, "CD81")) || (IsMagic(s, "OKTA"))) m_nChannels = 8; else
if ((s[0]=='F') && (s[1]=='L') && (s[2]=='T') && (s[3]>='4') && (s[3]<='9')) m_nChannels = s[3] - '0'; else
if ((s[0]>='4') && (s[0]<='9') && (s[1]=='C') && (s[2]=='H') && (s[3]=='N')) m_nChannels = s[0] - '0'; else
@@ -332,6 +332,11 @@
psmp->nLoopStart = 0;
psmp->nLoopEnd = 0;
}
+ // Fix for most likely broken sample loops. This fixes super_sufm_-_new_life.mod which has a long sample which is looped from 0 to 4.
+ if(psmp->nLoopEnd <= 8 && psmp->nLoopStart == 0 && psmp->nLength > psmp->nLoopEnd)
+ {
+ psmp->nLoopEnd = 0;
+ }
if (psmp->nLoopEnd > psmp->nLoopStart)
{
psmp->uFlags |= CHN_LOOP;
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-11-07 16:37:22 UTC (rev 759)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-11-13 13:49:04 UTC (rev 760)
@@ -1996,7 +1996,7 @@
case CMD_POSITIONJUMP:
m_nNextPatStartRow = 0; // FT2 E60 bug
nPosJump = param;
- if((m_dwSongFlags & SONG_PATTERNLOOP && m_nSeqOverride == 0))
+ if((m_dwSongFlags & SONG_PATTERNLOOP) && m_nSeqOverride == 0)
{
m_nSeqOverride = param + 1;
//Releasing pattern loop after position jump could cause
@@ -2104,15 +2104,18 @@
//if (((!bNoLoop) && (nPosJump < MAX_ORDERS))
if (nPosJump>=Order.size())
nPosJump = 0;
- if ((!bNoLoop)
- //end rewbs.fix
- && ((nPosJump != (int)m_nCurrentPattern) || (nBreakRow != (int)m_nRow)))
+
+ // This checks whether we're jumping to the same row we're already on.
+ // Sounds pretty stupid and pointless to me. And noone else does this, either.
+ //if((nPosJump != (int)m_nCurrentPattern) || (nBreakRow != (int)m_nRow))
{
// IT compatibility: don't reset loop count on pattern break
if (nPosJump != (int)m_nCurrentPattern && !IsCompatibleMode(TRK_IMPULSETRACKER))
{
for (CHANNELINDEX i = 0; i < m_nChannels; i++)
+ {
Chn[i].nPatternLoopCount = 0;
+ }
}
m_nNextPattern = nPosJump;
m_nNextRow = (UINT)nBreakRow;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2011-02-12 20:40:34
|
Revision: 798
http://modplug.svn.sourceforge.net/modplug/?rev=798&view=rev
Author: saga-games
Date: 2011-02-12 20:40:27 +0000 (Sat, 12 Feb 2011)
Log Message:
-----------
[Mod] Made the IT bidi loop flag non-static as loading another IT file reset the flag. I guess passing another parameter won't make the mixer slower...
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2011-02-11 23:28:58 UTC (rev 797)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2011-02-12 20:40:27 UTC (rev 798)
@@ -1425,8 +1425,8 @@
/////////////////////////////////////////////////////////////////////////
-static LONG MPPFASTCALL GetSampleCount(MODCHANNEL *pChn, LONG nSamples)
-//---------------------------------------------------------------------
+static LONG MPPFASTCALL GetSampleCount(MODCHANNEL *pChn, LONG nSamples, bool bITBidiMode)
+//---------------------------------------------------------------------------------------
{
LONG nLoopStart = (pChn->dwFlags & CHN_LOOP) ? pChn->nLoopStart : 0;
LONG nInc = pChn->nInc;
@@ -1479,8 +1479,7 @@
pChn->nPos = pChn->nLength - nDeltaHi - (nDeltaLo>>16);
pChn->nPosLo = nDeltaLo & 0xffff;
// Impulse Tracker's software mixer would put a -2 (instead of -1) in the following line (doesn't happen on a GUS)
- // The bidi mode flag is stored in a static CSoundFile variable. Dirty!
- if ((pChn->nPos <= pChn->nLoopStart) || (pChn->nPos >= pChn->nLength)) pChn->nPos = pChn->nLength - (CSoundFile::m_bITBidiMode ? 2 : 1);
+ if ((pChn->nPos <= pChn->nLoopStart) || (pChn->nPos >= pChn->nLength)) pChn->nPos = pChn->nLength - (bITBidiMode ? 2 : 1);
} else
{
if (nInc < 0) // This is a bug
@@ -1663,7 +1662,7 @@
{
if ((LONG)nrampsamples > pChannel->nRampLength) nrampsamples = pChannel->nRampLength;
}
- if ((nSmpCount = GetSampleCount(pChannel, nrampsamples)) <= 0)
+ if ((nSmpCount = GetSampleCount(pChannel, nrampsamples, m_bITBidiMode)) <= 0)
{
// Stopping the channel
pChannel->pCurrentSample = NULL;
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-02-11 23:28:58 UTC (rev 797)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-02-12 20:40:27 UTC (rev 798)
@@ -438,7 +438,6 @@
CTuningCollection* CSoundFile::s_pTuningsSharedBuiltIn(0);
CTuningCollection* CSoundFile::s_pTuningsSharedLocal(0);
uint8 CSoundFile::s_DefaultPlugVolumeHandling = PLUGIN_VOLUMEHANDLING_IGNORE;
-bool CSoundFile::m_bITBidiMode = false;
#pragma warning(disable : 4355) // "'this' : used in base member initializer list"
CSoundFile::CSoundFile() :
@@ -473,6 +472,7 @@
m_nMaxSample = 0;
m_ModFlags = 0;
+ m_bITBidiMode = false;
m_pModDoc = NULL;
m_dwLastSavedWithVersion=0;
@@ -3096,5 +3096,5 @@
void CSoundFile::SetupITBidiMode()
//--------------------------------
{
- CSoundFile::m_bITBidiMode = IsCompatibleMode(TRK_IMPULSETRACKER);
+ m_bITBidiMode = IsCompatibleMode(TRK_IMPULSETRACKER);
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2011-02-11 23:28:58 UTC (rev 797)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2011-02-12 20:40:27 UTC (rev 798)
@@ -574,12 +574,12 @@
private: //Misc data
uint16 m_ModFlags;
const CModSpecifications* m_pModSpecs;
+ bool m_bITBidiMode; // Process bidi loops like Impulse Tracker (see Fastmix.cpp for an explanation)
// For handling backwards jumps and stuff to prevent infinite loops when counting the mod length or rendering to wav.
VisitedRowsType m_VisitedRows;
-
public: // Static Members
static UINT m_nXBassDepth, m_nXBassRange;
static float m_nMaxSample;
@@ -593,10 +593,8 @@
static LPSNDMIXHOOKPROC gpSndMixHook;
static PMIXPLUGINCREATEPROC gpMixPluginCreateProc;
static uint8 s_DefaultPlugVolumeHandling;
- static bool m_bITBidiMode; // Process bidi loops like Impulse Tracker (see Fastmix.cpp for an explanation)
-
public: // for Editing
CModDoc* m_pModDoc; // Can be a null pointer f.e. when previewing samples from the treeview.
MODTYPE m_nType;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-05-02 23:29:05
|
Revision: 2005
http://sourceforge.net/p/modplug/code/2005
Author: manxorist
Date: 2013-05-02 23:28:58 +0000 (Thu, 02 May 2013)
Log Message:
-----------
[Fix] Fix volume ramping on samples played on the first row/tick of a song. In r188, a fix for an audible click on song start when the global volume was >0 and got set to 0 right in the first row was commited (see http://forum.openmpt.org/index.php?topic=523.0 ). This completely disabled not only global volume ramping but also sample volume ramping for all samples triggered directly at song start. The new fix works by checking if the global volume was unset before (which is afaik only the case at song start (so, IsGlobalVolumeUnset() just returns IsFirstTick()). In this case, the global volume is directly applyed and any global volume ramping is skipped.
[Fix] Also reset global volume ramping state when SetCurrentPos(0) is called.
Revision Links:
--------------
http://sourceforge.net/p/modplug/code/188
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-01 21:47:50 UTC (rev 2004)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-02 23:28:58 UTC (rev 2005)
@@ -406,7 +406,6 @@
MemsetZero(MixFloatBuffer);
gnDryLOfsVol = 0;
gnDryROfsVol = 0;
- gnVolumeRampUpSamplesActual = 42;
m_nType = MOD_TYPE_NONE;
m_nChannels = 0;
m_nMixChannels = 0;
@@ -933,11 +932,18 @@
for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++)
Chn[i].Reset(resetMask, *this, i);
- if (!nPos)
+ if(nPos == 0)
{
m_nGlobalVolume = m_nDefaultGlobalVolume;
m_nMusicSpeed = m_nDefaultSpeed;
m_nMusicTempo = m_nDefaultTempo;
+
+ // do not ramp global volume when starting playback
+ m_lHighResRampingGlobalVolume = m_nGlobalVolume<<VOLUMERAMPPRECISION;
+ m_nGlobalVolumeDestination = m_nGlobalVolume;
+ m_nSamplesToGlobalVolRampDest = 0;
+ m_nGlobalVolumeRampAmount = 0;
+
visitedSongRows.Initialize(true);
}
m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED | SONG_GLOBALFADE);
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-05-01 21:47:50 UTC (rev 2004)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-05-02 23:28:58 UTC (rev 2005)
@@ -297,7 +297,7 @@
#ifndef NO_AGC
CAGC m_AGC;
#endif
- UINT gnVolumeRampUpSamplesActual;
+
#ifdef MODPLUG_TRACKER
static LPSNDMIXHOOKPROC gpSndMixHook;
#endif
@@ -342,6 +342,7 @@
UINT m_nGlobalVolume, m_nSamplesToGlobalVolRampDest, m_nGlobalVolumeRampAmount,
m_nGlobalVolumeDestination, m_nSamplePreAmp, m_nVSTiVolume;
long m_lHighResRampingGlobalVolume;
+ bool IsGlobalVolumeUnset() const { return IsFirstTick(); }
UINT m_nFreqFactor, m_nTempoFactor, m_nOldGlbVolSlide;
LONG m_nMinPeriod, m_nMaxPeriod; // min period = highest possible frequency, max period = lowest possible frequency
LONG m_nRepeatCount; // -1 means repeat infinitely.
@@ -459,6 +460,7 @@
const char *GetInstrumentName(INSTRUMENTINDEX nInstr) const;
UINT GetMusicSpeed() const { return m_nMusicSpeed; }
UINT GetMusicTempo() const { return m_nMusicTempo; }
+ bool IsFirstTick() const { return (m_lTotalSampleCount == 0); }
//Get modlength in various cases: total length, length to
//specific order&row etc. Return value is in seconds.
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-01 21:47:50 UTC (rev 2004)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-02 23:28:58 UTC (rev 2005)
@@ -88,9 +88,6 @@
void CSoundFile::SetMixerSettings(const MixerSettings &mixersettings)
//-------------------------------------------------------------------
{
- // Start with ramping disabled to avoid clicks on first read.
- // Ramping is now set after the first read in CSoundFile::Read();
- gnVolumeRampUpSamplesActual = 0;
SetPreAmp(mixersettings.m_nPreAmp); // adjust agc
bool reset = false;
if(
@@ -379,8 +376,6 @@
lRead -= lCount;
m_nBufferCount -= lCount;
m_lTotalSampleCount += lCount; // increase sample count for VSTTimeInfo.
- // Turn on ramping after first read (fix http://forum.openmpt.org/index.php?topic=523.0 )
- gnVolumeRampUpSamplesActual = m_MixerSettings.glVolumeRampUpSamples;
}
MixDone:
if (lRead) memset(lpBuffer, (m_MixerSettings.m_SampleFormat == SampleFormatUnsigned8) ? 0x80 : 0, lRead * lSampleSize);
@@ -1571,7 +1566,7 @@
{
const bool rampUp = (pChn->newLeftVol > pChn->leftVol) || (pChn->newRightVol > pChn->rightVol);
int32 rampLength, globalRampLength, instrRampLength = 0;
- rampLength = globalRampLength = (rampUp ? gnVolumeRampUpSamplesActual : m_MixerSettings.glVolumeRampDownSamples);
+ rampLength = globalRampLength = (rampUp ? m_MixerSettings.glVolumeRampUpSamples : m_MixerSettings.glVolumeRampDownSamples);
//XXXih: add real support for bidi ramping here
if(pChn->pModInstrument != nullptr && rampUp)
@@ -2234,12 +2229,18 @@
{
long step = 0;
- if (m_nGlobalVolumeDestination != m_nGlobalVolume)
+ if(IsGlobalVolumeUnset())
{
+ // do not ramp if no global volume was set before (which is the case at song start), to prevent audible glitches when default volume is > 0 and it is set to 0 in the first row
+ m_nGlobalVolumeDestination = m_nGlobalVolume;
+ m_nSamplesToGlobalVolRampDest = 0;
+ m_nGlobalVolumeRampAmount = 0;
+ } else if(m_nGlobalVolumeDestination != m_nGlobalVolume)
+ {
// User has provided new global volume
const bool rampUp = m_nGlobalVolumeDestination > m_nGlobalVolume;
m_nGlobalVolumeDestination = m_nGlobalVolume;
- m_nSamplesToGlobalVolRampDest = m_nGlobalVolumeRampAmount = rampUp ? gnVolumeRampUpSamplesActual : m_MixerSettings.glVolumeRampDownSamples;
+ m_nSamplesToGlobalVolRampDest = m_nGlobalVolumeRampAmount = rampUp ? m_MixerSettings.glVolumeRampUpSamples : m_MixerSettings.glVolumeRampDownSamples;
}
if (m_nSamplesToGlobalVolRampDest > 0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-09-03 16:04:15
|
Revision: 2630
http://sourceforge.net/p/modplug/code/2630
Author: saga-games
Date: 2013-09-03 16:04:06 +0000 (Tue, 03 Sep 2013)
Log Message:
-----------
[Fix] IT Loader: Fixed detection MPT 1.0 alpha.
[Imp] XM Loader: Don't enable smooth ramping heuristic for old XM revisions (this feature was introduced in a later version of FT2)
[Imp] MOD Loader: When loading SoundTracker modules, automatically enable ProTracker 1.x mode.
[Ref] Various smaller changes.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/Load_ptm.cpp
trunk/OpenMPT/soundlib/Load_s3m.cpp
trunk/OpenMPT/soundlib/Load_stm.cpp
trunk/OpenMPT/soundlib/Load_umx.cpp
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/MIDIEvents.h
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2013-09-03 15:23:51 UTC (rev 2629)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-09-03 16:04:06 UTC (rev 2630)
@@ -396,13 +396,6 @@
madeWithTracker = "ModPlug tracker b3.3 - 1.09";
interpretModPlugMade = true;
}
- else if(fileHeader.cwtv == 0x0214 && fileHeader.cmwt == 0x0200 && fileHeader.reserved == 0)
- {
- // ModPlug Tracker 1.00a5, instruments 560 bytes apart
- m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 00, 00, A5);
- madeWithTracker = "ModPlug tracker 1.00a5";
- interpretModPlugMade = true;
- }
} else // case: type == MOD_TYPE_MPT
{
if (fileHeader.cwtv >= verMptFileVerLoadLimit)
@@ -959,6 +952,12 @@
&& fileHeader.msglength == 0 && fileHeader.msgoffset == 0 && fileHeader.reserved == 0)
{
madeWithTracker = "OpenSPC conversion";
+ } else if(fileHeader.cwtv == 0x0214 && fileHeader.cmwt == 0x0200 && fileHeader.reserved == 0)
+ {
+ // ModPlug Tracker 1.00a5, instruments 560 bytes apart
+ m_dwLastSavedWithVersion = MAKE_VERSION_NUMERIC(1, 00, 00, A5);
+ madeWithTracker = "ModPlug tracker 1.00a5";
+ interpretModPlugMade = true;
} else if(fileHeader.cwtv == 0x0214 && fileHeader.cmwt == 0x0214 && fileHeader.reserved == ITFileHeader::chibiMagic)
{
madeWithTracker = "ChibiTracker";
@@ -1401,7 +1400,7 @@
dwPos += 8;
const CHANNELINDEX maxChannels = MIN(specs.channelsMax, GetNumChannels());
- std::vector<BYTE> chnmask(maxChannels, 0xFF);
+ std::vector<uint8> chnmask(maxChannels, 0xFF);
std::vector<ModCommand> lastvalue(maxChannels, ModCommand::Empty());
for(ROWINDEX row = 0; row < writeRows; row++)
@@ -1566,7 +1565,8 @@
#else
bool compress = false;
#endif // MODPLUG_TRACKER
- // Old MPT will only consider the IT2.15 compression flag if the header version also indicates IT2.15.
+ // Old MPT, DUMB and probably other libraries will only consider the IT2.15 compression flag if the header version also indicates IT2.15.
+ // Old MilkyTracker will only assume IT2.15 compression with cmwt == 0x215, ignoring the delta flag completely.
itss.ConvertToIT(Samples[nsmp], GetType(), compress, itHeader.cmwt >= 0x215);
mpt::String::Write<mpt::String::nullTerminated>(itss.name, m_szNames[nsmp]);
@@ -1816,13 +1816,13 @@
mpt::String::SetNullTerminator(m_MixPlugins[plug].Info.szLibraryName);
//data for VST setchunk? size lies just after standard plugin data.
- FileReader pluginDataChunk = chunk.GetChunk(chunk.ReadUint32LE());
- uint32 pluginDataChunkSize = mpt::saturate_cast<uint32>(pluginDataChunk.BytesLeft());
+ const uint32 pluginDataChunkSize = chunk.ReadUint32LE();
+ FileReader pluginDataChunk = chunk.GetChunk(pluginDataChunkSize);
if(pluginDataChunk.IsValid())
{
m_MixPlugins[plug].nPluginDataSize = 0;
- m_MixPlugins[plug].pPluginData = new char [pluginDataChunkSize];
+ m_MixPlugins[plug].pPluginData = new (std::nothrow) char[pluginDataChunkSize];
if(m_MixPlugins[plug].pPluginData)
{
m_MixPlugins[plug].nPluginDataSize = pluginDataChunkSize;
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2013-09-03 15:23:51 UTC (rev 2629)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2013-09-03 16:04:06 UTC (rev 2630)
@@ -889,7 +889,7 @@
m_nMinPeriod = 14 * 4;
m_nMaxPeriod = 3424 * 4;
m_nSamplePreAmp = 64;
- m_SongFlags.reset();
+ m_SongFlags = SONG_PT1XMODE;
mpt::String::Read<mpt::String::spacePadded>(songName, songname);
// Setup channel pan positions and volume
Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-09-03 15:23:51 UTC (rev 2629)
+++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2013-09-03 16:04:06 UTC (rev 2630)
@@ -27,7 +27,7 @@
uint16 numSamples; // Number of instruments (1..255)
uint16 numPatterns; // Number of patterns (1..128)
uint16 numChannels; // Number of channels (voices) used (1..32)
- uint8 flags[2]; // Set to 0
+ uint16 flags; // Set to 0
uint8 reserved2[2]; // Reserved, set to 0
char magic[4]; // Song identification, 'PTMF'
uint8 reserved3[16]; // Reserved, set to 0
@@ -42,6 +42,7 @@
SwapBytesLE(numSamples);
SwapBytesLE(numPatterns);
SwapBytesLE(numChannels);
+ SwapBytesLE(flags);
for(std::size_t i = 0; i < CountOf(patOffsets); i++)
{
SwapBytesLE(patOffsets[i]);
@@ -141,6 +142,9 @@
PTMFileHeader fileHeader;
if(!file.ReadConvertEndianness(fileHeader)
|| memcmp(fileHeader.magic, "PTMF", 4)
+ || fileHeader.dosEOF != 26
+ || fileHeader.versionHi > 2
+ || fileHeader.flags != 0
|| !fileHeader.numChannels
|| fileHeader.numChannels > 32
|| !fileHeader.numOrders || fileHeader.numOrders > 256
Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_s3m.cpp 2013-09-03 15:23:51 UTC (rev 2629)
+++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2013-09-03 16:04:06 UTC (rev 2630)
@@ -18,7 +18,7 @@
void CSoundFile::S3MConvert(ModCommand &m, bool fromIT) const
-//--------------------------------------------------------
+//-----------------------------------------------------------
{
switch(m.command | 0x40)
{
@@ -876,9 +876,9 @@
size_t writtenLength = sampleHeader[smp].GetSampleFormat(false).WriteSample(f, Samples[realSmp], smpLength);
sampleDataOffset += writtenLength;
- if((writtenLength % 16) != 0)
+ if((writtenLength % 16u) != 0)
{
- size_t fillSize = 16 - (writtenLength % 16);
+ size_t fillSize = 16 - (writtenLength % 16u);
fwrite(filler, fillSize, 1, f);
sampleDataOffset += fillSize;
}
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2013-09-03 15:23:51 UTC (rev 2629)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2013-09-03 16:04:06 UTC (rev 2630)
@@ -27,7 +27,7 @@
char filename[12]; // Can't have long comments - just filename comments :)
uint8 zero;
uint8 disk; // A blast from the past
- uint16 offset; // ISA in memory when in ST 2
+ uint8 offset[2]; // ISA in memory when in ST 2
uint16 length; // Sample length
uint16 loopStart; // Loop start point
uint16 loopEnd; // Loop end point
@@ -43,7 +43,7 @@
mpt::String::Read<mpt::String::nullTerminated>(mptSmp.filename, filename);
mptSmp.nC5Speed = sampleRate;
- mptSmp.nVolume = std::min(volume * 4u, 256u);
+ mptSmp.nVolume = std::min<uint8>(volume, 64) * 4;
mptSmp.nLength = length;
mptSmp.nLoopStart = loopStart;
mptSmp.nLoopEnd = loopEnd;
@@ -230,16 +230,6 @@
switch(m->command)
{
-#ifdef MODPLUG_TRACKER
- case CMD_SPEED:
- // ST2 assumes that the tempo is 125 * 16 BPM, and effects are updated
- // on every 16th tick of a row. This is pretty hard to handle in the tracker,
- // so we just assume the tempo is 125 and divide the speed by 16 instead.
- // Parameters below 10 might behave weird.
- m->param >>= 4;
- break;
-#endif // MODPLUG_TRACKER
-
case CMD_PATTERNBREAK:
m->param = (m->param & 0xF0) * 10 + (m->param & 0x0F);
if(breakRow > m->param)
@@ -267,12 +257,23 @@
// broken... oh well. not a big loss.
break;
+#ifdef MODPLUG_TRACKER
+ case CMD_SPEED:
+ // ST2 assumes that the tempo is 125 * 16 BPM (or in other words: ticks are
+ // 16 times as precise as in ProTracker), and effects are updated on every
+ // 16th tick of a row. This is pretty hard to handle in the tracker when not
+ // natively supporting STM editing, so we just assume the tempo is 125 and
+ // divide the speed by 16 instead. Parameters below 10 might behave weird.
+ m->param >>= 4;
+#endif // MODPLUG_TRACKER
+
+ // Intentonal fall-through
default:
// Anything not listed above is a no-op if there's no value.
// (ST2 doesn't have effect memory)
if(!m->param)
{
- m->command= CMD_NONE;
+ m->command = CMD_NONE;
}
break;
}
Modified: trunk/OpenMPT/soundlib/Load_umx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_umx.cpp 2013-09-03 15:23:51 UTC (rev 2629)
+++ trunk/OpenMPT/soundlib/Load_umx.cpp 2013-09-03 16:04:06 UTC (rev 2630)
@@ -204,6 +204,7 @@
// Now we can be pretty sure that we're doing the right thing.
InitializeGlobals();
+ madeWithTracker = mpt::String::Format("Unreal Package v%u", fileHeader.packageVersion);
for(uint32 i = 0; i < fileHeader.exportCount; i++)
{
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2013-09-03 15:23:51 UTC (rev 2629)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2013-09-03 16:04:06 UTC (rev 2630)
@@ -583,6 +583,7 @@
}
if(madeWith[verFT2Generic]
+ && fileHeader.version < 0x0104 // Old versions of FT2 didn't have (smooth) ramping. Disable it for those versions where we can be sure that there should be no ramping.
#ifdef MODPLUG_TRACKER
&& TrackerSettings::Instance().autoApplySmoothFT2Ramping
#endif // MODPLUG_TRACKER
@@ -719,7 +720,7 @@
fileHeader.flags = fileHeader.flags;
// Fasttracker 2 will happily accept any tempo faster than 255 BPM. XMPlay does also support this, great!
- fileHeader.tempo = static_cast<uint16>(Clamp(m_nDefaultTempo, 32u, 512u));
+ fileHeader.tempo = static_cast<uint16>(m_nDefaultTempo);
fileHeader.speed = static_cast<uint16>(Clamp(m_nDefaultSpeed, 1u, 31u));
fileHeader.ConvertEndianness();
Modified: trunk/OpenMPT/soundlib/MIDIEvents.h
===================================================================
--- trunk/OpenMPT/soundlib/MIDIEvents.h 2013-09-03 15:23:51 UTC (rev 2629)
+++ trunk/OpenMPT/soundlib/MIDIEvents.h 2013-09-03 16:04:06 UTC (rev 2630)
@@ -108,7 +108,7 @@
MIDICC_GeneralPurposeButton3_OnOff = 82,
MIDICC_GeneralPurposeButton4_OnOff = 83,
MIDICC_EffectsLevel = 91,
- MIDICC_TremuloLevel = 92,
+ MIDICC_TremoloLevel = 92,
MIDICC_ChorusLevel = 93,
MIDICC_CelesteLevel = 94,
MIDICC_PhaserLevel = 95,
@@ -224,7 +224,7 @@
"", //89
"", //90
"EffectsLevel", //91
- "TremuloLevel", //92
+ "TremoloLevel", //92
"ChorusLevel", //93
"CelesteLevel", //94
"PhaserLevel", //95
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-18 09:53:09
|
Revision: 3899
http://sourceforge.net/p/modplug/code/3899
Author: manxorist
Date: 2014-03-18 09:53:02 +0000 (Tue, 18 Mar 2014)
Log Message:
-----------
[Ref] Silence MSVC warnings.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_dmf.cpp
trunk/OpenMPT/soundlib/modcommand.cpp
Modified: trunk/OpenMPT/soundlib/Load_dmf.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-03-18 09:43:33 UTC (rev 3898)
+++ trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-03-18 09:53:02 UTC (rev 3899)
@@ -279,8 +279,8 @@
{
uint8 ontime = (val >> 4);
uint8 offtime = (val & 0x0F);
- ontime = Clamp(ontime * internalTicks / 15, 1, 15);
- offtime = Clamp(offtime * internalTicks / 15, 1, 15);
+ ontime = static_cast<uint8>(Clamp(ontime * internalTicks / 15, 1, 15));
+ offtime = static_cast<uint8>(Clamp(offtime * internalTicks / 15, 1, 15));
return (ontime << 4) | offtime;
}
@@ -742,7 +742,7 @@
useMem2 = true;
break;
case 7: // Scratch to Note (neat! but we don't have such an effect...)
- m->note = Clamp(effectParam2 + 25, NOTE_MIN, NOTE_MAX);
+ m->note = static_cast<ModCommand::NOTE>(Clamp(effectParam2 + 25, NOTE_MIN, NOTE_MAX));
effect2 = CMD_TONEPORTAMENTO;
effectParam2 = 0xFF;
useMem2 = true;
Modified: trunk/OpenMPT/soundlib/modcommand.cpp
===================================================================
--- trunk/OpenMPT/soundlib/modcommand.cpp 2014-03-18 09:43:33 UTC (rev 3898)
+++ trunk/OpenMPT/soundlib/modcommand.cpp 2014-03-18 09:53:02 UTC (rev 3899)
@@ -556,7 +556,7 @@
case VOLCMD_PANNING:
command = CMD_PANNING8;
- param = Clamp(vol << 2, 0, 0xFF);
+ param = mpt::saturate_cast<uint8>(vol << 2);
break;
case VOLCMD_VOLSLIDEDOWN:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2015-03-01 12:30:47
|
Revision: 4798
http://sourceforge.net/p/modplug/code/4798
Author: saga-games
Date: 2015-03-01 12:30:39 +0000 (Sun, 01 Mar 2015)
Log Message:
-----------
[Fix] Mod Conversion: Tempo commands broke when converting XM to MOD.
[Ref] STM loader cleanup.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_stm.cpp
trunk/OpenMPT/soundlib/modcommand.cpp
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2015-02-27 22:21:54 UTC (rev 4797)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2015-03-01 12:30:39 UTC (rev 4798)
@@ -14,10 +14,6 @@
OPENMPT_NAMESPACE_BEGIN
-#if MPT_COMPILER_MSVC
-#pragma warning(disable:4244) //"conversion from 'type1' to 'type2', possible loss of data"
-#endif
-
#ifdef NEEDS_PRAGMA_PACK
#pragma pack(push, 1)
#endif
@@ -29,14 +25,14 @@
char filename[12]; // Can't have long comments - just filename comments :)
uint8 zero;
uint8 disk; // A blast from the past
- uint16 offset; // ISA in memory when in ST 2
+ uint16 offset; // 20-bit offset in file (lower 4 bits are zero)
uint16 length; // Sample length
uint16 loopStart; // Loop start point
uint16 loopEnd; // Loop end point
uint8 volume; // Volume
uint8 reserved2;
uint16 sampleRate;
- uint8 reserved3[6]; // Yet more of PSi's reserved crap
+ uint8 reserved3[6];
// Convert an STM sample header to OpenMPT's internal sample header.
void ConvertToMPT(ModSample &mptSmp) const
@@ -50,12 +46,7 @@
mptSmp.nLoopStart = loopStart;
mptSmp.nLoopEnd = loopEnd;
- if(mptSmp.nLength < 2 || volume == 0)
- {
- // As WTF as the above condition might sound, it seems to make sense.
- // The zero-volume samples in acidlamb.stm shouldn't be loaded, but they have an actual sample length.
- mptSmp.nLength = 0;
- }
+ if(mptSmp.nLength < 2) mptSmp.nLength = 0;
if(mptSmp.nLoopStart < mptSmp.nLength
&& mptSmp.nLoopEnd > mptSmp.nLoopStart
@@ -87,12 +78,12 @@
char trackername[8]; // !SCREAM! for ST 2.xx
uint8 dosEof; // 0x1A
uint8 filetype; // 1=song, 2=module (only 2 is supported, of course) :)
- uint8 verMajor; // Like 2
- uint8 verMinor; // "ditto"
- uint8 initTempo; // initspeed= stm inittempo>>4
+ uint8 verMajor;
+ uint8 verMinor;
+ uint8 initTempo; // Ticks per row. Keep in mind that effects are only updated on every 16th tick.
uint8 numPatterns; // number of patterns
- uint8 globalVolume; // <- WoW! a RiGHT TRiANGLE =8*)
- uint8 reserved[13]; // More of PSi's internal crap
+ uint8 globalVolume;
+ uint8 reserved[13];
STMSampleHeader samples[31]; // Sample headers
uint8 order[128]; // Order list
@@ -251,6 +242,7 @@
switch(m->command)
{
case CMD_VOLUMESLIDE:
+ // Lower nibble always has precedence, and there are no fine slides.
if(m->param & 0x0F) m->param &= 0x0F;
else m->param &= 0xF0;
break;
@@ -306,7 +298,7 @@
if(breakPos != ORDERINDEX_INVALID)
{
- Patterns[pat].WriteEffect(EffectWriter(CMD_POSITIONJUMP, breakPos).Row(breakRow).Retry(EffectWriter::rmTryPreviousRow));
+ Patterns[pat].WriteEffect(EffectWriter(CMD_POSITIONJUMP, static_cast<ModCommand::PARAM>(breakPos)).Row(breakRow).Retry(EffectWriter::rmTryPreviousRow));
}
}
@@ -328,9 +320,6 @@
if(sampleOffset > sizeof(STMPatternEntry) && sampleOffset < file.GetLength())
{
file.Seek(sampleOffset);
- } else
- {
- file.Seek((file.GetPosition() + 15) & (~15));
}
sampleIO.ReadSample(sample, file);
}
Modified: trunk/OpenMPT/soundlib/modcommand.cpp
===================================================================
--- trunk/OpenMPT/soundlib/modcommand.cpp 2015-02-27 22:21:54 UTC (rev 4797)
+++ trunk/OpenMPT/soundlib/modcommand.cpp 2015-03-01 12:30:39 UTC (rev 4798)
@@ -501,7 +501,7 @@
switch(command)
{
case CMD_TEMPO:
- param = std::min<PARAM>(param, 0x21);
+ param = std::max<PARAM>(param, 0x21);
break;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2015-03-06 22:16:29
|
Revision: 4830
http://sourceforge.net/p/modplug/code/4830
Author: saga-games
Date: 2015-03-06 22:16:16 +0000 (Fri, 06 Mar 2015)
Log Message:
-----------
[Fix] More PLM fixes (+ features not supported in the alpha version of DT2 available on Modland), tx dojoe
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_plm.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/Load_plm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_plm.cpp 2015-03-05 00:08:20 UTC (rev 4829)
+++ trunk/OpenMPT/soundlib/Load_plm.cpp 2015-03-06 22:16:16 UTC (rev 4830)
@@ -50,6 +50,7 @@
enum SampleFlags
{
smp16Bit = 1,
+ smpPingPong = 2,
};
char magic[4]; // "PLS\x1A"
@@ -140,8 +141,10 @@
InitializeChannels();
SetModFlag(MSF_COMPATIBLE_PLAY, true);
m_nType = MOD_TYPE_PLM;
+ m_SongFlags = SONG_ITOLDEFFECTS;
madeWithTracker = "Disorder Tracker 2";
- mpt::String::Read<mpt::String::maybeNullTerminated>(songName, fileHeader.songName);
+ // Some PLMs use ASCIIZ, some space-padding strings...weird. Oh, and the file browser stops at 0 bytes in the name, the main GUI doesn't.
+ mpt::String::Read<mpt::String::spacePadded>(songName, fileHeader.songName);
m_nChannels = fileHeader.numChannels + 1; // Additional channel for writing pattern breaks
m_nSamplePreAmp = fileHeader.amplify;
m_nDefaultTempo = fileHeader.tempo;
@@ -194,7 +197,11 @@
// Apparently there is a bug in DT2 which adds an extra byte before the sample data.
sampleHeader.headerSize++;
}
- if(sample.nLoopEnd > sample.nLoopStart) sample.uFlags.set(CHN_LOOP);
+ if(sample.nLoopEnd > sample.nLoopStart)
+ {
+ sample.uFlags.set(CHN_LOOP);
+ if(sampleHeader.flags & PLMSampleHeader::smpPingPong) sample.uFlags.set(CHN_PINGPONGLOOP);
+ }
sample.SanitizeLoops();
if(loadFlags & loadSampleData)
@@ -242,7 +249,8 @@
CMD_S3MCMDEX, // Pattern Delay
CMD_FINEVIBRATO,
CMD_VIBRATOVOL,
- CMD_TONEPORTAVOL
+ CMD_TONEPORTAVOL,
+ CMD_OFFSET, // Percentage offset
};
for(uint16 i = 0; i < fileHeader.numOrders; i++)
@@ -256,7 +264,7 @@
ORDERINDEX curOrd = ord.x / rowsPerPat;
ROWINDEX curRow = ord.x % rowsPerPat;
- const CHANNELINDEX numChannels = std::min<CHANNELINDEX>(patHeader.numChannels, fileHeader.numChannels - ord.y);
+ const CHANNELINDEX numChannels = std::min<uint8>(patHeader.numChannels, fileHeader.numChannels - ord.y);
const uint32 patternEnd = ord.x + patHeader.numRows;
maxPos = std::max(maxPos, patternEnd);
@@ -333,7 +341,7 @@
m->param = 0xC0 | std::min<ModCommand::PARAM>(m->param, 0x0F);
break;
case 0x12: // Pattern Delay
- m->param = 0x60 | std::min<ModCommand::PARAM>(m->param, 0x0F);
+ m->param = 0xE0 | std::min<ModCommand::PARAM>(m->param, 0x0F);
break;
case 0x04: // Volume Slide
case 0x14: // Vibrato + Volume Slide
@@ -344,6 +352,11 @@
m->param |= 0x0F;
}
break;
+ case 0x16: // Percentage offset
+ if(m->instr > 0 && m->instr <= m_nSamples)
+ {
+ m->param = mpt::saturate_cast<ModCommand::PARAM>(((m->param * Samples[m->instr].nLength) / 255) >> 8);
+ }
}
}
}
@@ -363,6 +376,19 @@
Patterns[endPat].Resize(endPatSize);
}
}
+ // If there are still any non-existent patterns in our order list, insert some blank patterns.
+ PATTERNINDEX blankPat = PATTERNINDEX_INVALID;
+ for(ORDERINDEX i = 0; i < Order.size(); i++)
+ {
+ if(Order[i] == Order.GetInvalidPatIndex())
+ {
+ if(blankPat == PATTERNINDEX_INVALID)
+ {
+ blankPat = Patterns.Insert(rowsPerPat);
+ }
+ Order[i] = blankPat;
+ }
+ }
return true;
}
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-05 00:08:20 UTC (rev 4829)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-03-06 22:16:16 UTC (rev 4830)
@@ -3051,6 +3051,10 @@
else
PortamentoMPT(pChn, param);
return;
+ } else if(GetType() == MOD_TYPE_PLM)
+ {
+ // A normal portamento up or down makes a follow-up tone portamento go the same direction.
+ pChn->nPortamentoDest = 1;
}
if (doFineSlides && param >= 0xE0)
@@ -3104,6 +3108,10 @@
else
PortamentoMPT(pChn, -static_cast<int>(param));
return;
+ } else if(GetType() == MOD_TYPE_PLM)
+ {
+ // A normal portamento up or down makes a follow-up tone portamento go the same direction.
+ pChn->nPortamentoDest = 65535;
}
if(doFineSlides && param >= 0xE0)
@@ -3414,8 +3422,16 @@
return;
} //End candidate MPT behavior.
+ bool doPorta = !pChn->isFirstTick || GetType() == MOD_TYPE_DBM;
+ if(GetType() == MOD_TYPE_PLM && param >= 0xF0)
+ {
+ param -= 0xF0;
+ doPorta = pChn->isFirstTick;
+ }
+
if(param) pChn->nPortamentoSlide = param * 4;
- if(pChn->nPeriod && pChn->nPortamentoDest && (!pChn->isFirstTick || GetType() == MOD_TYPE_DBM))
+
+ if(pChn->nPeriod && pChn->nPortamentoDest && doPorta)
{
if (pChn->nPeriod < pChn->nPortamentoDest)
{
@@ -4542,8 +4558,7 @@
pChn->nPos = pChn->nLength; // Old FX: Clip to end of sample
else
pChn->nPos = 0; // Reset to beginning of sample
- }
- else
+ } else
{
pChn->nPos = pChn->nLoopStart;
if(m_SongFlags[SONG_ITOLDEFFECTS] && pChn->nLength > 4)
@@ -4719,7 +4734,7 @@
void CSoundFile::DoFreqSlide(ModChannel *pChn, LONG nFreqSlide) const
//-------------------------------------------------------------------
{
- if (!pChn->nPeriod) return;
+ if(!pChn->nPeriod) return;
if(m_SongFlags[SONG_LINEARSLIDES] && GetType() != MOD_TYPE_XM)
{
// IT Linear slides
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2011-02-16 13:26:33
|
Revision: 801
http://modplug.svn.sourceforge.net/modplug/?rev=801&view=rev
Author: saga-games
Date: 2011-02-16 13:26:26 +0000 (Wed, 16 Feb 2011)
Log Message:
-----------
[Fix] AMF / MED Loaders: Ignore short loops (http://bugs.openmpt.org/view.php?id=70) - probably caused by bad MOD conversions, at least in the AMF example?
Modified Paths:
--------------
trunk/OpenMPT/soundlib/LOAD_AMF.CPP
trunk/OpenMPT/soundlib/Load_med.cpp
Modified: trunk/OpenMPT/soundlib/LOAD_AMF.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2011-02-14 18:35:31 UTC (rev 800)
+++ trunk/OpenMPT/soundlib/LOAD_AMF.CPP 2011-02-16 13:26:26 UTC (rev 801)
@@ -210,6 +210,7 @@
psmp->nLength = LittleEndian(*((LPDWORD)(lpStream+dwMemPos+25)));
psmp->nLoopStart = LittleEndian(*((LPDWORD)(lpStream+dwMemPos+29)));
psmp->nLoopEnd = psmp->nLoopStart + LittleEndian(*((LPDWORD)(lpStream+dwMemPos+33)));
+ if (psmp->nLoopEnd <= 2) psmp->nLoopEnd = 0;
if ((psmp->nLoopEnd > psmp->nLoopStart) && (psmp->nLoopEnd <= psmp->nLength))
{
psmp->uFlags = CHN_LOOP;
Modified: trunk/OpenMPT/soundlib/Load_med.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_med.cpp 2011-02-14 18:35:31 UTC (rev 800)
+++ trunk/OpenMPT/soundlib/Load_med.cpp 2011-02-16 13:26:26 UTC (rev 801)
@@ -621,6 +621,7 @@
if (pSmp->nVolume > 256) pSmp->nVolume = 256;
pSmp->RelativeTone = -12 * pmsh->sample[iSHdr].strans;
pSmp->nPan = 128;
+ if (pSmp->nLoopEnd <= 2) pSmp->nLoopEnd = 0;
if (pSmp->nLoopEnd) pSmp->uFlags |= CHN_LOOP;
}
// Common Flags
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2011-04-01 15:03:24
|
Revision: 835
http://modplug.svn.sourceforge.net/modplug/?rev=835&view=rev
Author: saga-games
Date: 2011-04-01 15:03:17 +0000 (Fri, 01 Apr 2011)
Log Message:
-----------
[Fix] S3M Loader: Sample header and sample data offsets can now be 0. (The specs only say that pattern offset 0 means "empty pattern")
[Reg] Removed S3M global volume hacks from revision 831 (there are too many non-ST3 S3Ms around to emulate this faithfully)
Revision Links:
--------------
http://modplug.svn.sourceforge.net/modplug/?rev=831&view=rev
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_s3m.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_s3m.cpp 2011-04-01 14:59:06 UTC (rev 834)
+++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2011-04-01 15:03:17 UTC (rev 835)
@@ -355,7 +355,7 @@
for (UINT iSmp=1; iSmp<=insnum; iSmp++)
{
UINT nInd = ((DWORD)smppos[iSmp - 1]) * 16;
- if ((!nInd) || (nInd + 0x50 > dwMemLength)) continue;
+ if (nInd + 0x50 > dwMemLength) continue;
memcpy(s, lpStream + nInd, 0x50);
memcpy(Samples[iSmp].filename, s+1, 12);
@@ -504,7 +504,7 @@
}
// Reading samples
- for (UINT iRaw = 1; iRaw <= insnum; iRaw++) if ((Samples[iRaw].nLength) && (smpdatapos[iRaw - 1]))
+ for (UINT iRaw = 1; iRaw <= insnum; iRaw++) if (Samples[iRaw].nLength)
{
UINT flags = (psfh.version == 1) ? RS_PCM8S : RS_PCM8U;
if (insflags[iRaw-1] & 4) flags += 5;
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-04-01 14:59:06 UTC (rev 834)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-04-01 15:03:17 UTC (rev 835)
@@ -343,11 +343,11 @@
break;
// Global Volume
case CMD_GLOBALVOLUME:
- // ST3 applies global volume on tick 1 and does other weird things, but we just emulate this part for now.
- if((GetType() & MOD_TYPE_S3M) && nMusicSpeed <= 1)
- {
- break;
- }
+ // ST3 applies global volume on tick 1 and does other weird things, but we won't emulate this for now.
+// if((GetType() & MOD_TYPE_S3M) && nMusicSpeed <= 1)
+// {
+// break;
+// }
if (!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))) param <<= 1;
if(IsCompatibleMode(TRK_IMPULSETRACKER | TRK_FASTTRACKER2 | TRK_SCREAMTRACKER))
@@ -1880,12 +1880,12 @@
// Set Global Volume
case CMD_GLOBALVOLUME:
- // ST3 applies global volume on tick 1 and does other weird things, but we just emulate this part for now.
- if(((GetType() & MOD_TYPE_S3M) && m_nTickCount != 1)
- || (!(GetType() & MOD_TYPE_S3M) && !(m_dwSongFlags & SONG_FIRSTTICK)))
- {
- break;
- }
+ // ST3 applies global volume on tick 1 and does other weird things, but we won't emulate this for now.
+// if(((GetType() & MOD_TYPE_S3M) && m_nTickCount != 1)
+// || (!(GetType() & MOD_TYPE_S3M) && !(m_dwSongFlags & SONG_FIRSTTICK)))
+// {
+// break;
+// }
if (!(GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT))) param <<= 1;
//IT compatibility 16. FT2, ST3 and IT ignore out-of-range values
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2011-07-15 22:14:52
|
Revision: 917
http://modplug.svn.sourceforge.net/modplug/?rev=917&view=rev
Author: saga-games
Date: 2011-07-15 22:14:45 +0000 (Fri, 15 Jul 2011)
Log Message:
-----------
[Fix] 8-Bit Stereo Samples were not saved correctly. (http://bugs.openmpt.org/view.php?id=153)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sampleio.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
Modified: trunk/OpenMPT/soundlib/Sampleio.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sampleio.cpp 2011-07-10 16:52:57 UTC (rev 916)
+++ trunk/OpenMPT/soundlib/Sampleio.cpp 2011-07-15 22:14:45 UTC (rev 917)
@@ -566,22 +566,20 @@
format.format = 1;
format.freqHz = pSmp->nC5Speed;
if (m_nType & (MOD_TYPE_MOD|MOD_TYPE_XM)) format.freqHz = TransposeToFrequency(pSmp->RelativeTone, pSmp->nFineTune);
- format.channels = (pSmp->uFlags & CHN_STEREO) ? 2 : 1;
- format.bitspersample = (pSmp->uFlags & CHN_16BIT) ? 16 : 8;
- format.samplesize = (format.channels*format.bitspersample)>>3;
+ format.channels = pSmp->GetNumChannels();
+ format.bitspersample = pSmp->GetElementarySampleSize() * 8;
+ format.samplesize = pSmp->GetBytesPerSample() * 8;
format.bytessec = format.freqHz*format.samplesize;
data.id_data = IFFID_data;
UINT nType;
- data.length = pSmp->nLength;
+ data.length = pSmp->GetSampleSizeInBytes();
if (pSmp->uFlags & CHN_STEREO)
{
nType = (pSmp->uFlags & CHN_16BIT) ? RS_STIPCM16S : RS_STIPCM8U;
- data.length *= 2;
} else
{
nType = (pSmp->uFlags & CHN_16BIT) ? RS_PCM16S : RS_PCM8U;
}
- if (pSmp->uFlags & CHN_16BIT) data.length *= 2;
header.filesize += data.length;
fwrite(&header, 1, sizeof(header), f);
fwrite(&format, 1, sizeof(format), f);
@@ -781,7 +779,7 @@
}
-VOID PatchToSample(CSoundFile *that, UINT nSample, LPBYTE lpStream, DWORD dwMemLength)
+void PatchToSample(CSoundFile *that, UINT nSample, LPBYTE lpStream, DWORD dwMemLength)
//------------------------------------------------------------------------------------
{
MODSAMPLE *pIns = &that->Samples[nSample];
@@ -877,7 +875,7 @@
// -! BEHAVIOUR_CHANGE#0003
pIns = new MODINSTRUMENT;
if (!pIns) return false;
- memset(pIns, 0, sizeof(MODINSTRUMENT));
+ MemsetZero(*pIns);
pIns->pTuning = pIns->s_DefaultTuning;
Instruments[nInstr] = pIns;
nSamples = plh->samples;
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2011-07-10 16:52:57 UTC (rev 916)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2011-07-15 22:14:45 UTC (rev 917)
@@ -1743,6 +1743,23 @@
if(f) fwrite(pSample, 1, len, f);
break;
+ // Stereo unsigned interleaved
+ case RS_STIPCM8U:
+ len = nLen * 2;
+ bufcount = 0;
+ for (UINT j=0; j<len; j++)
+ {
+ *((uint8 *)(&buffer[bufcount])) = *((uint8 *)(&pSample[j])) + 0x80;
+ bufcount++;
+ if (bufcount >= sizeof(buffer))
+ {
+ if(f) fwrite(buffer, 1, bufcount, f);
+ bufcount = 0;
+ }
+ }
+ if (bufcount) if(f) fwrite(buffer, 1, bufcount, f);
+ break;
+
// Default: assume 8-bit PCM data
default:
len = nLen;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2011-07-30 21:27:41
|
Revision: 945
http://modplug.svn.sourceforge.net/modplug/?rev=945&view=rev
Author: saga-games
Date: 2011-07-30 21:27:33 +0000 (Sat, 30 Jul 2011)
Log Message:
-----------
[Ref] Shuffled around a lot of effect processing in sndmix.cpp (with an upcoming commit in mind...)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2011-07-30 20:40:29 UTC (rev 944)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2011-07-30 21:27:33 UTC (rev 945)
@@ -18,6 +18,7 @@
#include "midi.h"
#include "Snd_defs.h"
#include "Endianness.h"
+#include "tuning.h"
// For VstInt32 and stuff - a stupid workaround for IMixPlugin.
#ifndef NO_VST
@@ -28,8 +29,8 @@
typedef intptr_t VstIntPtr;
#endif
-class CTuningBase;
-typedef CTuningBase CTuning;
+//class CTuningBase;
+//typedef CTuningBase CTuning;
// Sample Struct
@@ -887,7 +888,31 @@
void SetTempo(UINT param, bool setAsNonModcommand = false);
void SetSpeed(UINT param);
-private:
+protected:
+ // Channel effect processing
+ void ProcessVolumeSwing(MODCHANNEL *pChn, int &vol);
+ void ProcessPanningSwing(MODCHANNEL *pChn);
+ void ProcessTremolo(MODCHANNEL *pChn, int &vol);
+ void ProcessTremor(MODCHANNEL *pChn, int &vol);
+
+ void ProcessVolumeEnvelope(MODCHANNEL *pChn, int &vol);
+ void ProcessPanningEnvelope(MODCHANNEL *pChn);
+ void ProcessPitchFilterEnvelope(MODCHANNEL *pChn, int &period);
+
+ void IncrementVolumeEnvelopePosition(MODCHANNEL *pChn);
+ void IncrementPanningEnvelopePosition(MODCHANNEL *pChn);
+ void IncrementPitchFilterEnvelopePosition(MODCHANNEL *pChn);
+
+ void ProcessInstrumentFade(MODCHANNEL *pChn, int &vol);
+
+ void ProcessPitchPanSeparation(MODCHANNEL *pChn);
+ void ProcessPanbrello(MODCHANNEL *pChn);
+
+ void ProcessArpeggio(MODCHANNEL *pChn, int &period, CTuning::NOTEINDEXTYPE &arpeggioSteps);
+ void ProcessVibrato(MODCHANNEL *pChn, int &period, CTuning::RATIOTYPE &vibratoFactor);
+ void ProcessSampleAutoVibrato(MODCHANNEL *pChn, int &period, CTuning::RATIOTYPE &vibratoFactor, int &nPeriodFrac);
+
+protected:
// Channel Effects
void PortamentoUp(MODCHANNEL *pChn, UINT param, const bool fineAsRegular = false);
void PortamentoDown(MODCHANNEL *pChn, UINT param, const bool fineAsRegular = false);
@@ -1046,7 +1071,7 @@
bool ReadFixedLineLengthMessage(const BYTE *data, const size_t length, const size_t lineLength, const size_t lineEndingLength, void (*pTextConverter)(char &) = nullptr);
public:
- int GetVolEnvValueFromPosition(int position, MODINSTRUMENT* pIns) const;
+ int GetVolEnvValueFromPosition(int position, const MODINSTRUMENT* pIns) const;
void ResetChannelEnvelopes(MODCHANNEL *pChn);
void ResetChannelEnvelope(MODCHANNEL_ENVINFO &env);
void SetDefaultInstrumentValues(MODINSTRUMENT *pIns);
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-07-30 20:40:29 UTC (rev 944)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-07-30 21:27:33 UTC (rev 945)
@@ -823,7 +823,7 @@
}
// Reset channel values
MODCHANNEL *pChn = Chn;
- MODCOMMAND *m = Patterns[m_nPattern] + m_nRow * m_nChannels;
+ MODCOMMAND *m = Patterns[m_nPattern].GetRow(m_nRow);
for (UINT nChn=0; nChn<m_nChannels; pChn++, nChn++, m++)
{
pChn->nRowNote = m->note;
@@ -874,6 +874,861 @@
}
+void CSoundFile::ProcessVolumeSwing(MODCHANNEL *pChn, int &vol)
+//-------------------------------------------------------------
+{
+ if(pChn->nVolSwing)
+ {
+ if(GetModFlag(MSF_OLDVOLSWING))
+ {
+ vol += pChn->nVolSwing;
+ }
+ else
+ {
+ pChn->nVolume += pChn->nVolSwing;
+ pChn->nVolume = CLAMP(pChn->nVolume, 0, 256);
+ vol = pChn->nVolume;
+ pChn->nVolSwing = 0;
+ }
+ }
+
+ vol = CLAMP(vol, 0, 256);
+}
+
+
+void CSoundFile::ProcessPanningSwing(MODCHANNEL *pChn)
+//----------------------------------------------------
+{
+ if(GetModFlag(MSF_OLDVOLSWING))
+ {
+ pChn->nRealPan = pChn->nPan + pChn->nPanSwing;
+ }
+ else
+ {
+ pChn->nPan += pChn->nPanSwing;
+ pChn->nPan = CLAMP(pChn->nPan, 0, 256);
+ pChn->nPanSwing = 0;
+ pChn->nRealPan = pChn->nPan;
+ }
+
+ pChn->nRealPan = CLAMP(pChn->nRealPan, 0, 256);
+}
+
+
+void CSoundFile::ProcessTremolo(MODCHANNEL *pChn, int &vol)
+//---------------------------------------------------------
+{
+ if (pChn->dwFlags & CHN_TREMOLO)
+ {
+ UINT trempos = pChn->nTremoloPos;
+ // IT compatibility: Why would you not want to execute tremolo at volume 0?
+ if (vol > 0 || IsCompatibleMode(TRK_IMPULSETRACKER))
+ {
+ // IT compatibility: We don't need a different attenuation here because of the different tables we're going to use
+ const int tremattn = (m_nType & MOD_TYPE_XM || IsCompatibleMode(TRK_IMPULSETRACKER)) ? 5 : 6;
+ switch (pChn->nTremoloType & 0x03)
+ {
+ case 1:
+ // IT compatibility: IT has its own, more precise tables
+ vol += ((IsCompatibleMode(TRK_IMPULSETRACKER) ? ITRampDownTable[trempos] : ModRampDownTable[trempos]) * (int)pChn->nTremoloDepth) >> tremattn;
+ break;
+ case 2:
+ // IT compatibility: IT has its own, more precise tables
+ vol += ((IsCompatibleMode(TRK_IMPULSETRACKER) ? ITSquareTable[trempos] : ModSquareTable[trempos]) * (int)pChn->nTremoloDepth) >> tremattn;
+ break;
+ case 3:
+ //IT compatibility 19. Use random values
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
+ vol += (((rand() & 0x7F) - 0x40) * (int)pChn->nTremoloDepth) >> tremattn;
+ else
+ vol += (ModRandomTable[trempos] * (int)pChn->nTremoloDepth) >> tremattn;
+ break;
+ default:
+ // IT compatibility: IT has its own, more precise tables
+ vol += ((IsCompatibleMode(TRK_IMPULSETRACKER) ? ITSinusTable[trempos] : ModSinusTable[trempos]) * (int)pChn->nTremoloDepth) >> tremattn;
+ }
+ }
+ if ((m_nTickCount) || ((m_nType & (MOD_TYPE_STM|MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) && (!(m_dwSongFlags & SONG_ITOLDEFFECTS))))
+ {
+ // IT compatibility: IT has its own, more precise tables
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
+ pChn->nTremoloPos = (pChn->nTremoloPos + 4 * pChn->nTremoloSpeed) & 0xFF;
+ else
+ pChn->nTremoloPos = (pChn->nTremoloPos + pChn->nTremoloSpeed) & 0x3F;
+ }
+ }
+}
+
+
+void CSoundFile::ProcessTremor(MODCHANNEL *pChn, int &vol)
+//--------------------------------------------------------
+{
+ if(pChn->nCommand == CMD_TREMOR)
+ {
+ // IT compatibility 12. / 13.: Tremor
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
+ {
+ if ((pChn->nTremorCount & 128) && pChn->nLength)
+ {
+ if (pChn->nTremorCount == 128)
+ pChn->nTremorCount = (pChn->nTremorParam >> 4) | 192;
+ else if (pChn->nTremorCount == 192)
+ pChn->nTremorCount = (pChn->nTremorParam & 0xf) | 128;
+ else
+ pChn->nTremorCount--;
+ }
+
+ if ((pChn->nTremorCount & 192) == 128)
+ vol = 0;
+ }
+ else
+ {
+ UINT n = (pChn->nTremorParam >> 4) + (pChn->nTremorParam & 0x0F);
+ UINT ontime = pChn->nTremorParam >> 4;
+ if ((!(m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) || (m_dwSongFlags & SONG_ITOLDEFFECTS))
+ {
+ n += 2;
+ ontime++;
+ }
+ UINT tremcount = (UINT)pChn->nTremorCount;
+ if (tremcount >= n) tremcount = 0;
+ if ((m_nTickCount) || (m_nType & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)))
+ {
+ if (tremcount >= ontime) vol = 0;
+ pChn->nTremorCount = (BYTE)(tremcount + 1);
+ }
+ }
+ pChn->dwFlags |= CHN_FASTVOLRAMP;
+ }
+}
+
+
+void CSoundFile::ProcessVolumeEnvelope(MODCHANNEL *pChn, int &vol)
+//----------------------------------------------------------------
+{
+ const MODINSTRUMENT *pIns = pChn->pModInstrument;
+
+ // IT Compatibility: S77 does not disable the volume envelope, it just pauses the counter
+ // Problem: This pauses on the wrong tick at the moment...
+ if (((pChn->dwFlags & CHN_VOLENV) || ((pIns->VolEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->VolEnv.nNodes))
+ {
+ int envvol = GetVolEnvValueFromPosition(pChn->VolEnv.nEnvPosition, pIns);
+
+ // if we are in the release portion of the envelope,
+ // rescale envelope factor so that it is proportional to the release point
+ // and release envelope beginning.
+ if (pIns->VolEnv.nReleaseNode != ENV_RELEASE_NODE_UNSET
+ && pChn->VolEnv.nEnvPosition >= pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode]
+ && pChn->VolEnv.nEnvValueAtReleaseJump != NOT_YET_RELEASED)
+ {
+ int envValueAtReleaseJump = pChn->VolEnv.nEnvValueAtReleaseJump;
+ int envValueAtReleaseNode = pIns->VolEnv.Values[pIns->VolEnv.nReleaseNode] << 2;
+
+ //If we have just hit the release node, force the current env value
+ //to be that of the release node. This works around the case where
+ // we have another node at the same position as the release node.
+ if (pChn->VolEnv.nEnvPosition == pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode])
+ envvol = envValueAtReleaseNode;
+
+ int relativeVolumeChange = (envvol - envValueAtReleaseNode) * 2;
+ envvol = envValueAtReleaseJump + relativeVolumeChange;
+ }
+ vol = (vol * CLAMP(envvol, 0, 512)) >> 8;
+ }
+
+}
+
+
+void CSoundFile::ProcessPanningEnvelope(MODCHANNEL *pChn)
+//-------------------------------------------------------
+{
+ const MODINSTRUMENT *pIns = pChn->pModInstrument;
+
+ // IT Compatibility: S79 does not disable the panning envelope, it just pauses the counter
+ // Problem: This pauses on the wrong tick at the moment...
+ if (((pChn->dwFlags & CHN_PANENV) || ((pIns->PanEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pIns->PanEnv.nNodes))
+ {
+ int envpos = pChn->PanEnv.nEnvPosition;
+ UINT pt = pIns->PanEnv.nNodes - 1;
+ for (UINT i=0; i<(UINT)(pIns->PanEnv.nNodes-1); i++)
+ {
+ if (envpos <= pIns->PanEnv.Ticks[i])
+ {
+ pt = i;
+ break;
+ }
+ }
+ int x2 = pIns->PanEnv.Ticks[pt], y2 = pIns->PanEnv.Values[pt];
+ int x1, envpan;
+ if (envpos >= x2)
+ {
+ envpan = y2;
+ x1 = x2;
+ } else if (pt)
+ {
+ envpan = pIns->PanEnv.Values[pt-1];
+ x1 = pIns->PanEnv.Ticks[pt-1];
+ } else
+ {
+ envpan = 128;
+ x1 = 0;
+ }
+ if ((x2 > x1) && (envpos > x1))
+ {
+ envpan += ((envpos - x1) * (y2 - envpan)) / (x2 - x1);
+ }
+
+ envpan = CLAMP(envpan, 0, 64);
+ int pan = pChn->nPan;
+ if (pan >= 128)
+ {
+ pan += ((envpan - 32) * (256 - pan)) / 32;
+ } else
+ {
+ pan += ((envpan - 32) * (pan)) / 32;
+ }
+
+ pChn->nRealPan = CLAMP(pan, 0, 256);
+ }
+}
+
+
+void CSoundFile::ProcessPitchFilterEnvelope(MODCHANNEL *pChn, int &period)
+//------------------------------------------------------------------------
+{
+ const MODINSTRUMENT *pIns = pChn->pModInstrument;
+
+ // IT Compatibility: S7B does not disable the pitch envelope, it just pauses the counter
+ // Problem: This pauses on the wrong tick at the moment...
+ if ((pIns) && ((pChn->dwFlags & CHN_PITCHENV) || ((pIns->PitchEnv.dwFlags & ENV_ENABLED) && IsCompatibleMode(TRK_IMPULSETRACKER))) && (pChn->pModInstrument->PitchEnv.nNodes))
+ {
+ int envpos = pChn->PitchEnv.nEnvPosition;
+ UINT pt = pIns->PitchEnv.nNodes - 1;
+ for (UINT i=0; i<(UINT)(pIns->PitchEnv.nNodes-1); i++)
+ {
+ if (envpos <= pIns->PitchEnv.Ticks[i])
+ {
+ pt = i;
+ break;
+ }
+ }
+ int x2 = pIns->PitchEnv.Ticks[pt];
+ int x1, envpitch;
+ if (envpos >= x2)
+ {
+ envpitch = (((int)pIns->PitchEnv.Values[pt]) - ENVELOPE_MID) * 8;
+ x1 = x2;
+ } else if (pt)
+ {
+ envpitch = (((int)pIns->PitchEnv.Values[pt-1]) - ENVELOPE_MID) * 8;
+ x1 = pIns->PitchEnv.Ticks[pt-1];
+ } else
+ {
+ envpitch = 0;
+ x1 = 0;
+ }
+ if (envpos > x2) envpos = x2;
+ if ((x2 > x1) && (envpos > x1))
+ {
+ int envpitchdest = (((int)pIns->PitchEnv.Values[pt]) - 32) * 8;
+ envpitch += ((envpos - x1) * (envpitchdest - envpitch)) / (x2 - x1);
+ }
+ envpitch = CLAMP(envpitch, -256, 256);
+
+ //if (pIns->PitchEnv.dwFlags & ENV_FILTER)
+ if (pChn->dwFlags & CHN_FILTERENV)
+ {
+ // Filter Envelope: controls cutoff frequency
+#ifndef NO_FILTER
+ SetupChannelFilter(pChn, (pChn->dwFlags & CHN_FILTER) ? false : true, envpitch);
+#endif // NO_FILTER
+ } else
+ {
+ // Pitch Envelope
+ if(m_nType == MOD_TYPE_MPT && pChn->pModInstrument && pChn->pModInstrument->pTuning)
+ {
+ if(pChn->nFineTune != envpitch)
+ {
+ pChn->nFineTune = envpitch;
+ pChn->m_CalculateFreq = true;
+ //Preliminary tests indicated that this behavior
+ //is very close to original(with 12TET) when finestep count
+ //is 15.
+ }
+ }
+ else //Original behavior
+ {
+ int l = envpitch;
+ if (l < 0)
+ {
+ l = -l;
+ if (l > 255) l = 255;
+ period = _muldiv(period, LinearSlideUpTable[l], 0x10000);
+ } else
+ {
+ if (l > 255) l = 255;
+ period = _muldiv(period, LinearSlideDownTable[l], 0x10000);
+ }
+ } //End: Original behavior.
+ }
+ }
+}
+
+
+void CSoundFile::IncrementVolumeEnvelopePosition(MODCHANNEL *pChn)
+//----------------------------------------------------------------
+{
+ const MODINSTRUMENT *pIns = pChn->pModInstrument;
+
+ if (pChn->dwFlags & CHN_VOLENV)
+ {
+ // Increase position
+ pChn->VolEnv.nEnvPosition++;
+ // Volume Loop ?
+ if (pIns->VolEnv.dwFlags & ENV_LOOP)
+ {
+ UINT volloopend = pIns->VolEnv.Ticks[pIns->VolEnv.nLoopEnd];
+ if (m_nType != MOD_TYPE_XM) volloopend++;
+ if (pChn->VolEnv.nEnvPosition == volloopend)
+ {
+ pChn->VolEnv.nEnvPosition = pIns->VolEnv.Ticks[pIns->VolEnv.nLoopStart];
+ if ((pIns->VolEnv.nLoopEnd == pIns->VolEnv.nLoopStart) && (!pIns->VolEnv.Values[pIns->VolEnv.nLoopStart])
+ && ((!(m_nType & MOD_TYPE_XM)) || (pIns->VolEnv.nLoopEnd+1 == (int)pIns->VolEnv.nNodes)))
+ {
+ pChn->dwFlags |= CHN_NOTEFADE;
+ pChn->nFadeOutVol = 0;
+ }
+ }
+ }
+ // Volume Sustain ?
+ if ((pIns->VolEnv.dwFlags & ENV_SUSTAIN) && (!(pChn->dwFlags & CHN_KEYOFF)))
+ {
+ if (pChn->VolEnv.nEnvPosition == (UINT)pIns->VolEnv.Ticks[pIns->VolEnv.nSustainEnd] + 1)
+ pChn->VolEnv.nEnvPosition = pIns->VolEnv.Ticks[pIns->VolEnv.nSustainStart];
+ } else
+ // End of Envelope ?
+ if (pChn->VolEnv.nEnvPosition > pIns->VolEnv.Ticks[pIns->VolEnv.nNodes - 1])
+ {
+ if ((m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) || (pChn->dwFlags & CHN_KEYOFF)) pChn->dwFlags |= CHN_NOTEFADE;
+ pChn->VolEnv.nEnvPosition = pIns->VolEnv.Ticks[pIns->VolEnv.nNodes - 1];
+ if ((!pIns->VolEnv.Values[pIns->VolEnv.nNodes-1]) && ((pChn->nMasterChn > 0) || (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT))))
+ {
+ pChn->dwFlags |= CHN_NOTEFADE;
+ pChn->nFadeOutVol = 0;
+ pChn->nRealVolume = 0;
+ }
+ }
+ }
+}
+
+
+void CSoundFile::IncrementPanningEnvelopePosition(MODCHANNEL *pChn)
+//-----------------------------------------------------------------
+{
+ const MODINSTRUMENT *pIns = pChn->pModInstrument;
+
+ if (pChn->dwFlags & CHN_PANENV)
+ {
+ pChn->PanEnv.nEnvPosition++;
+ if (pIns->PanEnv.dwFlags & ENV_LOOP)
+ {
+ UINT panloopend = pIns->PanEnv.Ticks[pIns->PanEnv.nLoopEnd];
+ if (m_nType != MOD_TYPE_XM) panloopend++;
+ if (pChn->PanEnv.nEnvPosition == panloopend)
+ pChn->PanEnv.nEnvPosition = pIns->PanEnv.Ticks[pIns->PanEnv.nLoopStart];
+ }
+ // Panning Sustain ?
+ if ((pIns->PanEnv.dwFlags & ENV_SUSTAIN) && (pChn->PanEnv.nEnvPosition == (UINT)pIns->PanEnv.Ticks[pIns->PanEnv.nSustainEnd]+1)
+ && (!(pChn->dwFlags & CHN_KEYOFF)))
+ {
+ // Panning sustained
+ pChn->PanEnv.nEnvPosition = pIns->PanEnv.Ticks[pIns->PanEnv.nSustainStart];
+ } else
+ {
+ if (pChn->PanEnv.nEnvPosition > pIns->PanEnv.Ticks[pIns->PanEnv.nNodes - 1])
+ pChn->PanEnv.nEnvPosition = pIns->PanEnv.Ticks[pIns->PanEnv.nNodes - 1];
+ }
+ }
+}
+
+
+void CSoundFile::IncrementPitchFilterEnvelopePosition(MODCHANNEL *pChn)
+//---------------------------------------------------------------------
+{
+ const MODINSTRUMENT *pIns = pChn->pModInstrument;
+
+ if (pChn->dwFlags & CHN_PITCHENV)
+ {
+ // Increase position
+ pChn->PitchEnv.nEnvPosition++;
+ // Pitch Loop ?
+ if (pIns->PitchEnv.dwFlags & ENV_LOOP)
+ {
+ UINT pitchloopend = pIns->PitchEnv.Ticks[pIns->PitchEnv.nLoopEnd];
+ //IT compatibility 24. Short envelope loops
+ if (IsCompatibleMode(TRK_IMPULSETRACKER)) pitchloopend++;
+ if (pChn->PitchEnv.nEnvPosition >= pitchloopend)
+ pChn->PitchEnv.nEnvPosition = pIns->PitchEnv.Ticks[pIns->PitchEnv.nLoopStart];
+ }
+ // Pitch Sustain ?
+ if ((pIns->PitchEnv.dwFlags & ENV_SUSTAIN) && (!(pChn->dwFlags & CHN_KEYOFF)))
+ {
+ if (pChn->PitchEnv.nEnvPosition == (UINT)pIns->PitchEnv.Ticks[pIns->PitchEnv.nSustainEnd]+1)
+ pChn->PitchEnv.nEnvPosition = pIns->PitchEnv.Ticks[pIns->PitchEnv.nSustainStart];
+ } else
+ {
+ if (pChn->PitchEnv.nEnvPosition > pIns->PitchEnv.Ticks[pIns->PitchEnv.nNodes - 1])
+ pChn->PitchEnv.nEnvPosition = pIns->PitchEnv.Ticks[pIns->PitchEnv.nNodes - 1];
+ }
+ }
+}
+
+
+void CSoundFile::ProcessInstrumentFade(MODCHANNEL *pChn, int &vol)
+//----------------------------------------------------------------
+{
+ // FadeOut volume
+ if (pChn->dwFlags & CHN_NOTEFADE)
+ {
+ const MODINSTRUMENT *pIns = pChn->pModInstrument;
+
+ UINT fadeout = pIns->nFadeOut;
+ if (fadeout)
+ {
+ pChn->nFadeOutVol -= fadeout << 1;
+ if (pChn->nFadeOutVol <= 0) pChn->nFadeOutVol = 0;
+ vol = (vol * pChn->nFadeOutVol) >> 16;
+ } else if (!pChn->nFadeOutVol)
+ {
+ vol = 0;
+ }
+ }
+}
+
+
+void CSoundFile::ProcessPitchPanSeparation(MODCHANNEL *pChn)
+//----------------------------------------------------------
+{
+ const MODINSTRUMENT *pIns = pChn->pModInstrument;
+
+ if ((pIns->nPPS) && (pChn->nRealPan) && (pChn->nNote))
+ {
+ // PPS value is 1/512, i.e. PPS=1 will adjust by 8/512 = 1/64 for each 8 semitones
+ // with PPS = 32 / PPC = C-5, E-6 will pan hard right (and D#6 will not)
+ // IT compatibility: IT has a wider pan range here
+ int pandelta = (int)pChn->nRealPan + (int)((int)(pChn->nNote - pIns->nPPC - 1) * (int)pIns->nPPS) / (int)(IsCompatibleMode(TRK_IMPULSETRACKER) ? 4 : 8);
+ pChn->nRealPan = CLAMP(pandelta, 0, 256);
+ }
+}
+
+
+void CSoundFile::ProcessPanbrello(MODCHANNEL *pChn)
+//-------------------------------------------------
+{
+ if (pChn->dwFlags & CHN_PANBRELLO)
+ {
+ UINT panpos;
+ // IT compatibility: IT has its own, more precise tables
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
+ panpos = pChn->nPanbrelloPos & 0xFF;
+ else
+ panpos = ((pChn->nPanbrelloPos + 0x10) >> 2) & 0x3F;
+ LONG pdelta;
+ switch (pChn->nPanbrelloType & 0x03)
+ {
+ case 1:
+ // IT compatibility: IT has its own, more precise tables
+ pdelta = IsCompatibleMode(TRK_IMPULSETRACKER) ? ITRampDownTable[panpos] : ModRampDownTable[panpos];
+ break;
+ case 2:
+ // IT compatibility: IT has its own, more precise tables
+ pdelta = IsCompatibleMode(TRK_IMPULSETRACKER) ? ITSquareTable[panpos] : ModSquareTable[panpos];
+ break;
+ case 3:
+ //IT compatibility 19. Use random values
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
+ pdelta = (rand() & 0x7f) - 0x40;
+ else
+ pdelta = ModRandomTable[panpos];
+ break;
+ default:
+ // IT compatibility: IT has its own, more precise tables
+ pdelta = IsCompatibleMode(TRK_IMPULSETRACKER) ? ITSinusTable[panpos] : ModSinusTable[panpos];
+ }
+ pChn->nPanbrelloPos += pChn->nPanbrelloSpeed;
+ pdelta = ((pdelta * (int)pChn->nPanbrelloDepth) + 2) >> 3;
+ pdelta += pChn->nRealPan;
+
+ pChn->nRealPan = CLAMP(pdelta, 0, 256);
+ //if(IsCompatibleMode(TRK_IMPULSETRACKER)) pChn->nPan = pChn->nRealPan; // TODO
+ }
+}
+
+
+void CSoundFile::ProcessArpeggio(MODCHANNEL *pChn, int &period, CTuning::NOTEINDEXTYPE &arpeggioSteps)
+//----------------------------------------------------------------------------------------------------
+{
+ if (pChn->nCommand == CMD_ARPEGGIO)
+ {
+#ifndef NO_VST
+#if 0
+ // EXPERIMENTAL VSTi arpeggio. Far from perfect!
+ if(pChn->pModInstrument && pChn->pModInstrument->nMixPlug && !(m_dwSongFlags & SONG_FIRSTTICK))
+ {
+ const MODINSTRUMENT *pIns = pChn->pModInstrument;
+ IMixPlugin *pPlugin = m_MixPlugins[pIns->nMixPlug - 1].pMixPlugin;
+ if(pPlugin)
+ {
+ // Temporary logic: This ensures that the first and last tick are both playing the base note.
+ int nCount = (int)m_nTickCount - (int)(m_nMusicSpeed * (m_nPatternDelay + 1) + m_nFrameDelay - 1);
+ int nStep = 0, nLastStep = 0;
+ nCount = -nCount;
+ switch(nCount % 3)
+ {
+ case 0:
+ nStep = 0;
+ nLastStep = pChn->nArpeggio & 0x0F;
+ break;
+ case 1:
+ nStep = pChn->nArpeggio >> 4;
+ nLastStep = 0;
+ break;
+ case 2:
+ nStep = pChn->nArpeggio & 0x0F;
+ nLastStep = pChn->nArpeggio >> 4;
+ break;
+ }
+ // First tick is always 0
+ if(m_nTickCount == 1)
+ nLastStep = 0;
+
+ pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, pChn->nNote + nStep, pChn->nVolume, nChn);
+ pPlugin->MidiCommand(pIns->nMidiChannel, pIns->nMidiProgram, pIns->wMidiBank, pChn->nNote + nLastStep + NOTE_KEYOFF, 0, nChn);
+ }
+ }
+#endif // 0
+#endif // NO_VST
+
+ if((m_nType & MOD_TYPE_MPT) && pChn->pModInstrument && pChn->pModInstrument->pTuning)
+ {
+ switch(m_nTickCount % 3)
+ {
+ case 0:
+ arpeggioSteps = 0;
+ break;
+ case 1:
+ arpeggioSteps = pChn->nArpeggio >> 4; // >> 4 <-> division by 16. This gives the first number in the parameter.
+ break;
+ case 2:
+ arpeggioSteps = pChn->nArpeggio % 16; //Gives the latter number in the parameter.
+ break;
+ }
+ pChn->m_CalculateFreq = true;
+ pChn->m_ReCalculateFreqOnFirstTick = true;
+ }
+ else
+ {
+ //IT playback compatibility 01 & 02
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
+ {
+ if(pChn->nArpeggio >> 4 != 0 || (pChn->nArpeggio & 0x0F) != 0)
+ {
+ switch(m_nTickCount % 3)
+ {
+ case 1: period = Util::Round<int>(period / TwoToPowerXOver12(pChn->nArpeggio >> 4)); break;
+ case 2: period = Util::Round<int>(period / TwoToPowerXOver12(pChn->nArpeggio & 0x0F)); break;
+ }
+ }
+ }
+ // FastTracker 2: Swedish tracker logic (TM) arpeggio
+ else if(IsCompatibleMode(TRK_FASTTRACKER2))
+ {
+ BYTE note = pChn->nNote;
+ int arpPos = 0;
+
+ if (!(m_dwSongFlags & SONG_FIRSTTICK))
+ {
+ arpPos = ((int)m_nMusicSpeed - (int)m_nTickCount) % 3;
+ if((m_nMusicSpeed > 18) && (m_nMusicSpeed - m_nTickCount > 16)) arpPos = 2; // swedish tracker logic, I love it
+ switch(arpPos)
+ {
+ case 1: note += (pChn->nArpeggio >> 4); break;
+ case 2: note += (pChn->nArpeggio & 0x0F); break;
+ }
+ }
+
+ if (note > 109 && arpPos != 0)
+ note = 109; // FT2's note limit
+
+ period = GetPeriodFromNote(note, pChn->nFineTune, pChn->nC5Speed);
+
+ }
+ // Other trackers
+ else
+ {
+ switch(m_nTickCount % 3)
+ {
+ case 1: period = GetPeriodFromNote(pChn->nNote + (pChn->nArpeggio >> 4), pChn->nFineTune, pChn->nC5Speed); break;
+ case 2: period = GetPeriodFromNote(pChn->nNote + (pChn->nArpeggio & 0x0F), pChn->nFineTune, pChn->nC5Speed); break;
+ }
+ }
+ }
+ }
+}
+
+
+void CSoundFile::ProcessVibrato(MODCHANNEL *pChn, int &period, CTuning::RATIOTYPE &vibratoFactor)
+//-----------------------------------------------------------------------------------------------
+{
+ if (pChn->dwFlags & CHN_VIBRATO)
+ {
+ UINT vibpos = pChn->nVibratoPos;
+ LONG vdelta;
+ switch (pChn->nVibratoType & 0x03)
+ {
+ case 1:
+ // IT compatibility: IT has its own, more precise tables
+ vdelta = IsCompatibleMode(TRK_IMPULSETRACKER) ? ITRampDownTable[vibpos] : ModRampDownTable[vibpos];
+ break;
+ case 2:
+ // IT compatibility: IT has its own, more precise tables
+ vdelta = IsCompatibleMode(TRK_IMPULSETRACKER) ? ITSquareTable[vibpos] : ModSquareTable[vibpos];
+ break;
+ case 3:
+ //IT compatibility 19. Use random values
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
+ vdelta = (rand() & 0x7F) - 0x40;
+ else
+ vdelta = ModRandomTable[vibpos];
+ break;
+ default:
+ // IT compatibility: IT has its own, more precise tables
+ vdelta = IsCompatibleMode(TRK_IMPULSETRACKER) ? ITSinusTable[vibpos] : ModSinusTable[vibpos];
+ }
+
+ if(m_nType == MOD_TYPE_MPT && pChn->pModInstrument && pChn->pModInstrument->pTuning)
+ {
+ //Hack implementation: Scaling vibratofactor to [0.95; 1.05]
+ //using figure from above tables and vibratodepth parameter
+ vibratoFactor += 0.05F * vdelta * pChn->m_VibratoDepth / 128.0F;
+ pChn->m_CalculateFreq = true;
+ pChn->m_ReCalculateFreqOnFirstTick = false;
+
+ if(m_nTickCount + 1 == m_nMusicSpeed)
+ pChn->m_ReCalculateFreqOnFirstTick = true;
+ }
+ else //Original behavior
+ {
+ UINT vdepth;
+ // IT compatibility: correct vibrato depth
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
+ {
+ // Yes, vibrato goes backwards with old effects enabled!
+ if(m_dwSongFlags & SONG_ITOLDEFFECTS)
+ {
+ vdepth = 5;
+ vdelta = -vdelta;
+ } else
+ {
+ vdepth = 6;
+ }
+ }
+ else
+ {
+ vdepth = ((!(m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT))) || (m_dwSongFlags & SONG_ITOLDEFFECTS)) ? 6 : 7;
+ }
+ vdelta = (vdelta * (int)pChn->nVibratoDepth) >> vdepth;
+ if ((m_dwSongFlags & SONG_LINEARSLIDES) && (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)))
+ {
+ LONG l = vdelta;
+ if (l < 0)
+ {
+ l = -l;
+ vdelta = _muldiv(period, LinearSlideDownTable[l >> 2], 0x10000) - period;
+ if (l & 0x03) vdelta += _muldiv(period, FineLinearSlideDownTable[l & 0x03], 0x10000) - period;
+ } else
+ {
+ vdelta = _muldiv(period, LinearSlideUpTable[l >> 2], 0x10000) - period;
+ if (l & 0x03) vdelta += _muldiv(period, FineLinearSlideUpTable[l & 0x03], 0x10000) - period;
+ }
+ }
+ period += vdelta;
+ }
+ if ((m_nTickCount) || ((m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (!(m_dwSongFlags & SONG_ITOLDEFFECTS))))
+ {
+ // IT compatibility: IT has its own, more precise tables
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
+ pChn->nVibratoPos = (vibpos + 4 * pChn->nVibratoSpeed) & 0xFF;
+ else
+ pChn->nVibratoPos = (vibpos + pChn->nVibratoSpeed) & 0x3F;
+ }
+ }
+}
+
+
+void CSoundFile::ProcessSampleAutoVibrato(MODCHANNEL *pChn, int &period, CTuning::RATIOTYPE &vibratoFactor, int &nPeriodFrac)
+//--------------------------------------------------------------------------------------------------------------------------
+{
+ // Sample Auto-Vibrato
+ if ((pChn->pModSample) && (pChn->pModSample->nVibDepth))
+ {
+ MODSAMPLE *pSmp = pChn->pModSample;
+ const bool alternativeTuning = pChn->pModInstrument && pChn->pModInstrument->pTuning;
+
+ // IT compatibility: Autovibrato is so much different in IT that I just put this in a separate code block, to get rid of a dozen IsCompatibilityMode() calls.
+ if(IsCompatibleMode(TRK_IMPULSETRACKER) && !alternativeTuning)
+ {
+ // Schism's autovibrato code
+
+ /*
+ X86 Assembler from ITTECH.TXT:
+ 1) Mov AX, [SomeVariableNameRelatingToVibrato]
+ 2) Add AL, Rate
+ 3) AdC AH, 0
+ 4) AH contains the depth of the vibrato as a fine-linear slide.
+ 5) Mov [SomeVariableNameRelatingToVibrato], AX ; For the next cycle.
+ */
+ const int vibpos = pChn->nAutoVibPos & 0xFF;
+ int adepth = pChn->nAutoVibDepth; // (1)
+ adepth += pSmp->nVibSweep & 0xFF; // (2 & 3)
+ adepth = min(adepth, (int)(pSmp->nVibDepth << 8));
+ pChn->nAutoVibDepth = adepth; // (5)
+ adepth >>= 8; // (4)
+
+ pChn->nAutoVibPos += pSmp->nVibRate;
+
+ int vdelta;
+ switch(pSmp->nVibType)
+ {
+ case VIB_RANDOM:
+ vdelta = (rand() & 0x7F) - 0x40;
+ break;
+ case VIB_RAMP_DOWN:
+ vdelta = ITRampDownTable[vibpos];
+ break;
+ case VIB_RAMP_UP:
+ vdelta = -ITRampDownTable[vibpos];
+ break;
+ case VIB_SQUARE:
+ vdelta = ITSquareTable[vibpos];
+ break;
+ case VIB_SINE:
+ default:
+ vdelta = ITSinusTable[vibpos];
+ break;
+ }
+
+ vdelta = (vdelta * adepth) >> 6;
+ int l = abs(vdelta);
+ if(vdelta < 0)
+ {
+ vdelta = _muldiv(period, LinearSlideDownTable[l >> 2], 0x10000) - period;
+ if (l & 0x03)
+ {
+ vdelta += _muldiv(period, FineLinearSlideDownTable[l & 0x03], 0x10000) - period;
+ }
+ } else
+ {
+ vdelta = _muldiv(period, LinearSlideUpTable[l >> 2], 0x10000) - period;
+ if (l & 0x03)
+ {
+ vdelta += _muldiv(period, FineLinearSlideUpTable[l & 0x03], 0x10000) - period;
+ }
+ }
+ period -= vdelta;
+
+ } else
+ {
+ // MPT's autovibrato code
+ if (pSmp->nVibSweep == 0)
+ {
+ pChn->nAutoVibDepth = pSmp->nVibDepth << 8;
+ } else
+ {
+ // Calculate current autovibrato depth using vibsweep
+ if (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT))
+ {
+ // Note: changed bitshift from 3 to 1 as the variable is not divided by 4 in the IT loader anymore
+ // - so we divide sweep by 4 here.
+ pChn->nAutoVibDepth += pSmp->nVibSweep << 1;
+ } else
+ {
+ if (!(pChn->dwFlags & CHN_KEYOFF))
+ {
+ pChn->nAutoVibDepth += (pSmp->nVibDepth << 8) / pSmp->nVibSweep;
+ }
+ }
+ if ((pChn->nAutoVibDepth >> 8) > pSmp->nVibDepth)
+ pChn->nAutoVibDepth = pSmp->nVibDepth << 8;
+ }
+ pChn->nAutoVibPos += pSmp->nVibRate;
+ int vdelta;
+ switch(pSmp->nVibType)
+ {
+ case VIB_RANDOM:
+ vdelta = ModRandomTable[pChn->nAutoVibPos & 0x3F];
+ pChn->nAutoVibPos++;
+ break;
+ case VIB_RAMP_DOWN:
+ vdelta = ((0x40 - (pChn->nAutoVibPos >> 1)) & 0x7F) - 0x40;
+ break;
+ case VIB_RAMP_UP:
+ vdelta = ((0x40 + (pChn->nAutoVibPos >> 1)) & 0x7f) - 0x40;
+ break;
+ case VIB_SQUARE:
+ vdelta = (pChn->nAutoVibPos & 128) ? +64 : -64;
+ break;
+ case VIB_SINE:
+ default:
+ vdelta = ft2VibratoTable[pChn->nAutoVibPos & 0xFF];
+ }
+ int n;
+ n = ((vdelta * pChn->nAutoVibDepth) >> 8);
+
+ if(alternativeTuning)
+ {
+ //Vib sweep is not taken into account here.
+ vibratoFactor += 0.05F * pSmp->nVibDepth * vdelta / 4096.0F; //4096 == 64^2
+ //See vibrato for explanation.
+ pChn->m_CalculateFreq = true;
+ /*
+ Finestep vibrato:
+ const float autoVibDepth = pSmp->nVibDepth * val / 4096.0F; //4096 == 64^2
+ vibratoFineSteps += static_cast<CTuning::FINESTEPTYPE>(pChn->pModInstrument->pTuning->GetFineStepCount() * autoVibDepth);
+ pChn->m_CalculateFreq = true;
+ */
+ }
+ else //Original behavior
+ {
+ if (m_n...
[truncated message content] |
|
From: <sag...@us...> - 2011-07-30 21:36:12
|
Revision: 946
http://modplug.svn.sourceforge.net/modplug/?rev=946&view=rev
Author: saga-games
Date: 2011-07-30 21:36:06 +0000 (Sat, 30 Jul 2011)
Log Message:
-----------
[Ref] Hey, we could even move the ramping code around...
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2011-07-30 21:27:33 UTC (rev 945)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2011-07-30 21:36:06 UTC (rev 946)
@@ -912,6 +912,8 @@
void ProcessVibrato(MODCHANNEL *pChn, int &period, CTuning::RATIOTYPE &vibratoFactor);
void ProcessSampleAutoVibrato(MODCHANNEL *pChn, int &period, CTuning::RATIOTYPE &vibratoFactor, int &nPeriodFrac);
+ void ProcessRamping(MODCHANNEL *pChn);
+
protected:
// Channel Effects
void PortamentoUp(MODCHANNEL *pChn, UINT param, const bool fineAsRegular = false);
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-07-30 21:27:33 UTC (rev 945)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-07-30 21:36:06 UTC (rev 946)
@@ -874,6 +874,10 @@
}
+////////////////////////////////////////////////////////////////////////////////////////////
+// Channel effect processing
+
+
void CSoundFile::ProcessVolumeSwing(MODCHANNEL *pChn, int &vol)
//-------------------------------------------------------------
{
@@ -1729,6 +1733,65 @@
}
+void CSoundFile::ProcessRamping(MODCHANNEL *pChn)
+//-----------------------------------------------
+{
+ pChn->nRightRamp = pChn->nLeftRamp = 0;
+ if ((pChn->dwFlags & CHN_VOLUMERAMP) // && gnVolumeRampSamples //rewbs: this allows us to use non ramping mix functions if ramping is 0
+ && ((pChn->nRightVol != pChn->nNewRightVol) || (pChn->nLeftVol != pChn->nNewLeftVol)))
+ {
+ LONG nRampLength = gnVolumeRampSamples;
+ // -> CODE#0027
+ // -> DESC="per-instrument volume ramping setup"
+ BOOL enableCustomRamp = pChn->pModInstrument && (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM));
+ if(enableCustomRamp) nRampLength = pChn->pModInstrument->nVolRamp ? (gdwMixingFreq * pChn->pModInstrument->nVolRamp / 100000) : gnVolumeRampSamples;
+ if(!nRampLength) nRampLength = 1;
+ // -! NEW_FEATURE#0027
+ LONG nRightDelta = ((pChn->nNewRightVol - pChn->nRightVol) << VOLUMERAMPPRECISION);
+ LONG nLeftDelta = ((pChn->nNewLeftVol - pChn->nLeftVol) << VOLUMERAMPPRECISION);
+#ifndef FASTSOUNDLIB
+ // -> CODE#0027
+ // -> DESC="per-instrument volume ramping setup "
+ // if ((gdwSoundSetup & SNDMIX_DIRECTTODISK)
+ // || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU))
+ // && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50)))
+ if ((gdwSoundSetup & SNDMIX_DIRECTTODISK)
+ || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU))
+ && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50) && !(enableCustomRamp && pChn->pModInstrument->nVolRamp)))
+ // -! NEW_FEATURE#0027
+ {
+ if ((pChn->nRightVol|pChn->nLeftVol) && (pChn->nNewRightVol|pChn->nNewLeftVol) && (!(pChn->dwFlags & CHN_FASTVOLRAMP)))
+ {
+ nRampLength = m_nBufferCount;
+ if (nRampLength > (1 << (VOLUMERAMPPRECISION-1))) nRampLength = (1 << (VOLUMERAMPPRECISION-1));
+ if (nRampLength < (LONG)gnVolumeRampSamples) nRampLength = gnVolumeRampSamples;
+ }
+ }
+#endif // FASTSOUNDLIB
+ pChn->nRightRamp = nRightDelta / nRampLength;
+ pChn->nLeftRamp = nLeftDelta / nRampLength;
+ pChn->nRightVol = pChn->nNewRightVol - ((pChn->nRightRamp * nRampLength) >> VOLUMERAMPPRECISION);
+ pChn->nLeftVol = pChn->nNewLeftVol - ((pChn->nLeftRamp * nRampLength) >> VOLUMERAMPPRECISION);
+ if (pChn->nRightRamp|pChn->nLeftRamp)
+ {
+ pChn->nRampLength = nRampLength;
+ } else
+ {
+ pChn->dwFlags &= ~CHN_VOLUMERAMP;
+ pChn->nRightVol = pChn->nNewRightVol;
+ pChn->nLeftVol = pChn->nNewLeftVol;
+ }
+ } else
+ {
+ pChn->dwFlags &= ~CHN_VOLUMERAMP;
+ pChn->nRightVol = pChn->nNewRightVol;
+ pChn->nLeftVol = pChn->nNewLeftVol;
+ }
+ pChn->nRampRightVol = pChn->nRightVol << VOLUMERAMPPRECISION;
+ pChn->nRampLeftVol = pChn->nLeftVol << VOLUMERAMPPRECISION;
+}
+
+
////////////////////////////////////////////////////////////////////////////////////////////
// Handles envelopes & mixer setup
@@ -2187,64 +2250,13 @@
pChn->nNewRightVol >>= extraAttenuation;
pChn->nNewLeftVol >>= extraAttenuation;
- pChn->nRightRamp = pChn->nLeftRamp = 0;
// Dolby Pro-Logic Surround
if ((pChn->dwFlags & CHN_SURROUND) && (gnChannels == 2)) pChn->nNewLeftVol = - pChn->nNewLeftVol;
// Checking Ping-Pong Loops
if (pChn->dwFlags & CHN_PINGPONGFLAG) pChn->nInc = -pChn->nInc;
// Setting up volume ramp
- if ((pChn->dwFlags & CHN_VOLUMERAMP) // && gnVolumeRampSamples //rewbs: this allows us to use non ramping mix functions if ramping is 0
- && ((pChn->nRightVol != pChn->nNewRightVol) || (pChn->nLeftVol != pChn->nNewLeftVol)))
- {
- LONG nRampLength = gnVolumeRampSamples;
-// -> CODE#0027
-// -> DESC="per-instrument volume ramping setup"
- BOOL enableCustomRamp = pChn->pModInstrument && (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_XM));
- if(enableCustomRamp) nRampLength = pChn->pModInstrument->nVolRamp ? (gdwMixingFreq * pChn->pModInstrument->nVolRamp / 100000) : gnVolumeRampSamples;
- if(!nRampLength) nRampLength = 1;
-// -! NEW_FEATURE#0027
- LONG nRightDelta = ((pChn->nNewRightVol - pChn->nRightVol) << VOLUMERAMPPRECISION);
- LONG nLeftDelta = ((pChn->nNewLeftVol - pChn->nLeftVol) << VOLUMERAMPPRECISION);
-#ifndef FASTSOUNDLIB
-// -> CODE#0027
-// -> DESC="per-instrument volume ramping setup "
-// if ((gdwSoundSetup & SNDMIX_DIRECTTODISK)
-// || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU))
-// && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50)))
- if ((gdwSoundSetup & SNDMIX_DIRECTTODISK)
- || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU))
- && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50) && !(enableCustomRamp && pChn->pModInstrument->nVolRamp)))
-// -! NEW_FEATURE#0027
- {
- if ((pChn->nRightVol|pChn->nLeftVol) && (pChn->nNewRightVol|pChn->nNewLeftVol) && (!(pChn->dwFlags & CHN_FASTVOLRAMP)))
- {
- nRampLength = m_nBufferCount;
- if (nRampLength > (1 << (VOLUMERAMPPRECISION-1))) nRampLength = (1 << (VOLUMERAMPPRECISION-1));
- if (nRampLength < (LONG)gnVolumeRampSamples) nRampLength = gnVolumeRampSamples;
- }
- }
-#endif // FASTSOUNDLIB
- pChn->nRightRamp = nRightDelta / nRampLength;
- pChn->nLeftRamp = nLeftDelta / nRampLength;
- pChn->nRightVol = pChn->nNewRightVol - ((pChn->nRightRamp * nRampLength) >> VOLUMERAMPPRECISION);
- pChn->nLeftVol = pChn->nNewLeftVol - ((pChn->nLeftRamp * nRampLength) >> VOLUMERAMPPRECISION);
- if (pChn->nRightRamp|pChn->nLeftRamp)
- {
- pChn->nRampLength = nRampLength;
- } else
- {
- pChn->dwFlags &= ~CHN_VOLUMERAMP;
- pChn->nRightVol = pChn->nNewRightVol;
- pChn->nLeftVol = pChn->nNewLeftVol;
- }
- } else
- {
- pChn->dwFlags &= ~CHN_VOLUMERAMP;
- pChn->nRightVol = pChn->nNewRightVol;
- pChn->nLeftVol = pChn->nNewLeftVol;
- }
- pChn->nRampRightVol = pChn->nRightVol << VOLUMERAMPPRECISION;
- pChn->nRampLeftVol = pChn->nLeftVol << VOLUMERAMPPRECISION;
+ ProcessRamping(pChn);
+
// Adding the channel in the channel list
ChnMix[m_nMixChannels++] = nChn;
} else
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2011-08-07 21:20:53
|
Revision: 960
http://modplug.svn.sourceforge.net/modplug/?rev=960&view=rev
Author: saga-games
Date: 2011-08-07 21:20:46 +0000 (Sun, 07 Aug 2011)
Log Message:
-----------
[Fix] Fixed vulnerability in WAV, AMS and DSM loaders (http://secunia.com/advisories/45131/).
Modified Paths:
--------------
trunk/OpenMPT/soundlib/LOAD_DSM.CPP
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Load_wav.cpp
Modified: trunk/OpenMPT/soundlib/LOAD_DSM.CPP
===================================================================
--- trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2011-08-05 15:48:20 UTC (rev 959)
+++ trunk/OpenMPT/soundlib/LOAD_DSM.CPP 2011-08-07 21:20:46 UTC (rev 960)
@@ -105,7 +105,7 @@
if (m_nChannels < 1) m_nChannels = 1;
if (m_nChannels > 16) m_nChannels = 16;
m_nSamples = psong->numsmp;
- if (m_nSamples > MAX_SAMPLES) m_nSamples = MAX_SAMPLES;
+ if (m_nSamples >= MAX_SAMPLES) m_nSamples = MAX_SAMPLES - 1;
m_nDefaultSpeed = psong->speed;
m_nDefaultTempo = psong->bpm;
m_nDefaultGlobalVolume = psong->globalvol << 2;
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2011-08-05 15:48:20 UTC (rev 959)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2011-08-07 21:20:46 UTC (rev 960)
@@ -82,7 +82,7 @@
if ((!lpStream) || (dwMemLength < 126)) return false;
if ((pfh->verhi != 0x01) || (strncmp(pfh->szHeader, "Extreme", 7))
- || (!pfh->patterns) || (!pfh->orders) || (!pfh->samples) || (pfh->samples > MAX_SAMPLES)
+ || (!pfh->patterns) || (!pfh->orders) || (!pfh->samples) || (pfh->samples >= MAX_SAMPLES)
|| (pfh->patterns > MAX_PATTERNS) || (pfh->orders > MAX_ORDERS))
{
return ReadAMS2(lpStream, dwMemLength);
@@ -366,7 +366,7 @@
dwMemPos = pfh->titlelen + 8;
psh = (AMS2SONGHEADER *)(lpStream + dwMemPos);
if (((psh->version & 0xFF00) != 0x0200) || (!psh->instruments)
- || (psh->instruments > MAX_INSTRUMENTS) || (!psh->patterns) || (!psh->orders)) return false;
+ || (psh->instruments >= MAX_INSTRUMENTS) || (!psh->patterns) || (!psh->orders)) return false;
dwMemPos += sizeof(AMS2SONGHEADER);
if (pfh->titlelen)
{
Modified: trunk/OpenMPT/soundlib/Load_wav.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_wav.cpp 2011-08-05 15:48:20 UTC (rev 959)
+++ trunk/OpenMPT/soundlib/Load_wav.cpp 2011-08-07 21:20:46 UTC (rev 960)
@@ -58,7 +58,7 @@
if(fail) return true;
UINT samplesize = (pfmt->channels * pfmt->bitspersample) >> 3;
UINT len = pdata->length, bytelen;
- if (dwMemPos + len > dwMemLength - 8) len = dwMemLength - dwMemPos - 8;
+ if (len > dwMemLength - 8 - dwMemPos) len = dwMemLength - dwMemPos - 8;
len /= samplesize;
bytelen = len;
if (pfmt->bitspersample >= 16) bytelen *= 2;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2011-08-08 14:57:44
|
Revision: 968
http://modplug.svn.sourceforge.net/modplug/?rev=968&view=rev
Author: saga-games
Date: 2011-08-08 14:57:37 +0000 (Mon, 08 Aug 2011)
Log Message:
-----------
[Ref] Some CHANNELINDEX refactoring.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-08-08 14:27:41 UTC (rev 967)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-08-08 14:57:37 UTC (rev 968)
@@ -753,8 +753,8 @@
}
-void CSoundFile::NoteChange(UINT nChn, int note, bool bPorta, bool bResetEnv, bool bManual)
-//-----------------------------------------------------------------------------------------
+void CSoundFile::NoteChange(CHANNELINDEX nChn, int note, bool bPorta, bool bResetEnv, bool bManual)
+//-------------------------------------------------------------------------------------------------
{
if (note < NOTE_MIN) return;
MODCHANNEL * const pChn = &Chn[nChn];
@@ -1045,20 +1045,20 @@
}
-UINT CSoundFile::GetNNAChannel(UINT nChn) const
-//---------------------------------------------
+CHANNELINDEX CSoundFile::GetNNAChannel(CHANNELINDEX nChn) const
+//-------------------------------------------------------------
{
const MODCHANNEL *pChn = &Chn[nChn];
// Check for empty channel
const MODCHANNEL *pi = &Chn[m_nChannels];
- for (UINT i=m_nChannels; i<MAX_CHANNELS; i++, pi++) if (!pi->nLength) return i;
+ for (CHANNELINDEX i=m_nChannels; i<MAX_CHANNELS; i++, pi++) if (!pi->nLength) return i;
if (!pChn->nFadeOutVol) return 0;
// All channels are used: check for lowest volume
- UINT result = 0;
+ CHANNELINDEX result = 0;
DWORD vol = 64*65536; // 25%
DWORD envpos = 0xFFFFFF;
const MODCHANNEL *pj = &Chn[m_nChannels];
- for (UINT j=m_nChannels; j<MAX_CHANNELS; j++, pj++)
+ for (CHANNELINDEX j=m_nChannels; j<MAX_CHANNELS; j++, pj++)
{
if (!pj->nFadeOutVol) return j;
DWORD v = pj->nVolume;
@@ -1078,8 +1078,8 @@
}
-void CSoundFile::CheckNNA(UINT nChn, UINT instr, int note, BOOL bForceCut)
-//------------------------------------------------------------------------
+void CSoundFile::CheckNNA(CHANNELINDEX nChn, UINT instr, int note, BOOL bForceCut)
+//--------------------------------------------------------------------------------
{
MODCHANNEL *pChn = &Chn[nChn];
MODINSTRUMENT* pHeader = 0;
@@ -1131,7 +1131,7 @@
if (pChn->dwFlags & CHN_MUTE) return;
bool applyDNAtoPlug; //rewbs.VSTiNNA
- for (UINT i=nChn; i<MAX_CHANNELS; p++, i++)
+ for (CHANNELINDEX i=nChn; i<MAX_CHANNELS; p++, i++)
if ((i >= m_nChannels) || (p == pChn))
{
applyDNAtoPlug = false; //rewbs.VSTiNNA
@@ -1248,7 +1248,7 @@
//if ((pChn->nVolume) && (pChn->nLength))
if (((pChn->nVolume) && (pChn->nLength)) || applyNNAtoPlug) //rewbs.VSTiNNA
{
- UINT n = GetNNAChannel(nChn);
+ CHANNELINDEX n = GetNNAChannel(nChn);
if (n)
{
MODCHANNEL *p = &Chn[n];
@@ -1939,9 +1939,9 @@
case CMD_GLOBALVOLSLIDE:
//IT compatibility 16. Saving last global volume slide param per channel (FT2/IT)
if(IsCompatibleMode(TRK_IMPULSETRACKER | TRK_FASTTRACKER2))
- GlobalVolSlide(param, &pChn->nOldGlobalVolSlide);
+ GlobalVolSlide(param, pChn->nOldGlobalVolSlide);
else
- GlobalVolSlide(param, &m_nOldGlbVolSlide);
+ GlobalVolSlide(param, m_nOldGlbVolSlide);
break;
// Set 8-bit Panning
@@ -2768,8 +2768,8 @@
}
-void CSoundFile::ExtendedMODCommands(UINT nChn, UINT param)
-//---------------------------------------------------------
+void CSoundFile::ExtendedMODCommands(CHANNELINDEX nChn, UINT param)
+//-----------------------------------------------------------------
{
MODCHANNEL *pChn = &Chn[nChn];
UINT command = param & 0xF0;
@@ -2833,8 +2833,8 @@
}
-void CSoundFile::ExtendedS3MCommands(UINT nChn, UINT param)
-//---------------------------------------------------------
+void CSoundFile::ExtendedS3MCommands(CHANNELINDEX nChn, UINT param)
+//-----------------------------------------------------------------
{
MODCHANNEL *pChn = &Chn[nChn];
UINT command = param & 0xF0;
@@ -2895,7 +2895,7 @@
case 2:
{
MODCHANNEL *bkp = &Chn[m_nChannels];
- for (UINT i=m_nChannels; i<MAX_CHANNELS; i++, bkp++)
+ for (CHANNELINDEX i=m_nChannels; i<MAX_CHANNELS; i++, bkp++)
{
if (bkp->nMasterChn == nChn+1)
{
@@ -3431,8 +3431,8 @@
//rewbs.volOffset: moved offset code to own method as it will be used in several places now
-void CSoundFile::SampleOffset(UINT nChn, UINT param, bool bPorta)
-//---------------------------------------------------------------
+void CSoundFile::SampleOffset(CHANNELINDEX nChn, UINT param, bool bPorta)
+//-----------------------------------------------------------------------
{
MODCHANNEL *pChn = &Chn[nChn];
@@ -3510,8 +3510,8 @@
}
//end rewbs.volOffset:
-void CSoundFile::RetrigNote(UINT nChn, int param, UINT offset) //rewbs.VolOffset: added offset param.
-//------------------------------------------------------------
+void CSoundFile::RetrigNote(CHANNELINDEX nChn, int param, UINT offset) //rewbs.VolOffset: added offset param.
+//--------------------------------------------------------------------
{
// Retrig: bit 8 is set if it's the new XM retrig
MODCHANNEL *pChn = &Chn[nChn];
@@ -3681,8 +3681,8 @@
}
-void CSoundFile::NoteCut(UINT nChn, UINT nTick)
-//---------------------------------------------
+void CSoundFile::NoteCut(CHANNELINDEX nChn, UINT nTick)
+//-----------------------------------------------------
{
if(nTick == 0)
{
@@ -3725,8 +3725,8 @@
}
-void CSoundFile::KeyOff(UINT nChn)
-//--------------------------------
+void CSoundFile::KeyOff(CHANNELINDEX nChn)
+//----------------------------------------
{
MODCHANNEL *pChn = &Chn[nChn];
const bool bKeyOn = (pChn->dwFlags & CHN_KEYOFF) ? false : true;
@@ -3881,11 +3881,11 @@
}
-void CSoundFile::GlobalVolSlide(UINT param, UINT * nOldGlobalVolSlide)
-//-----------------------------------------
+void CSoundFile::GlobalVolSlide(UINT param, UINT &nOldGlobalVolSlide)
+//--------------------------------------------------------------------
{
LONG nGlbSlide = 0;
- if (param) *nOldGlobalVolSlide = param; else param = *nOldGlobalVolSlide;
+ if (param) nOldGlobalVolSlide = param; else param = nOldGlobalVolSlide;
if (((param & 0x0F) == 0x0F) && (param & 0xF0))
{
if (m_dwSongFlags & SONG_FIRSTTICK) nGlbSlide = (param >> 4) * 2;
@@ -4077,8 +4077,8 @@
}
-UINT CSoundFile::GetBestPlugin(UINT nChn, UINT priority, bool respectMutes)
-//-------------------------------------------------------------------------
+UINT CSoundFile::GetBestPlugin(CHANNELINDEX nChn, UINT priority, bool respectMutes)
+//---------------------------------------------------------------------------------
{
if (nChn > MAX_CHANNELS) //Check valid channel number
{
@@ -4112,41 +4112,46 @@
}
-UINT __cdecl CSoundFile::GetChannelPlugin(UINT nChn, bool respectMutes) const
-//---------------------------------------------------------------------------
+UINT __cdecl CSoundFile::GetChannelPlugin(CHANNELINDEX nChn, bool respectMutes) const
+//-----------------------------------------------------------------------------------
{
const MODCHANNEL *pChn = &Chn[nChn];
// If it looks like this is an NNA channel, we need to find the master channel.
// This ensures we pick up the right ChnSettings.
// NB: nMasterChn==0 means no master channel, so we need to -1 to get correct index.
- if (nChn>=m_nChannels && pChn && pChn->nMasterChn>0) {
+ if (nChn>=m_nChannels && pChn && pChn->nMasterChn > 0)
+ {
nChn = pChn->nMasterChn-1;
}
UINT nPlugin;
- if ( (respectMutes && (pChn->dwFlags & CHN_MUTE)) ||
- (pChn->dwFlags&CHN_NOFX) ) {
+ if ( (respectMutes && (pChn->dwFlags & CHN_MUTE)) || (pChn->dwFlags&CHN_NOFX) )
+ {
nPlugin = 0;
- } else {
+ } else
+ {
nPlugin = ChnSettings[nChn].nMixPlugin;
}
return nPlugin;
}
-UINT CSoundFile::GetActiveInstrumentPlugin(UINT nChn, bool respectMutes) const
-//----------------------------------------------------------------------------
+UINT CSoundFile::GetActiveInstrumentPlugin(CHANNELINDEX nChn, bool respectMutes) const
+//------------------------------------------------------------------------------------
{
const MODCHANNEL *pChn = &Chn[nChn];
// Unlike channel settings, pModInstrument is copied from the original chan to the NNA chan,
// so we don't need to worry about finding the master chan.
UINT nPlugin=0;
- if (pChn && pChn->pModInstrument) {
- if (respectMutes && pChn->pModSample && (pChn->pModSample->uFlags & CHN_MUTE)) {
+ if (pChn && pChn->pModInstrument)
+ {
+ if (respectMutes && pChn->pModSample && (pChn->pModSample->uFlags & CHN_MUTE))
+ {
nPlugin = 0;
- } else {
+ } else
+ {
nPlugin = pChn->pModInstrument->nMixPlug;
}
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2011-08-08 14:27:41 UTC (rev 967)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2011-08-08 14:57:37 UTC (rev 968)
@@ -215,7 +215,8 @@
MODINSTRUMENT *pModInstrument; // Currently assigned instrument slot
MODCHANNEL_ENVINFO VolEnv, PanEnv, PitchEnv; // Envelope playback info
MODSAMPLE *pModSample; // Currently assigned sample slot
- DWORD nMasterChn, nVUMeter;
+ CHANNELINDEX nMasterChn;
+ DWORD nVUMeter;
LONG nGlobalVol, nInsVol;
LONG nFineTune, nTranspose;
LONG nPortamentoSlide, nAutoVibDepth;
@@ -881,13 +882,13 @@
BOOL ReadNote();
BOOL ProcessRow();
BOOL ProcessEffects();
- UINT GetNNAChannel(UINT nChn) const;
- void CheckNNA(UINT nChn, UINT instr, int note, BOOL bForceCut);
- void NoteChange(UINT nChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false);
+ CHANNELINDEX GetNNAChannel(CHANNELINDEX nChn) const;
+ void CheckNNA(CHANNELINDEX nChn, UINT instr, int note, BOOL bForceCut);
+ void NoteChange(CHANNELINDEX nChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false);
void InstrumentChange(MODCHANNEL *pChn, UINT instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true);
// Channel Effects
- void KeyOff(UINT nChn);
+ void KeyOff(CHANNELINDEX nChn);
// Global Effects
void SetTempo(UINT param, bool setAsNonModcommand = false);
void SetSpeed(UINT param);
@@ -938,12 +939,12 @@
void FineVolumeDown(MODCHANNEL *pChn, UINT param);
void Tremolo(MODCHANNEL *pChn, UINT param);
void Panbrello(MODCHANNEL *pChn, UINT param);
- void RetrigNote(UINT nChn, int param, UINT offset=0); //rewbs.volOffset: added last param
- void SampleOffset(UINT nChn, UINT param, bool bPorta); //rewbs.volOffset: moved offset code to own method
- void NoteCut(UINT nChn, UINT nTick);
+ void RetrigNote(CHANNELINDEX nChn, int param, UINT offset=0); //rewbs.volOffset: added last param
+ void SampleOffset(CHANNELINDEX nChn, UINT param, bool bPorta); //rewbs.volOffset: moved offset code to own method
+ void NoteCut(CHANNELINDEX nChn, UINT nTick);
int PatternLoop(MODCHANNEL *, UINT param);
- void ExtendedMODCommands(UINT nChn, UINT param);
- void ExtendedS3MCommands(UINT nChn, UINT param);
+ void ExtendedMODCommands(CHANNELINDEX nChn, UINT param);
+ void ExtendedS3MCommands(CHANNELINDEX nChn, UINT param);
void ExtendedChannelEffect(MODCHANNEL *, UINT param);
inline void InvertLoop(MODCHANNEL* pChn);
void ProcessMacroOnChannel(CHANNELINDEX nChn);
@@ -952,7 +953,7 @@
void SetupChannelFilter(MODCHANNEL *pChn, bool bReset, int flt_modifier = 256) const;
// Low-Level effect processing
void DoFreqSlide(MODCHANNEL *pChn, LONG nFreqSlide);
- void GlobalVolSlide(UINT param, UINT * nOldGlobalVolSlide);
+ void GlobalVolSlide(UINT param, UINT &nOldGlobalVolSlide);
DWORD IsSongFinished(UINT nOrder, UINT nRow) const;
void UpdateTimeSignature();
@@ -1028,7 +1029,7 @@
DWORD CutOffToFrequency(UINT nCutOff, int flt_modifier=256) const; // [0-255] => [1-10KHz]
#endif
#ifdef MODPLUG_TRACKER
- VOID ProcessMidiOut(UINT nChn, MODCHANNEL *pChn); //rewbs.VSTdelay : added arg.
+ VOID ProcessMidiOut(CHANNELINDEX nChn, MODCHANNEL *pChn); //rewbs.VSTdelay : added arg.
#endif
VOID ApplyGlobalVolume(int SoundBuffer[], long lTotalSampleCount);
@@ -1084,8 +1085,8 @@
void ResetChannelEnvelope(MODCHANNEL_ENVINFO &env);
void SetDefaultInstrumentValues(MODINSTRUMENT *pIns);
private:
- UINT __cdecl GetChannelPlugin(UINT nChan, bool respectMutes) const;
- UINT __cdecl GetActiveInstrumentPlugin(UINT nChan, bool respectMutes) const;
+ UINT __cdecl GetChannelPlugin(CHANNELINDEX nChn, bool respectMutes) const;
+ UINT __cdecl GetActiveInstrumentPlugin(CHANNELINDEX, bool respectMutes) const;
UINT GetBestMidiChan(const MODCHANNEL *pChn) const;
void HandlePatternTransitionEvents();
@@ -1093,7 +1094,7 @@
long GetSampleOffset();
public:
- UINT GetBestPlugin(UINT nChn, UINT priority, bool respectMutes);
+ UINT GetBestPlugin(CHANNELINDEX nChn, UINT priority, bool respectMutes);
// A couple of functions for handling backwards jumps and stuff to prevent infinite loops when counting the mod length or rendering to wav.
public:
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-08-08 14:27:41 UTC (rev 967)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-08-08 14:57:37 UTC (rev 968)
@@ -824,7 +824,7 @@
// Reset channel values
MODCHANNEL *pChn = Chn;
MODCOMMAND *m = Patterns[m_nPattern].GetRow(m_nRow);
- for (UINT nChn=0; nChn<m_nChannels; pChn++, nChn++, m++)
+ for (CHANNELINDEX nChn=0; nChn<m_nChannels; pChn++, nChn++, m++)
{
pChn->nRowNote = m->note;
pChn->nRowInstr = m->instr;
@@ -1864,7 +1864,7 @@
{
/*int nchn32 = 0;
MODCHANNEL *pChn = Chn;
- for (UINT nChn=0; nChn<m_nChannels; nChn++,pChn++)
+ for (CHANNELINDEX nChn=0; nChn<m_nChannels; nChn++,pChn++)
{
//if(!(pChn->dwFlags & CHN_MUTE)) //removed by rewbs: fix http://www.modplug.com/forum/viewtopic.php?t=3358
nchn32++;
@@ -1908,7 +1908,7 @@
// Update channels data
m_nMixChannels = 0;
MODCHANNEL *pChn = Chn;
- for (UINT nChn = 0; nChn < MAX_CHANNELS; nChn++, pChn++)
+ for (CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++, pChn++)
{
skipchn:
@@ -2331,22 +2331,29 @@
//-------------------------------------------------------
{
MODCHANNEL *pChn = &Chn[nChn];
- if(nChn < m_nChannels && pChn->nRowCommand == CMD_MIDI || pChn->nRowCommand == CMD_SMOOTHMIDI)
+ if(nChn < m_nChannels)
{
- // Only smooth MIDI macros are processed on every tick
- if((pChn->nRowCommand == CMD_MIDI) && !(m_dwSongFlags & SONG_FIRSTTICK)) return;
- if(pChn->nRowParam < 0x80)
- ProcessMIDIMacro(nChn, (pChn->nRowCommand == CMD_SMOOTHMIDI), m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], pChn->nRowParam);
- else
- ProcessMIDIMacro(nChn, (pChn->nRowCommand == CMD_SMOOTHMIDI), m_MidiCfg.szMidiZXXExt[(pChn->nRowParam & 0x7F)], 0);
+ // TODO evaluate per-plugin macros here
+ //ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_PAN]);
+ //ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_VOLUME]);
+
+ if(pChn->nRowCommand == CMD_MIDI || pChn->nRowCommand == CMD_SMOOTHMIDI)
+ {
+ // Only smooth MIDI macros are processed on every tick
+ if((pChn->nRowCommand == CMD_MIDI) && !(m_dwSongFlags & SONG_FIRSTTICK)) return;
+ if(pChn->nRowParam < 0x80)
+ ProcessMIDIMacro(nChn, (pChn->nRowCommand == CMD_SMOOTHMIDI), m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], pChn->nRowParam);
+ else
+ ProcessMIDIMacro(nChn, (pChn->nRowCommand == CMD_SMOOTHMIDI), m_MidiCfg.szMidiZXXExt[(pChn->nRowParam & 0x7F)], 0);
+ }
}
}
#ifdef MODPLUG_TRACKER
-VOID CSoundFile::ProcessMidiOut(UINT nChn, MODCHANNEL *pChn) //rewbs.VSTdelay: added arg
-//----------------------------------------------------------
+VOID CSoundFile::ProcessMidiOut(CHANNELINDEX nChn, MODCHANNEL *pChn) //rewbs.VSTdelay: added arg
+//------------------------------------------------------------------
{
// Do we need to process midi?
// For now there is no difference between mute and sync mute with VSTis.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|