|
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.
|