|
From: <sag...@us...> - 2014-03-09 14:54:31
|
Revision: 3852
http://sourceforge.net/p/modplug/code/3852
Author: saga-games
Date: 2014-03-09 14:54:24 +0000 (Sun, 09 Mar 2014)
Log Message:
-----------
[Ref] Kill LPCBYTE.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_mdl.cpp
trunk/OpenMPT/soundlib/Load_med.cpp
trunk/OpenMPT/soundlib/Load_mid.cpp
trunk/OpenMPT/soundlib/Load_mt2.cpp
trunk/OpenMPT/soundlib/Snd_defs.h
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mdl.cpp 2014-03-09 14:11:32 UTC (rev 3851)
+++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2014-03-09 14:54:24 UTC (rev 3852)
@@ -286,8 +286,8 @@
-bool CSoundFile::ReadMDL(const BYTE *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags)
-//------------------------------------------------------------------------------------------------
+bool CSoundFile::ReadMDL(const uint8 *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags)
+//-------------------------------------------------------------------------------------------------
{
DWORD dwMemPos, dwPos, blocklen, dwTrackPos;
const MDLFileHeader *pmsh = (const MDLFileHeader *)lpStream;
@@ -299,7 +299,7 @@
BYTE smpinfo[MAX_SAMPLES];
BYTE insvolenv[MAX_INSTRUMENTS];
BYTE inspanenv[MAX_INSTRUMENTS];
- LPCBYTE pvolenv, ppanenv, ppitchenv;
+ const uint8 *pvolenv, *ppanenv, *ppitchenv;
UINT nvolenv, npanenv, npitchenv;
std::vector<ROWINDEX> patternLength;
@@ -660,7 +660,7 @@
// Setup volume envelope
if ((nvolenv) && (pvolenv) && (insvolenv[iIns]))
{
- LPCBYTE pve = pvolenv;
+ const uint8 *pve = pvolenv;
for (UINT nve = 0; nve < nvolenv; nve++, pve += 33)
{
if (pve[0] + 1 == insvolenv[iIns])
@@ -670,7 +670,7 @@
// Setup panning envelope
if ((npanenv) && (ppanenv) && (inspanenv[iIns]))
{
- LPCBYTE ppe = ppanenv;
+ const uint8 *ppe = ppanenv;
for (UINT npe = 0; npe < npanenv; npe++, ppe += 33)
{
if (ppe[0] + 1 == inspanenv[iIns])
Modified: trunk/OpenMPT/soundlib/Load_med.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_med.cpp 2014-03-09 14:11:32 UTC (rev 3851)
+++ trunk/OpenMPT/soundlib/Load_med.cpp 2014-03-09 14:54:24 UTC (rev 3852)
@@ -500,8 +500,8 @@
}
-bool CSoundFile::ReadMed(const BYTE *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags)
-//------------------------------------------------------------------------------------------------
+bool CSoundFile::ReadMed(const uint8 *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags)
+//-------------------------------------------------------------------------------------------------
{
const MEDMODULEHEADER *pmmh;
const MMD0SONGHEADER *pmsh;
Modified: trunk/OpenMPT/soundlib/Load_mid.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mid.cpp 2014-03-09 14:11:32 UTC (rev 3851)
+++ trunk/OpenMPT/soundlib/Load_mid.cpp 2014-03-09 14:54:24 UTC (rev 3852)
@@ -92,7 +92,7 @@
typedef struct MIDITRACK
{
- LPCBYTE ptracks, ptrmax;
+ const uint8 *ptracks, *ptrmax;
DWORD status;
LONG nexteventtime;
} MIDITRACK;
@@ -466,8 +466,8 @@
#define MIDIGLOBAL_XGSYSTEMON 0x0200
-bool CSoundFile::ReadMID(const BYTE *lpStream, DWORD dwMemLength, ModLoadingFlags loadFlags)
-//------------------------------------------------------------------------------------------
+bool CSoundFile::ReadMID(const uint8 *lpStream, DWORD dwMemLength, ModLoadingFlags loadFlags)
+//-------------------------------------------------------------------------------------------
{
const MIDIFILEHEADER *pmfh = (const MIDIFILEHEADER *)lpStream;
const MIDITRACKHEADER *pmth;
Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-03-09 14:11:32 UTC (rev 3851)
+++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-03-09 14:54:24 UTC (rev 3852)
@@ -218,8 +218,8 @@
}
-bool CSoundFile::ReadMT2(LPCBYTE lpStream, DWORD dwMemLength, ModLoadingFlags loadFlags)
-//--------------------------------------------------------------------------------------
+bool CSoundFile::ReadMT2(const uint8 *lpStream, DWORD dwMemLength, ModLoadingFlags loadFlags)
+//------------------------------------------------------------------------------------------
{
MT2FILEHEADER *pfh = (MT2FILEHEADER *)lpStream;
DWORD dwMemPos, dwDrumDataPos, dwExtraDataPos;
Modified: trunk/OpenMPT/soundlib/Snd_defs.h
===================================================================
--- trunk/OpenMPT/soundlib/Snd_defs.h 2014-03-09 14:11:32 UTC (rev 3851)
+++ trunk/OpenMPT/soundlib/Snd_defs.h 2014-03-09 14:54:24 UTC (rev 3852)
@@ -14,10 +14,6 @@
#include "../common/typedefs.h"
#include "../common/FlagSet.h"
-#ifndef LPCBYTE
-typedef const BYTE * LPCBYTE;
-#endif
-
typedef uint32 ROWINDEX;
const ROWINDEX ROWINDEX_INVALID = uint32_max;
typedef uint16 CHANNELINDEX;
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-09 14:11:32 UTC (rev 3851)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-03-09 14:54:24 UTC (rev 3852)
@@ -761,7 +761,7 @@
}
file.Rewind();
- LPCBYTE lpStream = reinterpret_cast<const unsigned char*>(file.GetRawData());
+ const uint8 *lpStream = reinterpret_cast<const unsigned char*>(file.GetRawData());
DWORD dwMemLength = file.GetLength();
if(!ReadXM(file, loadFlags)
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-03-09 14:11:32 UTC (rev 3851)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-03-09 14:54:24 UTC (rev 3852)
@@ -630,7 +630,7 @@
bool ReadS3M(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadMod(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadM15(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMed(const LPCBYTE lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
+ bool ReadMed(const uint8 *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadMTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadSTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadIT(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
@@ -642,14 +642,14 @@
bool ReadFAR(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadAMS(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadAMS2(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMDL(const LPCBYTE lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
+ bool ReadMDL(const uint8 *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadOKT(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadDMF(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadPTM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadDBM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadAMF_Asylum(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadAMF_DSMI(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMT2(const LPCBYTE lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
+ bool ReadMT2(const uint8 *lpStream, const DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadPSM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadPSM16(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadUMX(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
@@ -659,7 +659,7 @@
bool ReadAM(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadJ2B(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
bool ReadDIGI(FileReader &file, ModLoadingFlags loadFlags = loadCompleteModule);
- bool ReadMID(const LPCBYTE lpStream, DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
+ bool ReadMID(const uint8 *lpStream, DWORD dwMemLength, ModLoadingFlags loadFlags = loadCompleteModule);
static std::vector<const char *> GetSupportedExtensions(bool otherFormats);
static std::pair<MOD_CHARSET_CERTAINTY, mpt::Charset> GetCharsetFromModType(MODTYPE modtype);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-03-09 17:20:05
|
Revision: 3854
http://sourceforge.net/p/modplug/code/3854
Author: saga-games
Date: 2014-03-09 17:19:57 +0000 (Sun, 09 Mar 2014)
Log Message:
-----------
[Ref] Rewrite PAT loader using FileReader. Note: This loader is still slightly broken (sample table seems to have an unwanted offset, and some files like KICK1.PAT are definitely played at the wrong pitch)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/SampleFormats.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-03-09 15:45:50 UTC (rev 3853)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-03-09 17:19:57 UTC (rev 3854)
@@ -61,15 +61,13 @@
bool CSoundFile::ReadSampleFromFile(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize)
//-------------------------------------------------------------------------------------------
{
- file.Rewind();
-
if(!nSample || nSample >= MAX_SAMPLES) return false;
if(!ReadWAVSample(nSample, file, mayNormalize)
&& !ReadXISample(nSample, file)
&& !ReadITISample(nSample, file)
&& !ReadAIFFSample(nSample, file, mayNormalize)
&& !ReadITSSample(nSample, file)
- && !ReadPATSample(nSample, reinterpret_cast<const uint8*>(file.GetRawData()), file.GetLength())
+ && !ReadPATSample(nSample, file)
&& !ReadIFFSample(nSample, file)
&& !ReadS3ISample(nSample, file)
&& !ReadFLACSample(nSample, file)
@@ -90,8 +88,7 @@
//--------------------------------------------------------------------------------------------------
{
if ((!nInstr) || (nInstr >= MAX_INSTRUMENTS)) return false;
- file.Rewind();
- if(!ReadPATInstrument(nInstr, reinterpret_cast<const uint8*>(file.GetRawData()), file.GetLength())
+ if(!ReadPATInstrument(nInstr, file)
&& !ReadXIInstrument(nInstr, file)
&& !ReadITIInstrument(nInstr, file)
// Generic read
@@ -507,59 +504,89 @@
#endif
-typedef struct PACKED GF1PATCHFILEHEADER
+struct PACKED GF1PatchFileHeader
{
- char magic[8]; // "GF1PATCH"
- char version[4]; // "100", or "110"
- char id[10]; // "ID#000002"
- char copyright[60]; // Copyright
- BYTE instrum; // Number of instruments in patch
- BYTE voices; // Number of voices, usually 14
- BYTE channels; // Number of wav channels that can be played concurently to the patch
- WORD samples; // Total number of waveforms for all the .PAT
- WORD volume; // Master volume
- DWORD data_size;
- BYTE reserved2[36];
-} GF1PATCHFILEHEADER;
+ char magic[8]; // "GF1PATCH"
+ char version[4]; // "100", or "110"
+ char id[10]; // "ID#000002"
+ char copyright[60]; // Copyright
+ uint8 numInstr; // Number of instruments in patch
+ uint8 voices; // Number of voices, usually 14
+ uint8 channels; // Number of wav channels that can be played concurently to the patch
+ uint16 numSamples; // Total number of waveforms for all the .PAT
+ uint16 volume; // Master volume
+ uint32 dataSize;
+ char reserved2[36];
-STATIC_ASSERT(sizeof(GF1PATCHFILEHEADER) == 129);
+ // Convert all multi-byte numeric values to current platform's endianness or vice versa.
+ void ConvertEndianness()
+ {
+ SwapBytesLE(numSamples);
+ SwapBytesLE(volume);
+ SwapBytesLE(dataSize);
+ }
+};
+STATIC_ASSERT(sizeof(GF1PatchFileHeader) == 129);
-typedef struct PACKED GF1INSTRUMENT
+
+struct PACKED GF1Instrument
{
- WORD id; // Instrument id: 0-65535
- char name[16]; // Name of instrument. Gravis doesn't seem to use it
- DWORD size; // Number of bytes for the instrument with header. (To skip to next instrument)
- BYTE layers; // Number of layers in instrument: 1-4
- BYTE reserved[40];
-} GF1INSTRUMENT;
+ uint16 id; // Instrument id: 0-65535
+ char name[16]; // Name of instrument. Gravis doesn't seem to use it
+ uint32 size; // Number of bytes for the instrument with header. (To skip to next instrument)
+ uint8 layers; // Number of layers in instrument: 1-4
+ char reserved[40];
-STATIC_ASSERT(sizeof(GF1INSTRUMENT) == 63);
+ // Convert all multi-byte numeric values to current platform's endianness or vice versa.
+ void ConvertEndianness()
+ {
+ SwapBytesLE(id);
+ SwapBytesLE(size);
+ }
+};
+STATIC_ASSERT(sizeof(GF1Instrument) == 63);
-typedef struct PACKED GF1SAMPLEHEADER
+
+struct PACKED GF1SampleHeader
{
char name[7]; // null terminated string. name of the wave.
- BYTE fractions; // Start loop point fraction in 4 bits + End loop point fraction in the 4 other bits.
- DWORD length; // total size of wavesample. limited to 65535 now by the drivers, not the card.
- DWORD loopstart; // start loop position in the wavesample
- DWORD loopend; // end loop position in the wavesample
- WORD freq; // Rate at which the wavesample has been sampled
- DWORD low_freq, high_freq, root_freq; // check note.h for the correspondance.
- int16 finetune; // fine tune. -512 to +512, EXCLUDING 0 cause it is a multiplier. 512 is one octave off, and 1 is a neutral value
- BYTE balance; // Balance: 0-15. 0=full left, 15 = full right
- BYTE env_rate[6]; // attack rates
- BYTE env_volume[6]; // attack volumes
- BYTE tremolo_sweep, tremolo_rate, tremolo_depth;
- BYTE vibrato_sweep, vibrato_rate, vibrato_depth;
- BYTE flags;
- int16 scale_frequency;
- WORD scale_factor;
- BYTE reserved[36];
-} GF1SAMPLEHEADER;
+ uint8 fractions; // Start loop point fraction in 4 bits + End loop point fraction in the 4 other bits.
+ uint32 length; // total size of wavesample. limited to 65535 now by the drivers, not the card.
+ uint32 loopstart; // start loop position in the wavesample
+ uint32 loopend; // end loop position in the wavesample
+ uint16 freq; // Rate at which the wavesample has been sampled
+ uint32 low_freq, high_freq, root_freq; // check note.h for the correspondance.
+ int16 finetune; // fine tune. -512 to +512, EXCLUDING 0 cause it is a multiplier. 512 is one octave off, and 1 is a neutral value
+ uint8 balance; // Balance: 0-15. 0=full left, 15 = full right
+ uint8 env_rate[6]; // attack rates
+ uint8 env_volume[6]; // attack volumes
+ uint8 tremolo_sweep, tremolo_rate, tremolo_depth;
+ uint8 vibrato_sweep, vibrato_rate, vibrato_depth;
+ uint8 flags;
+ int16 scale_frequency;
+ uint16 scale_factor;
+ char reserved[36];
-STATIC_ASSERT(sizeof(GF1SAMPLEHEADER) == 96);
+ // Convert all multi-byte numeric values to current platform's endianness or vice versa.
+ void ConvertEndianness()
+ {
+ SwapBytesLE(length);
+ SwapBytesLE(loopstart);
+ SwapBytesLE(loopend);
+ SwapBytesLE(freq);
+ SwapBytesLE(low_freq);
+ SwapBytesLE(high_freq);
+ SwapBytesLE(root_freq);
+ SwapBytesLE(finetune);
+ SwapBytesLE(scale_frequency);
+ SwapBytesLE(scale_factor);
+ }
+};
+STATIC_ASSERT(sizeof(GF1SampleHeader) == 96);
+
// -- GF1 Envelopes --
//
// It can be represented like this (the envelope is totally bogus, it is
@@ -591,18 +618,24 @@
// bit 7: off/on clamped release (6th point, env)
-typedef struct PACKED GF1LAYER
+struct PACKED GF1Layer
{
- BYTE previous; // If !=0 the wavesample to use is from the previous layer. The waveheader is still needed
- BYTE id; // Layer id: 0-3
- DWORD size; // data size in bytes in the layer, without the header. to skip to next layer for example:
- BYTE samples; // number of wavesamples
- BYTE reserved[40];
-} GF1LAYER;
+ uint8 previous; // If !=0 the wavesample to use is from the previous layer. The waveheader is still needed
+ uint8 id; // Layer id: 0-3
+ uint32 size; // data size in bytes in the layer, without the header. to skip to next layer for example:
+ uint8 samples; // number of wavesamples
+ char reserved[40];
-STATIC_ASSERT(sizeof(GF1LAYER) == 47);
+ // Convert all multi-byte numeric values to current platform's endianness or vice versa.
+ void ConvertEndianness()
+ {
+ SwapBytesLE(size);
+ }
+};
+STATIC_ASSERT(sizeof(GF1Layer) == 47);
+
#ifdef NEEDS_PRAGMA_PACK
#pragma pack(pop)
#endif
@@ -616,36 +649,31 @@
}
-static void PatchToSample(CSoundFile *that, SAMPLEINDEX nSample, const uint8 *lpStream, DWORD dwMemLength)
-//--------------------------------------------------------------------------------------------------------
+static void PatchToSample(CSoundFile *that, SAMPLEINDEX nSample, GF1SampleHeader &sampleHeader, FileReader &file)
+//---------------------------------------------------------------------------------------------------------------
{
ModSample &sample = that->GetSample(nSample);
- DWORD dwMemPos = sizeof(GF1SAMPLEHEADER);
- GF1SAMPLEHEADER *psh = (GF1SAMPLEHEADER *)(lpStream);
- if(dwMemLength < sizeof(GF1SAMPLEHEADER)) return;
- if(psh->name[0])
- {
- mpt::String::Read<mpt::String::maybeNullTerminated>(that->m_szNames[nSample], psh->name);
- }
+ file.ReadConvertEndianness(sampleHeader);
+
sample.Initialize();
- if(psh->flags & 4) sample.uFlags |= CHN_LOOP;
- if(psh->flags & 8) sample.uFlags |= CHN_PINGPONGLOOP;
- sample.nLength = psh->length;
- sample.nLoopStart = psh->loopstart;
- sample.nLoopEnd = psh->loopend;
- sample.nC5Speed = psh->freq;
- sample.nPan = (psh->balance << 4) + 8;
+ if(sampleHeader.flags & 4) sample.uFlags.set(CHN_LOOP);
+ if(sampleHeader.flags & 8) sample.uFlags.set(CHN_PINGPONGLOOP);
+ sample.nLength = sampleHeader.length;
+ sample.nLoopStart = sampleHeader.loopstart;
+ sample.nLoopEnd = sampleHeader.loopend;
+ sample.nC5Speed = sampleHeader.freq;
+ sample.nPan = (sampleHeader.balance * 256 + 8) / 15;
if(sample.nPan > 256) sample.nPan = 128;
sample.nVibType = VIB_SINE;
- sample.nVibSweep = psh->vibrato_sweep;
- sample.nVibDepth = psh->vibrato_depth;
- sample.nVibRate = psh->vibrato_rate/4;
+ sample.nVibSweep = sampleHeader.vibrato_sweep;
+ sample.nVibDepth = sampleHeader.vibrato_depth;
+ sample.nVibRate = sampleHeader.vibrato_rate / 4;
sample.FrequencyToTranspose();
- sample.RelativeTone += static_cast<int8>(84 - PatchFreqToNote(psh->root_freq));
- if(psh->scale_factor)
+ sample.RelativeTone += static_cast<int8>(84 - PatchFreqToNote(sampleHeader.root_freq));
+ if(sampleHeader.scale_factor)
{
- sample.RelativeTone = static_cast<uint8>(sample.RelativeTone - (psh->scale_frequency - 60));
+ sample.RelativeTone = static_cast<uint8>(sample.RelativeTone - (sampleHeader.scale_frequency - 60));
}
sample.TransposeToFrequency();
@@ -653,61 +681,75 @@
SampleIO::_8bit,
SampleIO::mono,
SampleIO::littleEndian,
- (psh->flags & 2) ? SampleIO::unsignedPCM : SampleIO::signedPCM);
+ (sampleHeader.flags & 2) ? SampleIO::unsignedPCM : SampleIO::signedPCM);
- if(psh->flags & 1)
+ if(sampleHeader.flags & 1)
{
sampleIO |= SampleIO::_16bit;
sample.nLength /= 2;
sample.nLoopStart /= 2;
sample.nLoopEnd /= 2;
}
- FileReader chunk(lpStream + dwMemPos, dwMemLength - dwMemPos);
- sampleIO.ReadSample(sample, chunk);
+ sampleIO.ReadSample(sample, file);
sample.PrecomputeLoops(*that, false);
+
+ mpt::String::Read<mpt::String::maybeNullTerminated>(that->m_szNames[nSample], sampleHeader.name);
}
-bool CSoundFile::ReadPATSample(SAMPLEINDEX nSample, const uint8 *lpStream, DWORD dwMemLength)
-//-------------------------------------------------------------------------------------------
+bool CSoundFile::ReadPATSample(SAMPLEINDEX nSample, FileReader &file)
+//-------------------------------------------------------------------
{
- DWORD dwMemPos = sizeof(GF1PATCHFILEHEADER)+sizeof(GF1INSTRUMENT)+sizeof(GF1LAYER);
- GF1PATCHFILEHEADER *phdr = (GF1PATCHFILEHEADER *)lpStream;
- GF1INSTRUMENT *pinshdr = (GF1INSTRUMENT *)(lpStream+sizeof(GF1PATCHFILEHEADER));
+ file.Rewind();
+ GF1PatchFileHeader fileHeader;
+ GF1Instrument instrHeader; // We only support one instrument
+ GF1Layer layerHeader;
+ if(!file.ReadConvertEndianness(fileHeader)
+ || memcmp(fileHeader.magic, "GF1PATCH", 8)
+ || (memcmp(fileHeader.version, "110\0", 4) && memcmp(fileHeader.version, "100\0", 4))
+ || memcmp(fileHeader.id, "ID#000002\0", 10)
+ || !fileHeader.numInstr || !fileHeader.numSamples
+ || !file.ReadConvertEndianness(instrHeader)
+ || !instrHeader.layers
+ || !file.ReadConvertEndianness(layerHeader)
+ || !layerHeader.samples)
+ {
+ return false;
+ }
- if ((!lpStream) || (dwMemLength < 512)
- || memcmp(phdr->magic, "GF1PATCH", 8)
- || (phdr->version[3] != 0) || (phdr->id[9] != 0) || (phdr->instrum < 1)
- || (!phdr->samples) || (!pinshdr->layers)) return false;
-
DestroySampleThreadsafe(nSample);
- PatchToSample(this, nSample, lpStream + dwMemPos, dwMemLength - dwMemPos);
- if (pinshdr->name[0] > ' ')
+ GF1SampleHeader sampleHeader;
+ PatchToSample(this, nSample, sampleHeader, file);
+
+ if(instrHeader.name[0] > ' ')
{
- memcpy(m_szNames[nSample], pinshdr->name, 16);
- m_szNames[nSample][16] = 0;
+ mpt::String::Read<mpt::String::maybeNullTerminated>(m_szNames[nSample], instrHeader.name);
}
return true;
}
// PAT Instrument
-bool CSoundFile::ReadPATInstrument(INSTRUMENTINDEX nInstr, const uint8 *lpStream, DWORD dwMemLength)
-//--------------------------------------------------------------------------------------------------
+bool CSoundFile::ReadPATInstrument(INSTRUMENTINDEX nInstr, FileReader &file)
+//--------------------------------------------------------------------------
{
- GF1PATCHFILEHEADER *phdr = (GF1PATCHFILEHEADER *)lpStream;
- GF1INSTRUMENT *pih = (GF1INSTRUMENT *)(lpStream+sizeof(GF1PATCHFILEHEADER));
- GF1LAYER *plh = (GF1LAYER *)(lpStream+sizeof(GF1PATCHFILEHEADER)+sizeof(GF1INSTRUMENT));
- DWORD dwMemPos = sizeof(GF1PATCHFILEHEADER)+sizeof(GF1INSTRUMENT)+sizeof(GF1LAYER);
- UINT nSamples;
+ file.Rewind();
+ GF1PatchFileHeader fileHeader;
+ GF1Instrument instrHeader; // We only support one instrument
+ GF1Layer layerHeader;
+ if(!file.ReadConvertEndianness(fileHeader)
+ || memcmp(fileHeader.magic, "GF1PATCH", 8)
+ || (memcmp(fileHeader.version, "110\0", 4) && memcmp(fileHeader.version, "100\0", 4))
+ || memcmp(fileHeader.id, "ID#000002\0", 10)
+ || !fileHeader.numInstr || !fileHeader.numSamples
+ || !file.ReadConvertEndianness(instrHeader)
+ || !instrHeader.layers
+ || !file.ReadConvertEndianness(layerHeader)
+ || !layerHeader.samples)
+ {
+ return false;
+ }
- if ((!lpStream) || (dwMemLength < 512)
- || memcmp(phdr->magic, "GF1PATCH", 8)
- || (phdr->version[3] != 0) || (phdr->id[9] != 0)
- || (phdr->instrum < 1) || (!phdr->samples)
- || (!pih->layers) || (!plh->samples)) return false;
- if (nInstr > m_nInstruments) m_nInstruments = nInstr;
-
ModInstrument *pIns = new (std::nothrow) ModInstrument();
if(pIns == nullptr)
{
@@ -715,81 +757,58 @@
}
DestroyInstrument(nInstr, deleteAssociatedSamples);
+ if (nInstr > m_nInstruments) m_nInstruments = nInstr;
+ Instruments[nInstr] = pIns;
- Instruments[nInstr] = pIns;
- nSamples = plh->samples;
- if (nSamples > 16) nSamples = 16;
- mpt::String::Copy(pIns->name, pih->name);
+ mpt::String::Read<mpt::String::maybeNullTerminated>(pIns->name, instrHeader.name);
pIns->nFadeOut = 2048;
- if (GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT))
+ if(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))
{
pIns->nNNA = NNA_NOTEOFF;
pIns->nDNA = DNA_NOTEFADE;
}
- SAMPLEINDEX nFreeSmp = 0;
- UINT nMinSmpNote = 0xff;
+
+ SAMPLEINDEX nextSample = 0;
+ int32 nMinSmpNote = 0xFF;
SAMPLEINDEX nMinSmp = 0;
- for (UINT iSmp=0; iSmp<nSamples; iSmp++)
+ for(uint8 smp = 0; smp < layerHeader.samples; smp++)
{
// Find a free sample
- nFreeSmp = GetNextFreeSample(nInstr, nFreeSmp + 1);
- if (nFreeSmp == SAMPLEINDEX_INVALID) break;
- if (m_nSamples < nFreeSmp) m_nSamples = nFreeSmp;
- if (!nMinSmp) nMinSmp = nFreeSmp;
+ nextSample = GetNextFreeSample(nInstr, nextSample + 1);
+ if(nextSample == SAMPLEINDEX_INVALID) break;
+ if(m_nSamples < nextSample) m_nSamples = nextSample;
+ if(!nMinSmp) nMinSmp = nextSample;
// Load it
- GF1SAMPLEHEADER *psh = (GF1SAMPLEHEADER *)(lpStream+dwMemPos);
- PatchToSample(this, nFreeSmp, lpStream+dwMemPos, dwMemLength-dwMemPos);
- LONG nMinNote = (psh->low_freq > 100) ? PatchFreqToNote(psh->low_freq) : 0;
- LONG nMaxNote = (psh->high_freq > 100) ? PatchFreqToNote(psh->high_freq) : NOTE_MAX;
- LONG nBaseNote = (psh->root_freq > 100) ? PatchFreqToNote(psh->root_freq) : -1;
- if ((!psh->scale_factor) && (nSamples == 1)) { nMinNote = 0; nMaxNote = NOTE_MAX; }
+ GF1SampleHeader sampleHeader;
+ PatchToSample(this, nextSample, sampleHeader, file);
+ int32 nMinNote = (sampleHeader.low_freq > 100) ? PatchFreqToNote(sampleHeader.low_freq) : 0;
+ int32 nMaxNote = (sampleHeader.high_freq > 100) ? PatchFreqToNote(sampleHeader.high_freq) : NOTE_MAX;
+ int32 nBaseNote = (sampleHeader.root_freq > 100) ? PatchFreqToNote(sampleHeader.root_freq) : -1;
+ if(!sampleHeader.scale_factor && layerHeader.samples == 1) { nMinNote = 0; nMaxNote = NOTE_MAX; }
// Fill Note Map
- for (UINT k=0; k<NOTE_MAX; k++)
+ for(int32 k = 0; k < NOTE_MAX; k++)
{
- if (((LONG)k == nBaseNote)
- || ((!pIns->Keyboard[k])
- && ((LONG)k >= nMinNote)
- && ((LONG)k <= nMaxNote)))
+ if(k == nBaseNote || (!pIns->Keyboard[k] && k >= nMinNote && k <= nMaxNote))
{
- if(!psh->scale_factor)
+ if(!sampleHeader.scale_factor)
pIns->NoteMap[k] = NOTE_MIDDLEC;
- pIns->Keyboard[k] = nFreeSmp;
- if (k < nMinSmpNote)
+ pIns->Keyboard[k] = nextSample;
+ if(k < nMinSmpNote)
{
nMinSmpNote = k;
- nMinSmp = nFreeSmp;
+ nMinSmp = nextSample;
}
}
}
- /*
- // Create dummy envelope
- if (!iSmp)
- {
- pIns->dwFlags |= ENV_VOLUME;
- if (psh->flags & 32) pIns->dwFlags |= ENV_VOLSUSTAIN;
- pIns->VolEnv.Values[0] = 64;
- pIns->VolEnv.Ticks[0] = 0;
- pIns->VolEnv.Values[1] = 64;
- pIns->VolEnv.Ticks[1] = 1;
- pIns->VolEnv.Values[2] = 32;
- pIns->VolEnv.Ticks[2] = 20;
- pIns->VolEnv.Values[3] = 0;
- pIns->VolEnv.Ticks[3] = 100;
- pIns->VolEnv.nNodes = 4;
- }
- */
- // Skip to next sample
- dwMemPos += sizeof(GF1SAMPLEHEADER)+psh->length;
- if (dwMemPos + sizeof(GF1SAMPLEHEADER) >= dwMemLength) break;
}
- if (nMinSmp)
+ if(nMinSmp)
{
// Fill note map and missing samples
- for (UINT k=0; k<NOTE_MAX; k++)
+ for(uint8 k = 0; k < NOTE_MAX; k++)
{
- if (!pIns->NoteMap[k]) pIns->NoteMap[k] = (BYTE)(k+1);
- if (!pIns->Keyboard[k])
+ if(!pIns->NoteMap[k]) pIns->NoteMap[k] = k + 1;
+ if(!pIns->Keyboard[k])
{
pIns->Keyboard[k] = nMinSmp;
} else
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-03-09 15:45:50 UTC (rev 3853)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-03-09 17:19:57 UTC (rev 3854)
@@ -852,7 +852,7 @@
// Samples file I/O
bool ReadSampleFromFile(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize=false);
bool ReadWAVSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize=false, FileReader *wsmpChunk = nullptr);
- bool ReadPATSample(SAMPLEINDEX nSample, const uint8 *lpMemFile, DWORD dwFileLength);
+ bool ReadPATSample(SAMPLEINDEX nSample, FileReader &file);
bool ReadS3ISample(SAMPLEINDEX nSample, FileReader &file);
bool ReadAIFFSample(SAMPLEINDEX nSample, FileReader &file, bool mayNormalize=false);
bool ReadXISample(SAMPLEINDEX nSample, FileReader &file);
@@ -871,7 +871,7 @@
bool ReadInstrumentFromFile(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize=false);
bool ReadXIInstrument(INSTRUMENTINDEX nInstr, FileReader &file);
bool ReadITIInstrument(INSTRUMENTINDEX nInstr, FileReader &file);
- bool ReadPATInstrument(INSTRUMENTINDEX nInstr, const uint8 *lpMemFile, DWORD dwFileLength);
+ bool ReadPATInstrument(INSTRUMENTINDEX nInstr, FileReader &file);
bool ReadSampleAsInstrument(INSTRUMENTINDEX nInstr, FileReader &file, bool mayNormalize=false);
#ifndef MODPLUG_NO_FILESAVE
bool SaveXIInstrument(INSTRUMENTINDEX nInstr, const mpt::PathString &filename) const;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-03-12 23:23:42
|
Revision: 3878
http://sourceforge.net/p/modplug/code/3878
Author: saga-games
Date: 2014-03-12 23:23:32 +0000 (Wed, 12 Mar 2014)
Log Message:
-----------
[Imp] Raise plugin limit from 100 to 250.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ITTools.cpp
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Snd_defs.h
Modified: trunk/OpenMPT/soundlib/ITTools.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ITTools.cpp 2014-03-12 15:04:21 UTC (rev 3877)
+++ trunk/OpenMPT/soundlib/ITTools.cpp 2014-03-12 23:23:32 UTC (rev 3878)
@@ -238,7 +238,7 @@
// MIDI Setup
mbank = mptIns.wMidiBank;
mpr = mptIns.nMidiProgram;
- if(mptIns.nMidiChannel || mptIns.nMixPlug == 0 || compatExport)
+ if(mptIns.nMidiChannel || mptIns.nMixPlug == 0 || mptIns.nMixPlug > 127 || compatExport)
{
// Default. Prefer MIDI channel over mixplug to keep the semantics intact.
mch = mptIns.nMidiChannel;
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2014-03-12 15:04:21 UTC (rev 3877)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-03-12 23:23:32 UTC (rev 3878)
@@ -1714,7 +1714,7 @@
// rewbs.modularPlugData
DWORD MPTxPlugDataSize = 4 + (sizeof(m_MixPlugins[i].fDryRatio)) + //4 for ID and size of dryRatio
4 + (sizeof(m_MixPlugins[i].defaultProgram)); //rewbs.plugDefaultProgram
- // for each extra entity, add 4 for ID, plus size of entity, plus optionally 4 for size of entity.
+ // for each extra entity, add 4 for ID, plus size of entity, plus optionally 4 for size of entity.
nPluginSize += MPTxPlugDataSize + 4; //+4 is for size itself: sizeof(DWORD) is 4
// rewbs.modularPlugData
@@ -1722,9 +1722,9 @@
{
// write plugin ID
id[0] = 'F';
- id[1] = 'X';
- id[2] = '0' + (i / 10);
- id[3] = '0' + (i % 10);
+ id[1] = i < 100 ? 'X' : '0' + i / 100;
+ id[2] = '0' + (i / 10) % 10u;
+ id[3] = '0' + (i % 10u);
fwrite(id, 1, 4, f);
// write plugin size:
@@ -1806,10 +1806,13 @@
ChnSettings[ch].nMixPlugin = (uint8)chunk.ReadUint32LE();
}
}
- // Plugin Data
- else if(memcmp(code, "FX00", 4) >= 0 && memcmp(code, "FX99", 4) <= 0)
+ // Plugin Data FX00, ... FX99, F100, ... F255
+#define ISNUMERIC(x) (code[(x)] >= '0' && code[(x)] <= '9')
+ else if(code[0] == 'F' && (code[1] == 'X' || ISNUMERIC(1)) && ISNUMERIC(2) && ISNUMERIC(3))
+#undef ISNUMERIC
{
PLUGINDEX plug = (code[2] - '0') * 10 + (code[3] - '0'); //calculate plug-in number.
+ if(code[1] != 'X') plug += (code[1] - '0') * 100;
if(plug < MAX_MIXPLUGINS)
{
Modified: trunk/OpenMPT/soundlib/Snd_defs.h
===================================================================
--- trunk/OpenMPT/soundlib/Snd_defs.h 2014-03-12 15:04:21 UTC (rev 3877)
+++ trunk/OpenMPT/soundlib/Snd_defs.h 2014-03-12 23:23:32 UTC (rev 3878)
@@ -44,8 +44,8 @@
const ORDERINDEX MAX_ORDERS = 256;
const PATTERNINDEX MAX_PATTERNS = 240;
const SAMPLEINDEX MAX_SAMPLES = 4000;
-const INSTRUMENTINDEX MAX_INSTRUMENTS = 256; //200
-const PLUGINDEX MAX_MIXPLUGINS = 100; //50
+const INSTRUMENTINDEX MAX_INSTRUMENTS = 256;
+const PLUGINDEX MAX_MIXPLUGINS = 250;
const SEQUENCEINDEX MAX_SEQUENCES = 50;
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:43:40
|
Revision: 3898
http://sourceforge.net/p/modplug/code/3898
Author: manxorist
Date: 2014-03-18 09:43:33 +0000 (Tue, 18 Mar 2014)
Log Message:
-----------
[Ref] Replace CLAMP with Clamp in soundlib/ .
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_dmf.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/modcommand.cpp
Modified: trunk/OpenMPT/soundlib/Load_dmf.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-03-18 08:56:19 UTC (rev 3897)
+++ trunk/OpenMPT/soundlib/Load_dmf.cpp 2014-03-18 09:43:33 UTC (rev 3898)
@@ -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 = Clamp(ontime * internalTicks / 15, 1, 15);
+ offtime = Clamp(offtime * internalTicks / 15, 1, 15);
return (ontime << 4) | offtime;
}
@@ -302,7 +302,7 @@
// MPT: 1 vibrato period == 64 ticks... we have internalTicks ticks per row.
// X-Tracker: Period length specified in rows!
const int periodInTicks = MAX(1, (val >> 4)) * internalTicks;
- const uint8 matchingPeriod = (uint8)CLAMP((128 / periodInTicks), 1, 15);
+ const uint8 matchingPeriod = (uint8)Clamp((128 / periodInTicks), 1, 15);
return (matchingPeriod << 4) | MAX(1, (val & 0x0F));
}
@@ -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 = Clamp(effectParam2 + 25, NOTE_MIN, NOTE_MAX);
effect2 = CMD_TONEPORTAMENTO;
effectParam2 = 0xFF;
useMem2 = true;
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-03-18 08:56:19 UTC (rev 3897)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-03-18 09:43:33 UTC (rev 3898)
@@ -374,9 +374,9 @@
// -> CODE#0010
// -> DESC="add extended parameter mechanism to pattern effects"
if(IsCompatibleMode(TRK_ALLTRACKERS)) // clamp tempo correctly in compatible mode
- memory.state.m_nMusicTempo = CLAMP(memory.state.m_nMusicTempo, 32, 255);
+ memory.state.m_nMusicTempo = Clamp(memory.state.m_nMusicTempo, 32u, 255u);
else
- memory.state.m_nMusicTempo = CLAMP(memory.state.m_nMusicTempo, GetModSpecifications().tempoMin, GetModSpecifications().tempoMax);
+ memory.state.m_nMusicTempo = Clamp(memory.state.m_nMusicTempo, GetModSpecifications().tempoMin, GetModSpecifications().tempoMax);
// -! NEW_FEATURE#0010
break;
@@ -1271,7 +1271,7 @@
if(IsCompatibleMode(TRK_IMPULSETRACKER))
{
// need to memorize the original note for various effects (e.g. PPS)
- pChn->nNote = CLAMP(realnote, NOTE_MIN, NOTE_MAX);
+ pChn->nNote = Clamp(realnote, NOTE_MIN, NOTE_MAX);
} else
{
pChn->nNote = note;
@@ -3637,7 +3637,7 @@
if (nChnSlide)
{
nChnSlide += pChn->nGlobalVol;
- nChnSlide = CLAMP(nChnSlide, 0, 64);
+ nChnSlide = Clamp(nChnSlide, 0, 64);
pChn->nGlobalVol = nChnSlide;
}
}
@@ -4728,7 +4728,7 @@
if(setAsNonModcommand)
{
// Set tempo from UI - ignore slide commands and such.
- m_PlayState.m_nMusicTempo = CLAMP(param, specs.tempoMin, specs.tempoMax);
+ m_PlayState.m_nMusicTempo = Clamp(param, specs.tempoMin, specs.tempoMax);
}
else
{
@@ -4747,9 +4747,9 @@
// -> CODE#0016
// -> DESC="default tempo update"
if(IsCompatibleMode(TRK_ALLTRACKERS)) // clamp tempo correctly in compatible mode
- m_PlayState.m_nMusicTempo = CLAMP(m_PlayState.m_nMusicTempo, 32, 255);
+ m_PlayState.m_nMusicTempo = Clamp(m_PlayState.m_nMusicTempo, 32u, 255u);
else
- m_PlayState.m_nMusicTempo = CLAMP(m_PlayState.m_nMusicTempo, specs.tempoMin, specs.tempoMax);
+ m_PlayState.m_nMusicTempo = Clamp(m_PlayState.m_nMusicTempo, specs.tempoMin, specs.tempoMax);
// -! BEHAVIOUR_CHANGE#0016
}
}
Modified: trunk/OpenMPT/soundlib/modcommand.cpp
===================================================================
--- trunk/OpenMPT/soundlib/modcommand.cpp 2014-03-18 08:56:19 UTC (rev 3897)
+++ trunk/OpenMPT/soundlib/modcommand.cpp 2014-03-18 09:43:33 UTC (rev 3898)
@@ -556,7 +556,7 @@
case VOLCMD_PANNING:
command = CMD_PANNING8;
- param = CLAMP(vol << 2, 0, 0xFF);
+ param = Clamp(vol << 2, 0, 0xFF);
break;
case VOLCMD_VOLSLIDEDOWN:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-03-24 11:17:03
|
Revision: 3952
http://sourceforge.net/p/modplug/code/3952
Author: manxorist
Date: 2014-03-24 11:16:58 +0000 (Mon, 24 Mar 2014)
Log Message:
-----------
[Ref] Silence the last 3 warnings in default libopenmpt GCC builds.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_mdl.cpp
trunk/OpenMPT/soundlib/Load_mtm.cpp
Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mdl.cpp 2014-03-24 11:14:49 UTC (rev 3951)
+++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2014-03-24 11:16:58 UTC (rev 3952)
@@ -447,9 +447,9 @@
const BYTE *ps = lpStream+dwPos+34+14*j;
while ((note < (UINT)(ps[1]+12)) && (note < NOTE_MAX))
{
- if (ps[0] < MAX_SAMPLES)
+ SAMPLEINDEX ismp = ps[0];
+ if(ismp < MAX_SAMPLES)
{
- int ismp = ps[0];
pIns->Keyboard[note] = ps[0];
Samples[ismp].nVolume = ps[2];
Samples[ismp].nPan = ps[4] << 1;
@@ -521,7 +521,7 @@
for (i = 0; i < nsamples; i++, dwPos += (pmsh->version > 0) ? sizeof(MDLSampleHeader) : sizeof(MDLSampleHeaderv0))
{
const MDLSampleHeaderCommon *info = reinterpret_cast<const MDLSampleHeaderCommon *>(lpStream + dwPos);
- if(info->sampleIndex >= MAX_SAMPLES || info->sampleIndex == 0)
+ if(!IsInRange(info->sampleIndex, 1, MAX_SAMPLES-1))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_mtm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mtm.cpp 2014-03-24 11:14:49 UTC (rev 3951)
+++ trunk/OpenMPT/soundlib/Load_mtm.cpp 2014-03-24 11:16:58 UTC (rev 3952)
@@ -107,7 +107,6 @@
|| fileHeader.lastOrder > 127
|| fileHeader.numChannels > 32
|| fileHeader.numChannels == 0
- || fileHeader.numSamples >= MAX_SAMPLES
|| fileHeader.lastPattern >= MAX_PATTERNS
|| fileHeader.beatsPerTrack == 0
|| !file.CanRead(sizeof(MTMSampleHeader) * fileHeader.numSamples + 128 + 192 * fileHeader.numTracks + 64 * (fileHeader.lastPattern + 1) + fileHeader.commentSize))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-04-22 22:22:47
|
Revision: 4018
http://sourceforge.net/p/modplug/code/4018
Author: saga-games
Date: 2014-04-22 22:22:40 +0000 (Tue, 22 Apr 2014)
Log Message:
-----------
[Fix] Better handling of PT-style offset (probably still wrong)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ModChannel.cpp
trunk/OpenMPT/soundlib/ModChannel.h
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/ModChannel.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModChannel.cpp 2014-04-22 17:13:25 UTC (rev 4017)
+++ trunk/OpenMPT/soundlib/ModChannel.cpp 2014-04-22 22:22:40 UTC (rev 4018)
@@ -35,6 +35,7 @@
}
nTremorCount = 0;
nEFxSpeed = 0;
+ proTrackerOffset = 0;
isFirstTick = false;
}
@@ -76,8 +77,7 @@
dwFlags = sndFile.ChnSettings[sourceChannel].dwFlags;
nPan = sndFile.ChnSettings[sourceChannel].nPan;
nGlobalVol = sndFile.ChnSettings[sourceChannel].nVolume;
- }
- else
+ } else
{
dwFlags.reset();
nPan = 128;
Modified: trunk/OpenMPT/soundlib/ModChannel.h
===================================================================
--- trunk/OpenMPT/soundlib/ModChannel.h 2014-04-22 17:13:25 UTC (rev 4017)
+++ trunk/OpenMPT/soundlib/ModChannel.h 2014-04-22 22:22:40 UTC (rev 4018)
@@ -63,6 +63,7 @@
// Information not used in the mixer
const ModInstrument *pModInstrument; // Currently assigned instrument slot
+ SmpLength proTrackerOffset; // Offset for instrument-less notes in ProTracker mode
FlagSet<ChannelFlags> dwOldFlags; // Flags from previous tick
int32 newLeftVol, newRightVol;
int32 nRealVolume, nRealPan;
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-04-22 17:13:25 UTC (rev 4017)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-04-22 22:22:40 UTC (rev 4018)
@@ -86,7 +86,6 @@
for(CHANNELINDEX chn = 0; chn < sndFile.GetNumChannels(); chn++)
{
state.Chn[chn].Reset(ModChannel::resetTotal, sndFile, chn);
- state.Chn[chn].nOldHiOffset = 0;
state.Chn[chn].nOldGlobalVolSlide = 0;
state.Chn[chn].nOldChnVolSlide = 0;
state.Chn[chn].nNote = state.Chn[chn].nNewNote = state.Chn[chn].nLastNote = NOTE_NONE;
@@ -1327,7 +1326,11 @@
pChn->nPosLo = 0;
if(m_SongFlags[SONG_PT1XMODE] && !pChn->rowCommand.instr)
{
- pChn->nPos = (pChn->nOldHiOffset << 16) + (pChn->nOldOffset << 8);
+ pChn->nPos = pChn->proTrackerOffset;
+ LimitMax(pChn->nPos, pChn->nLength - 1);
+ } else
+ {
+ pChn->proTrackerOffset = 0;
}
pChn->dwFlags = (pChn->dwFlags & CHN_CHANNELFLAGS) | (static_cast<ChannelFlags>(pSmp->uFlags) & CHN_SAMPLEFLAGS);
if(pChn->dwFlags[CHN_SUSTAINLOOP])
@@ -4439,6 +4442,9 @@
pChn->nPos = param;
pChn->nPosLo = 0;
}
+ if(pChn->rowCommand.IsNote()) pChn->proTrackerOffset = param;
+ else if(pChn->rowCommand.instr) pChn->proTrackerOffset = 0;
+ pChn->proTrackerOffset += param;
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-05-01 22:59:13
|
Revision: 4028
http://sourceforge.net/p/modplug/code/4028
Author: saga-games
Date: 2014-05-01 22:59:06 +0000 (Thu, 01 May 2014)
Log Message:
-----------
[Fix] Global volume slides were not limited properly when jumping around in a module.
[Fix] Sample sync on jump could break if there was an EDx command in MOD/XM.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-05-01 19:07:49 UTC (rev 4027)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-05-01 22:59:06 UTC (rev 4028)
@@ -523,7 +523,7 @@
if (!(GetType() & GLOBALVOL_7BIT_FORMATS)) param <<= 1;
memory.state.m_nGlobalVolume -= param * (memory.state.m_nMusicSpeed - 1);
}
- memory.state.m_nGlobalVolume = Clamp(memory.state.m_nGlobalVolume, 0u, 256u);
+ memory.state.m_nGlobalVolume = Clamp(memory.state.m_nGlobalVolume, 0, 256);
break;
case CMD_CHANNELVOLUME:
if (param <= 64) pChn->nGlobalVol = param;
@@ -679,12 +679,14 @@
if(p->command == CMD_MODCMDEX)
{
switch(p->param & 0xF0)
+ {
case 0x10:
case 0x20:
case 0xA0:
case 0xB0:
stopNote = true;
- break;
+ break;
+ }
}
}
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-05-01 19:07:49 UTC (rev 4027)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-05-01 22:59:06 UTC (rev 4028)
@@ -872,7 +872,7 @@
if (!m_nDefaultSpeed) m_nDefaultSpeed = 6;
m_PlayState.m_nMusicSpeed = m_nDefaultSpeed;
m_PlayState.m_nMusicTempo = m_nDefaultTempo;
- m_PlayState.m_nGlobalVolume = m_nDefaultGlobalVolume;
+ m_PlayState.m_nGlobalVolume = static_cast<int32>(m_nDefaultGlobalVolume);
m_PlayState.m_lHighResRampingGlobalVolume = m_PlayState.m_nGlobalVolume<<VOLUMERAMPPRECISION;
m_PlayState.m_nGlobalVolumeDestination = m_PlayState.m_nGlobalVolume;
m_PlayState.m_nSamplesToGlobalVolRampDest = 0;
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-05-01 19:07:49 UTC (rev 4027)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-05-01 22:59:06 UTC (rev 4028)
@@ -446,9 +446,9 @@
// Global volume
public:
- uint32 m_nGlobalVolume;
+ int32 m_nGlobalVolume;
protected:
- uint32 m_nSamplesToGlobalVolRampDest, m_nGlobalVolumeRampAmount,
+ int32 m_nSamplesToGlobalVolRampDest, m_nGlobalVolumeRampAmount,
m_nGlobalVolumeDestination;
int32 m_lHighResRampingGlobalVolume;
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-05-01 19:07:49 UTC (rev 4027)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-05-01 22:59:06 UTC (rev 4028)
@@ -2219,7 +2219,7 @@
template<int channels>
-forceinline void ApplyGlobalVolumeWithRamping(int *SoundBuffer, int *RearBuffer, int32 lCount, uint32 m_nGlobalVolume, int32 step, uint32 &m_nSamplesToGlobalVolRampDest, int32 &m_lHighResRampingGlobalVolume)
+forceinline void ApplyGlobalVolumeWithRamping(int *SoundBuffer, int *RearBuffer, int32 lCount, int32 m_nGlobalVolume, int32 step, int32 &m_nSamplesToGlobalVolRampDest, int32 &m_lHighResRampingGlobalVolume)
{
const bool isStereo = (channels >= 2);
const bool hasRear = (channels >= 4);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-05-24 07:59:42
|
Revision: 4061
http://sourceforge.net/p/modplug/code/4061
Author: manxorist
Date: 2014-05-24 07:59:34 +0000 (Sat, 24 May 2014)
Log Message:
-----------
[Ref] Tiny cleanups.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Dither.cpp
trunk/OpenMPT/soundlib/MixerLoops.h
trunk/OpenMPT/soundlib/Mmcmp.cpp
Modified: trunk/OpenMPT/soundlib/Dither.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Dither.cpp 2014-05-23 16:56:27 UTC (rev 4060)
+++ trunk/OpenMPT/soundlib/Dither.cpp 2014-05-24 07:59:34 UTC (rev 4061)
@@ -41,8 +41,8 @@
#ifdef ENABLE_X86
-void X86_Dither(int *pBuffer, UINT nSamples, UINT nBits, DitherModPlugState *state)
-//---------------------------------------------------------------------------------
+void X86_Dither(int *pBuffer, uint32 nSamples, uint32 nBits, DitherModPlugState *state)
+//-------------------------------------------------------------------------------------
{
if(nBits + MIXING_ATTENUATION + 1 >= 32) //if(nBits>16)
{
@@ -99,11 +99,11 @@
a ^= 0x10204080u;
a += 0x78649E7Du + (b * 4);
b += ((a << 16 ) | (a >> 16)) * 5;
- return (int32)b;
+ return static_cast<int32>(b);
}
-static void C_Dither(int *pBuffer, std::size_t count, UINT nBits, DitherModPlugState *state)
-//------------------------------------------------------------------------------------------
+static void C_Dither(int *pBuffer, std::size_t count, uint32 nBits, DitherModPlugState *state)
+//--------------------------------------------------------------------------------------------
{
if(nBits + MIXING_ATTENUATION + 1 >= 32) //if(nBits>16)
{
@@ -127,8 +127,8 @@
}
-static void Dither_ModPlug(int *pBuffer, std::size_t count, std::size_t channels, UINT nBits, DitherModPlugState &state)
-//----------------------------------------------------------------------------------------------------------------------
+static void Dither_ModPlug(int *pBuffer, std::size_t count, std::size_t channels, uint32 nBits, DitherModPlugState &state)
+//------------------------------------------------------------------------------------------------------------------------
{
#ifdef ENABLE_X86
X86_Dither(pBuffer, count * channels, nBits, &state);
Modified: trunk/OpenMPT/soundlib/MixerLoops.h
===================================================================
--- trunk/OpenMPT/soundlib/MixerLoops.h 2014-05-23 16:56:27 UTC (rev 4060)
+++ trunk/OpenMPT/soundlib/MixerLoops.h 2014-05-24 07:59:34 UTC (rev 4061)
@@ -27,7 +27,7 @@
void ApplyGain(float *outputBuffer, float * const *outputBuffers, std::size_t offset, std::size_t channels, std::size_t countChunk, float gainFactor);
#endif // !MODPLUG_TRACKER
-void InitMixBuffer(mixsample_t *pBuffer, UINT nSamples);
+void InitMixBuffer(mixsample_t *pBuffer, uint32 nSamples);
void InterleaveFrontRear(mixsample_t *pFrontBuf, mixsample_t *pRearBuf, uint32 nFrames);
void MonoFromStereo(mixsample_t *pMixBuf, uint32 nSamples);
Modified: trunk/OpenMPT/soundlib/Mmcmp.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Mmcmp.cpp 2014-05-23 16:56:27 UTC (rev 4060)
+++ trunk/OpenMPT/soundlib/Mmcmp.cpp 2014-05-24 07:59:34 UTC (rev 4061)
@@ -222,7 +222,7 @@
uint32 memPos = blkPos + sizeof(MMCMPBLOCK) + blk.sub_blk * sizeof(MMCMPSUBBLOCK);
#ifdef MMCMP_LOG
- Log("block %d: flags=%04X sub_blocks=%d", nBlock, (UINT)pblk->flags, (UINT)pblk->sub_blk);
+ Log("block %d: flags=%04X sub_blocks=%d", nBlock, (uint32)pblk->flags, (uint32)pblk->sub_blk);
Log(" pksize=%d unpksize=%d", pblk->pk_size, pblk->unpk_size);
Log(" tt_entries=%d num_bits=%d\n", pblk->tt_entries, pblk->num_bits);
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-08-01 18:57:14
|
Revision: 4200
http://sourceforge.net/p/modplug/code/4200
Author: saga-games
Date: 2014-08-01 18:56:58 +0000 (Fri, 01 Aug 2014)
Log Message:
-----------
[Fix] FT2 compatibility: Tentatively fix arpeggio after pitch slide behaviour (http://bugs.openmpt.org/view.php?id=542) - note that the current behaviour is not 100% correct because of the finetune weirdness in FT2's RelocateTon function. Test case: ArpSlide.xm
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 2014-07-31 11:32:15 UTC (rev 4199)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-08-01 18:56:58 UTC (rev 4200)
@@ -4899,8 +4899,9 @@
//////////////////////////////////////////////////////
// Note/Period/Frequency functions
-UINT CSoundFile::GetNoteFromPeriod(UINT period) const
-//---------------------------------------------------
+// Find lowest note which has same or lower period as a given period (i.e. the note has the same or higher frequency)
+UINT CSoundFile::GetNoteFromPeriod(UINT period, int nFineTune, UINT nC5Speed) const
+//---------------------------------------------------------------------------------
{
if (!period) return 0;
if (GetType() & (MOD_TYPE_MED|MOD_TYPE_MOD|MOD_TYPE_DIGI|MOD_TYPE_MTM|MOD_TYPE_669|MOD_TYPE_OKT|MOD_TYPE_AMF0))
@@ -4922,12 +4923,22 @@
return 6*12+36;
} else
{
- for (UINT i=NOTE_MIN; i<NOTE_MAX; i++)
+ // This essentially implements std::lower_bound, with the difference that we don't need an iterable container.
+ uint32 minNote = NOTE_MIN, maxNote = NOTE_MAX, count = maxNote - minNote + 1;
+ while(count > 0)
{
- LONG n = GetPeriodFromNote(i, 0, 0);
- if ((n > 0) && (n <= (LONG)period)) return i;
+ const uint32 step = count / 2, midNote = minNote + step;
+ uint32 n = GetPeriodFromNote(midNote, nFineTune, nC5Speed);
+ if(n > period || !n)
+ {
+ minNote = midNote + 1;
+ count -= step + 1;
+ } else
+ {
+ count = step;
+ }
}
- return NOTE_MAX;
+ return minNote;
}
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-07-31 11:32:15 UTC (rev 4199)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-08-01 18:56:58 UTC (rev 4200)
@@ -874,9 +874,9 @@
bool ReadSampleFromSong(SAMPLEINDEX targetSample, const CSoundFile &srcSong, SAMPLEINDEX sourceSample);
// Period/Note functions
- UINT GetNoteFromPeriod(UINT period) const;
+ UINT GetNoteFromPeriod(UINT period, int nFineTune = 0, UINT nC5Speed = 0) const;
UINT GetPeriodFromNote(UINT note, int nFineTune, UINT nC5Speed) const;
- UINT GetFreqFromPeriod(UINT period, UINT nC5Speed, int nPeriodFrac=0) const;
+ UINT GetFreqFromPeriod(UINT period, UINT nC5Speed, int nPeriodFrac = 0) const;
// Misc functions
ModSample &GetSample(SAMPLEINDEX sample) { ASSERT(sample <= m_nSamples && sample < CountOf(Samples)); return Samples[sample]; }
const ModSample &GetSample(SAMPLEINDEX sample) const { ASSERT(sample <= m_nSamples && sample < CountOf(Samples)); return Samples[sample]; }
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-07-31 11:32:15 UTC (rev 4199)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-08-01 18:56:58 UTC (rev 4200)
@@ -1219,15 +1219,18 @@
}
} else if(IsCompatibleMode(TRK_FASTTRACKER2))
{
- uint8 note = pChn->nNote;
- int arpPos = 0;
-
+ // FastTracker 2: Swedish tracker logic (TM) arpeggio
if(!m_SongFlags[SONG_FIRSTTICK])
{
- arpPos = m_PlayState.m_nMusicSpeed - (m_PlayState.m_nTickCount % m_PlayState.m_nMusicSpeed);
+ // Arpeggio is added on top of current note, but cannot do it the IT way because of
+ // the behaviour in ArpeggioClamp.xm.
+ // Test case: ArpSlide.xm
+ uint8 note = GetNoteFromPeriod(period, pChn->nFineTune, pChn->nC5Speed);//pChn->nNote;
+
// The fact that arpeggio behaves in a totally fucked up way at 16 ticks/row or more is that the arpeggio offset LUT only has 16 entries in FT2.
// At more than 16 ticks/row, FT2 reads into the vibrato table, which is placed right after the arpeggio table.
// Test case: Arpeggio.xm
+ int arpPos = m_PlayState.m_nMusicSpeed - (m_PlayState.m_nTickCount % m_PlayState.m_nMusicSpeed);
if(arpPos > 16) arpPos = 2;
else if(arpPos == 16) arpPos = 0;
else arpPos %= 3;
@@ -1236,13 +1239,13 @@
case 1: note += (pChn->nArpeggio >> 4); break;
case 2: note += (pChn->nArpeggio & 0x0F); break;
}
- }
- // Test case: ArpeggioClamp.xm
- if(note > 108 + NOTE_MIN && arpPos != 0)
- note = 108 + NOTE_MIN; // FT2's note limit
+ // Test case: ArpeggioClamp.xm
+ if(note > 108 + NOTE_MIN && arpPos != 0)
+ note = 108 + NOTE_MIN; // FT2's note limit
- period = GetPeriodFromNote(note, pChn->nFineTune, pChn->nC5Speed);
+ period = GetPeriodFromNote(note, pChn->nFineTune, pChn->nC5Speed);
+ }
}
// Other trackers
else
@@ -2171,7 +2174,7 @@
{
ModCommand::NOTE realNote = note;
if(ModCommand::IsNote(note))
- realNote = pIns->NoteMap[note - 1];
+ realNote = pIns->NoteMap[note - NOTE_MIN];
pPlugin->MidiCommand(GetBestMidiChannel(nChn), pIns->nMidiProgram, pIns->wMidiBank, realNote, static_cast<uint16>(chn.nVolume), nChn);
} else if(hasVolCommand)
{
@@ -2195,7 +2198,7 @@
ModCommand::NOTE realNote = note;
if(ModCommand::IsNote(note))
- realNote = pIns->NoteMap[note - 1];
+ realNote = pIns->NoteMap[note - NOTE_MIN];
// Experimental VST panning
//ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_PAN], 0, nPlugin);
pPlugin->MidiCommand(GetBestMidiChannel(nChn), pIns->nMidiProgram, pIns->wMidiBank, realNote, velocity, nChn);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-08-31 19:13:43
|
Revision: 4223
http://sourceforge.net/p/modplug/code/4223
Author: saga-games
Date: 2014-08-31 19:13:30 +0000 (Sun, 31 Aug 2014)
Log Message:
-----------
[Fix] ProTracker compatibility: Properly implement PT-style sample swapping, which is only supposed to happend at the end of the sample and not instantly. Test case: PTInstrSwap.mod
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2014-08-31 16:02:44 UTC (rev 4222)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2014-08-31 19:13:30 UTC (rev 4223)
@@ -324,6 +324,7 @@
if ((nMixPlugin > 0) && (nMixPlugin <= MAX_MIXPLUGINS))
{
+ // Render into plugin buffer instead of global buffer
SNDMIXPLUGINSTATE *pPlugin = m_MixPlugins[nMixPlugin - 1].pMixState;
if ((pPlugin) && (pPlugin->pMixBuffer))
{
@@ -373,6 +374,7 @@
{
if (nrampsamples > chn.nRampLength) nrampsamples = chn.nRampLength;
}
+
if((nSmpCount = GetSampleCount(chn, nrampsamples, ITPingPongMode)) <= 0)
{
// Stopping the channel
@@ -388,6 +390,7 @@
chn.dwFlags.reset(CHN_PINGPONGFLAG);
break;
}
+
// Should we mix this channel ?
if((nchmixed >= m_MixerSettings.m_nMaxMixChannels && realtimeMix) // Too many channels
|| (!chn.nRampLength && !(chn.leftVol | chn.rightVol))) // Channel is completely silent
@@ -463,6 +466,24 @@
chn.nRampLength -= nSmpCount;
}
}
+
+ // ProTracker compatibility: Instrument changes without a note do not happen instantly, but rather when the sample loop has finished playing.
+ // Test case: PTInstrSwap.mod
+ if(m_SongFlags[SONG_PT1XMODE] && chn.nPos >= chn.nLoopEnd && chn.dwFlags[CHN_LOOP] && chn.nNewIns && chn.nNewIns <= GetNumSamples() && chn.pModSample != &Samples[chn.nNewIns])
+ {
+ const ModSample &smp = Samples[chn.nNewIns];
+ chn.pModSample = &smp;
+ chn.pCurrentSample = smp.pSample;
+ chn.dwFlags = (chn.dwFlags & CHN_CHANNELFLAGS) | smp.uFlags;
+ chn.nLoopStart = smp.nLoopStart;
+ chn.nLoopEnd = smp.nLoopEnd;
+ chn.nLength = smp.uFlags[CHN_LOOP] ? smp.nLoopEnd : smp.nLength;
+ chn.nPos = chn.nLoopStart;
+ if(!chn.pCurrentSample)
+ {
+ break;
+ }
+ }
} while(nsamples > 0);
// Restore sample pointer in case it got changed through loop wrap-around
@@ -520,8 +541,8 @@
#endif // MPT_INTMIXER
} else
{
- memset(pState->pOutBufferL, 0, nCount * sizeof(float));
- memset(pState->pOutBufferR, 0, nCount * sizeof(float));
+ memset(pState->pOutBufferL, 0, nCount * sizeof(pState->pOutBufferL[0]));
+ memset(pState->pOutBufferR, 0, nCount * sizeof(pState->pOutBufferR[0]));
}
pState->dwFlags &= ~SNDMIXPLUGINSTATE::psfMixReady;
}
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-08-31 16:02:44 UTC (rev 4222)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-08-31 19:13:30 UTC (rev 4223)
@@ -1176,17 +1176,13 @@
}
if(pChn->dwFlags[CHN_LOOP] && pChn->nLoopEnd < pChn->nLength) pChn->nLength = pChn->nLoopEnd;
- // Fix sample position on instrument change. This is needed for PT1x MOD and IT "on the fly" sample change.
+ // Fix sample position on instrument change. This is needed for IT "on the fly" sample change.
// XXX is this actually called? In ProcessEffects(), a note-on effect is emulated if there's an on the fly sample change!
if(pChn->nPos >= pChn->nLength)
{
if((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)))
{
pChn->nPos = pChn->nPosLo = 0;
- } else if((GetType() & MOD_TYPE_MOD)) // TODO does not always seem to work, especially with short chip samples?
- {
- pChn->nPos = pChn->nLoopStart;
- pChn->nPosLo = 0;
}
}
}
@@ -2177,7 +2173,7 @@
if(retrigEnv) //Case: instrument with no note data.
{
//IT compatibility: Instrument with no note.
- if(IsCompatibleMode(TRK_IMPULSETRACKER) || m_SongFlags[SONG_PT1XMODE])
+ if(IsCompatibleMode(TRK_IMPULSETRACKER))
{
if(GetNumInstruments())
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-09-29 23:37:55
|
Revision: 4329
http://sourceforge.net/p/modplug/code/4329
Author: saga-games
Date: 2014-09-29 23:37:44 +0000 (Mon, 29 Sep 2014)
Log Message:
-----------
[Ref] Split MOD-/DIGI-specific part of CSoundFile::GetNoteFromPeriod into the MOD pattern reader. It is not needed in any other cases and may lead to unwanted effects when trying to use this function in other contexts.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-09-29 14:44:41 UTC (rev 4328)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-09-29 23:37:44 UTC (rev 4329)
@@ -464,7 +464,25 @@
uint16 period = (((static_cast<uint16>(data[0]) & 0x0F) << 8) | data[1]);
if(period > 0 && period != 0xFFF)
{
- m.note = static_cast<ModCommand::NOTE>(GetNoteFromPeriod(period * 4));
+ m.note = 6 * 12 + 35 + NOTE_MIN;
+ for(int i = 0; i < 6 * 12; i++)
+ {
+ if(period >= ProTrackerPeriodTable[i])
+ {
+ if(period != ProTrackerPeriodTable[i] && i != 0)
+ {
+ uint16 p1 = ProTrackerPeriodTable[i - 1];
+ uint16 p2 = ProTrackerPeriodTable[i];
+ if(p1 - period < (period - p2))
+ {
+ m.note = static_cast<ModCommand::NOTE>(i + 35 + NOTE_MIN);
+ break;
+ }
+ }
+ m.note = static_cast<ModCommand::NOTE>(i + 36 + NOTE_MIN);
+ break;
+ }
+ }
}
// Read Instrument
m.instr = (data[2] >> 4) | (data[0] & 0x10);
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-09-29 14:44:41 UTC (rev 4328)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-09-29 23:37:44 UTC (rev 4329)
@@ -4928,46 +4928,25 @@
//---------------------------------------------------------------------------------
{
if (!period) return 0;
- if (GetType() & (MOD_TYPE_MED|MOD_TYPE_MOD|MOD_TYPE_DIGI|MOD_TYPE_MTM|MOD_TYPE_669|MOD_TYPE_OKT|MOD_TYPE_AMF0))
+ // This essentially implements std::lower_bound, with the difference that we don't need an iterable container.
+ uint32 minNote = NOTE_MIN, maxNote = NOTE_MAX, count = maxNote - minNote + 1;
+ while(count > 0)
{
- period >>= 2;
- for (UINT i=0; i<6*12; i++)
+ const uint32 step = count / 2, midNote = minNote + step;
+ uint32 n = GetPeriodFromNote(midNote, nFineTune, nC5Speed);
+ if(n > period || !n)
{
- if (period >= ProTrackerPeriodTable[i])
- {
- if ((period != ProTrackerPeriodTable[i]) && (i))
- {
- UINT p1 = ProTrackerPeriodTable[i-1];
- UINT p2 = ProTrackerPeriodTable[i];
- if (p1 - period < (period - p2)) return i+36;
- }
- return i+1+36;
- }
- }
- return 6*12+36;
- } else
- {
- // This essentially implements std::lower_bound, with the difference that we don't need an iterable container.
- uint32 minNote = NOTE_MIN, maxNote = NOTE_MAX, count = maxNote - minNote + 1;
- while(count > 0)
+ minNote = midNote + 1;
+ count -= step + 1;
+ } else
{
- const uint32 step = count / 2, midNote = minNote + step;
- uint32 n = GetPeriodFromNote(midNote, nFineTune, nC5Speed);
- if(n > period || !n)
- {
- minNote = midNote + 1;
- count -= step + 1;
- } else
- {
- count = step;
- }
+ count = step;
}
- return minNote;
}
+ return minNote;
}
-
UINT CSoundFile::GetPeriodFromNote(UINT note, int nFineTune, UINT nC5Speed) const
//-------------------------------------------------------------------------------
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-10-04 13:55:18
|
Revision: 4370
http://sourceforge.net/p/modplug/code/4370
Author: saga-games
Date: 2014-10-04 13:55:11 +0000 (Sat, 04 Oct 2014)
Log Message:
-----------
[Fix] Use normal compatible mix mode instead of FT2 panning mix mode for XM files that were compatibility-exported with OpenMPT 1.22 or older.
[Ref] Small readability changes in Snd_fx.cpp
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-10-04 13:50:53 UTC (rev 4369)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-10-04 13:55:11 UTC (rev 4370)
@@ -4952,10 +4952,10 @@
//-------------------------------------------------------------------------------
{
if (note == NOTE_NONE || (note >= NOTE_MIN_SPECIAL)) return 0;
+ note -= NOTE_MIN;
if (GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT|MOD_TYPE_MT2|MOD_TYPE_S3M|MOD_TYPE_STM|MOD_TYPE_MDL|MOD_TYPE_ULT|MOD_TYPE_WAV|MOD_TYPE_669
|MOD_TYPE_FAR|MOD_TYPE_DMF|MOD_TYPE_PTM|MOD_TYPE_AMS|MOD_TYPE_AMS2|MOD_TYPE_DBM|MOD_TYPE_AMF|MOD_TYPE_PSM|MOD_TYPE_J2B|MOD_TYPE_IMF))
{
- note -= NOTE_MIN;
if(m_SongFlags[SONG_LINEARSLIDES])
{
// In IT linear slide mode, periods are equal to frequency.
@@ -4964,14 +4964,14 @@
{
if (!nC5Speed) nC5Speed = 8363;
//(a*b)/c
- return Util::muldiv(8363, (FreqS3MTable[note % 12] << 5), nC5Speed << (note / 12));
+ return Util::muldiv_unsigned(8363, (FreqS3MTable[note % 12] << 5), nC5Speed << (note / 12));
//8363 * freq[note%12] / nC5Speed * 2^(5-note/12)
}
} else
if (GetType() == MOD_TYPE_XM)
{
- if (note < 13) note = 13;
- note -= 13;
+ if (note < 12) note = 12;
+ note -= 12;
// FT2 Compatibility: The lower three bits of the finetune are truncated.
// Test case: Finetune-Precision.xm
@@ -5010,7 +5010,6 @@
}
} else
{
- note--;
nFineTune = XM2MODFineTune(nFineTune);
if ((nFineTune) || (note < 36) || (note >= 36 + 6 * 12))
return (ProTrackerTunedPeriods[nFineTune * 12 + note % 12] << 5) >> (note / 12);
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-04 13:50:53 UTC (rev 4369)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-04 13:55:11 UTC (rev 4370)
@@ -625,8 +625,6 @@
MemsetZero(Instruments);
MemsetZero(m_szNames);
MemsetZero(m_MixPlugins);
- Order.Init();
- Patterns.ClearPatterns();
m_PlayState.m_lTotalSampleCount = 0;
m_PlayState.m_bPositionChanged = true;
@@ -2270,7 +2268,7 @@
// Previously the values were just added up, so let's fix this!
m.volcmd = VOLCMD_NONE;
const uint16 param = static_cast<uint16>(m.param) + static_cast<uint16>(m.vol << 4);
- m.param = mpt::saturate_cast<uint8>(param);
+ m.param = mpt::saturate_cast<ModCommand::PARAM>(param);
}
if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 09)
@@ -2383,12 +2381,20 @@
}
}
- if(m_dwLastSavedWithVersion >= MAKE_VERSION_NUMERIC(1, 22, 07, 19)
- && m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 23, 01, 04)
- && GetType() == MOD_TYPE_XM
- && GetMixLevels() == mixLevels_compatible)
+ // Starting from OpenMPT 1.22.07.19, FT2-style panning was applied compatible mix mode.
+ // Starting from OpenMPT 1.23.01.04, FT2-style panning has its own mix mode instead.
+ if(GetType() == MOD_TYPE_XM)
{
- SetMixLevels(mixLevels_compatible_FT2);
+ if(m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 07, 19)
+ && GetMixLevels() == mixLevels_compatible_FT2)
+ {
+ SetMixLevels(mixLevels_compatible);
+ } else if(m_dwLastSavedWithVersion >= MAKE_VERSION_NUMERIC(1, 22, 07, 19)
+ && m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 23, 01, 04)
+ && GetMixLevels() == mixLevels_compatible)
+ {
+ SetMixLevels(mixLevels_compatible_FT2);
+ }
}
Patterns.ForEachModCommand(UpgradePatternData(*this));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-10-07 08:51:44
|
Revision: 4402
http://sourceforge.net/p/modplug/code/4402
Author: manxorist
Date: 2014-10-07 08:51:36 +0000 (Tue, 07 Oct 2014)
Log Message:
-----------
[Ref] WriteInstrumentHeaderStructOrField() should not get compiled if MODPLUG_NO_FILESAVE.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-06 22:58:33 UTC (rev 4401)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-07 08:51:36 UTC (rev 4402)
@@ -291,6 +291,7 @@
}
} // unnamed namespace.
+#ifndef MODPLUG_NO_FILESAVE
// Write (in 'file') 'input' ModInstrument with 'code' & 'size' extra field infos for each member
void WriteInstrumentHeaderStructOrField(ModInstrument * input, FILE * file, uint32 only_this_code, int16 fixedsize)
{
@@ -375,6 +376,7 @@
WRITE_MPTHEADER_sized_member( VolEnv.dwFlags , uint32 , VFLG )
WRITE_MPTHEADER_sized_member( midiPWD , int8 , MPWD )
}
+#endif // !MODPLUG_NO_FILESAVE
// --------------------------------------------------------------------------------------------
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-10-06 22:58:33 UTC (rev 4401)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-10-07 08:51:36 UTC (rev 4402)
@@ -59,7 +59,9 @@
// -----------------------------------------------------------------------------------------
// MODULAR ModInstrument FIELD ACCESS : body content at the (near) top of Sndfile.cpp !!!
// -----------------------------------------------------------------------------------------
+#ifndef MODPLUG_NO_FILESAVE
extern void WriteInstrumentHeaderStructOrField(ModInstrument * input, FILE * file, uint32 only_this_code = -1 /* -1 for all */, int16 fixedsize = 0);
+#endif // !MODPLUG_NO_FILESAVE
extern bool ReadInstrumentHeaderField(ModInstrument * input, uint32 fcode, uint16 fsize, FileReader &file);
// --------------------------------------------------------------------------------------------
// --------------------------------------------------------------------------------------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-10-19 22:17:15
|
Revision: 4449
http://sourceforge.net/p/modplug/code/4449
Author: saga-games
Date: 2014-10-19 22:17:05 +0000 (Sun, 19 Oct 2014)
Log Message:
-----------
[Fix] Replacing a sample didn't update the sample length properly when the sample loop was active, leading to possible garbage playback.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/modsmp_ctrl.cpp
trunk/OpenMPT/soundlib/modsmp_ctrl.h
Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.cpp
===================================================================
--- trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2014-10-19 20:47:50 UTC (rev 4448)
+++ trunk/OpenMPT/soundlib/modsmp_ctrl.cpp 2014-10-19 22:17:05 UTC (rev 4449)
@@ -34,7 +34,7 @@
CriticalSection cs;
- ctrlChn::ReplaceSample(sndFile.m_PlayState.Chn, &smp, pNewSample, nNewLength, setFlags, resetFlags);
+ ctrlChn::ReplaceSample(sndFile.m_PlayState.Chn, smp, pNewSample, nNewLength, setFlags, resetFlags);
smp.pSample = pNewSample;
smp.nLength = nNewLength;
ModSample::FreeSample(pOldSmp);
@@ -737,7 +737,7 @@
{
void ReplaceSample( ModChannel (&Chn)[MAX_CHANNELS],
- const ModSample * const pSample,
+ const ModSample &sample,
const void * const pNewSample,
const SmpLength nNewLength,
FlagSet<ChannelFlags> setFlags,
@@ -745,14 +745,23 @@
{
for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++)
{
- if (Chn[i].pModSample == pSample)
+ if (Chn[i].pModSample == &sample)
{
if (Chn[i].pCurrentSample != nullptr)
Chn[i].pCurrentSample = pNewSample;
if (Chn[i].nPos > nNewLength)
Chn[i].nPos = 0;
if (Chn[i].nLength > 0)
- Chn[i].nLength = nNewLength;
+ LimitMax(Chn[i].nLength, nNewLength);
+ if(Chn[i].InSustainLoop())
+ {
+ Chn[i].nLoopStart = sample.nSustainStart;
+ Chn[i].nLoopEnd = sample.nSustainEnd;
+ } else
+ {
+ Chn[i].nLoopStart = sample.nLoopStart;
+ Chn[i].nLoopEnd = sample.nLoopEnd;
+ }
Chn[i].dwFlags.set(setFlags);
Chn[i].dwFlags.reset(resetFlags);
}
Modified: trunk/OpenMPT/soundlib/modsmp_ctrl.h
===================================================================
--- trunk/OpenMPT/soundlib/modsmp_ctrl.h 2014-10-19 20:47:50 UTC (rev 4448)
+++ trunk/OpenMPT/soundlib/modsmp_ctrl.h 2014-10-19 22:17:05 UTC (rev 4449)
@@ -95,7 +95,7 @@
// Replaces sample from sound channels by given sample.
void ReplaceSample( ModChannel (&Chn)[MAX_CHANNELS],
- const ModSample * const pSample,
+ const ModSample &sample,
const void * const pNewSample,
const SmpLength nNewLength,
FlagSet<ChannelFlags> setFlags,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-10-25 15:29:37
|
Revision: 4490
http://sourceforge.net/p/modplug/code/4490
Author: saga-games
Date: 2014-10-25 15:29:21 +0000 (Sat, 25 Oct 2014)
Log Message:
-----------
[Fix] Two include renames were missing in previous commit.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/tuningCollection.cpp
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-25 15:27:10 UTC (rev 4489)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-10-25 15:29:21 UTC (rev 4490)
@@ -24,7 +24,7 @@
#include "tuningcollection.h"
#include "../common/StringFixer.h"
#include "FileReader.h"
-#include "../common/mptFstream.h"
+#include "../common/mptFileIO.h"
#include <sstream>
#include <time.h>
Modified: trunk/OpenMPT/soundlib/tuningCollection.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuningCollection.cpp 2014-10-25 15:27:10 UTC (rev 4489)
+++ trunk/OpenMPT/soundlib/tuningCollection.cpp 2014-10-25 15:29:21 UTC (rev 4490)
@@ -14,7 +14,7 @@
#include "../common/serialization_utils.h"
#include <algorithm>
#include <bitset>
-#include "../common/mptFstream.h"
+#include "../common/mptFileIO.h"
OPENMPT_NAMESPACE_BEGIN
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-10-26 15:39:00
|
Revision: 4505
http://sourceforge.net/p/modplug/code/4505
Author: saga-games
Date: 2014-10-26 15:38:43 +0000 (Sun, 26 Oct 2014)
Log Message:
-----------
[Fix] Load extended song properties failed if MPT_EXTERNAL_SAMPLES is not enabled.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-26 15:27:49 UTC (rev 4504)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-10-26 15:38:43 UTC (rev 4505)
@@ -650,11 +650,11 @@
sampleHeader.GetSampleFormat(fileHeader.cwtv).ReadSample(sample, file);
} else
{
-#ifdef MPT_EXTERNAL_SAMPLES
// External sample in MPTM file
- std::string filenameU8;
size_t strLen;
file.ReadVarInt(strLen);
+#ifdef MPT_EXTERNAL_SAMPLES
+ std::string filenameU8;
file.ReadString<mpt::String::maybeNullTerminated>(filenameU8, strLen);
mpt::PathString filename = mpt::PathString::FromUTF8(filenameU8);
@@ -675,6 +675,8 @@
{
sample.uFlags.reset(SMP_KEEPONDISK);
}
+#else
+ file.Skip(strLen);
#endif // MPT_EXTERNAL_SAMPLES
}
lastSampleOffset = std::max(lastSampleOffset, file.GetPosition());
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-26 15:27:49 UTC (rev 4504)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2014-10-26 15:38:43 UTC (rev 4505)
@@ -1470,11 +1470,11 @@
sampleHeader.GetSampleFormat().ReadSample(Samples[nSample], file);
} else
{
-#ifdef MPT_EXTERNAL_SAMPLES
// External sample
- std::string filenameU8;
size_t strLen;
file.ReadVarInt(strLen);
+#ifdef MPT_EXTERNAL_SAMPLES
+ std::string filenameU8;
file.ReadString<mpt::String::maybeNullTerminated>(filenameU8, strLen);
mpt::PathString filename = mpt::PathString::FromUTF8(filenameU8);
@@ -1492,6 +1492,8 @@
{
sample.uFlags.reset(SMP_KEEPONDISK);
}
+#else
+ file.Skip(strLen);
#endif // MPT_EXTERNAL_SAMPLES
}
sample.PrecomputeLoops(*this, false);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-11-01 21:02:06
|
Revision: 4532
http://sourceforge.net/p/modplug/code/4532
Author: saga-games
Date: 2014-11-01 21:01:50 +0000 (Sat, 01 Nov 2014)
Log Message:
-----------
[Ref] Make CPatternContainer::Insert return true on success instead of failure.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_669.cpp
trunk/OpenMPT/soundlib/Load_amf.cpp
trunk/OpenMPT/soundlib/Load_ams.cpp
trunk/OpenMPT/soundlib/Load_dbm.cpp
trunk/OpenMPT/soundlib/Load_digi.cpp
trunk/OpenMPT/soundlib/Load_dsm.cpp
trunk/OpenMPT/soundlib/Load_far.cpp
trunk/OpenMPT/soundlib/Load_gdm.cpp
trunk/OpenMPT/soundlib/Load_imf.cpp
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_itp.cpp
trunk/OpenMPT/soundlib/Load_mdl.cpp
trunk/OpenMPT/soundlib/Load_med.cpp
trunk/OpenMPT/soundlib/Load_mid.cpp
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/Load_mt2.cpp
trunk/OpenMPT/soundlib/Load_mtm.cpp
trunk/OpenMPT/soundlib/Load_okt.cpp
trunk/OpenMPT/soundlib/Load_psm.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_wav.cpp
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/load_j2b.cpp
trunk/OpenMPT/soundlib/patternContainer.cpp
trunk/OpenMPT/soundlib/patternContainer.h
Modified: trunk/OpenMPT/soundlib/Load_669.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_669.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_669.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -155,7 +155,7 @@
// Reading Patterns
for(PATTERNINDEX pat = 0; pat < fileHeader.patterns; pat++)
{
- if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, 64))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, 64))
{
file.Skip(64 * 8 * 3);
continue;
Modified: trunk/OpenMPT/soundlib/Load_amf.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_amf.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_amf.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -149,7 +149,7 @@
// Read Patterns
for(PATTERNINDEX pat = 0; pat < fileHeader.numPatterns; pat++)
{
- if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, 64))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, 64))
{
file.Skip(64 * 4 * 8);
continue;
@@ -568,7 +568,7 @@
// Create the patterns from the list of tracks
for(PATTERNINDEX pat = 0; pat < fileHeader.numOrders; pat++)
{
- if(Patterns.Insert(pat, patternLength[pat]))
+ if(!Patterns.Insert(pat, patternLength[pat]))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_ams.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ams.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_ams.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -442,7 +442,7 @@
char name[11];
ReadAMSString(name, file);
// Create pattern now, so name won't be reset later.
- if(!Patterns.Insert(pat, 64))
+ if(Patterns.Insert(pat, 64))
{
Patterns[pat].SetName(name);
}
@@ -966,7 +966,7 @@
// We don't need to know the number of channels or commands.
patternChunk.Skip(1);
- if(Patterns.Insert(pat, numRows))
+ if(!Patterns.Insert(pat, numRows))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_dbm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_dbm.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_dbm.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -429,7 +429,7 @@
uint32 packedSize = patternChunk.ReadUint32BE();
FileReader chunk = patternChunk.ReadChunk(packedSize);
- if(Patterns.Insert(pat, numRows))
+ if(!Patterns.Insert(pat, numRows))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_digi.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_digi.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_digi.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -158,7 +158,7 @@
patternChunk = file.ReadChunk(4 * 64 * GetNumChannels());
}
- if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, 64))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, 64))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_dsm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_dsm.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_dsm.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -208,7 +208,7 @@
if(!memcmp(chunkHeader.magic, "PATT", 4) && (loadFlags & loadPatternData))
{
// Read pattern
- if(Patterns.Insert(patNum, 64))
+ if(!Patterns.Insert(patNum, 64))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_far.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_far.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_far.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -221,7 +221,7 @@
// Calculate pattern length in rows (every event is 4 bytes, and we have 16 channels)
ROWINDEX numRows = (orderHeader.patternSize[pat] - 2) / (16 * 4);
- if(!(loadFlags & loadPatternData) || !numRows || numRows > MAX_PATTERN_ROWS || Patterns.Insert(pat, numRows))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, numRows))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_gdm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_gdm.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_gdm.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -305,7 +305,7 @@
}
FileReader chunk = file.ReadChunk(patternLength - 2);
- if(!(loadFlags & loadPatternData) || !chunk.IsValid() || Patterns.Insert(pat, 64))
+ if(!(loadFlags & loadPatternData) || !chunk.IsValid() || !Patterns.Insert(pat, 64))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_imf.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_imf.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_imf.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -483,7 +483,7 @@
const uint16 length = file.ReadUint16LE(), numRows = file.ReadUint16LE();
FileReader patternChunk = file.ReadChunk(length - 4);
- if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, numRows))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, numRows))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -787,7 +787,7 @@
if(patPos[pat] == 0 || !file.Seek(patPos[pat]))
{
// Empty 64-row pattern
- if(Patterns.Insert(pat, 64))
+ if(!Patterns.Insert(pat, 64))
{
AddToLog(mpt::String::Print("Allocating patterns failed starting from pattern %1", pat));
break;
@@ -803,7 +803,7 @@
if(numRows < GetModSpecifications().patternRowsMin
|| numRows > GetModSpecifications().patternRowsMax
|| !file.Skip(4)
- || Patterns.Insert(pat, numRows))
+ || !Patterns.Insert(pat, numRows))
continue;
FileReader patternData = file.ReadChunk(len);
Modified: trunk/OpenMPT/soundlib/Load_itp.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_itp.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_itp.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -178,7 +178,7 @@
FileReader patternChunk = file.ReadChunk(numRows * size * GetNumChannels());
// Allocate pattern
- if(!(loadFlags & loadPatternData) || numRows == 0 || numRows > MAX_PATTERN_ROWS || Patterns.Insert(pat, numRows))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, numRows))
{
pattNames.Skip(patNameLen);
continue;
Modified: trunk/OpenMPT/soundlib/Load_mdl.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mdl.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_mdl.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -645,7 +645,7 @@
{
for (UINT ipat=0; ipat<npatterns; ipat++)
{
- if(Patterns.Insert(ipat, patternLength[ipat]))
+ if(!Patterns.Insert(ipat, patternLength[ipat]))
{
break;
}
Modified: trunk/OpenMPT/soundlib/Load_med.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_med.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_med.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -864,7 +864,7 @@
lines = pmb->lines + 1;
tracks = pmb->numtracks;
if (!tracks) tracks = m_nChannels;
- if(Patterns.Insert(iBlk, lines)) continue;
+ if(!Patterns.Insert(iBlk, lines)) continue;
ModCommand *p = Patterns[iBlk];
const uint8 * s = (const uint8 *)(lpStream + dwPos + 2);
UINT maxlen = tracks*lines*3;
Modified: trunk/OpenMPT/soundlib/Load_mid.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mid.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_mid.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -616,7 +616,7 @@
do
{
// Allocate current pattern if not allocated yet
- if (!Patterns[pat] && Patterns.Insert(pat, importPatternLen))
+ if (!Patterns[pat] && !Patterns.Insert(pat, importPatternLen))
{
break;
}
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -662,7 +662,7 @@
if((pat % 2u) == 0)
{
// Only create "even" patterns for FLT8 files
- if(!(loadFlags & loadPatternData) || Patterns.Insert(pat / 2, 64))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat / 2, 64))
{
file.Skip(readChannels * 64 * 4);
continue;
@@ -671,7 +671,7 @@
actualPattern /= 2;
} else
{
- if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, 64))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, 64))
{
file.Skip(readChannels * 64 * 4);
continue;
@@ -986,7 +986,7 @@
// Reading patterns
for(PATTERNINDEX pat = 0; pat < numPatterns; pat++)
{
- if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, 64))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, 64))
{
file.Skip(64 * 4 * 4);
continue;
@@ -1203,7 +1203,7 @@
for(PATTERNINDEX pat = 0; pat < numOrders; pat++)
{
Order[pat] = pat;
- if(Patterns.Insert(pat, 64))
+ if(!Patterns.Insert(pat, 64))
continue;
for(CHANNELINDEX chn = 0; chn < 4; chn++)
Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -487,7 +487,7 @@
LimitMax(numRows, MAX_PATTERN_ROWS);
if(!numRows
|| !(loadFlags & loadPatternData)
- || Patterns.Insert(pat, numRows))
+ || !Patterns.Insert(pat, numRows))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_mtm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mtm.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_mtm.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -152,7 +152,7 @@
for(PATTERNINDEX pat = 0; pat <= fileHeader.lastPattern; pat++)
{
- if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, rowsPerPat))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, rowsPerPat))
{
break;
}
Modified: trunk/OpenMPT/soundlib/Load_okt.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_okt.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_okt.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -124,7 +124,7 @@
ROWINDEX rows = Clamp(static_cast<ROWINDEX>(chunk.ReadUint16BE()), ROWINDEX(1), MAX_PATTERN_ROWS);
- if(sndFile.Patterns.Insert(nPat, rows))
+ if(!sndFile.Patterns.Insert(nPat, rows))
{
return;
}
Modified: trunk/OpenMPT/soundlib/Load_psm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_psm.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_psm.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -665,7 +665,7 @@
uint16 numRows = patternChunk.ReadUint16LE();
- if(Patterns.Insert(pat, numRows))
+ if(!Patterns.Insert(pat, numRows))
{
break;
}
@@ -1225,7 +1225,7 @@
// Patterns are padded to 16 Bytes
FileReader patternChunk = file.ReadChunk(((patternHeader.size + 15) & ~15) - sizeof(PSM16PatternHeader));
- if(Patterns.Insert(pat, patternHeader.numRows))
+ if(!Patterns.Insert(pat, patternHeader.numRows))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_ptm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ptm.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_ptm.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -204,7 +204,7 @@
for(PATTERNINDEX pat = 0; pat < fileHeader.numPatterns; pat++)
{
- if(Patterns.Insert(pat, 64)
+ if(!Patterns.Insert(pat, 64)
|| fileHeader.patOffsets[pat] == 0
|| !file.Seek(fileHeader.patOffsets[pat] << 4))
{
Modified: trunk/OpenMPT/soundlib/Load_s3m.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_s3m.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_s3m.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -425,7 +425,7 @@
for(PATTERNINDEX pat = 0; pat < readPatterns; pat++)
{
// A zero parapointer indicates an empty pattern.
- if(Patterns.Insert(pat, 64) || patternOffsets[pat] == 0 || !file.Seek(patternOffsets[pat] * 16))
+ if(!Patterns.Insert(pat, 64) || patternOffsets[pat] == 0 || !file.Seek(patternOffsets[pat] * 16))
{
continue;
}
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -204,7 +204,7 @@
{
STMPatternData patternData;
- if(!(loadFlags & loadPatternData) || Patterns.Insert(pat, 64) || !file.ReadConvertEndianness(patternData))
+ if(!(loadFlags & loadPatternData) || !Patterns.Insert(pat, 64) || !file.ReadConvertEndianness(patternData))
{
file.Skip(sizeof(patternData));
continue;
Modified: trunk/OpenMPT/soundlib/Load_ult.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_ult.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_ult.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -452,7 +452,7 @@
for(PATTERNINDEX pat = 0; pat < numPats; pat++)
{
- if(Patterns.Insert(pat, 64))
+ if(!Patterns.Insert(pat, 64))
return false;
}
Modified: trunk/OpenMPT/soundlib/Load_wav.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_wav.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_wav.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -62,7 +62,7 @@
InitializeGlobals();
m_nChannels = std::max(wavFile.GetNumChannels(), uint16(2));
- if(Patterns.Insert(0, 64) || Patterns.Insert(1, 64))
+ if(!Patterns.Insert(0, 64) || !Patterns.Insert(1, 64))
{
return false;
}
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -155,7 +155,7 @@
file.Seek(curPos + headerSize);
FileReader patternChunk = file.ReadChunk(packedSize);
- if(sndFile.Patterns.Insert(pat, numRows) || packedSize == 0)
+ if(!sndFile.Patterns.Insert(pat, numRows) || packedSize == 0)
{
continue;
}
Modified: trunk/OpenMPT/soundlib/load_j2b.cpp
===================================================================
--- trunk/OpenMPT/soundlib/load_j2b.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/load_j2b.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -622,7 +622,7 @@
ROWINDEX numRows = Clamp(static_cast<ROWINDEX>(chunk.ReadUint8()) + 1, ROWINDEX(1), MAX_PATTERN_ROWS);
- if(sndFile.Patterns.Insert(pat, numRows))
+ if(!sndFile.Patterns.Insert(pat, numRows))
return false;
const CHANNELINDEX channels = sndFile.GetNumChannels();
Modified: trunk/OpenMPT/soundlib/patternContainer.cpp
===================================================================
--- trunk/OpenMPT/soundlib/patternContainer.cpp 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/patternContainer.cpp 2014-11-01 21:01:50 UTC (rev 4532)
@@ -66,7 +66,7 @@
PATTERNINDEX i = 0;
for(i = 0; i < m_Patterns.size(); i++)
if(!m_Patterns[i]) break;
- if(Insert(i, rows))
+ if(!Insert(i, rows))
return PATTERNINDEX_INVALID;
else return i;
Modified: trunk/OpenMPT/soundlib/patternContainer.h
===================================================================
--- trunk/OpenMPT/soundlib/patternContainer.h 2014-11-01 20:27:32 UTC (rev 4531)
+++ trunk/OpenMPT/soundlib/patternContainer.h 2014-11-01 21:01:50 UTC (rev 4532)
@@ -49,7 +49,7 @@
void DestroyPatterns();
//Insert (default)pattern to given position. If pattern already exists at that position,
- //ignoring request. Returns true on failure, false otherwise.
+ //ignoring request. Returns true on success, false otherwise.
bool Insert(const PATTERNINDEX index, const ROWINDEX rows);
//Insert pattern to position with the lowest index, and return that index, PATTERNINDEX_INVALID
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2014-11-01 21:51:17
|
Revision: 4534
http://sourceforge.net/p/modplug/code/4534
Author: manxorist
Date: 2014-11-01 21:51:00 +0000 (Sat, 01 Nov 2014)
Log Message:
-----------
[Fix] Avoid undefined behaviour (found with clang undefined behaviour sanitizer): Declaring an over-aligned type with alignas(32) causes the compiler to legally assume all objects of that type to have that very alignment. Additionally, it also causes all types containing this type to be that much over-aligned. Calling operator new on such an over-aligned type is undefined behaviour, as is accessing an object that is mis-aligned- The purpose of desiring alignment of struct ModChannel is only to have each consecutive item in an array start at a cacheline. The gain is questionable as we are not risking any kind of false sharing here (everything is single-threaded) and there is even the possibility of performance decrease due to alignment because of added padding and thus cache pressure increase. In order to keep things simple, just unconditianlly remove the extended alignemnt instead of doing custom aligned allocation for every CSoundFile object.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ModChannel.h
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/ModChannel.h
===================================================================
--- trunk/OpenMPT/soundlib/ModChannel.h 2014-11-01 21:14:29 UTC (rev 4533)
+++ trunk/OpenMPT/soundlib/ModChannel.h 2014-11-01 21:51:00 UTC (rev 4534)
@@ -14,12 +14,8 @@
class CSoundFile;
-#if MPT_COMPILER_MSVC
-#pragma warning(disable:4324) //structure was padded due to __declspec(align())
-#endif
-
// Mix Channel Struct
-struct ALIGN(32) ModChannel
+struct ModChannel
{
// Envelope playback info
struct EnvInfo
@@ -194,7 +190,7 @@
// Default pattern channel settings
-struct ALIGN(32) ModChannelSettings
+struct ModChannelSettings
{
FlagSet<ChannelFlags> dwFlags; // Channel flags
uint16 nPan; // Initial pan (0...256)
@@ -217,8 +213,4 @@
}
};
-#if MPT_COMPILER_MSVC
-#pragma warning(default:4324) //structure was padded due to __declspec(align())
-#endif
-
OPENMPT_NAMESPACE_END
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2014-11-01 21:14:29 UTC (rev 4533)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2014-11-01 21:51:00 UTC (rev 4534)
@@ -241,11 +241,6 @@
};
-#if MPT_COMPILER_MSVC
-#pragma warning(disable:4324) //structure was padded due to __declspec(align())
-#endif
-
-
//==============
class CSoundFile
//==============
@@ -917,11 +912,7 @@
};
-#if MPT_COMPILER_MSVC
-#pragma warning(default : 4324) //structure was padded due to __declspec(align())
-#endif
-
extern const char szNoteNames[12][4];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-11-02 12:38:05
|
Revision: 4536
http://sourceforge.net/p/modplug/code/4536
Author: saga-games
Date: 2014-11-02 12:37:47 +0000 (Sun, 02 Nov 2014)
Log Message:
-----------
[Ref] Introduce a typedef for FlagSet<ChannelFlags, uint16> and clarify why we use it.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ModSample.h
trunk/OpenMPT/soundlib/Snd_defs.h
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/WAVTools.cpp
trunk/OpenMPT/soundlib/WAVTools.h
Modified: trunk/OpenMPT/soundlib/ModSample.h
===================================================================
--- trunk/OpenMPT/soundlib/ModSample.h 2014-11-02 01:18:42 UTC (rev 4535)
+++ trunk/OpenMPT/soundlib/ModSample.h 2014-11-02 12:37:47 UTC (rev 4536)
@@ -30,7 +30,7 @@
uint16 nPan; // Default sample panning (if pan flag is set), 0...256
uint16 nVolume; // Default volume, 0...256
uint16 nGlobalVol; // Global volume (sample volume is multiplied by this), 0...64
- FlagSet<ChannelFlags, uint16> uFlags; // Sample flags
+ SampleFlags uFlags; // Sample flags (see ChannelFlags enum)
int8 RelativeTone; // Relative note to middle c (for MOD/XM)
int8 nFineTune; // Finetune period (for MOD/XM), -128...127
uint8 nVibType; // Auto vibrato type, see VibratoType enum
Modified: trunk/OpenMPT/soundlib/Snd_defs.h
===================================================================
--- trunk/OpenMPT/soundlib/Snd_defs.h 2014-11-02 01:18:42 UTC (rev 4535)
+++ trunk/OpenMPT/soundlib/Snd_defs.h 2014-11-02 12:37:47 UTC (rev 4536)
@@ -166,11 +166,13 @@
};
DECLARE_FLAGSET(ChannelFlags)
-
#define CHN_SAMPLEFLAGS (CHN_16BIT | CHN_LOOP | CHN_PINGPONGLOOP | CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN | CHN_PANNING | CHN_STEREO | CHN_PINGPONGFLAG | CHN_REVERSE)
#define CHN_CHANNELFLAGS (~CHN_SAMPLEFLAGS)
+// Sample flags fit into the first 16 bits, and with the current memory layout, storing them as a 16-bit integer gives struct ModSample a nice cacheable 64 bytes size in 32-bit builds.
+typedef FlagSet<ChannelFlags, uint16> SampleFlags;
+
// Instrument envelope-specific flags
enum EnvelopeFlags
{
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-11-02 01:18:42 UTC (rev 4535)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-11-02 12:37:47 UTC (rev 4536)
@@ -2100,7 +2100,7 @@
ModSample &sample = GetSample(smp);
SmpLength newLength = sample.nLength;
void *newData = sample.pSample;
- FlagSet<ChannelFlags, uint16> newFlags = sample.uFlags;
+ SampleFlags newFlags = sample.uFlags;
sample = origSample;
sample.nLength = newLength;
Modified: trunk/OpenMPT/soundlib/WAVTools.cpp
===================================================================
--- trunk/OpenMPT/soundlib/WAVTools.cpp 2014-11-02 01:18:42 UTC (rev 4535)
+++ trunk/OpenMPT/soundlib/WAVTools.cpp 2014-11-02 12:37:47 UTC (rev 4536)
@@ -207,8 +207,8 @@
// Apply WAV loop information to a mod sample.
-void WAVSampleLoop::ApplyToSample(SmpLength &start, SmpLength &end, SmpLength sampleLength, FlagSet<ChannelFlags, uint16> &flags, ChannelFlags enableFlag, ChannelFlags bidiFlag, bool mptLoopFix) const
-//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+void WAVSampleLoop::ApplyToSample(SmpLength &start, SmpLength &end, SmpLength sampleLength, SampleFlags &flags, ChannelFlags enableFlag, ChannelFlags bidiFlag, bool mptLoopFix) const
+//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{
if(loopEnd == 0)
{
Modified: trunk/OpenMPT/soundlib/WAVTools.h
===================================================================
--- trunk/OpenMPT/soundlib/WAVTools.h 2014-11-02 01:18:42 UTC (rev 4535)
+++ trunk/OpenMPT/soundlib/WAVTools.h 2014-11-02 12:37:47 UTC (rev 4536)
@@ -239,7 +239,7 @@
}
// Apply WAV loop information to a mod sample.
- void ApplyToSample(SmpLength &start, SmpLength &end, SmpLength sampleLength, FlagSet<ChannelFlags, uint16> &flags, ChannelFlags enableFlag, ChannelFlags bidiFlag, bool mptLoopFix) const;
+ void ApplyToSample(SmpLength &start, SmpLength &end, SmpLength sampleLength, SampleFlags &flags, ChannelFlags enableFlag, ChannelFlags bidiFlag, bool mptLoopFix) const;
// Convert internal loop information into a WAV loop.
void ConvertToWAV(SmpLength start, SmpLength end, bool bidi);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-11-07 00:46:51
|
Revision: 4556
http://sourceforge.net/p/modplug/code/4556
Author: saga-games
Date: 2014-11-07 00:46:39 +0000 (Fri, 07 Nov 2014)
Log Message:
-----------
[Fix] XM compatiblity: Make arpeggio behave even more like in FT2 by properly rounding the base note after portamento (test case: ArpSlide.xm)
[Fix] Glissando should only affect tone portamento, not portamento up / down effects. Further more, in ProTracker 1/2 mode, it is only applied on rows with portamento effects.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_flt.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
trunk/OpenMPT/soundlib/modcommand.h
Modified: trunk/OpenMPT/soundlib/Snd_flt.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_flt.cpp 2014-11-06 20:48:55 UTC (rev 4555)
+++ trunk/OpenMPT/soundlib/Snd_flt.cpp 2014-11-07 00:46:39 UTC (rev 4556)
@@ -69,7 +69,7 @@
// Filtering is only ever done in IT if either cutoff is not full or if resonance is set.
if(IsCompatibleMode(TRK_IMPULSETRACKER) && resonance == 0 && computedCutoff >= 254)
{
- if(pChn->rowCommand.IsNote() && !pChn->dwFlags[CHN_PORTAMENTO] && !pChn->nMasterChn && m_SongFlags[SONG_FIRSTTICK])
+ if(pChn->rowCommand.IsNote() && !pChn->rowCommand.IsPortamento() && !pChn->nMasterChn && m_SongFlags[SONG_FIRSTTICK])
{
// Z7F next to a note disables the filter, however in other cases this should not happen.
// Test cases: filter-reset.it, filter-reset-carry.it, filter-nna.it
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-11-06 20:48:55 UTC (rev 4555)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-11-07 00:46:39 UTC (rev 4556)
@@ -145,7 +145,7 @@
{
const ModCommand &m = *Patterns[seekPat].GetpModCommand(target.pos.row, i);
if(m.note == NOTE_NOTECUT || m.note == NOTE_KEYOFF || (m.note == NOTE_FADE && GetNumInstruments())
- || (m.IsNote() && m.command != CMD_TONEPORTAMENTO && m.command != CMD_TONEPORTAVOL && m.volcmd != VOLCMD_TONEPORTAMENTO))
+ || (m.IsNote() && !m.IsPortamento()))
{
adjustSampleChn[i] = false;
}
@@ -1835,7 +1835,7 @@
UINT vol = pChn->rowCommand.vol;
UINT cmd = pChn->rowCommand.command;
UINT param = pChn->rowCommand.param;
- bool bPorta = (cmd == CMD_TONEPORTAMENTO) || (cmd == CMD_TONEPORTAVOL) || (volcmd == VOLCMD_TONEPORTAMENTO);
+ bool bPorta = pChn->rowCommand.IsPortamento();
UINT nStartTick = 0;
pChn->isFirstTick = (m_PlayState.m_nTickCount == 0);
@@ -4943,6 +4943,11 @@
//---------------------------------------------------------------------------------
{
if (!period) return 0;
+ if(IsCompatibleMode(TRK_FASTTRACKER2))
+ {
+ // FT2's "RelocateTon" function actually rounds up and down, while GetNoteFromPeriod normally just truncates.
+ nFineTune += 64;
+ }
// This essentially implements std::lower_bound, with the difference that we don't need an iterable container.
uint32 minNote = NOTE_MIN, maxNote = NOTE_MAX, count = maxNote - minNote + 1;
const bool periodIsFreq = m_SongFlags[SONG_LINEARSLIDES] && GetType() != MOD_TYPE_XM;
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-06 20:48:55 UTC (rev 4555)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-07 00:46:39 UTC (rev 4556)
@@ -133,25 +133,19 @@
static void ApplyStereoSeparation(mixsample_t *mixBuf, CSoundFile::samplecount_t count, int32 separation)
//-------------------------------------------------------------------------------------------------------
{
-#ifdef MPT_INTMIXER
- const mixsample_t fac1 = 64 + separation / 2, fac2 = 64 - separation / 2;
+ const mixsample_t fac1 = static_cast<mixsample_t>(64 + separation / 2), fac2 = static_cast<mixsample_t>(64 - separation / 2);
for(CSoundFile::samplecount_t i = 0; i < count; i++)
{
- mixsample_t l = mixBuf[0], r = mixBuf[1];
+ const mixsample_t l = mixBuf[0], r = mixBuf[1];
+#ifdef MPT_INTMIXER
mixBuf[0] = static_cast<mixsample_t>((Util::mul32to64(l, fac1) + Util::mul32to64(r, fac2)) >> 7);
mixBuf[1] = static_cast<mixsample_t>((Util::mul32to64(l, fac2) + Util::mul32to64(r, fac1)) >> 7);
- mixBuf += 2;
- }
#else
- const mixsample_t fac1 = static_cast<mixsample_t>(64 + separation / 2), fac2 = static_cast<mixsample_t>(64 - separation / 2);
- for(CSoundFile::samplecount_t i = 0; i < count; i++)
- {
- mixsample_t l = mixBuf[0], r = mixBuf[1];
mixBuf[0] = (l * fac1 + r * fac2) / mixsample_t(128);
mixBuf[1] = (l * fac2 + r * fac1) / mixsample_t(128);
+#endif
mixBuf += 2;
}
-#endif
}
@@ -539,7 +533,7 @@
pChn->rightVol = pChn->newRightVol;
pChn->leftVol = pChn->newLeftVol;
- pChn->dwFlags.reset(CHN_PORTAMENTO | CHN_VIBRATO | CHN_TREMOLO | CHN_PANBRELLO);
+ pChn->dwFlags.reset(CHN_VIBRATO | CHN_TREMOLO | CHN_PANBRELLO);
pChn->nCommand = CMD_NONE;
pChn->m_plugParamValueStep = 0;
}
@@ -1211,15 +1205,9 @@
{
switch(m_PlayState.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 & 0x0F; //Gives the latter number in the parameter.
- break;
+ case 0: arpeggioSteps = 0; break;
+ case 1: arpeggioSteps = pChn->nArpeggio >> 4; break;
+ case 2: arpeggioSteps = pChn->nArpeggio & 0x0F; break;
}
pChn->m_CalculateFreq = true;
pChn->m_ReCalculateFreqOnFirstTick = true;
@@ -1867,8 +1855,8 @@
period = pChn->nPeriod;
// When glissando mode is set to semitones, clamp to the next halftone.
- if((pChn->dwFlags[CHN_GLISSANDO] && IsCompatibleMode(TRK_ALLTRACKERS))
- || ((pChn->dwFlags & (CHN_GLISSANDO | CHN_PORTAMENTO)) == (CHN_GLISSANDO | CHN_PORTAMENTO) && !IsCompatibleMode(TRK_ALLTRACKERS)))
+ if((pChn->dwFlags & (CHN_GLISSANDO | CHN_PORTAMENTO)) == (CHN_GLISSANDO | CHN_PORTAMENTO)
+ && (!m_SongFlags[SONG_PT1XMODE] || (pChn->rowCommand.IsPortamento() && !m_SongFlags[SONG_FIRSTTICK])))
{
if(period != pChn->cachedPeriod)
{
Modified: trunk/OpenMPT/soundlib/modcommand.h
===================================================================
--- trunk/OpenMPT/soundlib/modcommand.h 2014-11-06 20:48:55 UTC (rev 4555)
+++ trunk/OpenMPT/soundlib/modcommand.h 2014-11-07 00:46:39 UTC (rev 4556)
@@ -174,6 +174,8 @@
// Returns true if and only if note is a valid musical note or the note entry is empty.
bool IsNoteOrEmpty() const { return note == NOTE_NONE || IsNote(); }
static bool IsNoteOrEmpty(NOTE note) { return note == NOTE_NONE || IsNote(note); }
+ // Returns true if any of the commands in this cell trigger a tone portamento.
+ bool IsPortamento() const { return command == CMD_TONEPORTAMENTO || command == CMD_TONEPORTAVOL || volcmd == VOLCMD_TONEPORTAMENTO; }
static EffectType GetEffectType(COMMAND cmd);
EffectType GetEffectType() const { return GetEffectType(command); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-11-07 21:13:17
|
Revision: 4558
http://sourceforge.net/p/modplug/code/4558
Author: saga-games
Date: 2014-11-07 21:13:10 +0000 (Fri, 07 Nov 2014)
Log Message:
-----------
[Ref] Convert InstrumentEnvelope::GetValueFromPosition back to using fixed point integer (fix possible performance loss on CPUs without hard floats, since this function may be called somewhat frequently in the mixer, and we really don't need floats here)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ModInstrument.cpp
trunk/OpenMPT/soundlib/ModInstrument.h
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/ModInstrument.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModInstrument.cpp 2014-11-07 10:55:50 UTC (rev 4557)
+++ trunk/OpenMPT/soundlib/ModInstrument.cpp 2014-11-07 21:13:10 UTC (rev 4558)
@@ -49,7 +49,7 @@
if(Ticks[nLoopEnd] - 1 > Ticks[nLoopEnd - 1])
{
// Insert an interpolated point just before the loop point.
- uint8 interpolatedValue = Util::Round<uint8>(GetValueFromPosition(Ticks[nLoopEnd] - 1) * 64.0f);
+ uint8 interpolatedValue = static_cast<uint8>(GetValueFromPosition(Ticks[nLoopEnd] - 1, 64));
if(nNodes + 1 < MAX_ENVPOINTS)
@@ -77,10 +77,11 @@
// Get envelope value at a given tick. Returns value in range [0.0, 1.0].
-float InstrumentEnvelope::GetValueFromPosition(int position, int range) const
-//---------------------------------------------------------------------------
+int32 InstrumentEnvelope::GetValueFromPosition(int position, int32 rangeOut, int32 rangeIn) const
+//-----------------------------------------------------------------------------------------------
{
uint32 pt = nNodes - 1u;
+ const int32 ENV_PRECISION = 1 << 16;
// Checking where current 'tick' is relative to the envelope points.
for(uint32 i = 0; i < nNodes - 1u; i++)
@@ -93,12 +94,12 @@
}
int x2 = Ticks[pt];
- float value = 0.0f;
+ int32 value = 0;
if(position >= x2)
{
// Case: current 'tick' is on a envelope point.
- value = static_cast<float>(Values[pt]) / float(range);
+ value = Values[pt] * ENV_PRECISION / rangeIn;
} else
{
// Case: current 'tick' is between two envelope points.
@@ -107,7 +108,7 @@
if(pt)
{
// Get previous node's value and tick.
- value = static_cast<float>(Values[pt - 1]) / float(range);
+ value = Values[pt - 1] * ENV_PRECISION / rangeIn;
x1 = Ticks[pt - 1];
}
@@ -115,11 +116,12 @@
{
// Linear approximation between the points;
// f(x + d) ~ f(x) + f'(x) * d, where f'(x) = (y2 - y1) / (x2 - x1)
- value += ((position - x1) * (static_cast<float>(Values[pt]) / float(range) - value)) / (x2 - x1);
+ value += ((position - x1) * (Values[pt] * ENV_PRECISION / rangeIn - value)) / (x2 - x1);
}
}
- return Clamp(value, 0.0f, 1.0f);
+ Limit(value, 0, ENV_PRECISION);
+ return (value * rangeOut + ENV_PRECISION / 2) / ENV_PRECISION;
}
Modified: trunk/OpenMPT/soundlib/ModInstrument.h
===================================================================
--- trunk/OpenMPT/soundlib/ModInstrument.h 2014-11-07 10:55:50 UTC (rev 4557)
+++ trunk/OpenMPT/soundlib/ModInstrument.h 2014-11-07 21:13:10 UTC (rev 4558)
@@ -44,8 +44,9 @@
// Convert envelope data between various formats.
void Convert(MODTYPE fromType, MODTYPE toType);
- // Get envelope value at a given tick. Returns value in range [0.0, 1.0].
- float GetValueFromPosition(int position, int range = ENVELOPE_MAX) const;
+ // Get envelope value at a given tick. Assumes that the envelope data is in rage [0, rangeIn],
+ // returns value in range [0, rangeOut].
+ int32 GetValueFromPosition(int position, int32 rangeOut, int32 rangeIn = ENVELOPE_MAX) const;
};
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-11-07 10:55:50 UTC (rev 4557)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2014-11-07 21:13:10 UTC (rev 4558)
@@ -4773,7 +4773,7 @@
if (pIns->VolEnv.nReleaseNode != ENV_RELEASE_NODE_UNSET)
{
- pChn->VolEnv.nEnvValueAtReleaseJump = Util::Round<int32>(pIns->VolEnv.GetValueFromPosition(pChn->VolEnv.nEnvPosition) * 256.0f);
+ pChn->VolEnv.nEnvValueAtReleaseJump = pIns->VolEnv.GetValueFromPosition(pChn->VolEnv.nEnvPosition, 256);
pChn->VolEnv.nEnvPosition = pIns->VolEnv.Ticks[pIns->VolEnv.nReleaseNode];
}
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-07 10:55:50 UTC (rev 4557)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-07 21:13:10 UTC (rev 4558)
@@ -816,7 +816,7 @@
}
const int envpos = pChn->VolEnv.nEnvPosition - (IsCompatibleMode(TRK_IMPULSETRACKER) ? 1 : 0);
// Get values in [0, 256]
- int envval = Util::Round<int>(pIns->VolEnv.GetValueFromPosition(envpos) * 256.0f);
+ int envval = pIns->VolEnv.GetValueFromPosition(envpos, 256);
// if we are in the release portion of the envelope,
// rescale envelope factor so that it is proportional to the release point
@@ -858,7 +858,7 @@
const int envpos = pChn->PanEnv.nEnvPosition - (IsCompatibleMode(TRK_IMPULSETRACKER) ? 1 : 0);
// Get values in [-32, 32]
- const int envval = Util::Round<int>((pIns->PanEnv.GetValueFromPosition(envpos) - 0.5f) * 64.0f);
+ const int envval = pIns->PanEnv.GetValueFromPosition(envpos, 64) - 32;
int pan = pChn->nRealPan;
if(pan >= 128)
@@ -890,15 +890,15 @@
const int envpos = pChn->PitchEnv.nEnvPosition - (IsCompatibleMode(TRK_IMPULSETRACKER) ? 1 : 0);
// Get values in [-256, 256]
#ifdef MODPLUG_TRACKER
- const int range = ENVELOPE_MAX;
- const float amp = 512.0f;
+ const int32 range = ENVELOPE_MAX;
+ const int32 amp = 512;
#else
// TODO: AMS2 envelopes behave differently when linear slides are off - emulate with 15 * (-128...127) >> 6
// Copy over vibrato behaviour for that?
- const int range = GetType() == MOD_TYPE_AMS2 ? uint8_max : ENVELOPE_MAX;
- const float amp = GetType() == MOD_TYPE_AMS2 ? 64.0f : 512.0f;
+ const int32 range = GetType() == MOD_TYPE_AMS2 ? uint8_max : ENVELOPE_MAX;
+ const int32 amp = GetType() == MOD_TYPE_AMS2 ? 64 : 512;
#endif
- const int envval = Util::Round<int>((pIns->PitchEnv.GetValueFromPosition(envpos, range) - 0.5f) * amp);
+ const int envval = pIns->PitchEnv.GetValueFromPosition(envpos, amp, range) - amp / 2;
if(pChn->PitchEnv.flags[ENV_FILTER])
{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2014-12-01 16:58:37
|
Revision: 4622
http://sourceforge.net/p/modplug/code/4622
Author: saga-games
Date: 2014-12-01 16:58:22 +0000 (Mon, 01 Dec 2014)
Log Message:
-----------
[Ref] Move external sample loading from individual loaders to CSoundFile::Create.
[Fix] When an external sample could not be found, its loop points were lost.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Load_mt2.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2014-12-01 13:52:00 UTC (rev 4621)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-12-01 16:58:22 UTC (rev 4622)
@@ -17,7 +17,7 @@
#include "../mptrack/TrackerSettings.h"
#endif // MODPLUG_TRACKER
#ifdef MPT_EXTERNAL_SAMPLES
-#include "../common/mptFileIO.h"
+#include "../common/mptPathString.h"
#endif // MPT_EXTERNAL_SAMPLES
#include "../common/mptIO.h"
#include "../common/serialization_utils.h"
@@ -642,28 +642,7 @@
std::string filenameU8;
file.ReadString<mpt::String::maybeNullTerminated>(filenameU8, strLen);
#ifdef MPT_EXTERNAL_SAMPLES
- mpt::PathString filename = mpt::PathString::FromUTF8(filenameU8);
-
- if(!filename.empty())
- {
- if(!file.GetFileName().empty())
- {
- filename = filename.RelativePathToAbsolute(file.GetFileName().GetPath());
- } else if(GetpModDoc() != nullptr)
- {
- filename = filename.RelativePathToAbsolute(GetpModDoc()->GetPathNameMpt().GetPath());
- }
- if(!LoadExternalSample(i + 1, filename))
- {
-#ifndef MODPLUG_TRACKER
- // OpenMPT has its own way of reporting this error
- AddToLog(LogError, mpt::String::Print(MPT_USTRING("Unable to load sample %1: %2"), i, filename.ToUnicode()));
-#endif // MODPLUG_TRACKER
- }
- } else
- {
- sample.uFlags.reset(SMP_KEEPONDISK);
- }
+ SetSamplePath(i + 1, mpt::PathString::FromUTF8(filenameU8));
#else
AddToLog(LogWarning, mpt::String::Print(MPT_USTRING("Loading external sample %1 ('%2') failed: External samples are not supported."), i, mpt::ToUnicode(mpt::CharsetUTF8, filenameU8)));
#endif // MPT_EXTERNAL_SAMPLES
Modified: trunk/OpenMPT/soundlib/Load_mt2.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-12-01 13:52:00 UTC (rev 4621)
+++ trunk/OpenMPT/soundlib/Load_mt2.cpp 2014-12-01 16:58:22 UTC (rev 4622)
@@ -13,10 +13,7 @@
#include "Loaders.h"
#ifdef MPT_EXTERNAL_SAMPLES
// For loading external samples
-#include "../common/mptFileIO.h"
-#ifdef MODPLUG_TRACKER
-#include "../mptrack/Moddoc.h"
-#endif // MODPLUG_TRACKER
+#include "../common/mptPathString.h"
#endif // MPT_EXTERNAL_SAMPLES
OPENMPT_NAMESPACE_BEGIN
@@ -1057,36 +1054,14 @@
mpt::String::Copy(mptSmp.filename, filename);
#ifdef MPT_EXTERNAL_SAMPLES
- mpt::PathString path(mpt::PathString::FromLocale(filename));
- mpt::PathString mt2FileName;
- if(!file.GetFileName().empty())
+ if(filename.length() >= 2
+ && filename.at(0) != '\\' // Relative path on same drive
+ && filename.at(1) != ':') // Absolute path
{
- mt2FileName = file.GetFileName();
-#ifdef MODPLUG_TRACKER
- } else if(GetpModDoc() != nullptr)
- {
- mt2FileName = GetpModDoc()->GetPathNameMpt();
-#endif // MODPLUG_TRACKER
+ // Relative path in same folder or sub folder
+ filename = ".\\" + filename;
}
- if(!mt2FileName.empty())
- {
- std::wstring pathStart = path.ToWide().substr(0, 2);
- if(pathStart.length() >= 2
- && pathStart.at(0) != L'\\'
- && pathStart.at(1) != L':')
- {
- // Relative path in sub directory
- path = MPT_PATHSTRING(".\\") + path;
- }
- path = path.RelativePathToAbsolute(mt2FileName.GetPath());
- }
- if(!LoadExternalSample(i + 1, path))
- {
-#ifndef MODPLUG_TRACKER
- // OpenMPT has its own way of reporting this error
- AddToLog(LogError, mpt::String::Print(MPT_USTRING("Unable to load sample %1: %2"), i, path.ToUnicode()));
-#endif // MODPLUG_TRACKER
- }
+ SetSamplePath(i + 1, mpt::PathString::FromLocale(filename));
#else
#if defined(MPT_WITH_CHARSET_LOCALE)
AddToLog(LogWarning, mpt::String::Print(MPT_USTRING("Loading external sample %1 ('%2') failed: External samples are not supported."), i, mpt::ToUnicode(mpt::CharsetLocale, filename)));
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-12-01 13:52:00 UTC (rev 4621)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-12-01 16:58:22 UTC (rev 4622)
@@ -850,26 +850,50 @@
m_PlayState.Chn[ich].Reset(ModChannel::resetTotal, *this, ich);
}
- // Checking samples
- ModSample *pSmp = Samples;
- for(SAMPLEINDEX nSmp = 0; nSmp < MAX_SAMPLES; nSmp++, pSmp++)
+ // Checking samples, load external samples
+ for(SAMPLEINDEX nSmp = 1; nSmp < MAX_SAMPLES; nSmp++)
{
// Adjust song / sample names
mpt::String::SetNullTerminator(m_szNames[nSmp]);
+ ModSample &sample = Samples[nSmp];
- if(pSmp->pSample)
+#ifdef MPT_EXTERNAL_SAMPLES
+ if(SampleHasPath(nSmp))
{
- pSmp->PrecomputeLoops(*this, false);
+ mpt::PathString filename = GetSamplePath(nSmp);
+ if(!file.GetFileName().empty())
+ {
+ filename = filename.RelativePathToAbsolute(file.GetFileName().GetPath());
+ } else if(GetpModDoc() != nullptr)
+ {
+ filename = filename.RelativePathToAbsolute(GetpModDoc()->GetPathNameMpt().GetPath());
+ }
+ if(!LoadExternalSample(nSmp, filename))
+ {
+#ifndef MODPLUG_TRACKER
+ // OpenMPT has its own way of reporting this error in CModDoc.
+ AddToLog(LogError, mpt::String::Print(MPT_USTRING("Unable to load sample %1: %2"), i, filename.ToUnicode()));
+#endif // MODPLUG_TRACKER
+ }
} else
{
- pSmp->nLength = 0;
- pSmp->nLoopStart = 0;
- pSmp->nLoopEnd = 0;
- pSmp->nSustainStart = 0;
- pSmp->nSustainEnd = 0;
- pSmp->uFlags.reset(CHN_LOOP | CHN_PINGPONGLOOP | CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN);
+ sample.uFlags.reset(SMP_KEEPONDISK);
}
- if(pSmp->nGlobalVol > 64) pSmp->nGlobalVol = 64;
+#endif // MPT_EXTERNAL_SAMPLES
+
+ if(sample.pSample)
+ {
+ sample.PrecomputeLoops(*this, false);
+ } else if(!sample.uFlags[SMP_KEEPONDISK])
+ {
+ sample.nLength = 0;
+ sample.nLoopStart = 0;
+ sample.nLoopEnd = 0;
+ sample.nSustainStart = 0;
+ sample.nSustainEnd = 0;
+ sample.uFlags.reset(CHN_LOOP | CHN_PINGPONGLOOP | CHN_SUSTAINLOOP | CHN_PINGPONGSUSTAIN);
+ }
+ if(sample.nGlobalVol > 64) sample.nGlobalVol = 64;
}
// Check invalid instruments
while ((m_nInstruments > 0) && (!Instruments[m_nInstruments])) m_nInstruments--;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2015-01-11 18:21:48
|
Revision: 4713
http://sourceforge.net/p/modplug/code/4713
Author: saga-games
Date: 2015-01-11 18:21:36 +0000 (Sun, 11 Jan 2015)
Log Message:
-----------
[Fix] IT compatibility: Default sample and instrument panning should only be reset by notes, not instrument numbers.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.h
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-01-11 17:34:09 UTC (rev 4712)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-01-11 18:21:36 UTC (rev 4713)
@@ -1003,47 +1003,29 @@
if (pIns && ((!IsCompatibleMode(TRK_IMPULSETRACKER) && pSmp) || pIns->nMixPlug))
pChn->nNNA = pIns->nNNA;
- if (pSmp)
+ // Update volume
+ if (pIns)
{
- if (pIns)
+ pChn->nInsVol = pIns->nGlobalVol;
+ if(pSmp != nullptr)
{
- pChn->nInsVol = (pSmp->nGlobalVol * pIns->nGlobalVol) >> 6;
- // Default instrument panning
- if(pIns->dwFlags[INS_SETPANNING])
- {
- pChn->nPan = pIns->nPan;
- // IT compatibility: Sample and instrument panning overrides channel surround status.
- // Test case: SmpInsPanSurround.it
- if(IsCompatibleMode(TRK_IMPULSETRACKER) && !m_SongFlags[SONG_SURROUNDPAN])
- {
- pChn->dwFlags.reset(CHN_SURROUND);
- }
- }
- } else
- {
- pChn->nInsVol = pSmp->nGlobalVol;
+ pChn->nInsVol = (pSmp->nGlobalVol * pChn->nInsVol) >> 6;
}
+ } else if (pSmp != nullptr)
+ {
+ pChn->nInsVol = pSmp->nGlobalVol;
+ }
- // Default sample panning
- if(pSmp->uFlags[CHN_PANNING] && (bUpdVol || !(GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))))
- {
- // FT2 compatibility: Only reset panning on instrument numbers, not notes (bUpdVol condition)
- // Test case: PanMemory.xm
- pChn->nPan = pSmp->nPan;
-
- // IT compatibility: Sample and instrument panning overrides channel surround status.
- // Test case: SmpInsPanSurround.it
- if(IsCompatibleMode(TRK_IMPULSETRACKER) && !m_SongFlags[SONG_SURROUNDPAN])
- {
- pChn->dwFlags.reset(CHN_SURROUND);
- }
- }
- } else if(pIns && pIns->HasValidMIDIChannel())
+ // Update panning
+ // FT2 compatibility: Only reset panning on instrument numbers, not notes (bUpdVol condition)
+ // Test case: PanMemory.xm
+ // IT compatibility: Sample and instrument panning is only applied on note change, not instrument change
+ // Test case: PanReset.it
+ if((bUpdVol || !(GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))) && !IsCompatibleMode(TRK_IMPULSETRACKER))
{
- pChn->nInsVol = pIns->nGlobalVol;
+ ApplyInstrumentPanning(pChn, pIns, pSmp);
}
-
// Reset envelopes
if(bResetEnv)
{
@@ -1344,6 +1326,10 @@
UINT period = GetPeriodFromNote(note, pChn->nFineTune, pChn->nC5Speed);
pChn->nPanbrelloOffset = 0;
+ // IT compatibility: Sample and instrument panning is only applied on note change, not instrument change
+ // Test case: PanReset.it
+ if(IsCompatibleMode(TRK_IMPULSETRACKER)) ApplyInstrumentPanning(pChn, pIns, pSmp);
+
if(!pSmp) return;
if(period)
{
@@ -1562,7 +1548,38 @@
{
if (!bManual) pChn->nPeriod = 0;
}
+}
+
+// Apply sample or instrumernt panning
+void CSoundFile::ApplyInstrumentPanning(ModChannel *pChn, const ModInstrument *instr, const ModSample *smp) const
+//---------------------------------------------------------------------------------------------------------------
+{
+ int32_t newPan = int32_min;
+ if(instr != nullptr)
+ {
+ // Default instrument panning
+ if(instr->dwFlags[INS_SETPANNING])
+ {
+ newPan = instr->nPan;
+ }
+ }
+
+ // Default sample panning
+ if(smp != nullptr && smp->uFlags[CHN_PANNING])
+ {
+ newPan = smp->nPan;
+ }
+ if(newPan != int32_min)
+ {
+ pChn->nPan = newPan;
+ // IT compatibility: Sample and instrument panning overrides channel surround status.
+ // Test case: SmpInsPanSurround.it
+ if(IsCompatibleMode(TRK_IMPULSETRACKER) && !m_SongFlags[SONG_SURROUNDPAN])
+ {
+ pChn->dwFlags.reset(CHN_SURROUND);
+ }
+ }
}
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2015-01-11 17:34:09 UTC (rev 4712)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2015-01-11 18:21:36 UTC (rev 4713)
@@ -775,6 +775,7 @@
void CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut);
void NoteChange(ModChannel *pChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false) const;
void InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true) const;
+ void ApplyInstrumentPanning(ModChannel *pChn, const ModInstrument *instr, const ModSample *smp) const;
// Channel Effects
void KeyOff(ModChannel *pChn) const;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2015-01-24 18:04:21
|
Revision: 4733
http://sourceforge.net/p/modplug/code/4733
Author: saga-games
Date: 2015-01-24 18:04:15 +0000 (Sat, 24 Jan 2015)
Log Message:
-----------
[Fix] In IT linear slide mode, frequency fixes were done the wrong way around when sliding less than 1Hz up or down and prevent pointless note stopping in IT files if the frequency drops below a certain point (there is no reason for this behaviour).
[Mod] Allow loading IT files with tempo 31 normally.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2015-01-23 22:51:31 UTC (rev 4732)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2015-01-24 18:04:15 UTC (rev 4733)
@@ -431,7 +431,7 @@
m_nDefaultGlobalVolume = fileHeader.globalvol << 1;
if(m_nDefaultGlobalVolume > MAX_GLOBAL_VOLUME) m_nDefaultGlobalVolume = MAX_GLOBAL_VOLUME;
if(fileHeader.speed) m_nDefaultSpeed = fileHeader.speed;
- m_nDefaultTempo = std::max(uint8(32), fileHeader.tempo); // Tempo 31 is possible. due to conflicts with the rest of the engine, let's just clamp it to 32.
+ m_nDefaultTempo = std::max(uint8(31), fileHeader.tempo);
m_nSamplePreAmp = std::min(fileHeader.mv, uint8(128));
// Reading Channels Pan Positions
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-01-23 22:51:31 UTC (rev 4732)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2015-01-24 18:04:15 UTC (rev 4733)
@@ -4712,7 +4712,7 @@
{
if (n > 255) n = 255;
pChn->nPeriod = Util::muldivr(pChn->nPeriod, LinearSlideUpTable[n], 65536);
- if (pChn->nPeriod == nOldPeriod) pChn->nPeriod = nOldPeriod-1;
+ if (pChn->nPeriod == nOldPeriod) pChn->nPeriod = nOldPeriod + 1;
}
} else
{
@@ -4721,22 +4721,14 @@
{
if (n > 255) n = 255;
pChn->nPeriod = Util::muldivr(pChn->nPeriod, LinearSlideDownTable[n], 65536);
- if (pChn->nPeriod == nOldPeriod) pChn->nPeriod = nOldPeriod+1;
+ if (pChn->nPeriod == nOldPeriod) pChn->nPeriod = nOldPeriod - 1;
}
}
} else
{
pChn->nPeriod += nFreqSlide;
}
- if(pChn->nPeriod < 1)
- {
- pChn->nPeriod = 1;
- if(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))
- {
- pChn->dwFlags.set(CHN_NOTEFADE);
- pChn->nFadeOutVol = 0;
- }
- }
+ if(pChn->nPeriod < 1) pChn->nPeriod = 1;
}
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2015-01-23 22:51:31 UTC (rev 4732)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2015-01-24 18:04:15 UTC (rev 4733)
@@ -899,7 +899,7 @@
// Check invalid instruments
while ((m_nInstruments > 0) && (!Instruments[m_nInstruments])) m_nInstruments--;
// Set default values
- if (m_nDefaultTempo < 32) m_nDefaultTempo = 125;
+ if (!m_nDefaultTempo) m_nDefaultTempo = 125;
if (!m_nDefaultSpeed) m_nDefaultSpeed = 6;
m_PlayState.m_nMusicSpeed = m_nDefaultSpeed;
m_PlayState.m_nMusicTempo = m_nDefaultTempo;
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2015-01-23 22:51:31 UTC (rev 4732)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2015-01-24 18:04:15 UTC (rev 4733)
@@ -1743,14 +1743,6 @@
freq = Util::muldivr(freq, m_PlayState.m_nMusicTempo, pIns->wPitchToTempoLock);
}
- if ((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && (freq < 256))
- {
- pChn->nFadeOutVol = 0;
- pChn->dwFlags.set(CHN_NOTEFADE);
- pChn->nRealVolume = 0;
- pChn->nCalcVolume = 0;
- }
-
return Util::muldivr(freq, 0x10000, m_MixerSettings.gdwMixingFreq << FREQ_FRACBITS);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2015-03-01 14:49:18
|
Revision: 4799
http://sourceforge.net/p/modplug/code/4799
Author: saga-games
Date: 2015-03-01 14:49:12 +0000 (Sun, 01 Mar 2015)
Log Message:
-----------
[Ref] Small chances here and there with no change in functionality
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ModInstrument.cpp
trunk/OpenMPT/soundlib/ModSample.cpp
trunk/OpenMPT/soundlib/ModSequence.cpp
trunk/OpenMPT/soundlib/modcommand.cpp
trunk/OpenMPT/soundlib/patternContainer.cpp
trunk/OpenMPT/soundlib/patternContainer.h
Modified: trunk/OpenMPT/soundlib/ModInstrument.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModInstrument.cpp 2015-03-01 12:30:39 UTC (rev 4798)
+++ trunk/OpenMPT/soundlib/ModInstrument.cpp 2015-03-01 14:49:12 UTC (rev 4799)
@@ -76,7 +76,8 @@
}
-// Get envelope value at a given tick. Returns value in range [0.0, 1.0].
+// Get envelope value at a given tick. Assumes that the envelope data is in rage [0, rangeIn],
+// returns value in range [0, rangeOut].
int32 InstrumentEnvelope::GetValueFromPosition(int position, int32 rangeOut, int32 rangeIn) const
//-----------------------------------------------------------------------------------------------
{
@@ -202,7 +203,7 @@
nMidiChannel = 1;
}
- // FT2 only has signed Pitch Wheel Depth, and it's limited to 0...36 (in the GUI, at least. As you would expect it from FT2, this value is actually not sanitized on load).
+ // FT2 only has unsigned Pitch Wheel Depth, and it's limited to 0...36 (in the GUI, at least. As you would expect it from FT2, this value is actually not sanitized on load).
midiPWD = static_cast<int8>(abs(midiPWD));
Limit(midiPWD, int8(0), int8(36));
Modified: trunk/OpenMPT/soundlib/ModSample.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModSample.cpp 2015-03-01 12:30:39 UTC (rev 4798)
+++ trunk/OpenMPT/soundlib/ModSample.cpp 2015-03-01 14:49:12 UTC (rev 4799)
@@ -193,7 +193,7 @@
const SmpLength maxSize = Util::MaxValueOfType(numSamples);
const SmpLength lookaheadBufferSize = 16 + (1 + 4 + 4) * InterpolationMaxLookahead;
- if(numSamples > maxSize || lookaheadBufferSize > maxSize - numSamples)
+ if(numSamples > MAX_SAMPLE_LENGTH || lookaheadBufferSize > maxSize - numSamples)
{
return 0;
}
Modified: trunk/OpenMPT/soundlib/ModSequence.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModSequence.cpp 2015-03-01 12:30:39 UTC (rev 4798)
+++ trunk/OpenMPT/soundlib/ModSequence.cpp 2015-03-01 14:49:12 UTC (rev 4799)
@@ -492,7 +492,7 @@
{
#ifdef MODPLUG_TRACKER
// Allow conversion only if there's only one sequence.
- if(GetNumSequences() != 1 || m_sndFile.GetType() != MOD_TYPE_MPT)
+ if(GetNumSequences() != 1 || m_sndFile.GetModSpecifications().sequencesMax <= 1)
return false;
bool hasSepPatterns = false;
@@ -554,7 +554,7 @@
{
if(m->command == CMD_POSITIONJUMP && m->param >= startOrd)
{
- m->param = static_cast<BYTE>(m->param - startOrd);
+ m->param = static_cast<ModCommand::PARAM>(m->param - startOrd);
}
}
}
@@ -639,7 +639,7 @@
m_sndFile.AddToLog(mpt::String::Print("CONFLICT: Pattern break commands in Pattern %1 might be broken since it has been used in several sequences!", nPat));
}
}
- m->param = static_cast<BYTE>(m->param + nFirstOrder);
+ m->param = static_cast<ModCommand::PARAM>(m->param + nFirstOrder);
patternsFixed[nPat] = removedSequences;
}
}
Modified: trunk/OpenMPT/soundlib/modcommand.cpp
===================================================================
--- trunk/OpenMPT/soundlib/modcommand.cpp 2015-03-01 12:30:39 UTC (rev 4798)
+++ trunk/OpenMPT/soundlib/modcommand.cpp 2015-03-01 14:49:12 UTC (rev 4799)
@@ -375,10 +375,6 @@
}
break;
- case CMD_SPEED:
- param = std::min<PARAM>(param, (toType == MOD_TYPE_XM) ? 0x1F : 0x20);
- break;
-
case CMD_TEMPO:
if(param < 0x20) command = CMD_NONE; // no tempo slides
break;
@@ -487,26 +483,21 @@
} // End if(oldTypeIsIT_MPT && newTypeIsXM)
///////////////////////////////////
- // MOD <-> XM: Speed/Tempo update
- if(oldTypeIsMOD && newTypeIsXM)
+ // MOD / XM Speed/Tempo limits
+ if(newTypeIsMOD_XM)
{
switch(command)
{
case CMD_SPEED:
- param = std::min<PARAM>(param, 0x1F);
+ param = std::min<PARAM>(param, (toType == MOD_TYPE_XM) ? 0x1F : 0x20);
break;
- }
- } else if(oldTypeIsXM && newTypeIsMOD)
- {
- switch(command)
- {
+ break;
case CMD_TEMPO:
- param = std::max<PARAM>(param, 0x21);
+ param = std::max<PARAM>(param, (toType == MOD_TYPE_XM) ? 0x20 : 0x21);
break;
}
}
-
///////////////////////////////////////////////////////////////////////
// Convert MOD to anything - adjust effect memory, remove Invert Loop
if(oldTypeIsMOD)
Modified: trunk/OpenMPT/soundlib/patternContainer.cpp
===================================================================
--- trunk/OpenMPT/soundlib/patternContainer.cpp 2015-03-01 12:30:39 UTC (rev 4798)
+++ trunk/OpenMPT/soundlib/patternContainer.cpp 2015-03-01 14:49:12 UTC (rev 4799)
@@ -91,19 +91,14 @@
m_Patterns[index].RemoveSignature();
m_Patterns[index].SetName("");
- if(!m_Patterns[index]) return false;
-
- return true;
+ return m_Patterns[index] != nullptr;
}
-bool CPatternContainer::Remove(const PATTERNINDEX ipat)
+void CPatternContainer::Remove(const PATTERNINDEX ipat)
//-----------------------------------------------------
{
- if(ipat >= m_Patterns.size())
- return true;
- m_Patterns[ipat].Deallocate();
- return false;
+ if(ipat < m_Patterns.size()) m_Patterns[ipat].Deallocate();
}
@@ -114,7 +109,7 @@
return false;
const ModCommand *m = m_Patterns[nPat].m_ModCommands;
- for(size_t i = m_Patterns[nPat].GetNumChannels() * m_Patterns[nPat].GetNumRows(); i > 0; i--, m++)
+ for(const ModCommand *mEnd = m + m_Patterns[nPat].GetNumChannels() * m_Patterns[nPat].GetNumRows(); m != mEnd; m++)
{
if(!m->IsEmpty(true))
return false;
@@ -123,17 +118,6 @@
}
-PATTERNINDEX CPatternContainer::GetIndex(const MODPATTERN* const pPat) const
-//--------------------------------------------------------------------------
-{
- const PATTERNINDEX endI = static_cast<PATTERNINDEX>(m_Patterns.size());
- for(PATTERNINDEX i = 0; i<endI; i++)
- if(&m_Patterns[i] == pPat) return i;
-
- return endI;
-}
-
-
void CPatternContainer::ResizeArray(const PATTERNINDEX newSize)
//-------------------------------------------------------------
{
@@ -246,7 +230,7 @@
nPatterns = nCount;
LimitMax(nPatterns, ModSpecs::mptm.patternsMax);
if (nPatterns > patc.Size())
- patc.ResizeArray(nPatterns);
+ patc.ResizeArray(nPatterns);
for(uint16 i = 0; i < nPatterns; i++)
{
ssb.ReadItem(patc[i], srlztn::ID::FromInt<uint16>(i), &ReadModPattern);
Modified: trunk/OpenMPT/soundlib/patternContainer.h
===================================================================
--- trunk/OpenMPT/soundlib/patternContainer.h 2015-03-01 12:30:39 UTC (rev 4798)
+++ trunk/OpenMPT/soundlib/patternContainer.h 2015-03-01 14:49:12 UTC (rev 4799)
@@ -61,7 +61,7 @@
//Remove pattern from given position. Currently it actually makes the pattern
//'invisible' - the pattern data is cleared but the actual pattern object won't get removed.
- bool Remove(const PATTERNINDEX index);
+ void Remove(const PATTERNINDEX index);
// Applies function object for modcommands in patterns in given range.
// Return: Copy of the function object.
@@ -75,9 +75,6 @@
CSoundFile& GetSoundFile() {return m_rSndFile;}
const CSoundFile& GetSoundFile() const {return m_rSndFile;}
- //Returns the index of given pattern, Size() if not found.
- PATTERNINDEX GetIndex(const MODPATTERN* const pPat) const;
-
// Return true if pattern can be accessed with operator[](iPat), false otherwise.
bool IsValidIndex(const PATTERNINDEX iPat) const {return (iPat < Size());}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|