|
From: <sag...@us...> - 2010-02-10 18:21:48
|
Revision: 490
http://modplug.svn.sourceforge.net/modplug/?rev=490&view=rev
Author: saga-games
Date: 2010-02-10 18:21:42 +0000 (Wed, 10 Feb 2010)
Log Message:
-----------
[Fix] IT Saver: Set unused channels' panning positions to 0xA0 like IT does (appears to fix a problem in IT's GUI)
[Fix] IT Saver: Fixed IT sample flags which could potentionally cause IT to screw up on loading/saving MPT-made modules with samples that are not used by an instrument.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_it.cpp
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2010-02-09 20:21:38 UTC (rev 489)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2010-02-10 18:21:42 UTC (rev 490)
@@ -1880,7 +1880,7 @@
header.sep = 128; // pan separation
dwHdrPos = sizeof(header) + header.ordnum;
// Channel Pan and Volume
- memset(header.chnpan, 0xFF, 64);
+ memset(header.chnpan, 0xA0, 64);
memset(header.chnvol, 64, 64);
for (UINT ich=0; ich</*m_nChannels*/64; ich++) //Header only has room for settings for 64 chans...
{
@@ -2286,25 +2286,45 @@
memcpy(itss.name, m_szNames[nsmp], 26);
itss.id = 0x53504D49;
itss.gvl = (BYTE)psmp->nGlobalVol;
- if (m_nInstruments)
+
+ UINT flags = RS_PCM8S;
+ if(psmp->nLength && psmp->pSample)
{
- for (UINT iu=1; iu<=m_nInstruments; iu++) if (Instruments[iu])
+ itss.flags = 0x01;
+ if (psmp->uFlags & CHN_LOOP) itss.flags |= 0x10;
+ if (psmp->uFlags & CHN_SUSTAINLOOP) itss.flags |= 0x20;
+ if (psmp->uFlags & CHN_PINGPONGLOOP) itss.flags |= 0x40;
+ if (psmp->uFlags & CHN_PINGPONGSUSTAIN) itss.flags |= 0x80;
+#ifndef NO_PACKING
+ if (nPacking)
{
- MODINSTRUMENT *pIns = Instruments[iu];
- for (UINT ju=0; ju<128; ju++) if (pIns->Keyboard[ju] == nsmp)
+ if ((!(psmp->uFlags & (CHN_16BIT|CHN_STEREO)))
+ && (CanPackSample(psmp->pSample, psmp->nLength, nPacking)))
{
- itss.flags = 0x01;
- break;
+ flags = RS_ADPCM4;
+ itss.cvt = 0xFF;
}
+ } else
+#endif // NO_PACKING
+ {
+ if (psmp->uFlags & CHN_STEREO)
+ {
+ flags = RS_STPCM8S;
+ itss.flags |= 0x04;
+ }
+ if (psmp->uFlags & CHN_16BIT)
+ {
+ itss.flags |= 0x02;
+ flags = (psmp->uFlags & CHN_STEREO) ? RS_STPCM16S : RS_PCM16S;
+ }
}
- } else
+ itss.cvt = 0x01;
+ }
+ else
{
- itss.flags = 0x01;
+ itss.flags = 0x00;
}
- if (psmp->uFlags & CHN_LOOP) itss.flags |= 0x10;
- if (psmp->uFlags & CHN_SUSTAINLOOP) itss.flags |= 0x20;
- if (psmp->uFlags & CHN_PINGPONGLOOP) itss.flags |= 0x40;
- if (psmp->uFlags & CHN_PINGPONGSUSTAIN) itss.flags |= 0x80;
+
itss.C5Speed = psmp->nC5Speed;
if (!itss.C5Speed) itss.C5Speed = 8363;
itss.length = psmp->nLength;
@@ -2319,34 +2339,8 @@
itss.vid = min(psmp->nVibDepth, 32);
itss.vir = min(psmp->nVibSweep, 255); //(psmp->nVibSweep < 64) ? psmp->nVibSweep * 4 : 255;
if (psmp->uFlags & CHN_PANNING) itss.dfp |= 0x80;
- if ((psmp->pSample) && (psmp->nLength)) itss.cvt = 0x01;
- UINT flags = RS_PCM8S;
-#ifndef NO_PACKING
- if (nPacking)
- {
- if ((!(psmp->uFlags & (CHN_16BIT|CHN_STEREO)))
- && (CanPackSample(psmp->pSample, psmp->nLength, nPacking)))
- {
- flags = RS_ADPCM4;
- itss.cvt = 0xFF;
- }
- } else
-#endif // NO_PACKING
- {
- if (psmp->uFlags & CHN_STEREO)
- {
- flags = RS_STPCM8S;
- itss.flags |= 0x04;
- }
- if (psmp->uFlags & CHN_16BIT)
- {
- itss.flags |= 0x02;
- flags = (psmp->uFlags & CHN_STEREO) ? RS_STPCM16S : RS_PCM16S;
- }
- }
+
itss.samplepointer = dwPos;
- if (!(psmp->pSample) || !(psmp->nLength))
- itss.flags = 0;
fseek(f, smppos[nsmp-1], SEEK_SET);
fwrite(&itss, 1, sizeof(ITSAMPLESTRUCT), f);
fseek(f, dwPos, SEEK_SET);
@@ -2489,7 +2483,7 @@
header.sep = 128; // pan separation
dwHdrPos = sizeof(header) + header.ordnum;
// Channel Pan and Volume
- memset(header.chnpan, 0xFF, 64);
+ memset(header.chnpan, 0xA0, 64);
memset(header.chnvol, 64, 64);
for (UINT ich=0; ich</*m_nChannels*/64; ich++) //Header only has room for settings for 64 chans...
{
@@ -2882,25 +2876,34 @@
SetNullTerminator(itss.name);
itss.id = 0x53504D49;
itss.gvl = (BYTE)psmp->nGlobalVol;
- if (m_nInstruments)
+
+ UINT flags = RS_PCM8S;
+ if(psmp->nLength && psmp->pSample)
{
- for (UINT iu=1; iu<=m_nInstruments; iu++) if (Instruments[iu])
+ itss.flags = 0x01;
+ if (psmp->uFlags & CHN_LOOP) itss.flags |= 0x10;
+ if (psmp->uFlags & CHN_SUSTAINLOOP) itss.flags |= 0x20;
+ if (psmp->uFlags & CHN_PINGPONGLOOP) itss.flags |= 0x40;
+ if (psmp->uFlags & CHN_PINGPONGSUSTAIN) itss.flags |= 0x80;
+
+ if (psmp->uFlags & CHN_STEREO)
{
- MODINSTRUMENT *pIns = Instruments[iu];
- for (UINT ju=0; ju<128; ju++) if (pIns->Keyboard[ju] == nsmp)
- {
- itss.flags = 0x01;
- break;
- }
+ flags = RS_STPCM8S;
+ itss.flags |= 0x04;
}
- } else
+ if (psmp->uFlags & CHN_16BIT)
+ {
+ itss.flags |= 0x02;
+ flags = (psmp->uFlags & CHN_STEREO) ? RS_STPCM16S : RS_PCM16S;
+ }
+
+ itss.cvt = 0x01;
+ }
+ else
{
- itss.flags = 0x01;
+ itss.flags = 0x00;
}
- if (psmp->uFlags & CHN_LOOP) itss.flags |= 0x10;
- if (psmp->uFlags & CHN_SUSTAINLOOP) itss.flags |= 0x20;
- if (psmp->uFlags & CHN_PINGPONGLOOP) itss.flags |= 0x40;
- if (psmp->uFlags & CHN_PINGPONGSUSTAIN) itss.flags |= 0x80;
+
itss.C5Speed = psmp->nC5Speed;
if (!itss.C5Speed) itss.C5Speed = 8363;
itss.length = psmp->nLength;
@@ -2915,21 +2918,8 @@
itss.vid = min(psmp->nVibDepth, 32);
itss.vir = min(psmp->nVibSweep, 255);
if (psmp->uFlags & CHN_PANNING) itss.dfp |= 0x80;
- if ((psmp->pSample) && (psmp->nLength)) itss.cvt = 0x01;
- UINT flags = RS_PCM8S;
- if (psmp->uFlags & CHN_STEREO)
- {
- flags = RS_STPCM8S;
- itss.flags |= 0x04;
- }
- if (psmp->uFlags & CHN_16BIT)
- {
- itss.flags |= 0x02;
- flags = (psmp->uFlags & CHN_STEREO) ? RS_STPCM16S : RS_PCM16S;
- }
+
itss.samplepointer = dwPos;
- if (!(psmp->pSample) || !(psmp->nLength))
- itss.flags = 0;
fseek(f, smppos[nsmp-1], SEEK_SET);
fwrite(&itss, 1, sizeof(ITSAMPLESTRUCT), f);
fseek(f, dwPos, SEEK_SET);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|