|
From: <sag...@us...> - 2012-12-14 10:13:39
|
Revision: 1460
http://sourceforge.net/p/modplug/code/1460
Author: saga-games
Date: 2012-12-14 10:13:33 +0000 (Fri, 14 Dec 2012)
Log Message:
-----------
[Fix] XM instrument saving failed if there were samples in the sample map that were only referenced below C-1 or above B-8.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
trunk/OpenMPT/soundlib/XMTools.cpp
trunk/OpenMPT/soundlib/XMTools.h
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2012-12-12 23:02:43 UTC (rev 1459)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2012-12-14 10:13:33 UTC (rev 1460)
@@ -17,10 +17,7 @@
#include "XMTools.h"
#include <algorithm>
-////////////////////////////////////////////////////////
-// FastTracker II XM file support
-
// Allocate samples for an instrument
vector<SAMPLEINDEX> AllocateXMSamples(CSoundFile &sndFile, SAMPLEINDEX numSamples)
//--------------------------------------------------------------------------------
@@ -319,6 +316,7 @@
// Now, read the complete struct.
file.SkipBack(4);
file.ReadStructPartial(instrHeader, instrHeader.size);
+ instrHeader.ConvertEndianness();
// Time for some version detection stuff.
if(madeWith == verOldModPlug)
@@ -348,7 +346,6 @@
continue;
}
- instrHeader.ConvertEndianness();
instrHeader.ConvertToMPT(*Instruments[instr]);
if(instrHeader.numSamples > 0)
@@ -386,6 +383,7 @@
{
XMSample sampleHeader;
file.ReadStructPartial(sampleHeader, copyBytes);
+ sampleHeader.ConvertEndianness();
sampleFlags.push_back(sampleHeader.GetSampleFormat());
sampleSize[sample] = sampleHeader.length;
@@ -575,25 +573,25 @@
BYTE xmph[9];
bool addChannel = false; // avoid odd channel count for FT2 compatibility
- XMFileHeader xmheader;
- MemsetZero(xmheader);
+ XMFileHeader fileHeader;
+ MemsetZero(fileHeader);
- memcpy(xmheader.signature, "Extended Module: ", 17);
- StringFixer::WriteString<StringFixer::spacePadded>(xmheader.songName, m_szNames[0]);
- xmheader.eof = 0x1A;
- memcpy(xmheader.trackerName, "OpenMPT " MPT_VERSION_STR " ", 20);
+ memcpy(fileHeader.signature, "Extended Module: ", 17);
+ StringFixer::WriteString<StringFixer::spacePadded>(fileHeader.songName, m_szNames[0]);
+ fileHeader.eof = 0x1A;
+ memcpy(fileHeader.trackerName, "OpenMPT " MPT_VERSION_STR " ", 20);
// Writing song header
- xmheader.version = 0x0104; // XM Format v1.04
- xmheader.size = sizeof(XMFileHeader) - 60; // minus everything before this field
- xmheader.restartPos = m_nRestartPos;
+ fileHeader.version = 0x0104; // XM Format v1.04
+ fileHeader.size = sizeof(XMFileHeader) - 60; // minus everything before this field
+ fileHeader.restartPos = m_nRestartPos;
- xmheader.channels = (m_nChannels + 1) & 0xFFFE; // avoid odd channel count for FT2 compatibility
+ fileHeader.channels = (m_nChannels + 1) & 0xFFFE; // avoid odd channel count for FT2 compatibility
if((m_nChannels & 1) && m_nChannels < MAX_BASECHANNELS) addChannel = true;
- if(compatibilityExport && xmheader.channels > 32)
- xmheader.channels = 32;
- if(xmheader.channels > MAX_BASECHANNELS) xmheader.channels = MAX_BASECHANNELS;
- xmheader.channels = xmheader.channels;
+ if(compatibilityExport && fileHeader.channels > 32)
+ fileHeader.channels = 32;
+ if(fileHeader.channels > MAX_BASECHANNELS) fileHeader.channels = MAX_BASECHANNELS;
+ fileHeader.channels = fileHeader.channels;
// Find out number of orders and patterns used.
// +++ and --- patterns are not taken into consideration as FastTracker does not support them.
@@ -609,29 +607,29 @@
}
if(!compatibilityExport) nMaxOrds = Order.GetLengthTailTrimmed(); // should really be removed at some point
- xmheader.orders = nMaxOrds;
- xmheader.patterns = nPatterns;
- xmheader.size = xmheader.size + nMaxOrds;
+ fileHeader.orders = nMaxOrds;
+ fileHeader.patterns = nPatterns;
+ fileHeader.size = fileHeader.size + nMaxOrds;
uint16 writeInstruments;
if(m_nInstruments > 0)
- xmheader.instruments = writeInstruments = m_nInstruments;
+ fileHeader.instruments = writeInstruments = m_nInstruments;
else
- xmheader.instruments = writeInstruments = m_nSamples;
+ fileHeader.instruments = writeInstruments = m_nSamples;
- if(m_SongFlags[SONG_LINEARSLIDES]) xmheader.flags |= XMFileHeader::linearSlides;
- if(m_SongFlags[SONG_EXFILTERRANGE] && !compatibilityExport) xmheader.flags |= XMFileHeader::extendedFilterRange;
- xmheader.flags = xmheader.flags;
+ if(m_SongFlags[SONG_LINEARSLIDES]) fileHeader.flags |= XMFileHeader::linearSlides;
+ if(m_SongFlags[SONG_EXFILTERRANGE] && !compatibilityExport) fileHeader.flags |= XMFileHeader::extendedFilterRange;
+ fileHeader.flags = fileHeader.flags;
// if(compatibilityExport)
// xmheader.tempo = static_cast<uint16>(Clamp(m_nDefaultTempo, 32u, 255u));
// else
// Fasttracker 2 will happily accept any tempo faster than 255 BPM. XMPlay does also support this, great!
- xmheader.tempo = static_cast<uint16>(Clamp(m_nDefaultTempo, 32u, 512u));
- xmheader.speed = static_cast<uint16>(Clamp(m_nDefaultSpeed, 1u, 31u));
+ fileHeader.tempo = static_cast<uint16>(Clamp(m_nDefaultTempo, 32u, 512u));
+ fileHeader.speed = static_cast<uint16>(Clamp(m_nDefaultSpeed, 1u, 31u));
- xmheader.ConvertEndianness();
- fwrite(&xmheader, 1, sizeof(xmheader), f);
+ fileHeader.ConvertEndianness();
+ fwrite(&fileHeader, 1, sizeof(fileHeader), f);
// write order list (wihout +++ and ---, explained above)
for(ORDERINDEX ord = 0; ord < Order.GetLengthTailTrimmed(); ord++)
@@ -647,7 +645,7 @@
for(PATTERNINDEX pat = 0; pat < nPatterns; pat++) if (Patterns[pat])
{
ModCommand *p = Patterns[pat];
- UINT len = 0;
+ size_t len = 0;
// Empty patterns are always loaded as 64-row patterns in FT2, regardless of their real size...
bool emptyPattern = true;
@@ -656,7 +654,7 @@
xmph[5] = (BYTE)(Patterns[pat].GetNumRows() & 0xFF);
xmph[6] = (BYTE)(Patterns[pat].GetNumRows() >> 8);
- for (UINT j = m_nChannels * Patterns[pat].GetNumRows(); j > 0; j--, p++)
+ for (size_t j = m_nChannels * Patterns[pat].GetNumRows(); j > 0; j--, p++)
{
// Don't write more than 32 channels
if(compatibilityExport && m_nChannels - ((j - 1) % m_nChannels) > 32) continue;
@@ -852,6 +850,7 @@
StringFixer::WriteString<StringFixer::spacePadded>(xmSample.name, m_szNames[samples[smp]]);
+ xmSample.ConvertEndianness();
fwrite(&xmSample, 1, sizeof(xmSample), f);
}
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2012-12-12 23:02:43 UTC (rev 1459)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2012-12-14 10:13:33 UTC (rev 1460)
@@ -982,7 +982,7 @@
for(SAMPLEINDEX i = 0; i < fileHeader.numSamples; i++)
{
XMSample sampleHeader;
- if(!file.Read(sampleHeader)
+ if(!file.ReadConvertEndianness(sampleHeader)
|| !sampleMap[i])
{
continue;
@@ -1047,6 +1047,7 @@
header.instrument.ApplyAutoVibratoToXM(Samples[samples[0]], GetType());
}
+ header.ConvertEndianness();
fwrite(&header, 1, sizeof(XIInstrumentHeader), f);
vector<SampleIO> sampleFlags(samples.size());
@@ -1066,6 +1067,7 @@
StringFixer::WriteString<StringFixer::spacePadded>(xmSample.name, m_szNames[samples[i]]);
+ xmSample.ConvertEndianness();
fwrite(&xmSample, 1, sizeof(xmSample), f);
}
@@ -1111,7 +1113,7 @@
// Read first sample header
XMSample sampleHeader;
- file.Read(sampleHeader);
+ file.ReadConvertEndianness(sampleHeader);
// Gotta skip 'em all!
file.Skip(sizeof(XMSample) * (fileHeader.numSamples - 1));
Modified: trunk/OpenMPT/soundlib/XMTools.cpp
===================================================================
--- trunk/OpenMPT/soundlib/XMTools.cpp 2012-12-12 23:02:43 UTC (rev 1459)
+++ trunk/OpenMPT/soundlib/XMTools.cpp 2012-12-14 10:13:33 UTC (rev 1460)
@@ -32,6 +32,22 @@
}
+// Convert all multi-byte numeric values to current platform's endianness or vice versa.
+void XMInstrument::ConvertEndianness()
+//------------------------------------
+{
+ for(size_t i = 0; i < CountOf(volEnv); i++)
+ {
+ SwapBytesLE(volEnv[i]);
+ SwapBytesLE(panEnv[i]);
+ }
+ SwapBytesLE(volFade);
+ SwapBytesLE(midiProgram);
+ SwapBytesLE(pitchWheelRange);
+}
+
+
+
// Convert OpenMPT's internal envelope representation to XM envelope data.
void XMInstrument::ConvertEnvelopeToXM(const InstrumentEnvelope &mptEnv, uint8 &numPoints, uint8 &flags, uint8 &sustain, uint8 &loopStart, uint8 &loopEnd, uint16 (&envData)[24])
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
@@ -41,8 +57,8 @@
// Envelope Data
for(size_t i = 0; i < numPoints; i++)
{
- envData[i * 2] = LittleEndianW(min(mptEnv.Ticks[i], uint16_max));
- envData[i * 2 + 1] = LittleEndianW(mptEnv.Values[i]);
+ envData[i * 2] = Util::Min(mptEnv.Ticks[i], uint16_max);
+ envData[i * 2 + 1] = mptEnv.Values[i];
}
// Envelope Flags
@@ -59,13 +75,13 @@
// Convert OpenMPT's internal sample representation to an XMInstrument.
-void XMInstrument::ConvertToXM(const ModInstrument &mptIns, bool compatibilityExport)
-//-----------------------------------------------------------------------------------
+uint16 XMInstrument::ConvertToXM(const ModInstrument &mptIns, bool compatibilityExport)
+//-------------------------------------------------------------------------------------
{
MemsetZero(*this);
// FFF is maximum in the FT2 GUI, but it can also accept other values. MilkyTracker just allows 0...4095 and 32767 ("cut")
- volFade = static_cast<uint16>(LittleEndianW(min(mptIns.nFadeOut, 32767)));
+ volFade = static_cast<uint16>(Util::Min(mptIns.nFadeOut, uint32(32767)));
// Convert envelopes
ConvertEnvelopeToXM(mptIns.VolEnv, volPoints, volFlags, volSustain, volLoopStart, volLoopEnd, volEnv);
@@ -93,6 +109,8 @@
}
midiProgram = (mptIns.nMidiProgram != 0 ? mptIns.nMidiProgram - 1 : 0);
pitchWheelRange = Util::Min(mptIns.midiPWD, int8(36));
+
+ return static_cast<uint16>(sampleList.size());
}
@@ -136,8 +154,8 @@
// Envelope Data
for(size_t i = 0; i < 12; i++)
{
- mptEnv.Ticks[i] = static_cast<WORD>(LittleEndianW(envData[i * 2]));
- mptEnv.Values[i] = static_cast<BYTE>(LittleEndianW(envData[i * 2 + 1]));
+ mptEnv.Ticks[i] = envData[i * 2];
+ mptEnv.Values[i] = static_cast<uint8>(envData[i * 2 + 1]);
if(i > 0 && mptEnv.Ticks[i] < mptEnv.Ticks[i - 1])
{
@@ -235,6 +253,7 @@
SwapBytesLE(size);
SwapBytesLE(sampleHeaderSize);
SwapBytesLE(numSamples);
+ instrument.ConvertEndianness();
}
@@ -258,13 +277,10 @@
void XMInstrumentHeader::ConvertToXM(const ModInstrument &mptIns, bool compatibilityExport)
//-----------------------------------------------------------------------------------------
{
- instrument.ConvertToXM(mptIns, compatibilityExport);
-
+ numSamples = instrument.ConvertToXM(mptIns, compatibilityExport);
StringFixer::WriteString<StringFixer::spacePadded>(name, mptIns.name);
- type = mptIns.nMidiProgram; // If FT2 writes crap here, we can do so, too!
-
- numSamples = static_cast<uint16>(Util::Min(mptIns.GetSamples().size(), size_t(compatibilityExport ? 16 : 32)));
+ type = mptIns.nMidiProgram; // If FT2 writes crap here, we can do so, too! (we probably shouldn't, though.)
}
@@ -298,6 +314,7 @@
{
SwapBytesLE(version);
SwapBytesLE(numSamples);
+ instrument.ConvertEndianness();
}
@@ -305,7 +322,7 @@
void XIInstrumentHeader::ConvertToXM(const ModInstrument &mptIns, bool compatibilityExport)
//-----------------------------------------------------------------------------------------
{
- instrument.ConvertToXM(mptIns, compatibilityExport);
+ numSamples = instrument.ConvertToXM(mptIns, compatibilityExport);
memcpy(signature, "Extended Instrument: ", 21);
StringFixer::WriteString<StringFixer::spacePadded>(name, mptIns.name);
@@ -313,9 +330,7 @@
memcpy(trackerName, "Created by OpenMPT ", 20);
- version = LittleEndianW(0x102);
-
- numSamples = static_cast<uint16>(LittleEndianW(Util::Min(mptIns.GetSamples().size(), size_t(compatibilityExport ? 16 : 32))));
+ version = 0x102;
}
@@ -338,6 +353,16 @@
}
+// Convert all multi-byte numeric values to current platform's endianness or vice versa.
+void XMSample::ConvertEndianness()
+//--------------------------------
+{
+ SwapBytesLE(length);
+ SwapBytesLE(loopStart);
+ SwapBytesLE(loopLength);
+}
+
+
// Convert OpenMPT's internal sample representation to an XMSample.
void XMSample::ConvertToXM(const ModSample &mptSmp, MODTYPE fromType, bool compatibilityExport)
//---------------------------------------------------------------------------------------------
@@ -386,10 +411,6 @@
loopStart *= 2;
loopLength *= 2;
}
-
- SwapBytesLE(length);
- SwapBytesLE(loopStart);
- SwapBytesLE(loopLength);
}
@@ -412,9 +433,9 @@
mptSmp.RelativeTone = relnote;
// Sample Length and Loops
- mptSmp.nLength = LittleEndian(length);
- mptSmp.nLoopStart = LittleEndian(loopStart);
- mptSmp.nLoopEnd = mptSmp.nLoopStart + LittleEndian(loopLength);
+ mptSmp.nLength = length;
+ mptSmp.nLoopStart = loopStart;
+ mptSmp.nLoopEnd = mptSmp.nLoopStart + loopLength;
if((flags & XMSample::sample16Bit))
{
Modified: trunk/OpenMPT/soundlib/XMTools.h
===================================================================
--- trunk/OpenMPT/soundlib/XMTools.h 2012-12-12 23:02:43 UTC (rev 1459)
+++ trunk/OpenMPT/soundlib/XMTools.h 2012-12-14 10:13:33 UTC (rev 1460)
@@ -79,13 +79,16 @@
uint8 muteComputer; // Mute instrument if MIDI is enabled (0 / 1)
uint8 reserved[15]; // Reserved
+ // Convert all multi-byte numeric values to current platform's endianness or vice versa.
+ void ConvertEndianness();
+
// Convert OpenMPT's internal envelope representation to XM envelope data.
void ConvertEnvelopeToXM(const InstrumentEnvelope &mptEnv, uint8 &numPoints, uint8 &flags, uint8 &sustain, uint8 &loopStart, uint8 &loopEnd, uint16 (&envData)[24]);
// Convert XM envelope data to an OpenMPT's internal envelope representation.
void ConvertEnvelopeToMPT(InstrumentEnvelope &mptEnv, uint8 numPoints, uint8 flags, uint8 sustain, uint8 loopStart, uint8 loopEnd, const uint16 (&envData)[24]) const;
// Convert OpenMPT's internal sample representation to an XMInstrument.
- void ConvertToXM(const ModInstrument &mptIns, bool compatibilityExport);
+ uint16 ConvertToXM(const ModInstrument &mptIns, bool compatibilityExport);
// Convert an XMInstrument to OpenMPT's internal instrument representation.
void ConvertToMPT(ModInstrument &mptIns) const;
// Apply auto-vibrato settings from sample to file.
@@ -177,6 +180,9 @@
uint8 reserved; // Reserved (abused for ModPlug's ADPCM compression)
char name[22]; // Sample Name, not null-terminated (any nulls are treated as spaces)
+ // Convert all multi-byte numeric values to current platform's endianness or vice versa.
+ void ConvertEndianness();
+
// Convert OpenMPT's internal sample representation to an XMSample.
void ConvertToXM(const ModSample &mptSmp, MODTYPE fromType, bool compatibilityExport);
// Convert an XMSample to OpenMPT's internal sample representation.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2012-12-16 14:44:06
|
Revision: 1465
http://sourceforge.net/p/modplug/code/1465
Author: saga-games
Date: 2012-12-16 14:44:01 +0000 (Sun, 16 Dec 2012)
Log Message:
-----------
[Fix] Getting a bit closer to IT's macro idiosyncrasies... Zxx is now only applied on first tick, before any other effects, \xx remains "sane". Also, volume 0 seems to be clamped to MIDI value 1 instead of 0.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2012-12-16 01:05:01 UTC (rev 1464)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2012-12-16 14:44:01 UTC (rev 1465)
@@ -1517,7 +1517,7 @@
// -> DESC="add extended parameter mechanism to pattern effects"
ModCommand *m = nullptr;
// -! NEW_FEATURE#0010
- for (CHANNELINDEX nChn = 0; nChn < m_nChannels; nChn++, pChn++)
+ for(CHANNELINDEX nChn = 0; nChn < GetNumChannels(); nChn++, pChn++)
{
UINT instr = pChn->rowCommand.instr;
UINT volcmd = pChn->rowCommand.volcmd;
@@ -1951,6 +1951,15 @@
if((GetType() == MOD_TYPE_S3M) && ChnSettings[nChn].dwFlags[CHN_MUTE]) // not even effects are processed on muted S3M channels
continue;
+ if(cmd == CMD_MIDI && m_SongFlags[SONG_FIRSTTICK])
+ {
+ // MIDI macro (Smooth MIDI macros are processed later, when we know all the volumes, panning, etc.)
+ if(param < 0x80)
+ ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], param);
+ else
+ ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiZXXExt[(param & 0x7F)], 0);
+ }
+
// Volume Column Effect (except volume & panning)
/* A few notes, paraphrased from ITTECH.TXT by Storlek (creator of schismtracker):
Ex/Fx/Gx are shared with Exx/Fxx/Gxx; Ex/Fx are 4x the 'normal' slide value
@@ -1962,7 +1971,7 @@
so... hxx = (hx | (oldhxx & 0xf0)) ???
TODO is this done correctly?
*/
- if ((volcmd > VOLCMD_PANNING) && (m_nTickCount >= nStartTick))
+ if((volcmd > VOLCMD_PANNING) && (m_nTickCount >= nStartTick))
{
if (volcmd == VOLCMD_TONEPORTAMENTO)
{
@@ -2078,18 +2087,13 @@
}
// Effects
- if (cmd) switch (cmd)
+ if(cmd != CMD_NONE) switch (cmd)
{
-// -> CODE#0010
-// -> DESC="add extended parameter mechanism to pattern effects"
- case CMD_XPARAM:
- break;
-// -> NEW_FEATURE#0010
// Set Volume
case CMD_VOLUME:
if(m_SongFlags[SONG_FIRSTTICK])
{
- pChn->nVolume = (param < 64) ? param*4 : 256;
+ pChn->nVolume = (param < 64) ? param * 4 : 256;
pChn->dwFlags.set(CHN_FASTVOLRAMP);
}
break;
@@ -2440,10 +2444,10 @@
nPosJump = param;
if(m_SongFlags[SONG_PATTERNLOOP] && m_nSeqOverride == ORDERINDEX_INVALID)
{
- m_nSeqOverride = param;
- //Releasing pattern loop after position jump could cause
- //instant jumps - modifying behavior so that now position jumps
- //occurs also when pattern loop is enabled.
+ m_nSeqOverride = param;
+ //Releasing pattern loop after position jump could cause
+ //instant jumps - modifying behavior so that now position jumps
+ //occurs also when pattern loop is enabled.
}
// see http://forum.openmpt.org/index.php?topic=2769.0 - FastTracker resets Dxx if Bxx is called _after_ Dxx
@@ -3622,20 +3626,20 @@
// This is "almost" how IT does it - apparently, IT seems to lag one row behind on global volume or channel volume changes.
const int swing = (IsCompatibleMode(TRK_IMPULSETRACKER) || GetModFlag(MSF_OLDVOLSWING)) ? pChn->nVolSwing : 0;
const int vol = _muldiv((pChn->nVolume + swing) * m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 20);
- data = (unsigned char)Util::Min(vol / 2, 127);
+ data = (unsigned char)Clamp(vol / 2, 1, 127);
//data = (unsigned char)min((pChn->nVolume * pChn->nGlobalVol * m_nGlobalVolume) >> (1 + 6 + 8), 127);
} else if(macro[pos] == 'u') // u: volume (calculated)
{
// Same note as with velocity applies here, but apparently also for instrument / sample volumes?
const int vol = _muldiv(pChn->nCalcVolume * m_nGlobalVolume, pChn->nGlobalVol * pChn->nInsVol, 1 << 26);
- data = (unsigned char)Util::Min(vol / 2, 127);
+ data = (unsigned char)Clamp(vol / 2, 1, 127);
//data = (unsigned char)min((pChn->nCalcVolume * pChn->nGlobalVol * m_nGlobalVolume) >> (7 + 6 + 8), 127);
} else if(macro[pos] == 'x') // x: pan set
{
- data = (unsigned char)min(pChn->nPan / 2, 127);
+ data = (unsigned char)Util::Min(pChn->nPan / 2, 127);
} else if(macro[pos] == 'y') // y: calculated pan
{
- data = (unsigned char)min(pChn->nRealPan / 2, 127);
+ data = (unsigned char)Util::Min(pChn->nRealPan / 2, 127);
} else if(macro[pos] == 'a') // a: high byte of bank select
{
if(pIns && pIns->wMidiBank)
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2012-12-16 01:05:01 UTC (rev 1464)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2012-12-16 14:44:01 UTC (rev 1465)
@@ -1900,7 +1900,7 @@
} else
#endif // MODPLUG_TRACKER
{
- if (!ProcessRow())
+ if(!ProcessRow())
return FALSE;
}
////////////////////////////////////////////////////////////////////////////////////
@@ -2400,19 +2400,18 @@
//-------------------------------------------------------
{
ModChannel *pChn = &Chn[nChn];
- if(nChn < m_nChannels)
+ if(nChn < GetNumChannels())
{
// TODO evaluate per-plugin macros here
//ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_PAN]);
//ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_VOLUME]);
- if(pChn->rowCommand.command == CMD_MIDI || pChn->rowCommand.command == CMD_SMOOTHMIDI)
+ if(pChn->rowCommand.command == CMD_SMOOTHMIDI)
{
- // Also non-smooth MIDI Macros are processed on every row to update macros with volume or panning variables.
if(pChn->rowCommand.param < 0x80)
- ProcessMIDIMacro(nChn, (pChn->rowCommand.command == CMD_SMOOTHMIDI), m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], pChn->rowCommand.param);
+ ProcessMIDIMacro(nChn, true, m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], pChn->rowCommand.param);
else
- ProcessMIDIMacro(nChn, (pChn->rowCommand.command == CMD_SMOOTHMIDI), m_MidiCfg.szMidiZXXExt[(pChn->rowCommand.param & 0x7F)], 0);
+ ProcessMIDIMacro(nChn, true, m_MidiCfg.szMidiZXXExt[(pChn->rowCommand.param & 0x7F)], 0);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2012-12-22 15:49:01
|
Revision: 1471
http://sourceforge.net/p/modplug/code/1471
Author: saga-games
Date: 2012-12-22 15:48:48 +0000 (Sat, 22 Dec 2012)
Log Message:
-----------
[Mod] Partly reverted Zxx behaviour changes from rev. 1465, so that we won't have 3 different Zxx behaviours in the end.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2012-12-21 23:28:12 UTC (rev 1470)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2012-12-22 15:48:48 UTC (rev 1471)
@@ -1951,15 +1951,6 @@
if((GetType() == MOD_TYPE_S3M) && ChnSettings[nChn].dwFlags[CHN_MUTE]) // not even effects are processed on muted S3M channels
continue;
- if(cmd == CMD_MIDI && m_SongFlags[SONG_FIRSTTICK])
- {
- // MIDI macro (Smooth MIDI macros are processed later, when we know all the volumes, panning, etc.)
- if(param < 0x80)
- ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], param);
- else
- ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiZXXExt[(param & 0x7F)], 0);
- }
-
// Volume Column Effect (except volume & panning)
/* A few notes, paraphrased from ITTECH.TXT by Storlek (creator of schismtracker):
Ex/Fx/Gx are shared with Exx/Fxx/Gxx; Ex/Fx are 4x the 'normal' slide value
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2012-12-21 23:28:12 UTC (rev 1470)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2012-12-22 15:48:48 UTC (rev 1471)
@@ -2406,12 +2406,12 @@
//ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_PAN]);
//ProcessMIDIMacro(nChn, false, m_MidiCfg.szMidiGlb[MIDIOUT_VOLUME]);
- if(pChn->rowCommand.command == CMD_SMOOTHMIDI)
+ if((pChn->rowCommand.command == CMD_MIDI && m_SongFlags[SONG_FIRSTTICK]) || pChn->rowCommand.command == CMD_SMOOTHMIDI)
{
if(pChn->rowCommand.param < 0x80)
- ProcessMIDIMacro(nChn, true, m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], pChn->rowCommand.param);
+ ProcessMIDIMacro(nChn, (pChn->rowCommand.command == CMD_SMOOTHMIDI), m_MidiCfg.szMidiSFXExt[pChn->nActiveMacro], pChn->rowCommand.param);
else
- ProcessMIDIMacro(nChn, true, m_MidiCfg.szMidiZXXExt[(pChn->rowCommand.param & 0x7F)], 0);
+ ProcessMIDIMacro(nChn, (pChn->rowCommand.command == CMD_SMOOTHMIDI), m_MidiCfg.szMidiZXXExt[(pChn->rowCommand.param & 0x7F)], 0);
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-01-19 15:14:48
|
Revision: 1501
http://sourceforge.net/p/modplug/code/1501
Author: saga-games
Date: 2013-01-19 15:14:38 +0000 (Sat, 19 Jan 2013)
Log Message:
-----------
[Ref] Eliminated dead, never-to-be-used again asm code.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Mmx_mix.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Tables.cpp
trunk/OpenMPT/soundlib/Waveform.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-01-19 13:56:24 UTC (rev 1500)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-01-19 15:14:38 UTC (rev 1501)
@@ -18,10 +18,7 @@
#include <math.h>
#endif
-// rewbs.resamplerConf
-#include "../mptrack/mptrack.h"
#include "WindowedFIR.h"
-// end rewbs.resamplerConf
#pragma bss_seg(".modplug")
Modified: trunk/OpenMPT/soundlib/Mmx_mix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-01-19 13:56:24 UTC (rev 1500)
+++ trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-01-19 15:14:38 UTC (rev 1501)
@@ -79,8 +79,6 @@
#pragma warning (disable:4799) // function has no EMMS instruction
-extern int SpectrumSinusTable[256*2];
-
// -> CODE#0024 UPDATE#04
// -> DESC="wav export update"
//const float _f2ic = (float)(1 << 28);
@@ -216,1072 +214,6 @@
}
-//////////////////////////////////////////////////////////////////////////
-// Stereo MMX mixing - no interpolation
-
-_declspec(naked) VOID __cdecl MMX_Mono8BitMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov eax, 0xFFFF
- movd mm6, eax
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov edx, MMX_PBUFMAX
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- add esi, [ecx+CHNOFS_NPOS]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- mov ebp, [ecx+CHNOFS_NINC]
- punpckldq mm6, mm6
- movq mm4, qword ptr [ecx+CHNOFS_NRIGHTVOL] //; mm4 = [ leftvol | rightvol ]
- pand mm4, mm6
- mov eax, edx
- sub eax, edi
- push ecx
- test eax, 8
- jz mixloop
- mov eax, ebx
- sar eax,16
- movsx eax, byte ptr [esi+eax]
- add edi, 8
- shl eax, 8
- movd mm0, eax
- punpckldq mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- add ebx, ebp
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop
- jmp done
- align 16
-mixloop:
- mov eax, ebx
- add ebx, ebp
- sar eax,16
- mov ecx, ebx
- movsx eax, byte ptr [esi+eax]
- sar ecx, 16
- add edi, 16
- movsx ecx, byte ptr [esi+ecx]
- shl eax, 8
- add ebx, ebp
- movd mm1, eax
- shl ecx, 8
- punpckldq mm1, mm1
- movd mm0, ecx
- pmaddwd mm1, mm4
- punpckldq mm0, mm0
- paddd mm1, qword ptr [edi-16]
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-16], mm1
- movq qword ptr [edi-8], mm0
- jb mixloop
-done:
- pop ecx
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- MMX_LEAVE
- }
-}
-
-
-_declspec(naked) VOID __cdecl MMX_Mono16BitMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov eax, 0xFFFF
- movd mm6, eax
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov edx, MMX_PBUFMAX
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- mov eax, [ecx+CHNOFS_NPOS]
- lea esi, [esi+eax*2]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- mov ebp, [ecx+CHNOFS_NINC]
- punpckldq mm6, mm6
- movq mm4, dword ptr [ecx+CHNOFS_NRIGHTVOL] // mm4 = [ leftvol | rightvol ]
- pand mm4, mm6
- mov eax, edx
- sub eax, edi
- push ecx
- test eax, 8
- jz mixloop
- mov eax, ebx
- sar eax,16
- movsx eax, word ptr [esi+eax*2]
- add edi, 8
- movd mm0, eax
- punpckldq mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- add ebx, ebp
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop
- jmp done
- align 16
-mixloop:
- mov eax, ebx
- add ebx, ebp
- sar eax, 16
- mov ecx, ebx
- movsx eax, word ptr [esi+eax*2]
- sar ecx, 16
- add edi, 16
- movsx ecx, word ptr [esi+ecx*2]
- movd mm1, eax
- add ebx, ebp
- punpckldq mm1, mm1
- movd mm0, ecx
- pmaddwd mm1, mm4
- punpckldq mm0, mm0
- pmaddwd mm0, mm4
- paddd mm1, qword ptr [edi-16]
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-16], mm1
- movq qword ptr [edi-8], mm0
- jb mixloop
-done:
- pop ecx
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- MMX_LEAVE
- }
-}
-
-
-/////////////////////////////////////////////////////////////////////////////////////
-// Linear interpolation
-
-
-_declspec(naked) VOID __cdecl MMX_Mono8BitLinearMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- add esi, [ecx+CHNOFS_NPOS]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- mov ebp, [ecx+CHNOFS_NINC]
- mov eax, 0x0000FFFF
- movq mm4, qword ptr [ecx+CHNOFS_NRIGHTVOL] // mm4 = [ leftvol | rightvol ]
- movd mm6, eax
- punpckldq mm6, mm6
- pand mm4, mm6
- mov ecx, MMX_PBUFMAX
-mixloop:
- mov eax, ebx
- sar eax, 16
- movsx edx, byte ptr [esi+eax]
- movsx eax, byte ptr [esi+eax+1]
- add edi, 8
- movd mm1, eax
- movd mm0, edx
- movzx edx, bh
- psubd mm1, mm0
- movd mm2, edx
- pslld mm0, 8
- pmaddwd mm1, mm2 // mm1 = poslo * (s2-s1)
- paddd mm0, mm1
- punpckldq mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- add ebx, ebp
- cmp edi, ecx
- movq qword ptr [edi-8], mm0
- jb mixloop
- mov ecx, MMX_PCHANNEL
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- MMX_LEAVE
- }
-}
-
-
-_declspec(naked) VOID __cdecl MMX_Mono16BitLinearMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- mov eax, [ecx+CHNOFS_NPOS]
- lea esi, [esi+eax*2]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- mov ebp, [ecx+CHNOFS_NINC]
- mov eax, 0x0000FFFF
- movq mm4, qword ptr [ecx+CHNOFS_NRIGHTVOL] // mm4 = [ leftvol | rightvol ]
- movd mm6, eax
- punpckldq mm6, mm6
- pand mm4, mm6
- mov ecx, MMX_PBUFMAX
-mixloop:
- mov eax, ebx
- sar eax, 16
- movsx edx, word ptr [esi+eax*2]
- movsx eax, word ptr [esi+eax*2+2]
- add edi, 8
- movd mm1, eax
- movzx eax, bh
- movd mm0, edx
- movd mm2, eax
- psubsw mm1, mm0
- pmaddwd mm1, mm2 // mm1 = poslo * (s2-s1)
- psrad mm1, 8
- paddd mm0, mm1
- punpckldq mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- add ebx, ebp
- cmp edi, ecx
- movq qword ptr [edi-8], mm0
- jb mixloop
- mov ecx, MMX_PCHANNEL
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- MMX_LEAVE
- }
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// 4-taps polyphase FIR resampling filter
-
-_declspec(naked) VOID __cdecl MMX_Mono8BitHQMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov eax, 0xFFFF
- movd mm6, eax
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov edx, MMX_PBUFMAX
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- add esi, [ecx+CHNOFS_NPOS]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- dec esi
- mov ebp, [ecx+CHNOFS_NINC]
- punpckldq mm6, mm6
- movq mm4, qword ptr [ecx+CHNOFS_NRIGHTVOL] //; mm4 = [ leftvol | rightvol ]
- pand mm4, mm6
- paddsw mm4, mm4
-mixloop:
- mov eax, ebx
- sar eax, 16
- movzx ecx, bh
- movd mm0, dword ptr [esi+eax]
- pxor mm7, mm7
- movq mm1, qword ptr [gFastSinc+ecx*8] // mm1 = [ c3 | c2 | c1 | c0 ]
- punpcklbw mm7, mm0 // mm7 = [ s3 | s2 | s1 | s0 ]
- pmaddwd mm7, mm1 // mm7 = [c3*s3+c2*s2|c1*s1+c0*s0]
- add edi, 8
- movq mm0, mm7
- psrlq mm7, 32
- paddd mm0, mm7
- punpckldq mm0, mm0
- psrad mm0, 15
- packssdw mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- add ebx, ebp
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop
- mov ecx, MMX_PCHANNEL
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- MMX_LEAVE
- }
-}
-
-
-_declspec(naked) VOID __cdecl MMX_Mono16BitHQMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov eax, 0xFFFF
- movd mm6, eax
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov edx, MMX_PBUFMAX
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- mov eax, [ecx+CHNOFS_NPOS]
- lea esi, [esi+eax*2-2]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- mov ebp, [ecx+CHNOFS_NINC]
- punpckldq mm6, mm6
- movq mm4, dword ptr [ecx+CHNOFS_NRIGHTVOL] // mm4 = [ leftvol | rightvol ]
- pand mm4, mm6
-mixloop:
- mov eax, ebx
- sar eax, 16
- movzx ecx, bh
- movq mm7, qword ptr [esi+eax*2] // mm7 = [ s3 | s2 | s1 | s0 ]
- movq mm1, qword ptr [gFastSinc+ecx*8] // mm1 = [ c3 | c2 | c1 | c0 ]
- add edi, 8
- pmaddwd mm7, mm1 // mm7 = [c3*s3+c2*s2|c1*s1+c0*s0]
- movq mm0, mm7
- psrlq mm7, 32
- paddd mm0, mm7
- punpckldq mm0, mm0
- psrad mm0, 14
- packssdw mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- add ebx, ebp
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop
- mov ecx, MMX_PCHANNEL
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- MMX_LEAVE
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// 8-taps polyphase FIR resampling filter
-
-_declspec(naked) VOID __cdecl MMX_Mono8BitKaiserMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov eax, 0xFFFF
- movd mm6, eax
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov edx, MMX_PBUFMAX
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- add esi, [ecx+CHNOFS_NPOS]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- sub esi, 3
- mov ebp, [ecx+CHNOFS_NINC]
- punpckldq mm6, mm6
- movq mm4, qword ptr [ecx+CHNOFS_NRIGHTVOL] //; mm4 = [ leftvol | rightvol ]
- pand mm4, mm6
- paddsw mm4, mm4
- cmp ebp, 0x18000
- jg mixloop2x
- cmp ebp, -0x18000
- jl mixloop2x
- cmp ebp, 0x13000
- jg mixloop3x
- cmp ebp, -0x13000
- jl mixloop3x
-mixloop:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm0, qword ptr [esi+eax] // mm0 = [s7|s6|s5|s4|s3|s2|s1|s0]
- pxor mm6, mm6
- movq mm1, qword ptr [gKaiserSinc+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm2, qword ptr [gKaiserSinc+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- punpcklbw mm6, mm0 // mm6 = [ s3 | s2 | s1 | s0 ]
- pxor mm7, mm7
- pmaddwd mm6, mm1
- punpckhbw mm7, mm0 // mm7 = [ s7 | s6 | s5 | s4 ]
- pmaddwd mm7, mm2
- add edi, 8
- add ebx, ebp
- paddd mm6, mm7
- movq mm0, mm6
- psrlq mm6, 32
- paddd mm0, mm6
- psrad mm0, 15
- punpckldq mm0, mm0
- packssdw mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop
- jmp done
-mixloop2x:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm0, qword ptr [esi+eax] // mm0 = [s7|s6|s5|s4|s3|s2|s1|s0]
- pxor mm6, mm6
- movq mm1, qword ptr [gDownsample2x+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm2, qword ptr [gDownsample2x+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- punpcklbw mm6, mm0 // mm6 = [ s3 | s2 | s1 | s0 ]
- pxor mm7, mm7
- pmaddwd mm6, mm1
- punpckhbw mm7, mm0 // mm7 = [ s7 | s6 | s5 | s4 ]
- pmaddwd mm7, mm2
- add edi, 8
- add ebx, ebp
- paddd mm6, mm7
- movq mm0, mm6
- psrlq mm6, 32
- paddd mm0, mm6
- psrad mm0, 15
- punpckldq mm0, mm0
- packssdw mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop2x
- jmp done
-mixloop3x:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm0, qword ptr [esi+eax] // mm0 = [s7|s6|s5|s4|s3|s2|s1|s0]
- pxor mm6, mm6
- movq mm1, qword ptr [gDownsample13x+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm2, qword ptr [gDownsample13x+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- punpcklbw mm6, mm0 // mm6 = [ s3 | s2 | s1 | s0 ]
- pxor mm7, mm7
- pmaddwd mm6, mm1
- punpckhbw mm7, mm0 // mm7 = [ s7 | s6 | s5 | s4 ]
- pmaddwd mm7, mm2
- add edi, 8
- add ebx, ebp
- paddd mm6, mm7
- movq mm0, mm6
- psrlq mm6, 32
- paddd mm0, mm6
- psrad mm0, 15
- punpckldq mm0, mm0
- packssdw mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop3x
-done:
- mov ecx, MMX_PCHANNEL
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- MMX_LEAVE
- }
-}
-
-
-_declspec(naked) VOID __cdecl MMX_Mono8BitKaiserRampMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov edx, MMX_PBUFMAX
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- add esi, [ecx+CHNOFS_NPOS]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- sub esi, 3
- mov ebp, [ecx+CHNOFS_NINC]
- movq mm4, qword ptr [ecx+ModChannel.nRampRightVol] // mm4 = [ leftvol | rightvol ]
- movq mm3, qword ptr [ecx+ModChannel.nRightRamp] // mm3 = [ leftramp | rightramp ]
- cmp ebp, 0x18000
- jg mixloop2x
- cmp ebp, -0x18000
- jl mixloop2x
- cmp ebp, 0x13000
- jg mixloop3x
- cmp ebp, -0x13000
- jl mixloop3x
-mixloop:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm0, qword ptr [esi+eax] // mm0 = [s7|s6|s5|s4|s3|s2|s1|s0]
- pxor mm6, mm6
- movq mm1, qword ptr [gKaiserSinc+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm2, qword ptr [gKaiserSinc+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- punpcklbw mm6, mm0 // mm6 = [ s3 | s2 | s1 | s0 ]
- pxor mm7, mm7
- pmaddwd mm6, mm1
- punpckhbw mm7, mm0 // mm7 = [ s7 | s6 | s5 | s4 ]
- pmaddwd mm7, mm2
- paddd mm4, mm3 // nRampVol += nRamp
- add edi, 8
- add ebx, ebp
- paddd mm6, mm7
- movq mm7, mm4
- movq mm0, mm6
- psrlq mm6, 32
- psrad mm7, VOLUMERAMPPRECISION-1 // nRampVol >> VOLUMERAMPPRECISION-1
- paddd mm0, mm6
- pxor mm6, mm6
- psrad mm0, 15
- packssdw mm7, mm7
- punpckldq mm0, mm0
- punpcklwd mm7, mm6
- packssdw mm0, mm0
- pmaddwd mm0, mm7
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop
- jmp done
-mixloop2x:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm0, qword ptr [esi+eax] // mm0 = [s7|s6|s5|s4|s3|s2|s1|s0]
- pxor mm6, mm6
- movq mm1, qword ptr [gDownsample2x+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm2, qword ptr [gDownsample2x+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- punpcklbw mm6, mm0 // mm6 = [ s3 | s2 | s1 | s0 ]
- pxor mm7, mm7
- pmaddwd mm6, mm1
- punpckhbw mm7, mm0 // mm7 = [ s7 | s6 | s5 | s4 ]
- pmaddwd mm7, mm2
- paddd mm4, mm3 // nRampVol += nRamp
- add edi, 8
- add ebx, ebp
- paddd mm6, mm7
- movq mm7, mm4
- movq mm0, mm6
- psrlq mm6, 32
- psrad mm7, VOLUMERAMPPRECISION-1 // nRampVol >> VOLUMERAMPPRECISION-1
- paddd mm0, mm6
- pxor mm6, mm6
- psrad mm0, 15
- packssdw mm7, mm7
- punpckldq mm0, mm0
- punpcklwd mm7, mm6
- packssdw mm0, mm0
- pmaddwd mm0, mm7
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop2x
- jmp done
-mixloop3x:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm0, qword ptr [esi+eax] // mm0 = [s7|s6|s5|s4|s3|s2|s1|s0]
- pxor mm6, mm6
- movq mm1, qword ptr [gDownsample13x+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm2, qword ptr [gDownsample13x+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- punpcklbw mm6, mm0 // mm6 = [ s3 | s2 | s1 | s0 ]
- pxor mm7, mm7
- pmaddwd mm6, mm1
- punpckhbw mm7, mm0 // mm7 = [ s7 | s6 | s5 | s4 ]
- pmaddwd mm7, mm2
- paddd mm4, mm3 // nRampVol += nRamp
- add edi, 8
- add ebx, ebp
- paddd mm6, mm7
- movq mm7, mm4
- movq mm0, mm6
- psrlq mm6, 32
- psrad mm7, VOLUMERAMPPRECISION-1 // nRampVol >> VOLUMERAMPPRECISION-1
- paddd mm0, mm6
- pxor mm6, mm6
- psrad mm0, 15
- packssdw mm7, mm7
- punpckldq mm0, mm0
- punpcklwd mm7, mm6
- packssdw mm0, mm0
- pmaddwd mm0, mm7
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop3x
-done:
- mov ecx, MMX_PCHANNEL
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- movq qword ptr [ecx+ModChannel.nRampRightVol], mm4
- psrad mm4, VOLUMERAMPPRECISION
- movq qword ptr [ecx+ModChannel.nRightVol], mm4
- MMX_LEAVE
- }
-}
-
-
-_declspec(naked) VOID __cdecl MMX_Mono16BitKaiserMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov eax, 0xFFFF
- movd mm6, eax
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov edx, MMX_PBUFMAX
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- mov eax, [ecx+CHNOFS_NPOS]
- lea esi, [esi+eax*2-6]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- mov ebp, [ecx+CHNOFS_NINC]
- punpckldq mm6, mm6
- movq mm4, dword ptr [ecx+CHNOFS_NRIGHTVOL] // mm4 = [ leftvol | rightvol ]
- pand mm4, mm6
- cmp ebp, 0x18000
- jg mixloop2x
- cmp ebp, -0x18000
- jl mixloop2x
- cmp ebp, 0x13000
- jg mixloop3x
- cmp ebp, -0x13000
- jl mixloop3x
-mixloop:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm6, qword ptr [esi+eax*2] // mm6 = [ s3 | s2 | s1 | s0 ]
- movq mm1, qword ptr [gKaiserSinc+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm7, qword ptr [esi+eax*2+8] // mm7 = [ s7 | s6 | s5 | s4 ]
- movq mm2, qword ptr [gKaiserSinc+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- pmaddwd mm6, mm1
- add edi, 8
- pmaddwd mm7, mm2
- add ebx, ebp
- paddd mm6, mm7
- movq mm0, mm6
- psrlq mm6, 32
- paddd mm0, mm6
- psrad mm0, 14
- punpckldq mm0, mm0
- packssdw mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop
- jmp done
-mixloop2x:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm6, qword ptr [esi+eax*2] // mm6 = [ s3 | s2 | s1 | s0 ]
- movq mm1, qword ptr [gDownsample2x+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm7, qword ptr [esi+eax*2+8] // mm7 = [ s7 | s6 | s5 | s4 ]
- movq mm2, qword ptr [gDownsample2x+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- pmaddwd mm6, mm1
- add edi, 8
- pmaddwd mm7, mm2
- add ebx, ebp
- paddd mm6, mm7
- movq mm0, mm6
- psrlq mm6, 32
- paddd mm0, mm6
- psrad mm0, 14
- punpckldq mm0, mm0
- packssdw mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop2x
- jmp done
-mixloop3x:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm6, qword ptr [esi+eax*2] // mm6 = [ s3 | s2 | s1 | s0 ]
- movq mm1, qword ptr [gDownsample13x+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm7, qword ptr [esi+eax*2+8] // mm7 = [ s7 | s6 | s5 | s4 ]
- movq mm2, qword ptr [gDownsample13x+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- pmaddwd mm6, mm1
- add edi, 8
- pmaddwd mm7, mm2
- add ebx, ebp
- paddd mm6, mm7
- movq mm0, mm6
- psrlq mm6, 32
- paddd mm0, mm6
- psrad mm0, 14
- punpckldq mm0, mm0
- packssdw mm0, mm0
- pmaddwd mm0, mm4
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop3x
-done:
- mov ecx, MMX_PCHANNEL
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- MMX_LEAVE
- }
-}
-
-
-_declspec(naked) VOID __cdecl MMX_Mono16BitKaiserRampMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov edx, MMX_PBUFMAX
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- mov eax, [ecx+CHNOFS_NPOS]
- lea esi, [esi+eax*2-6]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- mov ebp, [ecx+CHNOFS_NINC]
- movq mm4, qword ptr [ecx+ModChannel.nRampRightVol] // mm4 = [ leftvol | rightvol ]
- movq mm3, qword ptr [ecx+ModChannel.nRightRamp] // mm3 = [ leftramp | rightramp ]
- cmp ebp, 0x18000
- jg mixloop2x
- cmp ebp, -0x18000
- jl mixloop2x
- cmp ebp, 0x13000
- jg mixloop3x
- cmp ebp, -0x13000
- jl mixloop3x
-mixloop:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm6, qword ptr [esi+eax*2] // mm6 = [ s3 | s2 | s1 | s0 ]
- movq mm1, qword ptr [gKaiserSinc+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm7, qword ptr [esi+eax*2+8] // mm7 = [ s7 | s6 | s5 | s4 ]
- movq mm2, qword ptr [gKaiserSinc+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- pmaddwd mm6, mm1
- add edi, 8
- pmaddwd mm7, mm2
- paddd mm4, mm3
- add ebx, ebp
- paddd mm6, mm7
- movq mm7, mm4
- movq mm0, mm6
- psrlq mm6, 32
- psrad mm7, VOLUMERAMPPRECISION // nRampVol >> VOLUMERAMPPRECISION
- paddd mm0, mm6
- pxor mm6, mm6
- psrad mm0, 14
- packssdw mm7, mm7
- punpckldq mm0, mm0
- punpcklwd mm7, mm6
- packssdw mm0, mm0
- pmaddwd mm0, mm7
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop
- jmp done
-mixloop2x:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm6, qword ptr [esi+eax*2] // mm6 = [ s3 | s2 | s1 | s0 ]
- movq mm1, qword ptr [gDownsample2x+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm7, qword ptr [esi+eax*2+8] // mm7 = [ s7 | s6 | s5 | s4 ]
- movq mm2, qword ptr [gDownsample2x+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- pmaddwd mm6, mm1
- add edi, 8
- pmaddwd mm7, mm2
- paddd mm4, mm3
- add ebx, ebp
- paddd mm6, mm7
- movq mm7, mm4
- movq mm0, mm6
- psrlq mm6, 32
- psrad mm7, VOLUMERAMPPRECISION // nRampVol >> VOLUMERAMPPRECISION
- paddd mm0, mm6
- pxor mm6, mm6
- psrad mm0, 14
- packssdw mm7, mm7
- punpckldq mm0, mm0
- punpcklwd mm7, mm6
- packssdw mm0, mm0
- pmaddwd mm0, mm7
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop2x
- jmp done
-mixloop3x:
- mov eax, ebx
- mov ecx, ebx
- sar eax, 16
- and ecx, 0xfff0
- movq mm6, qword ptr [esi+eax*2] // mm6 = [ s3 | s2 | s1 | s0 ]
- movq mm1, qword ptr [gDownsample13x+ecx] // mm1 = [ c3 | c2 | c1 | c0 ]
- movq mm7, qword ptr [esi+eax*2+8] // mm7 = [ s7 | s6 | s5 | s4 ]
- movq mm2, qword ptr [gDownsample13x+ecx+8] // mm2 = [ c7 | c6 | c5 | c4 ]
- pmaddwd mm6, mm1
- add edi, 8
- pmaddwd mm7, mm2
- paddd mm4, mm3
- add ebx, ebp
- paddd mm6, mm7
- movq mm7, mm4
- movq mm0, mm6
- psrlq mm6, 32
- psrad mm7, VOLUMERAMPPRECISION // nRampVol >> VOLUMERAMPPRECISION
- paddd mm0, mm6
- pxor mm6, mm6
- psrad mm0, 14
- packssdw mm7, mm7
- punpckldq mm0, mm0
- punpcklwd mm7, mm6
- packssdw mm0, mm0
- pmaddwd mm0, mm7
- paddd mm0, qword ptr [edi-8]
- cmp edi, edx
- movq qword ptr [edi-8], mm0
- jb mixloop3x
-done:
- mov ecx, MMX_PCHANNEL
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- movq qword ptr [ecx+ModChannel.nRampRightVol], mm4
- psrad mm4, VOLUMERAMPPRECISION
- movq qword ptr [ecx+ModChannel.nRightVol], mm4
- MMX_LEAVE
- }
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Filtered + linear interpolation + ramping
-
-_declspec(naked) VOID __cdecl MMX_FilterMono8BitLinearRampMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- mov eax, [ecx+CHNOFS_NPOS]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- mov ebp, [ecx+CHNOFS_NINC]
- mov edx, [ecx+ModChannel.nRampLength]
- add esi, eax
- or edx, edx
- movq mm4, qword ptr [ecx+ModChannel.nRampRightVol] // mm4 = [ leftvol | rightvol ]
- movq mm3, qword ptr [ecx+ModChannel.nRightRamp] // mm3 = [ leftramp | rightramp ]
- jnz noramp
- movq mm4, qword ptr [ecx+ModChannel.nRightVol]
- pxor mm3, mm3
- pslld mm4, VOLUMERAMPPRECISION
-noramp:
- movq mm6, qword ptr [ecx+ModChannel.nFilter_Y1] // mm6 = [ y2 | y1 ]
- movd mm0, dword ptr [ecx+ModChannel.nFilter_B0]
- movd mm1, dword ptr [ecx+ModChannel.nFilter_B1]
- punpckldq mm0, mm1 // mm0 = [ b1 | b0 ]
- movd mm7, dword ptr [ecx+ModChannel.nFilter_HP]
- movd mm2, dword ptr [ecx+ModChannel.nFilter_A0]
- punpckldq mm7, mm2 // mm7 = [ a0 | hp ]
- packssdw mm7, mm0 // mm7 = [ b1 | b0 | a0 | hp ]
- mov ecx, MMX_PBUFMAX
-mixloop:
- mov eax, ebx
- sar eax, 16
- add edi, 8
- movsx edx, byte ptr [esi+eax]
- movsx eax, byte ptr [esi+eax]
- movd mm0, edx
- sub eax, edx
- movzx edx, bh
- imul edx, eax
- pslld mm0, 8
- movd mm1, edx
- movq mm5, mm7
- paddd mm0, mm1 // mm0 = s0+x*(s1-s0)
- pxor mm1, mm1
- psrad mm0, 1
- punpcklwd mm5, mm5 // mm5 = [ a0 | a0 | hp | hp ]
- packssdw mm1, mm6 // mm1 = [ y2 | y1 | 0 | 0 ]
- pand mm5, mm0 // mm5 = [ 0 | vol&hp ]
- pslld mm0, 16 // mm0 = [ 0 | 0 | vol| 0 ]
- por mm0, mm1 // mm0 = [ y2 | y1 | vol| 0 ]
- pmaddwd mm0, mm7 // mm0 = [ y1*b0+y2*b1 | vol*a0 ]
- mov eax, 4096
- paddd mm4, mm3
- movd mm1, eax
- paddd mm1, mm0
- punpckhdq mm0, mm0
- paddd mm0, mm1
- psrad mm0, 13
- movq mm1, mm0
- punpckldq mm0, mm0
- psubd mm1, mm5
- movq mm5, qword ptr [edi-8]
- movq mm2, mm4
- psrad mm2, VOLUMERAMPPRECISION // nRampVol >> VOLUMERAMPPRECISION
- packssdw mm2, mm2
- packssdw mm0, mm0
- punpcklwd mm2, mm2
- pmaddwd mm0, mm2
- punpckldq mm1, mm6
- movq mm6, mm1
- add ebx, ebp
- paddd mm0, mm5
- cmp edi, ecx
- movq qword ptr [edi-8], mm0
- jb mixloop
- mov ecx, MMX_PCHANNEL
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- movq qword ptr [ecx+ModChannel.nRampRightVol], mm4
- psrad mm4, VOLUMERAMPPRECISION
- movq qword ptr [ecx+ModChannel.nRightVol], mm4
- movq qword ptr [ecx+ModChannel.nFilter_Y1], mm6
- MMX_LEAVE
- }
-}
-
-
-_declspec(naked) VOID __cdecl MMX_FilterMono16BitLinearRampMix(ModChannel *pChannel, int *pbuffer, int *pbufmax)
-{
- _asm {
- MMX_ENTER
- mov ecx, MMX_PCHANNEL
- mov edi, MMX_PBUFFER
- mov esi, [ecx+CHNOFS_PCURRENTSAMPLE]
- mov eax, [ecx+CHNOFS_NPOS]
- movzx ebx, word ptr [ecx+CHNOFS_NPOSLO]
- mov ebp, [ecx+CHNOFS_NINC]
- mov edx, [ecx+ModChannel.nRampLength]
- lea esi, [esi+eax*2]
- or edx, edx
- movq mm4, qword ptr [ecx+ModChannel.nRampRightVol] // mm4 = [ leftvol | rightvol ]
- movq mm3, qword ptr [ecx+ModChannel.nRightRamp] // mm3 = [ leftramp | rightramp ]
- jnz noramp
- movq mm4, qword ptr [ecx+ModChannel.nRightVol]
- pxor mm3, mm3
- pslld mm4, VOLUMERAMPPRECISION
-noramp:
- movq mm6, qword ptr [ecx+ModChannel.nFilter_Y1] // mm6 = [ y2 | y1 ]
- movd mm0, dword ptr [ecx+ModChannel.nFilter_B0]
- movd mm1, dword ptr [ecx+ModChannel.nFilter_B1]
- punpckldq mm0, mm1 // mm0 = [ b1 | b0 ]
- movd mm7, dword ptr [ecx+ModChannel.nFilter_HP]
- movd mm2, dword ptr [ecx+ModChannel.nFilter_A0]
- punpckldq mm7, mm2 // mm7 = [ a0 | hp ]
- packssdw mm7, mm0 // mm7 = [ b1 | b0 | a0 | hp ]
- mov ecx, MMX_PBUFMAX
-mixloop:
- mov eax, ebx
- sar eax, 16
- add edi, 8
- movd mm0, dword ptr [esi+eax*2] // mm0 = [ 0 | 0 | s1 | s0 ]
- movzx edx, bh // edx = x
- mov eax, 0x100
- sub eax, edx // eax = 1-x
- shl edx, 16
- or eax, edx // eax = [ x | 1-x ]
- movd mm1, eax // mm1 = [ 0 | 0 | x | 1-x ]
- pmaddwd mm0, mm1 // mm0 = [ 0 | x*s1+(1-x)*s0 ]
- movq mm5, mm7
- pxor mm1, mm1
- psrad mm0, 9
- punpcklwd mm5, mm5 // mm5 = [ a0 | a0 | hp | hp ]
- packssdw mm1, mm6 // mm1 = [ y2 | y1 | 0 | 0 ]
- pand mm5, mm0 // mm5 = [ 0 | vol&hp ]
- pslld mm0, 16 // mm0 = [ 0 | 0 | vol| 0 ]
- por mm0, mm1 // mm0 = [ y2 | y1 | vol| 0 ]
- pmaddwd mm0, mm7 // mm0 = [ y1*b0+y2*b1 | vol*a0 ]
- mov eax, 4096
- paddd mm4, mm3
- movd mm1, eax
- paddd mm1, mm0
- punpckhdq mm0, mm0
- paddd mm0, mm1
- psrad mm0, 13
- movq mm1, mm0
- punpckldq mm0, mm0
- psubd mm1, mm5
- movq mm5, qword ptr [edi-8]
- movq mm2, mm4
- psrad mm2, VOLUMERAMPPRECISION // nRampVol >> VOLUMERAMPPRECISION
- packssdw mm2, mm2
- packssdw mm0, mm0
- punpcklwd mm2, mm2
- pmaddwd mm0, mm2
- punpckldq mm1, mm6
- movq mm6, mm1
- add ebx, ebp
- paddd mm0, mm5
- cmp edi, ecx
- movq qword ptr [edi-8], mm0
- jb mixloop
- mov ecx, MMX_PCHANNEL
- mov word ptr [ecx+CHNOFS_NPOSLO], bx
- sar ebx, 16
- add dword ptr [ecx+CHNOFS_NPOS], ebx
- movq qword ptr [ecx+ModChannel.nRampRightVol], mm4
- psrad mm4, VOLUMERAMPPRECISION
- movq qword ptr [ecx+ModChannel.nRightVol], mm4
- movq qword ptr [ecx+ModChannel.nFilter_Y1], mm6
- MMX_LEAVE
- }
-}
-
-
-
-//////////////////////////////////////////////////////////////////////////////
-
-
-// MMX_Spectrum(signed char *pBuffer, UINT nSamples, UINT nInc, UINT nSmpSize, LPLONG lpSinCos)
-__declspec(naked) void __cdecl MMX_Spectrum(signed char *, UINT, UINT, UINT, LPLONG)
-//----------------------------------------------------------------------------------
-{
- __asm {
- MMX_ENTER
- mov eax, 0x40*4
- mov edi, MMX_PARAM1 // edi = s(t)
- mov ecx, MMX_PARAM2 // ecx = nSamples
- movd mm4, eax // mm4 = wt
- mov eax, MMX_PARAM3
- shl eax, 2
- movd mm5, eax // mm5 = w
- xor eax, eax
- mov ebx, MMX_PARAM4 // ebx = nInc
- movd mm2, eax // mm2 = E[s(t).cos(wt)|s(t).sin(wt)]
- movd ebp, mm4
-SpectrumLoop:
- movsx edx, byte ptr [edi] // edx = s(t)
- and ebp, 0x1FF*4
- and edx, 0xFFFF
- movd mm0, dword ptr SpectrumSinusTable[ebp]
- add ebp, 0x80*4
- add edi, ebx
- and ebp, 0x1FF*4
- movd mm6, edx
- movd mm1, dword ptr SpectrumSinusTable[ebp]
- punpckldq mm6, mm6 // mm6 = [ s(t) | s(t) ]
- punpckldq mm0, mm1 // mm0 = [ cos(wt) | sin(wt) ]
- pmaddwd mm0, mm6 // mm0 = [s(t).cos(wt)|s(t).sin(wt)]
- paddd mm4, mm5
- paddd mm2, mm0
- dec ecx
- movd ebp, mm4
- jnz SpectrumLoop
- mov eax, MMX_PARAM5
- movq qword ptr [eax], mm2
- emms
- MMX_LEAVE
- }
-}
-
-
#endif // MMX code
//////////////////////////////////////////////////////////////////////////////////
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-01-19 13:56:24 UTC (rev 1500)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-01-19 15:14:38 UTC (rev 1501)
@@ -505,9 +505,6 @@
/*static*/ void EQStereo(int *pbuffer, UINT nCount);
/*static*/ void EQMono(int *pbuffer, UINT nCount);
#endif
- // Analyzer Functions
- static UINT WaveConvert(LPBYTE lpSrc, signed char *lpDest, UINT nSamples);
- static UINT WaveStereoConvert(LPBYTE lpSrc, signed char *lpDest, UINT nSamples);
static LONG SpectrumAnalyzer(signed char *pBuffer, UINT nSamples, UINT nInc, UINT nChannels);
// Float <-> Int conversion routines
/*static */VOID StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount);
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2013-01-19 13:56:24 UTC (rev 1500)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2013-01-19 15:14:38 UTC (rev 1501)
@@ -496,44 +496,6 @@
};
-int SpectrumSinusTable[256*2] =
-{
- 0, 1, 1, 2, 3, 3, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11,
- 12, 13, 14, 14, 15, 16, 17, 17, 18, 19, 20, 20, 21, 22, 22, 23,
- 24, 25, 25, 26, 27, 28, 28, 29, 30, 30, 31, 32, 32, 33, 34, 34,
- 35, 36, 36, 37, 38, 38, 39, 39, 40, 41, 41, 42, 42, 43, 44, 44,
- 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52,
- 53, 53, 53, 54, 54, ...
[truncated message content] |
|
From: <sag...@us...> - 2013-01-19 16:40:21
|
Revision: 1502
http://sourceforge.net/p/modplug/code/1502
Author: saga-games
Date: 2013-01-19 16:40:12 +0000 (Sat, 19 Jan 2013)
Log Message:
-----------
[Fix] Rearranging instruments didn't delete old samples properly, so they could be made visible again after adding a new sample.
[Ref] Removed some more old asm stuff.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Mmx_mix.cpp
trunk/OpenMPT/soundlib/ModChannel.h
trunk/OpenMPT/soundlib/SampleFormats.cpp
Modified: trunk/OpenMPT/soundlib/Mmx_mix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-01-19 15:14:38 UTC (rev 1501)
+++ trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-01-19 16:40:12 UTC (rev 1502)
@@ -35,60 +35,6 @@
#define PROCSUPPORT_3DNOW 0x08
#define PROCSUPPORT_SSE 0x10
-// Byte offsets into the ModChannel structure
-#define CHNOFS_PCURRENTSAMPLE ModChannel.pCurrentSample // 0
-#define CHNOFS_NPOS ModChannel.nPos // 4
-#define CHNOFS_NPOSLO ModChannel.nPosLo // 8
-#define CHNOFS_NINC ModChannel.nInc // 12
-#define CHNOFS_NRIGHTVOL ModChannel.nRightVol // 16
-#define CHNOFS_NLEFTVOL ModChannel.nLeftVol // 20
-#define CHNOFS_NRIGHTRAMP ModChannel.nRightRamp // 24
-#define CHNOFS_NLEFTRAMP ModChannel.nLeftRamp // 28
-
-
-#ifdef ENABLE_MMX
-
-#define MMX_PARAM1 20[esp]
-#define MMX_PARAM2 24[esp]
-#define MMX_PARAM3 28[esp]
-#define MMX_PARAM4 32[esp]
-#define MMX_PARAM5 36[esp]
-
-#define MMX_PCHANNEL MMX_PARAM1
-#define MMX_PBUFFER MMX_PARAM2
-#define MMX_PBUFMAX MMX_PARAM3
-
-#define MMX_ENTER \
- __asm push ebx \
- __asm push esi \
- __asm push edi \
- __asm push ebp
-
-
-#define MMX_LEAVE \
- __asm pop ebp \
- __asm pop edi \
- __asm pop esi \
- __asm pop ebx \
- __asm ret
-
-
-#endif
-
-#pragma warning (disable:4100)
-#pragma warning (disable:4799) // function has no EMMS instruction
-
-
-// -> CODE#0024 UPDATE#04
-// -> DESC="wav export update"
-//const float _f2ic = (float)(1 << 28);
-//const float _i2fc = (float)(1.0 / (1 << 28));
-//const float _f2ic = (float)0x7fffffff;
-//const float _i2fc = (float)(1.0 / 0x7fffffff);
-//const float _f2ic = (float)MIXING_CLIPMAX;
-//const float _i2fc = (float)(1.0/MIXING_CLIPMAX);
-// -! NEW_FEATURE#0024
-
static unsigned int QueryProcessorExtensions()
{
static unsigned int fProcessorExtensions = 0;
Modified: trunk/OpenMPT/soundlib/ModChannel.h
===================================================================
--- trunk/OpenMPT/soundlib/ModChannel.h 2013-01-19 15:14:38 UTC (rev 1501)
+++ trunk/OpenMPT/soundlib/ModChannel.h 2013-01-19 16:40:12 UTC (rev 1502)
@@ -30,9 +30,6 @@
// Mix Channel Struct
typedef struct __declspec(align(32)) ModChannel_
{
- // First 32-bytes: Most used mixing information: don't change it
- // These fields are accessed directly by the MMX mixing code (look out for CHNOFS_PCURRENTSAMPLE).
- // In the meantime, MMX mixing has been removed because it interfered with the new resonant filter code, and the byte offsets are also no longer hardcoded...
LPSTR pCurrentSample; // Currently playing sample (nullptr if no sample is playing)
uint32 nPos;
uint32 nPosLo; // actually 16-bit (fractional part)
@@ -41,7 +38,7 @@
int32 nLeftVol;
int32 nRightRamp;
int32 nLeftRamp;
- // 2nd cache line
+
SmpLength nLength;
SmpLength nLoopStart;
SmpLength nLoopEnd;
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-01-19 15:14:38 UTC (rev 1501)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-01-19 16:40:12 UTC (rev 1502)
@@ -119,8 +119,7 @@
bool CSoundFile::DestroyInstrument(INSTRUMENTINDEX nInstr, deleteInstrumentSamples removeSamples)
//-----------------------------------------------------------------------------------------------
{
- if ((!nInstr) || (nInstr > m_nInstruments)) return false;
- if (!Instruments[nInstr]) return true;
+ if(nInstr == 0 || nInstr >= MAX_INSTRUMENTS || !Instruments[nInstr]) return true;
#ifdef MODPLUG_TRACKER
if(removeSamples == askDeleteAssociatedSamples)
@@ -475,7 +474,7 @@
fwrite(&padding, 1, 1, f);
}
fwrite(&smpl, 1, smpl.wsiHdr.smpl_len + 8, f);
-
+
// "LIST" field
list.list_id = LittleEndian(IFFID_LIST);
list.list_len = LittleEndian(sizeof(list) - 8 // LIST
@@ -685,7 +684,7 @@
sample.nVibDepth = psh->vibrato_depth;
sample.nVibRate = psh->vibrato_rate/4;
sample.FrequencyToTranspose();
- sample.RelativeTone += static_cast<uint8>(84 - PatchFreqToNote(psh->root_freq));
+ sample.RelativeTone += static_cast<int8>(84 - PatchFreqToNote(psh->root_freq));
if(psh->scale_factor)
{
sample.RelativeTone = static_cast<uint8>(sample.RelativeTone - (psh->scale_frequency - 60));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-01-21 21:41:12
|
Revision: 1505
http://sourceforge.net/p/modplug/code/1505
Author: saga-games
Date: 2013-01-21 21:41:04 +0000 (Mon, 21 Jan 2013)
Log Message:
-----------
[Ref] Got rid of unused FASTSOUNDLIB queries.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/RowVisitor.cpp
trunk/OpenMPT/soundlib/Snd_dsp.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
trunk/OpenMPT/soundlib/Tables.cpp
trunk/OpenMPT/soundlib/Waveform.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-01-20 18:40:43 UTC (rev 1504)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-01-21 21:41:04 UTC (rev 1505)
@@ -30,10 +30,8 @@
int MixReverbBuffer[MIXBUFFERSIZE * 2];
#endif
-#ifndef FASTSOUNDLIB
int MixRearBuffer[MIXBUFFERSIZE * 2];
float MixFloatBuffer[MIXBUFFERSIZE * 2];
-#endif
#pragma bss_seg()
@@ -529,7 +527,6 @@
SNDMIX_STOREMONOVOL
END_MIX_INTERFACE()
-#ifndef FASTSOUNDLIB
BEGIN_MIX_INTERFACE(Mono8BitHQMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8HQSRC
@@ -541,10 +538,6 @@
SNDMIX_GETMONOVOL16HQSRC
SNDMIX_STOREMONOVOL
END_MIX_INTERFACE()
-#else
-#define Mono8BitHQMix Mono8BitLinearMix
-#define Mono16BitHQMix Mono16BitLinearMix
-#endif
// Volume Ramps
BEGIN_RAMPMIX_INTERFACE(Mono8BitRampMix)
@@ -571,7 +564,6 @@
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
-#ifndef FASTSOUNDLIB
BEGIN_RAMPMIX_INTERFACE(Mono8BitHQRampMix)
SNDMIX_BEGINSAMPLELOOP8
SNDMIX_GETMONOVOL8HQSRC
@@ -584,16 +576,9 @@
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
-#else
-#define Mono8BitHQRampMix Mono8BitLinearRampMix
-#define Mono16BitHQRampMix Mono16BitLinearRampMix
-#endif
-
//////////////////////////////////////////////////////
// 8-taps polyphase resampling filter
-#ifndef FASTSOUNDLIB
-
// Normal
BEGIN_MIX_INTERFACE(Mono8BitKaiserMix)
SNDMIX_INITSINCTABLE
@@ -624,22 +609,12 @@
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
-
-#else
-#define Mono8BitKaiserMix Mono8BitHQMix
-#define Mono16BitKaiserMix Mono16BitHQMix
-#define Mono8BitKaiserRampMix Mono8BitHQRampMix
-#define Mono16BitKaiserRampMix Mono16BitHQRampMix
-#endif
-
// -> BEHAVIOUR_CHANGE#0025
// -> DESC="enable polyphase resampling on stereo samples"
// rewbs.resamplerConf
//////////////////////////////////////////////////////
// FIR filter
-#ifndef FASTSOUNDLIB
-
// Normal
BEGIN_MIX_INTERFACE(Mono8BitFIRFilterMix)
//SNDMIX_INITSINCTABLE
@@ -670,13 +645,6 @@
SNDMIX_RAMPMONOVOL
END_RAMPMIX_INTERFACE()
-
-#else
-#define Mono8BitFIRFilterMix Mono8BitHQMix
-#define Mono16BitFIRFilterMix Mono16BitHQMix
-#define Mono8BitFIRFilterRampMix Mono8BitHQRampMix
-#define Mono16BitFIRFilterRampMix Mono16BitHQRampMix
-#endif
//end rewbs.resamplerConf
// -! BEHAVIOUR_CHANGE#0025
@@ -1492,10 +1460,8 @@
DWORD nchused, nchmixed;
if (!count) return 0;
-#ifndef FASTSOUNDLIB
BOOL bSurround;
if (gnChannels > 2) X86_InitMixBuffer(MixRearBuffer, count*2);
-#endif
nchused = nchmixed = 0;
for (UINT nChn=0; nChn<m_nMixChannels; nChn++)
{
@@ -1579,9 +1545,7 @@
pOfsR = &gnRvbROfsVol;
pOfsL = &gnRvbLOfsVol;
}
- #ifndef FASTSOUNDLIB
bSurround = (pbuffer == MixRearBuffer);
- #endif
#else
pbuffer = MixSoundBuffer;
#endif
@@ -2114,8 +2078,6 @@
//////////////////////////////////////////////////////////////////////////
// Noise Shaping (Dither)
-#ifndef FASTSOUNDLIB
-
#pragma warning(disable:4731) // ebp modified
void MPPASMCALL X86_Dither(int *pBuffer, UINT nSamples, UINT nBits)
@@ -2196,9 +2158,7 @@
}
}
-#endif // FASTSOUNDLIB
-
VOID MPPASMCALL X86_MonoFromStereo(int *pMixBuf, UINT nSamples)
//-------------------------------------------------------------
{
Modified: trunk/OpenMPT/soundlib/RowVisitor.cpp
===================================================================
--- trunk/OpenMPT/soundlib/RowVisitor.cpp 2013-01-20 18:40:43 UTC (rev 1504)
+++ trunk/OpenMPT/soundlib/RowVisitor.cpp 2013-01-21 21:41:04 UTC (rev 1505)
@@ -39,12 +39,15 @@
for(ORDERINDEX order = 0; order < endOrder; order++)
{
VisitedRowsBaseType &row = visitedRows[order];
- // If we want to reset the vectors completely, we overwrite existing items with false.
+ const size_t size = GetVisitedRowsVectorSize(sndFile.Order[order]);
if(reset)
{
- row.assign(row.size(), false);
+ // If we want to reset the vectors completely, we overwrite existing items with false.
+ row.assign(size, false);
+ } else
+ {
+ row.resize(size, false);
}
- row.resize(GetVisitedRowsVectorSize(sndFile.Order[order]), false);
}
}
Modified: trunk/OpenMPT/soundlib/Snd_dsp.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_dsp.cpp 2013-01-20 18:40:43 UTC (rev 1504)
+++ trunk/OpenMPT/soundlib/Snd_dsp.cpp 2013-01-21 21:41:04 UTC (rev 1505)
@@ -279,7 +279,6 @@
}
-#ifndef FASTSOUNDLIB
// 4-channels surround
static void ProcessQuadSurround(int count)
//----------------------------------------
@@ -309,7 +308,6 @@
}
nDolbyHP_Y1 = hy1;
}
-#endif
void CSoundFile::ProcessStereoDSP(int count)
@@ -318,9 +316,7 @@
// Dolby Pro-Logic Surround
if (gdwSoundSetup & SNDMIX_SURROUND)
{
-#ifndef FASTSOUNDLIB
if (gnChannels > 2) ProcessQuadSurround(count); else
-#endif
ProcessStereoSurround(count);
}
// DC Removal
@@ -412,7 +408,6 @@
}
-#ifndef FASTSOUNDLIB
//////////////////////////////////////////////////////////////////////////
//
@@ -496,12 +491,10 @@
}
}
-#endif // FASTSOUNDLIB
-
/////////////////////////////////////////////////////////////////
// Clean DSP Effects interface
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-01-20 18:40:43 UTC (rev 1504)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-01-21 21:41:04 UTC (rev 1505)
@@ -4330,8 +4330,7 @@
//-----------------------------------
{
// ModPlug Tracker and Mod-Plugin don't do this check
-#ifndef MODPLUG_TRACKER
-#ifndef FASTSOUNDLIB
+#ifdef MODPLUG_PLAYER
// Big Hack!!!
if ((!param) || (param >= 0x80) || ((GetType() & (MOD_TYPE_MOD|MOD_TYPE_XM|MOD_TYPE_MT2)) && (param >= 0x1E)))
{
@@ -4340,8 +4339,7 @@
GlobalFadeSong(1000);
}
}
-#endif // FASTSOUNDLIB
-#endif // MODPLUG_TRACKER
+#endif // MODPLUG_PLAYER
// Allow high speed values here for VBlank MODs. (Maybe it would be better to have a "VBlank MOD" flag somewhere? Is it worth the effort?)
if ((param) && (param <= GetModSpecifications().speedMax || (GetType() & MOD_TYPE_MOD))) m_nMusicSpeed = param;
}
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-01-20 18:40:43 UTC (rev 1504)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-01-21 21:41:04 UTC (rev 1505)
@@ -34,7 +34,6 @@
"|mo3"
#endif
;
-//Should there be mptm?
#endif // NO_ARCHIVE_SUPPORT
#else // NO_COPYRIGHT: EarSaver only loads mod/s3m/xm/it/wav
#define MODPLUG_BASIC_SUPPORT
@@ -171,7 +170,7 @@
RPB. [EXT] nRowsPerBeat;
RPM. [EXT] nRowsPerMeasure;
RS.. nResSwing;
-SEP@ [EXT] chunk SEPARATOR tag
+SEP@ [EXT] chunk SEPARATOR tag
SPA. [EXT] m_nSamplePreAmp;
TM.. [EXT] nTempoMode;
VE.. VolEnv.nNodes;
@@ -258,8 +257,8 @@
fwrite(&dwFlags, 1, fsize, file);
}
-WRITE_MPTHEADER_sized_member( nGlobalVol , UINT , GV.. )
-WRITE_MPTHEADER_sized_member( nPan , UINT , P... )
+WRITE_MPTHEADER_sized_member( nGlobalVol , uint32 , GV.. )
+WRITE_MPTHEADER_sized_member( nPan , uint32 , P... )
WRITE_MPTHEADER_sized_member( VolEnv.nNodes , uint32 , VE.. )
WRITE_MPTHEADER_sized_member( PanEnv.nNodes , uint32 , PE.. )
WRITE_MPTHEADER_sized_member( PitchEnv.nNodes , uint32 , PiE. )
@@ -391,11 +390,11 @@
GET_MPTHEADER_sized_member( nPluginVelocityHandling , uint8 , PVEH )
GET_MPTHEADER_sized_member( nPluginVolumeHandling , uint8 , PVOH )
GET_MPTHEADER_sized_member( PitchEnv.nReleaseNode , uint8 , PERN )
-GET_MPTHEADER_sized_member( PanEnv.nReleaseNode , uint8 , AERN )
+GET_MPTHEADER_sized_member( PanEnv.nReleaseNode , uint8 , AERN )
GET_MPTHEADER_sized_member( VolEnv.nReleaseNode , uint8 , VERN )
-GET_MPTHEADER_sized_member( PitchEnv.dwFlags , DWORD , PFLG )
-GET_MPTHEADER_sized_member( PanEnv.dwFlags , DWORD , AFLG )
-GET_MPTHEADER_sized_member( VolEnv.dwFlags , DWORD , VFLG )
+GET_MPTHEADER_sized_member( PitchEnv.dwFlags , uint32 , PFLG )
+GET_MPTHEADER_sized_member( PanEnv.dwFlags , uint32 , AFLG )
+GET_MPTHEADER_sized_member( VolEnv.dwFlags , uint32 , VFLG )
GET_MPTHEADER_sized_member( midiPWD , int8 , MPWD )
}
@@ -612,7 +611,6 @@
#ifndef MODPLUG_BASIC_SUPPORT
&& !ReadSTM(file)
&& !ReadMed(lpStream, dwMemLength)
-#ifndef FASTSOUNDLIB
&& !ReadMTM(file)
&& !ReadMDL(lpStream, dwMemLength)
&& !ReadDBM(lpStream, dwMemLength)
@@ -634,7 +632,6 @@
#ifdef MODPLUG_TRACKER
&& !ReadMID(lpStream, dwMemLength)
#endif // MODPLUG_TRACKER
-#endif
#endif // MODPLUG_BASIC_SUPPORT
&& !ReadGDM(file)
&& !ReadIMF(lpStream, dwMemLength)
@@ -1411,8 +1408,6 @@
}
-#ifndef FASTSOUNDLIB
-
// Check whether a sample is used.
// In sample mode, the sample numbers in all patterns are checked.
// In instrument mode, it is only checked if a sample is referenced by an instrument (but not if the sample is actually played anywhere)
@@ -1598,7 +1593,6 @@
return true;
}
-#endif // FASTSOUNDLIB
void CSoundFile::DeleteStaticdata()
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-01-20 18:40:43 UTC (rev 1504)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-01-21 21:41:04 UTC (rev 1505)
@@ -472,7 +472,7 @@
public:
// Mixer Config
- static BOOL SetMixerSettings(const MixerSettings & mixersettings);
+ static void SetMixerSettings(const MixerSettings &mixersettings);
static MixerSettings GetMixerSettings();
static BOOL InitPlayer(BOOL bReset=FALSE);
static BOOL SetWaveConfig(UINT nRate,UINT nBits,UINT nChannels,BOOL bMMX=FALSE);
@@ -787,19 +787,15 @@
///////////////////////////////////////////////////////////
// File Formats Information (name, extension, etc)
-#ifndef FASTSOUNDLIB
-
-typedef struct MODFORMATINFO
+struct MODFORMATINFO
{
MODTYPE mtFormatId; // MOD_TYPE_XXXX
LPCSTR lpszFormatName; // "ProTracker"
LPCSTR lpszExtension; // ".xxx"
DWORD dwPadding;
-} MODFORMATINFO;
+};
-#endif
-
// Read instrument property with 'code' and 'size' from 'file' to instrument 'pIns'.
void ReadInstrumentExtensionField(ModInstrument* pIns, const uint32 code, const uint16 size, FileReader &file);
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-01-20 18:40:43 UTC (rev 1504)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-01-21 21:41:04 UTC (rev 1505)
@@ -63,7 +63,7 @@
extern VOID MPPASMCALL X86_InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nSamples);
extern VOID MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs);
extern VOID MPPASMCALL X86_MonoFromStereo(int *pMixBuf, UINT nSamples);
-extern void SndMixInitializeTables(const MixerSettings & mixersettings);
+extern void SndMixInitializeTables(const MixerSettings &mixersettings);
extern short int ModSinusTable[64];
extern short int ModRampDownTable[64];
@@ -162,7 +162,7 @@
neg eax
rneg:
mov result, eax
- }
+}
return result;
}
@@ -214,8 +214,8 @@
}
-BOOL CSoundFile::SetMixerSettings(const MixerSettings & mixersettings)
-//--------------------------------------------------------------------
+void CSoundFile::SetMixerSettings(const MixerSettings &mixersettings)
+//-------------------------------------------------------------------
{
// Start with ramping disabled to avoid clicks on first read.
@@ -226,12 +226,10 @@
gdWFIRCutoff = mixersettings.gdWFIRCutoff;
gbWFIRType = mixersettings.gbWFIRType;
-
- return TRUE;
}
MixerSettings CSoundFile::GetMixerSettings()
-//--------------------------------------------------------------------
+//------------------------------------------
{
MixerSettings mixersettings;
mixersettings.glVolumeRampUpSamples = gnVolumeRampUpSamplesTarget;
@@ -245,13 +243,12 @@
BOOL CSoundFile::InitPlayer(BOOL bReset)
//--------------------------------------
{
-#ifndef FASTSOUNDLIB
if (!gbInitTables)
{
SndMixInitializeTables(GetMixerSettings());
gbInitTables = true;
}
-#endif
+
if (m_nMaxMixChannels > MAX_CHANNELS) m_nMaxMixChannels = MAX_CHANNELS;
if (gdwMixingFreq < 4000) gdwMixingFreq = 4000;
if (gdwMixingFreq > MAX_SAMPLE_RATE) gdwMixingFreq = MAX_SAMPLE_RATE;
@@ -320,11 +317,9 @@
m_nMixStat = 0;
lSampleSize = gnChannels;
- if (gnBitsPerSample == 16) { lSampleSize *= 2; pCvt = X86_Convert32To16; }
-#ifndef FASTSOUNDLIB
- else if (gnBitsPerSample == 24) { lSampleSize *= 3; pCvt = X86_Convert32To24; }
- else if (gnBitsPerSample == 32) { lSampleSize *= 4; pCvt = X86_Convert32To32; }
-#endif // FASTSOUNDLIB
+ if(gnBitsPerSample == 16) { lSampleSize *= 2; pCvt = X86_Convert32To16; }
+ else if(gnBitsPerSample == 24) { lSampleSize *= 3; pCvt = X86_Convert32To24; }
+ else if(gnBitsPerSample == 32) { lSampleSize *= 4; pCvt = X86_Convert32To32; }
lMax = cbBuffer / lSampleSize;
if ((!lMax) || (!lpBuffer) || (!m_nChannels)) return 0;
@@ -338,13 +333,11 @@
if (!m_nBufferCount)
{
-#ifndef FASTSOUNDLIB
if(m_SongFlags[SONG_FADINGSONG])
{
m_SongFlags.set(SONG_ENDREACHED);
m_nBufferCount = lRead;
} else
-#endif // FASTSOUNDLIB
if (ReadNote())
{
@@ -367,9 +360,7 @@
}
#endif // MODPLUG_TRACKER
-#ifndef FASTSOUNDLIB
if (!FadeSong(FADESONGDELAY) || m_bIsRendering) //rewbs: disable song fade when rendering.
-#endif // FASTSOUNDLIB
{
m_SongFlags.set(SONG_ENDREACHED);
if (lRead == lMax || m_bIsRendering) //rewbs: don't complete buffer when rendering
@@ -453,16 +444,13 @@
UINT lTotalSampleCount = lSampleCount; // Including rear channels
-#ifndef FASTSOUNDLIB
// Multichannel
if (gnChannels > 2)
{
X86_InterleaveFrontRear(MixSoundBuffer, MixRearBuffer, lSampleCount);
lTotalSampleCount *= 2;
}
-#endif // FASTSOUNDLIB
-#ifndef FASTSOUNDLIB
// Noise Shaping
if (gnBitsPerSample <= 16)
{
@@ -477,7 +465,6 @@
//Currently only used for VU Meter, so it's OK to do it after global Vol.
gpSndMixHook(MixSoundBuffer, lTotalSampleCount, gnChannels);
}
-#endif // FASTSOUNDLIB
// Perform clipping
lpBuffer += pCvt(lpBuffer, MixSoundBuffer, lTotalSampleCount);
@@ -689,7 +676,7 @@
if (nStat2) { pSndFile->m_nMixStat += nStat2 - 1; pSndFile->m_nMixStat /= nStat2; }
return lMax - lRead;
}
-#endif // FASTSOUNDLIB
+#endif // MODPLUG_PLAYER
/////////////////////////////////////////////////////////////////////////////
@@ -1866,7 +1853,6 @@
LONG nRightDelta = ((pChn->nNewRightVol - pChn->nRightVol) << VOLUMERAMPPRECISION);
LONG nLeftDelta = ((pChn->nNewLeftVol - pChn->nLeftVol) << VOLUMERAMPPRECISION);
-#ifndef FASTSOUNDLIB
// if ((gdwSoundSetup & SNDMIX_DIRECTTODISK)
// || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU))
// && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50)))
@@ -1886,7 +1872,6 @@
}
}
}
-#endif // FASTSOUNDLIB
pChn->nRightRamp = nRightDelta / rampLength;
pChn->nLeftRamp = nLeftDelta / rampLength;
@@ -2269,9 +2254,7 @@
pan /= 128;
pan += 128;
Limit(pan, 0, 256);
-#ifndef FASTSOUNDLIB
if (gdwSoundSetup & SNDMIX_REVERSESTEREO) pan = 256 - pan;
-#endif
LONG realvol;
if (m_pConfig->getUseGlobalPreAmp())
@@ -2316,7 +2299,7 @@
} else
{
pChn->dwFlags.reset(CHN_NOIDO | CHN_HQSRC);
-#ifndef FASTSOUNDLIB
+
if (pChn->nInc == 0x10000)
{
pChn->dwFlags.set(CHN_NOIDO);
@@ -2354,9 +2337,6 @@
|| ((gnCPUUsage > 80) && (pChn->nNewLeftVol < 0x100) && (pChn->nNewRightVol < 0x100)))
pChn->dwFlags.set(CHN_NOIDO);
}
-#else
- if (pChn->nInc >= 0xFE00) pChn->dwFlags.set(CHN_NOIDO);
-#endif // FASTSOUNDLIB
}
/*if (m_pConfig->getUseGlobalPreAmp())
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2013-01-20 18:40:43 UTC (rev 1504)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2013-01-21 21:41:04 UTC (rev 1505)
@@ -19,7 +19,6 @@
///////////////////////////////////////////////////////////////////////
-#ifndef FASTSOUNDLIB
/*MODFORMATINFO gModFormatInfo[] =
{
@@ -52,13 +51,9 @@
{ MOD_TYPE_IMF, "Imago Orpheus", ".imf", 0 },
};*/
-#endif
-
///////////////////////////////////////////////////////////////////////
-#ifndef FASTSOUNDLIB
#pragma data_seg(".tables")
#pragma bss_seg(".modplug")
-#endif
///////////////////////////////////////////////////////////////////////
@@ -496,7 +491,6 @@
};
-#ifndef FASTSOUNDLIB
// Reversed sinc coefficients
// we should avoid all compiler directives like this. It will cause errors in vanilla VC6.
@@ -663,5 +657,3 @@
//end ericus' downsampling improvement.
}
-
-#endif // not FASTSOUNDLIB
Modified: trunk/OpenMPT/soundlib/Waveform.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Waveform.cpp 2013-01-20 18:40:43 UTC (rev 1504)
+++ trunk/OpenMPT/soundlib/Waveform.cpp 2013-01-21 21:41:04 UTC (rev 1505)
@@ -12,8 +12,6 @@
#include "stdafx.h"
#include "sndfile.h"
-#ifndef FASTSOUNDLIB
-
#define ASM_NORMALIZE
#ifdef ASM_NORMALIZE
@@ -102,6 +100,3 @@
return i;
#endif
}
-
-
-#endif // FASTSOUNDLIB
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-02-04 16:32:04
|
Revision: 1514
http://sourceforge.net/p/modplug/code/1514
Author: saga-games
Date: 2013-02-04 16:31:55 +0000 (Mon, 04 Feb 2013)
Log Message:
-----------
[Ref] Removed more unused CPU-limiting code.
[Mod] XM tempo limits were accidentally set to 10000 a while ago (this will come... but not now.)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_defs.h
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/mod_specifications.h
Modified: trunk/OpenMPT/soundlib/Snd_defs.h
===================================================================
--- trunk/OpenMPT/soundlib/Snd_defs.h 2013-02-03 20:58:24 UTC (rev 1513)
+++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-02-04 16:31:55 UTC (rev 1514)
@@ -253,7 +253,7 @@
SONG_FADINGSONG = 0x0100, // Song is fading out
SONG_ENDREACHED = 0x0200, // Song is finished
SONG_GLOBALFADE = 0x0400, // Song is fading out
- SONG_CPUVERYHIGH = 0x0800, // High CPU usage
+ //SONG_CPUVERYHIGH = 0x0800, // High CPU usage
SONG_FIRSTTICK = 0x1000, // Is set when the current tick is the first tick of the row
SONG_MPTFILTERMODE = 0x2000, // Local filter mode (reset filter on each note)
SONG_SURROUNDPAN = 0x4000, // Pan in the rear channels
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-02-03 20:58:24 UTC (rev 1513)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-02-04 16:31:55 UTC (rev 1514)
@@ -1303,8 +1303,8 @@
}
-void CSoundFile::CheckNNA(CHANNELINDEX nChn, UINT instr, int note, BOOL bForceCut)
-//--------------------------------------------------------------------------------
+void CSoundFile::CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut)
+//-------------------------------------------------------------------------------
{
ModChannel *pChn = &Chn[nChn];
ModInstrument *pIns = nullptr;
@@ -1314,23 +1314,24 @@
return;
}
// Always NNA cut - using
- if ((!(m_nType & (MOD_TYPE_IT|MOD_TYPE_MPT|MOD_TYPE_MT2))) || (!m_nInstruments) || (bForceCut))
+ if(!(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_MT2)) || !m_nInstruments || forceCut)
{
- if (m_SongFlags[SONG_CPUVERYHIGH]
- || (!pChn->nLength) || pChn->dwFlags[CHN_MUTE]
- | ((!pChn->nLeftVol) && (!pChn->nRightVol))) return;
+ if(!pChn->nLength || pChn->dwFlags[CHN_MUTE] || !(pChn->nLeftVol | pChn->nRightVol))
+ {
+ return;
+ }
- UINT n = GetNNAChannel(nChn);
- if (!n) return;
- ModChannel *p = &Chn[n];
+ CHANNELINDEX n = GetNNAChannel(nChn);
+ if(!n) return;
+ ModChannel &chn = Chn[n];
// Copy Channel
- *p = *pChn;
- p->dwFlags.reset(CHN_VIBRATO | CHN_TREMOLO | CHN_PANBRELLO | CHN_MUTE | CHN_PORTAMENTO);
- p->nMasterChn = nChn + 1;
- p->nCommand = CMD_NONE;
+ chn = *pChn;
+ chn.dwFlags.reset(CHN_VIBRATO | CHN_TREMOLO | CHN_PANBRELLO | CHN_MUTE | CHN_PORTAMENTO);
+ chn.nMasterChn = nChn + 1;
+ chn.nCommand = CMD_NONE;
// Cut the note
- p->nFadeOutVol = 0;
- p->dwFlags.set(CHN_NOTEFADE | CHN_FASTVOLRAMP);
+ chn.nFadeOutVol = 0;
+ chn.dwFlags.set(CHN_NOTEFADE | CHN_FASTVOLRAMP);
// Stop this channel
pChn->nLength = pChn->nPos = pChn->nPosLo = 0;
pChn->nROfs = pChn->nLOfs = 0;
@@ -1351,7 +1352,7 @@
n = pIns->Keyboard[note - 1];
note = pIns->NoteMap[note - 1];
if(n > 0 && n < MAX_SAMPLES) pSample = Samples[n].pSample;
- }
+ }
} else pSample = nullptr;
}
ModChannel *p = pChn;
@@ -1895,9 +1896,9 @@
pChn->nNewNote = pChn->nLastNote = note;
// New Note Action ?
- if (!bPorta)
+ if(!bPorta)
{
- CheckNNA(nChn, instr, note, FALSE);
+ CheckNNA(nChn, instr, note, false);
}
}
@@ -4136,7 +4137,7 @@
}
UINT nNote = pChn->nNewNote;
int32 nOldPeriod = pChn->nPeriod;
- if ((nNote) && (nNote <= NOTE_MAX) && (pChn->nLength)) CheckNNA(nChn, 0, nNote, TRUE);
+ if ((nNote) && (nNote <= NOTE_MAX) && (pChn->nLength)) CheckNNA(nChn, 0, nNote, true);
bool bResetEnv = false;
if (GetType() & (MOD_TYPE_XM|MOD_TYPE_MT2))
{
@@ -4172,7 +4173,7 @@
// Now we can also store the retrig value for IT...
if(!IsCompatibleMode(TRK_IMPULSETRACKER))
- pChn->nRetrigCount = (BYTE)nRetrigCount;
+ pChn->nRetrigCount = nRetrigCount;
}
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-02-03 20:58:24 UTC (rev 1513)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-02-04 16:31:55 UTC (rev 1514)
@@ -1024,7 +1024,7 @@
m_nMusicTempo = m_nDefaultTempo;
visitedSongRows.Initialize(true);
}
- m_SongFlags.reset(SONG_CPUVERYHIGH | SONG_FADINGSONG | SONG_ENDREACHED | SONG_GLOBALFADE);
+ m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED | SONG_GLOBALFADE);
for (nPattern = 0; nPattern < Order.size(); nPattern++)
{
UINT ord = Order[nPattern];
@@ -1121,7 +1121,7 @@
m_nNextPatStartRow = 0;
}
- m_SongFlags.reset(SONG_CPUVERYHIGH | SONG_FADINGSONG | SONG_ENDREACHED | SONG_GLOBALFADE);
+ m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED | SONG_GLOBALFADE);
}
//rewbs.VSTCompliance
@@ -1199,7 +1199,7 @@
void CSoundFile::ResetChannels()
//------------------------------
{
- m_SongFlags.reset(SONG_CPUVERYHIGH | SONG_FADINGSONG | SONG_ENDREACHED | SONG_GLOBALFADE);
+ m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED | SONG_GLOBALFADE);
m_nBufferCount = 0;
for (UINT i=0; i<MAX_CHANNELS; i++)
{
@@ -1378,36 +1378,6 @@
}
-void CSoundFile::CheckCPUUsage(UINT nCPU)
-//---------------------------------------
-{
- if (nCPU > 100) nCPU = 100;
- gnCPUUsage = nCPU;
- if (nCPU < 90)
- {
- m_SongFlags.reset(SONG_CPUVERYHIGH);
- } else
- if(m_SongFlags[SONG_CPUVERYHIGH] && nCPU >= 94)
- {
- UINT i=MAX_CHANNELS;
- while (i >= 8)
- {
- i--;
- if (Chn[i].nLength)
- {
- Chn[i].nLength = Chn[i].nPos = 0;
- nCPU -= 2;
- if (nCPU < 94) break;
- }
- }
- } else
- if (nCPU > 90)
- {
- m_SongFlags.set(SONG_CPUVERYHIGH);
- }
-}
-
-
// Check whether a sample is used.
// In sample mode, the sample numbers in all patterns are checked.
// In instrument mode, it is only checked if a sample is referenced by an instrument (but not if the sample is actually played anywhere)
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-02-03 20:58:24 UTC (rev 1513)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-02-04 16:31:55 UTC (rev 1514)
@@ -380,7 +380,6 @@
int GetRepeatCount() const { return m_nRepeatCount; }
bool IsPaused() const { return m_SongFlags[SONG_PAUSED | SONG_STEP]; } // Added SONG_STEP as it seems to be desirable in most cases to check for this as well.
void LoopPattern(PATTERNINDEX nPat, ROWINDEX nRow = 0);
- void CheckCPUUsage(UINT nCPU);
void SetupITBidiMode();
@@ -517,7 +516,7 @@
BOOL ProcessRow();
BOOL ProcessEffects();
CHANNELINDEX GetNNAChannel(CHANNELINDEX nChn) const;
- void CheckNNA(CHANNELINDEX nChn, UINT instr, int note, BOOL bForceCut);
+ void CheckNNA(CHANNELINDEX nChn, UINT instr, int note, bool forceCut);
void NoteChange(CHANNELINDEX nChn, int note, bool bPorta = false, bool bResetEnv = true, bool bManual = false);
void InstrumentChange(ModChannel *pChn, UINT instr, bool bPorta = false, bool bUpdVol = true, bool bResetEnv = true);
Modified: trunk/OpenMPT/soundlib/mod_specifications.h
===================================================================
--- trunk/OpenMPT/soundlib/mod_specifications.h 2013-02-03 20:58:24 UTC (rev 1513)
+++ trunk/OpenMPT/soundlib/mod_specifications.h 2013-02-04 16:31:55 UTC (rev 1514)
@@ -182,7 +182,7 @@
1, // Channel min
32, // Channel max
32, // Min tempo
- 10000, // Max tempo
+ 512, // Max tempo
1, // Min pattern rows
256, // Max pattern rows
20, // Max mod name length
@@ -225,7 +225,7 @@
1, // Channel min
127, // Channel max
32, // Min tempo
- 10000, // Max tempo
+ 512, // Max tempo
1, // Min pattern rows
1024, // Max pattern rows
20, // Max mod name length
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-02-11 22:31:10
|
Revision: 1520
http://sourceforge.net/p/modplug/code/1520
Author: saga-games
Date: 2013-02-11 22:31:02 +0000 (Mon, 11 Feb 2013)
Log Message:
-----------
[Fix] Updated mod_specifications.h was missing in rev.1518
[Fix] Saving MODs with != 4 channels broke some revisions ago.
[Mod] Can now create MODs with up to 99 channels.
[Ref] The actual CModSpecifications objects have been moved to mod_specifications.cpp, so that they are not inserted into every compilation unit => yay, smaller executable!
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_mod.cpp
trunk/OpenMPT/soundlib/mod_specifications.cpp
trunk/OpenMPT/soundlib/mod_specifications.h
Modified: trunk/OpenMPT/soundlib/Load_mod.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_mod.cpp 2013-02-11 21:58:06 UTC (rev 1519)
+++ trunk/OpenMPT/soundlib/Load_mod.cpp 2013-02-11 22:31:02 UTC (rev 1520)
@@ -1046,25 +1046,23 @@
fwrite(&fileHeader, sizeof(fileHeader), 1, f);
// Write magic bytes
- char magic[4];
+ char modMagic[6];
CHANNELINDEX writeChannels = min(99, GetNumChannels());
if(writeChannels == 4)
{
if(writePatterns < 64)
{
- memcpy(magic, "M.K.", 4);
+ memcpy(modMagic, "M.K.", 4);
} else
{
// More than 64 patterns
- memcpy(magic, "M!K!", 4);
+ memcpy(modMagic, "M!K!", 4);
}
} else
{
- char magic[6];
- sprintf(magic, "%luCHN", writeChannels);
- memcpy(magic, magic, 4);
+ sprintf(modMagic, "%luCHN", writeChannels);
}
- fwrite(&magic, sizeof(magic), 1, f);
+ fwrite(&modMagic, 4, 1, f);
// Write patterns
vector<uint8> events;
Modified: trunk/OpenMPT/soundlib/mod_specifications.cpp
===================================================================
--- trunk/OpenMPT/soundlib/mod_specifications.cpp 2013-02-11 21:58:06 UTC (rev 1519)
+++ trunk/OpenMPT/soundlib/mod_specifications.cpp 2013-02-11 22:31:02 UTC (rev 1520)
@@ -13,6 +13,353 @@
#include "../common/misc_util.h"
+namespace ModSpecs
+{
+
+const CModSpecifications mptm =
+{
+ /*
+ TODO: Proper, less arbitrarily chosen values here.
+ NOTE: If changing limits, see whether:
+ -savefile format and GUI methods can handle new values(might not be a small task :).
+ */
+ "mptm", // File extension
+ MOD_TYPE_MPT, // Internal MODTYPE value
+ NOTE_MIN, // Minimum note index
+ NOTE_MAX, // Maximum note index
+ true, // Has notecut.
+ true, // Has noteoff.
+ true, // Has notefade.
+ 4000, // Pattern max.
+ 4000, // Order max.
+ 1, // Channel min
+ 127, // Channel max
+ 32, // Min tempo
+ 512, // Max tempo
+ 1, // Min pattern rows
+ 1024, // Max pattern rows
+ 25, // Max mod name length
+ 25, // Max sample name length
+ 12, // Max sample filename length
+ 25, // Max instrument name length
+ 12, // Max instrument filename length
+ 3999, // SamplesMax
+ 255, // instrumentMax
+ mixLevels_117RC3, // defaultMixLevels
+ 200, // Max MIDI mapping directives
+ 1, // Min Speed
+ 255, // Max Speed
+ true, // Has song comments
+ MAX_ENVPOINTS, // Envelope point count
+ true, // Has envelope release node
+ " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z\\:#??", // Supported Effects
+ " vpcdabuhlrgfe?o", // Supported Volume Column commands
+ true, // Has "+++" pattern
+ true, // Has restart position (order)
+ true, // Supports plugins
+ true, // Custom pattern time signatures
+ true, // Pattern names
+ SONG_LINEARSLIDES | SONG_EXFILTERRANGE | SONG_ITOLDEFFECTS | SONG_ITCOMPATGXX | SONG_EMBEDMIDICFG, // Supported song flags
+};
+
+
+
+
+const CModSpecifications mod =
+{
+ "mod", // File extension
+ MOD_TYPE_MOD, // Internal MODTYPE value
+ 37, // Minimum note index
+ 108, // Maximum note index
+ false, // No notecut.
+ false, // No noteoff.
+ false, // No notefade.
+ 128, // Pattern max.
+ 128, // Order max.
+ 4, // Channel min
+ 99, // Channel max
+ 32, // Min tempo
+ 255, // Max tempo
+ 64, // Min pattern rows
+ 64, // Max pattern rows
+ 20, // Max mod name length
+ 22, // Max sample name length
+ 0, // Max sample filename length
+ 0, // Max instrument name length
+ 0, // Max instrument filename length
+ 31, // SamplesMax
+ 0, // instrumentMax
+ mixLevels_compatible, // defaultMixLevels
+ 0, // Max MIDI mapping directives
+ 1, // Min Speed
+ 32, // Max Speed
+ false, // No song comments
+ 0, // No instrument envelopes
+ false, // No envelope release node
+ " 0123456789ABCD?FF?E?????????????????", // Supported Effects
+ " ???????????????", // Supported Volume Column commands
+ false, // Doesn't have "+++" pattern
+ true, // Has restart position (order)
+ false, // Doesn't support plugins
+ false, // No custom pattern time signatures
+ false, // No pattern names
+ SONG_PT1XMODE, // Supported song flags
+};
+
+
+const CModSpecifications xm =
+{
+ "xm", // File extension
+ MOD_TYPE_XM, // Internal MODTYPE value
+ 13, // Minimum note index
+ 108, // Maximum note index
+ false, // No notecut.
+ true, // Has noteoff.
+ false, // No notefade.
+ 256, // Pattern max.
+ 255, // Order max.
+ 1, // Channel min
+ 32, // Channel max
+ 32, // Min tempo
+ 512, // Max tempo
+ 1, // Min pattern rows
+ 256, // Max pattern rows
+ 20, // Max mod name length
+ 22, // Max sample name length
+ 0, // Max sample filename length
+ 22, // Max instrument name length
+ 0, // Max instrument filename length
+ 128 * 16, // SamplesMax (actually 16 per instrument)
+ 128, // instrumentMax
+ mixLevels_compatible, // defaultMixLevels
+ 0, // Max MIDI mapping directives
+ 1, // Min Speed
+ 31, // Max Speed
+ false, // No song comments
+ 12, // Envelope point count
+ false, // No envelope release node
+ " 0123456789ABCDRFFTE???GHK??XPL??????", // Supported Effects
+ " vpcdabuhlrg????", // Supported Volume Column commands
+ false, // Doesn't have "+++" pattern
+ true, // Has restart position (order)
+ false, // Doesn't support plugins
+ false, // No custom pattern time signatures
+ false, // No pattern names
+ SONG_LINEARSLIDES, // Supported song flags
+};
+
+// XM with MPT extensions
+const CModSpecifications xmEx =
+{
+ "xm", // File extension
+ MOD_TYPE_XM, // Internal MODTYPE value
+ 13, // Minimum note index
+ 108, // Maximum note index
+ false, // No notecut.
+ true, // Has noteoff.
+ false, // No notefade.
+ 256, // Pattern max.
+ 255, // Order max.
+ 1, // Channel min
+ 127, // Channel max
+ 32, // Min tempo
+ 512, // Max tempo
+ 1, // Min pattern rows
+ 1024, // Max pattern rows
+ 20, // Max mod name length
+ 22, // Max sample name length
+ 0, // Max sample filename length
+ 22, // Max instrument name length
+ 0, // Max instrument filename length
+ MAX_SAMPLES - 1, // SamplesMax (actually 32 per instrument(256 * 32 = 8192), but limited to MAX_SAMPLES = 4000)
+ 255, // instrumentMax
+ mixLevels_compatible, // defaultMixLevels
+ 200, // Max MIDI mapping directives
+ 1, // Min Speed
+ 31, // Max Speed
+ true, // Has song comments
+ 12, // Envelope point count
+ false, // No envelope release node
+ " 0123456789ABCDRFFTE???GHK?YXPLZ\\?#??", // Supported Effects
+ " vpcdabuhlrgfe?o", // Supported Volume Column commands
+ false, // Doesn't have "+++" pattern
+ true, // Has restart position (order)
+ true, // Supports plugins
+ false, // No custom pattern time signatures
+ true, // Pattern names
+ SONG_LINEARSLIDES | SONG_EXFILTERRANGE | SONG_EMBEDMIDICFG, // Supported song flags
+};
+
+const CModSpecifications s3m =
+{
+ "s3m", // File extension
+ MOD_TYPE_S3M, // Internal MODTYPE value
+ 13, // Minimum note index
+ 108, // Maximum note index
+ true, // Has notecut.
+ false, // No noteoff.
+ false, // No notefade.
+ 100, // Pattern max.
+ 255, // Order max.
+ 1, // Channel min
+ 32, // Channel max
+ 33, // Min tempo
+ 255, // Max tempo
+ 64, // Min pattern rows
+ 64, // Max pattern rows
+ 27, // Max mod name length
+ 27, // Max sample name length
+ 12, // Max sample filename length
+ 0, // Max instrument name length
+ 0, // Max instrument filename length
+ 99, // SamplesMax
+ 0, // instrumentMax
+ mixLevels_compatible, // defaultMixLevels
+ 0, // Max MIDI mapping directives
+ 1, // Min Speed
+ 255, // Max Speed
+ false, // No song comments
+ 0, // No instrument envelopes
+ false, // No envelope release node
+ " JFEGHLKRXODB?CQATI?SMNVW?U??????????", // Supported Effects
+ " vp?????????????", // Supported Volume Column commands
+ true, // Has "+++" pattern
+ false, // Doesn't have restart position (order)
+ false, // Doesn't support plugins
+ false, // No custom pattern time signatures
+ false, // No pattern names
+ SONG_FASTVOLSLIDES | SONG_AMIGALIMITS, // Supported song flags
+};
+
+// S3M with MPT extensions
+const CModSpecifications s3mEx =
+{
+ "s3m", // File extension
+ MOD_TYPE_S3M, // Internal MODTYPE value
+ 13, // Minimum note index
+ 108, // Maximum note index
+ true, // Has notecut.
+ false, // No noteoff.
+ false, // No notefade.
+ 100, // Pattern max.
+ 255, // Order max.
+ 1, // Channel min
+ 32, // Channel max
+ 33, // Min tempo
+ 255, // Max tempo
+ 64, // Min pattern rows
+ 64, // Max pattern rows
+ 27, // Max mod name length
+ 27, // Max sample name length
+ 12, // Max sample filename length
+ 0, // Max instrument name length
+ 0, // Max instrument filename length
+ 99, // SamplesMax
+ 0, // instrumentMax
+ mixLevels_compatible, // defaultMixLevels
+ 0, // Max MIDI mapping directives
+ 1, // Min Speed
+ 255, // Max Speed
+ false, // No song comments
+ 0, // No instrument envelopes
+ false, // No envelope release node
+ " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z?????", // Supported Effects
+ " vp?????????????", // Supported Volume Column commands
+ true, // Has "+++" pattern
+ false, // Doesn't have restart position (order)
+ false, // Doesn't support plugins
+ false, // No custom pattern time signatures
+ false, // No pattern names
+ SONG_FASTVOLSLIDES | SONG_AMIGALIMITS, // Supported song flags
+};
+
+const CModSpecifications it =
+{
+ "it", // File extension
+ MOD_TYPE_IT, // Internal MODTYPE value
+ 1, // Minimum note index
+ 120, // Maximum note index
+ true, // Has notecut.
+ true, // Has noteoff.
+ true, // Has notefade.
+ 200, // Pattern max.
+ 256, // Order max.
+ 1, // Channel min
+ 64, // Channel max
+ 32, // Min tempo
+ 255, // Max tempo
+ 1, // Min pattern rows
+ 200, // Max pattern rows
+ 25, // Max mod name length
+ 25, // Max sample name length
+ 12, // Max sample filename length
+ 25, // Max instrument name length
+ 12, // Max instrument filename length
+ 99, // SamplesMax
+ 99, // instrumentMax
+ mixLevels_compatible, // defaultMixLevels
+ 0, // Max MIDI mapping directives
+ 1, // Min Speed
+ 255, // Max Speed
+ true, // Has song comments
+ 25, // Envelope point count
+ false, // No envelope release node
+ " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z?????", // Supported Effects
+ " vpcdab?h??gfe??", // Supported Volume Column commands
+ true, // Has "+++" pattern
+ false, // Doesn't have restart position (order)
+ false, // Doesn't support plugins
+ false, // No custom pattern time signatures
+ false, // No pattern names
+ SONG_LINEARSLIDES | SONG_ITOLDEFFECTS | SONG_ITCOMPATGXX | SONG_EMBEDMIDICFG, // Supported song flags
+};
+
+const CModSpecifications itEx =
+{
+ "it", // File extension
+ MOD_TYPE_IT, // Internal MODTYPE value
+ 1, // Minimum note index
+ 120, // Maximum note index
+ true, // Has notecut.
+ true, // Has noteoff.
+ true, // Has notefade.
+ 240, // Pattern max.
+ 256, // Order max.
+ 1, // Channel min
+ 127, // Channel max
+ 32, // Min tempo
+ 512, // Max tempo
+ 1, // Min pattern rows
+ 1024, // Max pattern rows
+ 25, // Max mod name length
+ 25, // Max sample name length
+ 12, // Max sample filename length
+ 25, // Max instrument name length
+ 12, // Max instrument filename length
+ 3999, // SamplesMax
+ 255, // instrumentMax
+ mixLevels_compatible, // defaultMixLevels
+ 200, // Max MIDI mapping directives
+ 1, // Min Speed
+ 255, // Max Speed
+ true, // Has song comments
+ 25, // Envelope point count
+ false, // No envelope release node
+ " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z\\?#??", // Supported Effects
+ " vpcdab?h??gfe?o", // Supported Volume Column commands
+ true, // Has "+++" pattern
+ false, // Doesn't have restart position (order)
+ true, // Supports plugins
+ false, // No custom pattern time signatures
+ true, // Pattern names
+ SONG_LINEARSLIDES | SONG_EXFILTERRANGE | SONG_ITOLDEFFECTS | SONG_ITCOMPATGXX | SONG_EMBEDMIDICFG | SONG_ITPROJECT | SONG_ITPEMBEDIH, // Supported song flags
+};
+
+const CModSpecifications *Collection[] = { &mptm, &mod, &s3m, &s3mEx, &xm, &xmEx, &it, &itEx };
+
+} // namespace ModSpecs
+
+
MODTYPE CModSpecifications::ExtensionToType(LPCTSTR pszExt)
//---------------------------------------------------------
{
@@ -47,7 +394,7 @@
bool CModSpecifications::HasNote(ModCommand::NOTE note) const
-//------------------------------------------------------------
+//-----------------------------------------------------------
{
if(note >= noteMin && note <= noteMax)
return true;
Modified: trunk/OpenMPT/soundlib/mod_specifications.h
===================================================================
--- trunk/OpenMPT/soundlib/mod_specifications.h 2013-02-11 21:58:06 UTC (rev 1519)
+++ trunk/OpenMPT/soundlib/mod_specifications.h 2013-02-11 22:31:02 UTC (rev 1520)
@@ -11,11 +11,11 @@
#pragma once
#include "Snd_defs.h"
-#include "modcommand.h" //
-#include "../soundlib/SoundFilePlayConfig.h" // mixlevel constants.
+#include "modcommand.h" // ModCommand::
+#include "../soundlib/SoundFilePlayConfig.h" // mixlevel constants.
-
+//=======================
struct CModSpecifications
//=======================
{
@@ -32,395 +32,55 @@
char GetVolEffectLetter(ModCommand::VOLCMD cmd) const;
// NOTE: If changing order, update all initializations below.
- char fileExtension[6]; // File extension without dot.
- MODTYPE internalType; // Internal MODTYPE value
- ModCommand::NOTE noteMin; // Minimum note index (index starts from 1)
- ModCommand::NOTE noteMax; // Maximum note index (index starts from 1)
- bool hasNoteCut; // True if format has notecut.
- bool hasNoteOff; // True if format has noteoff.
- bool hasNoteFade; // True if format has notefade.
+ char fileExtension[6]; // File extension without dot.
+ MODTYPE internalType; // Internal MODTYPE value
+ ModCommand::NOTE noteMin; // Minimum note index (index starts from 1)
+ ModCommand::NOTE noteMax; // Maximum note index (index starts from 1)
+ bool hasNoteCut; // True if format has notecut.
+ bool hasNoteOff; // True if format has noteoff.
+ bool hasNoteFade; // True if format has notefade.
PATTERNINDEX patternsMax;
ORDERINDEX ordersMax;
- CHANNELINDEX channelsMin; // Minimum number of editable channels in pattern.
- CHANNELINDEX channelsMax; // Maximum number of editable channels in pattern.
+ CHANNELINDEX channelsMin; // Minimum number of editable channels in pattern.
+ CHANNELINDEX channelsMax; // Maximum number of editable channels in pattern.
TEMPO tempoMin;
TEMPO tempoMax;
ROWINDEX patternRowsMin;
ROWINDEX patternRowsMax;
- uint16 modNameLengthMax; // Meaning 'usable letters', possible null character is not included.
- uint16 sampleNameLengthMax; // Dito
- uint16 sampleFilenameLengthMax; // Dito
- uint16 instrNameLengthMax; // Dito
- uint16 instrFilenameLengthMax; // Dito
- SAMPLEINDEX samplesMax; // Max number of samples == Highest possible sample index
- INSTRUMENTINDEX instrumentsMax; // Max number of instruments == Highest possible instrument index
- BYTE defaultMixLevels;
- BYTE MIDIMappingDirectivesMax;
- UINT speedMin; // Minimum ticks per frame
- UINT speedMax; // Maximum ticks per frame
- bool hasComments; // True if format has a comments field
- uint8 envelopePointsMax; // Maximum number of points of each envelope
- bool hasReleaseNode; // Envelope release node
- char commands[MAX_EFFECTS + 1]; // An array holding all commands this format supports; commands that are not supported are marked with "?"
- char volcommands[MAX_VOLCMDS + 1]; // dito, but for volume column
- bool hasIgnoreIndex; // Does "+++" pattern exist?
- bool hasRestartPos;
- bool supportsPlugins;
- bool hasPatternSignatures; // Can patterns have a custom time signature?
- bool hasPatternNames; // Cat patterns have a name?
- SongFlags songFlags; // Supported song flags
+ uint16 modNameLengthMax; // Meaning 'usable letters', possible null character is not included.
+ uint16 sampleNameLengthMax; // Dito
+ uint16 sampleFilenameLengthMax; // Dito
+ uint16 instrNameLengthMax; // Dito
+ uint16 instrFilenameLengthMax; // Dito
+ SAMPLEINDEX samplesMax; // Max number of samples == Highest possible sample index
+ INSTRUMENTINDEX instrumentsMax; // Max number of instruments == Highest possible instrument index
+ mixLevels defaultMixLevels; // Default mix levels that are used when creating a new file in this format
+ uint8 MIDIMappingDirectivesMax; // Number of MIDI Mapping directives that the format can store (0 = none)
+ UINT speedMin; // Minimum ticks per frame
+ UINT speedMax; // Maximum ticks per frame
+ bool hasComments; // True if format has a comments field
+ uint8 envelopePointsMax; // Maximum number of points of each envelope
+ bool hasReleaseNode; // Envelope release node
+ char commands[MAX_EFFECTS + 1]; // An array holding all commands this format supports; commands that are not supported are marked with "?"
+ char volcommands[MAX_VOLCMDS + 1]; // dito, but for volume column
+ bool hasIgnoreIndex; // Does "+++" pattern exist?
+ bool hasRestartPos; // Format has an automatic restart order position
+ bool supportsPlugins; // Format can store plugins
+ bool hasPatternSignatures; // Can patterns have a custom time signature?
+ bool hasPatternNames; // Cat patterns have a name?
+ SongFlags songFlags; // Supported song flags
};
namespace ModSpecs
{
-
-const CModSpecifications mptm =
-{
- /*
- TODO: Proper, less arbitrarily chosen values here.
- NOTE: If changing limits, see whether:
- -savefile format and GUI methods can handle new values(might not be a small task :).
- */
- "mptm", // File extension
- MOD_TYPE_MPT, // Internal MODTYPE value
- NOTE_MIN, // Minimum note index
- NOTE_MAX, // Maximum note index
- true, // Has notecut.
- true, // Has noteoff.
- true, // Has notefade.
- 4000, // Pattern max.
- 4000, // Order max.
- 1, // Channel min
- 127, // Channel max
- 32, // Min tempo
- 512, // Max tempo
- 1, // Min pattern rows
- 1024, // Max pattern rows
- 25, // Max mod name length
- 25, // Max sample name length
- 12, // Max sample filename length
- 25, // Max instrument name length
- 12, // Max instrument filename length
- 3999, // SamplesMax
- 255, // instrumentMax
- mixLevels_117RC3, // defaultMixLevels
- 200, // Max MIDI mapping directives
- 1, // Min Speed
- 255, // Max Speed
- true, // Has song comments
- MAX_ENVPOINTS, // Envelope point count
- true, // Has envelope release node
- " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z\\:#", // Supported Effects
- " vpcdabuhlrgfe?o", // Supported Volume Column commands
- true, // Has "+++" pattern
- true, // Has restart position (order)
- true, // Supports plugins
- true, // Custom pattern time signatures
- true, // Pattern names
- SONG_LINEARSLIDES | SONG_EXFILTERRANGE | SONG_ITOLDEFFECTS | SONG_ITCOMPATGXX | SONG_EMBEDMIDICFG, // Supported song flags
-};
-
-
-
-
-const CModSpecifications mod =
-{
- // TODO: Set correct values.
- "mod", // File extension
- MOD_TYPE_MOD, // Internal MODTYPE value
- 37, // Minimum note index
- 108, // Maximum note index
- false, // No notecut.
- false, // No noteoff.
- false, // No notefade.
- 128, // Pattern max.
- 128, // Order max.
- 4, // Channel min
- 32, // Channel max
- 32, // Min tempo
- 255, // Max tempo
- 64, // Min pattern rows
- 64, // Max pattern rows
- 20, // Max mod name length
- 22, // Max sample name length
- 0, // Max sample filename length
- 0, // Max instrument name length
- 0, // Max instrument filename length
- 31, // SamplesMax
- 0, // instrumentMax
- mixLevels_compatible, // defaultMixLevels
- 0, // Max MIDI mapping directives
- 1, // Min Speed
- 32, // Max Speed
- false, // No song comments
- 0, // No instrument envelopes
- false, // No envelope release node
- " 0123456789ABCD?FF?E???????????????", // Supported Effects
- " ???????????????", // Supported Volume Column commands
- false, // Doesn't have "+++" pattern
- true, // Has restart position (order)
- false, // Doesn't support plugins
- false, // No custom pattern time signatures
- false, // No pattern names
- SONG_PT1XMODE, // Supported song flags
-};
-
-
-const CModSpecifications xm =
-{
- // TODO: Set correct values.
- "xm", // File extension
- MOD_TYPE_XM, // Internal MODTYPE value
- 13, // Minimum note index
- 108, // Maximum note index
- false, // No notecut.
- true, // Has noteoff.
- false, // No notefade.
- 256, // Pattern max.
- 255, // Order max.
- 1, // Channel min
- 32, // Channel max
- 32, // Min tempo
- 512, // Max tempo
- 1, // Min pattern rows
- 256, // Max pattern rows
- 20, // Max mod name length
- 22, // Max sample name length
- 0, // Max sample filename length
- 22, // Max instrument name length
- 0, // Max instrument filename length
- 128 * 16, // SamplesMax (actually 16 per instrument)
- 128, // instrumentMax
- mixLevels_compatible, // defaultMixLevels
- 0, // Max MIDI mapping directives
- 1, // Min Speed
- 31, // Max Speed
- false, // No song comments
- 12, // Envelope point count
- false, // No envelope release node
- " 0123456789ABCDRFFTE???GHK??XPL????", // Supported Effects
- " vpcdabuhlrg????", // Supported Volume Column commands
- false, // Doesn't have "+++" pattern
- true, // Has restart position (order)
- false, // Doesn't support plugins
- false, // No custom pattern time signatures
- false, // No pattern names
- SONG_LINEARSLIDES, // Supported song flags
-};
-
-// XM with MPT extensions
-const CModSpecifications xmEx =
-{
- // TODO: Set correct values.
- "xm", // File extension
- MOD_TYPE_XM, // Internal MODTYPE value
- 13, // Minimum note index
- 108, // Maximum note index
- false, // No notecut.
- true, // Has noteoff.
- false, // No notefade.
- 256, // Pattern max.
- 255, // Order max.
- 1, // Channel min
- 127, // Channel max
- 32, // Min tempo
- 512, // Max tempo
- 1, // Min pattern rows
- 1024, // Max pattern rows
- 20, // Max mod name length
- 22, // Max sample name length
- 0, // Max sample filename length
- 22, // Max instrument name length
- 0, // Max instrument filename length
- MAX_SAMPLES - 1, // SamplesMax (actually 32 per instrument(256 * 32 = 8192), but limited to MAX_SAMPLES = 4000)
- 255, // instrumentMax
- mixLevels_compatible, // defaultMixLevels
- 200, // Max MIDI mapping directives
- 1, // Min Speed
- 31, // Max Speed
- true, // Has song comments
- 12, // Envelope point count
- false, // No envelope release node
- " 0123456789ABCDRFFTE???GHK?YXPLZ\\?#", // Supported Effects
- " vpcdabuhlrgfe?o", // Supported Volume Column commands
- false, // Doesn't have "+++" pattern
- true, // Has restart position (order)
- true, // Supports plugins
- false, // No custom pattern time signatures
- true, // Pattern names
- SONG_LINEARSLIDES | SONG_EXFILTERRANGE | SONG_EMBEDMIDICFG, // Supported song flags
-};
-
-const CModSpecifications s3m =
-{
- // TODO: Set correct values.
- "s3m", // File extension
- MOD_TYPE_S3M, // Internal MODTYPE value
- 13, // Minimum note index
- 108, // Maximum note index
- true, // Has notecut.
- false, // No noteoff.
- false, // No notefade.
- 100, // Pattern max.
- 255, // Order max.
- 1, // Channel min
- 32, // Channel max
- 33, // Min tempo
- 255, // Max tempo
- 64, // Min pattern rows
- 64, // Max pattern rows
- 27, // Max mod name length
- 27, // Max sample name length
- 12, // Max sample filename length
- 0, // Max instrument name length
- 0, // Max instrument filename length
- 99, // SamplesMax
- 0, // instrumentMax
- mixLevels_compatible, // defaultMixLevels
- 0, // Max MIDI mapping directives
- 1, // Min Speed
- 255, // Max Speed
- false, // No song comments
- 0, // No instrument envelopes
- false, // No envelope release node
- " JFEGHLKRXODB?CQATI?SMNVW?U????????", // Supported Effects
- " vp?????????????", // Supported Volume Column commands
- true, // Has "+++" pattern
- false, // Doesn't have restart position (order)
- false, // Doesn't support plugins
- false, // No custom pattern time signatures
- false, // No pattern names
- SONG_FASTVOLSLIDES | SONG_AMIGALIMITS, // Supported song flags
-};
-
-// S3M with MPT extensions
-const CModSpecifications s3mEx =
-{
- // TODO: Set correct values.
- "s3m", // File extension
- MOD_TYPE_S3M, // Internal MODTYPE value
- 13, // Minimum note index
- 108, // Maximum note index
- true, // Has notecut.
- false, // No noteoff.
- false, // No notefade.
- 100, // Pattern max.
- 255, // Order max.
- 1, // Channel min
- 32, // Channel max
- 33, // Min tempo
- 255, // Max tempo
- 64, // Min pattern rows
- 64, // Max pattern rows
- 27, // Max mod name length
- 27, // Max sample name length
- 12, // Max sample filename length
- 0, // Max instrument name length
- 0, // Max instrument filename length
- 99, // SamplesMax
- 0, // instrumentMax
- mixLevels_compatible, // defaultMixLevels
- 0, // Max MIDI mapping directives
- 1, // Min Speed
- 255, // Max Speed
- false, // No song comments
- 0, // No instrument envelopes
- false, // No envelope release node
- " JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z???", // Supported Effects
- " vp?????????????", // Supported Volume Column commands
- true, // Has "+++" pattern
- false, // Doesn't have restart position (order)
- false, // Doesn't support plugins
- false, // No custom pattern time signatures
- false, // No pattern names
- SONG_FASTVOLSLIDES | SONG_AMIGALIMITS, // Supported song flags
-};
-
-const CModSpecifications it =
-{
- // TODO: Set correct values.
- "it", // File extension
- MOD_TYPE_IT, // Internal MODTYPE value
- 1, // Minimum note index
- 120, // Maximum note index
- true, // Has notecut.
- true, // Has noteoff.
- true, // Has notefade.
- 200, // Pattern max.
- 256, // Order max.
- 1, // Channel min
- 64, // Channel max
- 32, // Min tempo
- 255, // Max tempo
- 1, // Min pattern rows
- 200, // Max pattern rows
- 25, // Max mod name length
- 25, ...
[truncated message content] |
|
From: <sag...@us...> - 2013-02-19 02:32:18
|
Revision: 1540
http://sourceforge.net/p/modplug/code/1540
Author: saga-games
Date: 2013-02-19 02:32:12 +0000 (Tue, 19 Feb 2013)
Log Message:
-----------
New files were not versioned in previous commit.
Added Paths:
-----------
trunk/OpenMPT/soundlib/ITCompression.cpp
trunk/OpenMPT/soundlib/ITCompression.h
Added: trunk/OpenMPT/soundlib/ITCompression.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ITCompression.cpp (rev 0)
+++ trunk/OpenMPT/soundlib/ITCompression.cpp 2013-02-19 02:32:12 UTC (rev 1540)
@@ -0,0 +1,464 @@
+/*
+ * ITCompression.cpp
+ * -----------------
+ * Purpose: Code for IT sample compression and decompression.
+ * Notes : The original Python compression code was written by GreaseMonkey and has been released into the public domain.
+ * Authors: OpenMPT Devs
+ * Ben "GreaseMonkey" Russell
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+
+
+#include <stdafx.h>
+#include "ITCompression.h"
+#include "../common/misc_util.h"
+
+// Algorithm parameters for 16-Bit samples
+struct IT16BitParams
+{
+ typedef int16 sample_t;
+ static const int16 lowerTab[];
+ static const int16 upperTab[];
+ static const int fetchA = 4, lowerB = -8, upperB = 7, defWidth = 17;
+ static int Clamp(sample_t v) { return int(v) & 0xFFFF; }
+};
+
+const int16 IT16BitParams::lowerTab[] = { 0, -1, -3, -7, -15, -31, -56, -120, -248, -504, -1016, -2040, -4088, -8184, -16376, -32760, -32768 };
+const int16 IT16BitParams::upperTab[] = { 0, 1, 3, 7, 15, 31, 55, 119, 247, 503, 1015, 2039, 4087, 8183, 16375, 32759, 32767 };
+
+// Algorithm parameters for 8-Bit samples
+struct IT8BitParams
+{
+ typedef int8 sample_t;
+ static const int8 lowerTab[];
+ static const int8 upperTab[];
+ static const int fetchA = 3, lowerB = -4, upperB = 3, defWidth = 9;
+ static int Clamp(sample_t v) { return int(v) & 0xFF; }
+};
+
+const int8 IT8BitParams::lowerTab[] = { 0, -1, -3, -7, -15, -31, -60, -124, -128 };
+const int8 IT8BitParams::upperTab[] = { 0, 1, 3, 7, 15, 31, 59, 123, 127 };
+
+static const int ITWidthChangeSize[] = { 4, 5, 6, 7, 8, 9, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 };
+
+//////////////////////////////////////////////////////////////////////////////
+// IT 2.14 compression
+
+
+ITCompression::ITCompression(const ModSample &sample, bool it215, FILE *f) : mptSample(sample), is215(it215), file(f)
+//-------------------------------------------------------------------------------------------------------------------
+{
+ packedData.resize(bufferSize);
+ packedTotalLength = 0;
+
+ for(uint8 chn = 0; chn < mptSample.GetNumChannels(); chn++)
+ {
+ SmpLength offset = 0;
+ SmpLength remain = mptSample.nLength;
+ while(remain > 0)
+ {
+ // Initialise output buffer and bit writer positions
+ packedLength = 2;
+ bitPos = 0;
+ remBits = 8;
+ byteVal = 0;
+
+ if(mptSample.GetElementarySampleSize() > 1)
+ Compress<IT16BitParams>(sample.pSample + 2 * chn, offset, remain);
+ else
+ Compress<IT8BitParams>(sample.pSample + chn, offset, remain);
+
+ if(file) fwrite(&packedData[0], packedLength, 1, file);
+ packedTotalLength += packedLength;
+
+ offset += baseLength;
+ remain -= baseLength;
+ }
+ }
+}
+
+
+template<typename T>
+void ITCompression::CopySample(void *target, const void *source, SmpLength offset, SmpLength length, SmpLength skip)
+//------------------------------------------------------------------------------------------------------------------
+{
+ T *out = static_cast<T *>(target);
+ const T *in = static_cast<const T *>(source) + offset * skip;
+ for(SmpLength i = 0, j = 0; j < length; i += skip, j++)
+ {
+ out[j] = in[i];
+ }
+}
+
+
+// Convert sample to delta values.
+template<typename T>
+void ITCompression::Deltafy()
+//---------------------------
+{
+ T *p = static_cast<T *>(sampleData);
+ int oldVal = 0;
+ for(SmpLength i = 0; i < baseLength; i++)
+ {
+ int newVal = p[i];
+ p[i] = static_cast<T>(newVal - oldVal);
+ oldVal = newVal;
+ }
+}
+
+
+template<typename Properties>
+void ITCompression::Compress(const void *data, SmpLength offset, SmpLength actualLength)
+//--------------------------------------------------------------------------------------
+{
+ baseLength = Util::Min(actualLength, SmpLength(0x8000 / sizeof(Properties::sample_t)));
+
+ sampleData = new (std::nothrow) Properties::sample_t[baseLength];
+ if(sampleData == nullptr)
+ {
+ return;
+ }
+
+ CopySample<Properties::sample_t>(sampleData, data, offset, baseLength, mptSample.GetNumChannels());
+
+ for(int i = 0; i < (is215 ? 2 : 1); i++)
+ {
+ Deltafy<Properties::sample_t>();
+ }
+
+ // Initialise bit width table with initial values
+ bwt.assign(baseLength, Properties::defWidth);
+
+ // Recurse!
+ SquishRecurse<Properties>(Properties::defWidth, Properties::defWidth, Properties::defWidth, Properties::defWidth - 2, 0, baseLength);
+
+ // Write those bits!
+ const Properties::sample_t *p = static_cast<Properties::sample_t *>(sampleData);
+ int width = Properties::defWidth;
+ for(size_t i = 0; i < baseLength; i++)
+ {
+ if(bwt[i] != width)
+ {
+ if(width <= 6)
+ {
+ // Mode A
+ ASSERT(width);
+ WriteBits(width, (1 << (width - 1)));
+ WriteBits(Properties::fetchA, ConvertWidth(width, bwt[i]));
+ } else if(width < Properties::defWidth)
+ {
+ // Mode B
+ int xv = (1 << (width - 1)) + Properties::lowerB + ConvertWidth(width, bwt[i]);
+ WriteBits(width, xv);
+ } else
+ {
+ // Mode C
+ ASSERT((bwt[i] - 1) >= 0);
+ WriteBits(width, (1 << (width - 1)) + bwt[i] - 1);
+ }
+
+ width = bwt[i];
+ }
+ WriteBits(width, Properties::Clamp(p[i]));
+ }
+
+ // Write last byte and update block length
+ WriteByte(byteVal);
+ packedData[0] = uint8((packedLength - 2) & 0xFF);
+ packedData[1] = uint8((packedLength - 2) >> 8);
+
+ Verify(data, sampleData, offset);
+
+ delete[] sampleData;
+}
+
+
+#ifdef MODPLUG_TRACKER
+#include "../mptrack/Mptrack.h" // For config filename
+#endif // MODPLUG_TRACKER
+
+// Check integrity of compressed data
+void ITCompression::Verify(const void *data, void *sampleData, SmpLength offset)
+//------------------------------------------------------------------------------
+{
+#ifdef MODPLUG_TRACKER
+ if(::GetPrivateProfileInt("Misc", "ITCompressionVerification", 0, theApp.GetConfigFileName()) != 0)
+ {
+ int8 *newSampleData = new (std::nothrow) int8[baseLength * mptSample.GetElementarySampleSize()];
+ if(mptSample.GetElementarySampleSize() > 1)
+ {
+ CopySample<int16>(sampleData, data, offset, baseLength, mptSample.GetNumChannels());
+ } else
+ {
+ CopySample<int8>(sampleData, data, offset, baseLength, mptSample.GetNumChannels());
+ }
+
+ FileReader data(&packedData[0], packedLength + 2);
+ ModSample sample = mptSample;
+ sample.uFlags.reset(CHN_STEREO);
+ sample.pSample = newSampleData;
+ sample.nLength = baseLength;
+ ITDecompression(data, sample, is215);
+
+ if(memcmp(sampleData, newSampleData, baseLength * mptSample.GetElementarySampleSize()))
+ {
+ Reporting::Error("CRITICAL ERROR! Sample compression failed for some sample!\nDisable IT compression NOW, find out which sample got broken and send the original sample to the OpenMPT devs!");
+ }
+ delete[] newSampleData;
+ }
+#endif // MODPLUG_TRACKER
+}
+
+
+int ITCompression::GetWidthChangeSize(int w, bool is16)
+//-----------------------------------------------------
+{
+ ASSERT(w > 0 && w <= CountOf(ITWidthChangeSize));
+ int wcs = ITWidthChangeSize[w - 1];
+ if(w <= 6 && is16)
+ wcs++;
+ return wcs;
+}
+
+
+template<typename Properties>
+void ITCompression::SquishRecurse(int sWidth, int lWidth, int rWidth, int width, SmpLength offset, SmpLength length)
+//------------------------------------------------------------------------------------------------------------------
+{
+ if(width + 1 < 1)
+ {
+ for(SmpLength i = offset; i < offset + length; i++)
+ bwt[i] = sWidth;
+ return;
+ }
+
+ ASSERT(width < CountOf(Properties::lowerTab));
+
+ SmpLength i = offset;
+ SmpLength end = offset + length;
+ const Properties::sample_t *p = static_cast<Properties::sample_t *>(sampleData);
+
+ while(i < end)
+ {
+ if(p[i] >= Properties::lowerTab[width] && p[i] <= Properties::upperTab[width])
+ {
+ SmpLength start = i;
+ // Check for how long we can keep this bit width
+ while(i < end && p[i] >= Properties::lowerTab[width] && p[i] <= Properties::upperTab[width])
+ {
+ i++;
+ }
+
+ const SmpLength blockLength = i - start;
+ const int xlwidth = start == offset ? lWidth : sWidth;
+ const int xrwidth = i == end ? rWidth : sWidth;
+
+ const bool is16 = sizeof(Properties::sample_t) > 1;
+ const int wcsl = GetWidthChangeSize(xlwidth, is16);
+ const int wcss = GetWidthChangeSize(sWidth, is16);
+ const int wcsw = GetWidthChangeSize(width + 1, is16);
+
+ bool comparison;
+ if(i == baseLength)
+ {
+ SmpLength keepDown = wcsl + (width + 1) * blockLength;
+ SmpLength levelLeft = wcsl + sWidth * blockLength;
+
+ if(xlwidth == sWidth)
+ levelLeft -= wcsl;
+
+ comparison = (keepDown <= levelLeft);
+ } else
+ {
+ SmpLength keepDown = wcsl + (width + 1) * blockLength + wcsw;
+ SmpLength levelLeft = wcsl + sWidth * blockLength + wcss;
+
+ if(xlwidth == sWidth)
+ levelLeft -= wcsl;
+ if(xrwidth == sWidth)
+ levelLeft -= wcss;
+
+ comparison = (keepDown <= levelLeft);
+ }
+ SquishRecurse<Properties>(comparison ? (width + 1) : sWidth, xlwidth, xrwidth, width - 1, start, blockLength);
+ } else
+ {
+ bwt[i] = sWidth;
+ i++;
+ }
+ }
+}
+
+
+int ITCompression::ConvertWidth(int curWidth, int newWidth)
+//---------------------------------------------------------
+{
+ curWidth--;
+ newWidth--;
+ ASSERT(newWidth != curWidth);
+ if(newWidth > curWidth)
+ newWidth--;
+ return newWidth;
+}
+
+
+void ITCompression::WriteBits(int width, int v)
+//---------------------------------------------
+{
+ while(width > remBits)
+ {
+ byteVal |= (v << bitPos);
+ width -= remBits;
+ v >>= remBits;
+ bitPos = 0;
+ remBits = 8;
+ WriteByte(byteVal);
+ byteVal = 0;
+ }
+
+ if(width > 0)
+ {
+ byteVal |= (v & ((1 << width) - 1)) << bitPos;
+ remBits -= width;
+ bitPos += width;
+ }
+}
+
+
+void ITCompression::WriteByte(uint8 v)
+//------------------------------------
+{
+ if(packedLength < bufferSize)
+ {
+ packedData[packedLength++] = v;
+ } else
+ {
+ // How could this happen, anyway?
+ ASSERT(false);
+ }
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// IT 2.14 decompression
+
+
+ITDecompression::ITDecompression(FileReader &file, ModSample &sample, bool it215) : mptSample(sample), is215(it215)
+//-----------------------------------------------------------------------------------------------------------------
+{
+ for(uint8 chn = 0; chn < mptSample.GetNumChannels(); chn++)
+ {
+ writtenSamples = writePos = 0;
+ while(writtenSamples < sample.nLength && file.BytesLeft())
+ {
+ chunk = file.GetChunk(file.ReadUint16LE());
+
+ if(mptSample.GetElementarySampleSize() > 1)
+ Uncompress<IT16BitParams>(mptSample.pSample + 2 * chn);
+ else
+ Uncompress<IT8BitParams>(mptSample.pSample + chn);
+ }
+ }
+}
+
+
+template<typename Properties>
+void ITDecompression::Uncompress(void *target)
+//--------------------------------------------
+{
+ // Initialise bit reader
+ dataPos = 0;
+ bitPos = 0;
+ remBits = 8;
+ mem1 = mem2 = 0;
+
+ curLength = Util::Min(mptSample.nLength - writtenSamples, SmpLength(0x8000 / sizeof(Properties::sample_t)));
+
+ int width = Properties::defWidth;
+ while(curLength > 0)
+ {
+ if(width < 1 || width > Properties::defWidth || dataPos >= chunk.GetLength())
+ {
+ // Error!
+ return;
+ }
+
+ int v = ReadBits(width);
+ const int topBit = (1 << (width - 1));
+ if(width <= 6)
+ {
+ // Mode A
+ if(v == topBit)
+ ChangeWidth(width, ReadBits(Properties::fetchA));
+ else
+ Write<Properties>(v, topBit, target);
+ } else if(width < Properties::defWidth)
+ {
+ // Mode B
+ if(v >= topBit + Properties::lowerB && v <= topBit + Properties::upperB)
+ ChangeWidth(width, v - (topBit + Properties::lowerB));
+ else
+ Write<Properties>(v, topBit, target);
+ } else
+ {
+ // Mode C
+ if(v & topBit)
+ width = (v & ~topBit) + 1;
+ else
+ Write<Properties>((v & ~topBit), 0, target);
+ }
+ }
+}
+
+
+void ITDecompression::ChangeWidth(int &curWidth, int width)
+//---------------------------------------------------------
+{
+ width++;
+ if(width >= curWidth)
+ width++;
+
+ ASSERT(curWidth != width);
+ curWidth = width;
+}
+
+
+int ITDecompression::ReadBits(int width)
+//--------------------------------------
+{
+ const uint8 *data = reinterpret_cast<const uint8 *>(chunk.GetRawData());
+ int v = 0, vPos = 0, vMask = (1 << width) - 1;
+ while(width >= remBits && dataPos < chunk.GetLength())
+ {
+ v |= (data[dataPos] >> bitPos) << vPos;
+ vPos += remBits;
+ width -= remBits;
+ dataPos++;
+ remBits = 8;
+ bitPos = 0;
+ }
+
+ if(width > 0 && dataPos < chunk.GetLength())
+ {
+ v |= (data[dataPos] >> bitPos) << vPos;
+ v &= vMask;
+ remBits -= width;
+ bitPos += width;
+ }
+ return v;
+}
+
+
+template<typename Properties>
+void ITDecompression::Write(int v, int topBit, void *target)
+//----------------------------------------------------------
+{
+ if(v & topBit)
+ v -= (topBit << 1);
+ mem1 += v;
+ mem2 += mem1;
+ static_cast<Properties::sample_t *>(target)[writePos] = static_cast<Properties::sample_t>(is215 ? mem2 : mem1);
+ writtenSamples++;
+ writePos += mptSample.GetNumChannels();
+ curLength--;
+}
Added: trunk/OpenMPT/soundlib/ITCompression.h
===================================================================
--- trunk/OpenMPT/soundlib/ITCompression.h (rev 0)
+++ trunk/OpenMPT/soundlib/ITCompression.h 2013-02-19 02:32:12 UTC (rev 1540)
@@ -0,0 +1,95 @@
+/*
+ * ITCompression.cpp
+ * -----------------
+ * Purpose: Code for IT sample compression and decompression.
+ * Notes : The original Python compression code was written by GreaseMonkey and has been released into the public domain.
+ * Authors: OpenMPT Devs
+ * Ben "GreaseMonkey" Russell
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+
+#pragma once
+
+#include "Snd_defs.h"
+#include <vector>
+#include "ModSample.h"
+#include "FileReader.h"
+
+
+//=================
+class ITCompression
+//=================
+{
+public:
+ ITCompression(const ModSample &sample, bool it215, FILE *f);
+ size_t GetCompressedSize() const { return packedTotalLength; }
+
+protected:
+ static const size_t bufferSize = 2 + 0xFFFF; // Our output buffer can't be longer than this.
+
+ std::vector<int> bwt; // Bit width table
+ std::vector<uint8> packedData; // Compressed data for current sample block
+ FILE *file;
+ void *sampleData; // Pre-processed sample data for currently compressed sample block
+ const ModSample &mptSample;
+ size_t packedLength; // Size of currently compressed sample block
+ size_t packedTotalLength; // Size of all compressed data so far
+ SmpLength baseLength; // Length of the currently compressed sample block (in samples)
+
+ // Bit writer
+ int bitPos; // Current bit position in this byte
+ int remBits; // Remaining bits in this byte
+ uint8 byteVal; // Current byte value to be written
+
+ bool is215; // Use IT2.15 compression (double deltas)
+
+ template<typename T>
+ static void CopySample(void *target, const void *source, SmpLength offset, SmpLength length, SmpLength skip);
+
+ template<typename T>
+ void Deltafy();
+
+ template<typename Properties>
+ void Compress(const void *data, SmpLength offset, SmpLength actualLength);
+ void Verify(const void *data, void *sampleData, SmpLength offset);
+
+ static int GetWidthChangeSize(int w, bool is16);
+
+ template<typename Properties>
+ void SquishRecurse(int sWidth, int lWidth, int rWidth, int width, SmpLength offset, SmpLength length);
+
+ static int ConvertWidth(int curWidth, int newWidth);
+ void WriteBits(int width, int v);
+
+ void WriteByte(uint8 v);
+};
+
+
+//===================
+class ITDecompression
+//===================
+{
+public:
+ ITDecompression(FileReader &file, ModSample &sample, bool it215);
+
+protected:
+ FileReader chunk;
+ ModSample &mptSample;
+
+ // Bit reader
+ SmpLength writtenSamples, writePos, curLength;
+ FileReader::off_t dataPos;
+ int mem1, mem2;
+ int bitPos;
+ int remBits;
+
+ bool is215; // Use IT2.15 compression (double deltas)
+
+ template<typename Properties>
+ void Uncompress(void *target);
+ static void ChangeWidth(int &curWidth, int width);
+ int ReadBits(int width);
+
+ template<typename Properties>
+ void Write(int v, int topbit, void *target);
+};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-02-19 18:41:08
|
Revision: 1542
http://sourceforge.net/p/modplug/code/1542
Author: saga-games
Date: 2013-02-19 18:40:54 +0000 (Tue, 19 Feb 2013)
Log Message:
-----------
[Ref] Got rid of (disabled) warnings in Load_it.cpp
[Ref] Small changes in ITCompression code
[Imp] Added basic validity checks in MPEG loader, so that not every semi-random binary blob is recognized as an MPEG stream. Might refuse to load some valid MPEG files with unknown tags...
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ITCompression.cpp
trunk/OpenMPT/soundlib/ITCompression.h
trunk/OpenMPT/soundlib/Load_it.cpp
trunk/OpenMPT/soundlib/SampleFormats.cpp
Modified: trunk/OpenMPT/soundlib/ITCompression.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ITCompression.cpp 2013-02-19 02:39:46 UTC (rev 1541)
+++ trunk/OpenMPT/soundlib/ITCompression.cpp 2013-02-19 18:40:54 UTC (rev 1542)
@@ -48,8 +48,13 @@
ITCompression::ITCompression(const ModSample &sample, bool it215, FILE *f) : mptSample(sample), is215(it215), file(f)
//-------------------------------------------------------------------------------------------------------------------
{
- packedData.resize(bufferSize);
+ packedData = new (std::nothrow) uint8[bufferSize];
+ sampleData = new (std::nothrow) uint8[blockSize];
packedTotalLength = 0;
+ if(packedData == nullptr || sampleData == nullptr)
+ {
+ return;
+ }
for(uint8 chn = 0; chn < mptSample.GetNumChannels(); chn++)
{
@@ -75,6 +80,9 @@
remain -= baseLength;
}
}
+
+ delete[] packedData;
+ delete[] sampleData;
}
@@ -111,17 +119,12 @@
void ITCompression::Compress(const void *data, SmpLength offset, SmpLength actualLength)
//--------------------------------------------------------------------------------------
{
- baseLength = Util::Min(actualLength, SmpLength(0x8000 / sizeof(Properties::sample_t)));
+ baseLength = Util::Min(actualLength, SmpLength(blockSize / sizeof(Properties::sample_t)));
- sampleData = new (std::nothrow) Properties::sample_t[baseLength];
- if(sampleData == nullptr)
- {
- return;
- }
-
CopySample<Properties::sample_t>(sampleData, data, offset, baseLength, mptSample.GetNumChannels());
- for(int i = 0; i < (is215 ? 2 : 1); i++)
+ Deltafy<Properties::sample_t>();
+ if(is215)
{
Deltafy<Properties::sample_t>();
}
@@ -168,8 +171,6 @@
packedData[1] = uint8((packedLength - 2) >> 8);
Verify(data, sampleData, offset);
-
- delete[] sampleData;
}
@@ -185,6 +186,7 @@
if(::GetPrivateProfileInt("Misc", "ITCompressionVerification", 0, theApp.GetConfigFileName()) != 0)
{
int8 *newSampleData = new (std::nothrow) int8[baseLength * mptSample.GetElementarySampleSize()];
+ // Load original sample data for this block again
if(mptSample.GetElementarySampleSize() > 1)
{
CopySample<int16>(sampleData, data, offset, baseLength, mptSample.GetNumChannels());
@@ -372,7 +374,7 @@
remBits = 8;
mem1 = mem2 = 0;
- curLength = Util::Min(mptSample.nLength - writtenSamples, SmpLength(0x8000 / sizeof(Properties::sample_t)));
+ curLength = Util::Min(mptSample.nLength - writtenSamples, SmpLength(ITCompression::blockSize / sizeof(Properties::sample_t)));
int width = Properties::defWidth;
while(curLength > 0)
Modified: trunk/OpenMPT/soundlib/ITCompression.h
===================================================================
--- trunk/OpenMPT/soundlib/ITCompression.h 2013-02-19 02:39:46 UTC (rev 1541)
+++ trunk/OpenMPT/soundlib/ITCompression.h 2013-02-19 18:40:54 UTC (rev 1542)
@@ -8,7 +8,7 @@
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
*/
-#pragma once
+#pragma once
#include "Snd_defs.h"
#include <vector>
@@ -24,17 +24,18 @@
ITCompression(const ModSample &sample, bool it215, FILE *f);
size_t GetCompressedSize() const { return packedTotalLength; }
-protected:
static const size_t bufferSize = 2 + 0xFFFF; // Our output buffer can't be longer than this.
+ static const size_t blockSize = 0x8000; // Block size (in bytes) in which samples are being processed
- std::vector<int> bwt; // Bit width table
- std::vector<uint8> packedData; // Compressed data for current sample block
- FILE *file;
- void *sampleData; // Pre-processed sample data for currently compressed sample block
- const ModSample &mptSample;
- size_t packedLength; // Size of currently compressed sample block
- size_t packedTotalLength; // Size of all compressed data so far
- SmpLength baseLength; // Length of the currently compressed sample block (in samples)
+protected:
+ std::vector<int> bwt; // Bit width table
+ uint8 *packedData; // Compressed data for current sample block
+ FILE *file; // File to which compressed data will be written (can be nullptr if you only want to find out the sample size)
+ void *sampleData; // Pre-processed sample data for currently compressed sample block
+ const ModSample &mptSample; // Sample that is being processed
+ size_t packedLength; // Size of currently compressed sample block
+ size_t packedTotalLength; // Size of all compressed data so far
+ SmpLength baseLength; // Length of the currently compressed sample block (in samples)
// Bit writer
int bitPos; // Current bit position in this byte
Modified: trunk/OpenMPT/soundlib/Load_it.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_it.cpp 2013-02-19 02:39:46 UTC (rev 1541)
+++ trunk/OpenMPT/soundlib/Load_it.cpp 2013-02-19 18:40:54 UTC (rev 1542)
@@ -221,14 +221,12 @@
-#pragma warning(disable:4244) //conversion from 'type1' to 'type2', possible loss of data
-
//////////////////////////////////////////////////////////
// Impulse Tracker IT file support
-UINT ConvertVolParam(const ModCommand *m)
-//---------------------------------------
+uint8 ConvertVolParam(const ModCommand *m)
+//----------------------------------------
{
return min(m->vol, 9);
}
@@ -972,7 +970,7 @@
const size_t num = 0;
#endif // MODPLUG_TRACKER
- uint16 fnum = min(num, uint16_max); // Number of entries that are actually going to be written
+ uint16 fnum = (uint16)min(num, uint16_max); // Number of entries that are actually going to be written
const size_t bytes_written = 2 + fnum * 8; // Number of bytes that are actually going to be written
if(f == nullptr)
@@ -1021,7 +1019,6 @@
return bytes_written;
}
-#pragma warning(disable:4100)
#ifdef MODPLUG_TRACKER
#include "../mptrack/Mptrack.h" // For config filename
@@ -1075,11 +1072,12 @@
//VERSION
if(GetType() == MOD_TYPE_MPT)
{
+ // MPTM
itHeader.cwtv = verMptFileVer; // Used in OMPT-hack versioning.
itHeader.cmwt = 0x888;
- }
- else //IT
+ } else
{
+ // IT
MptVersion::VersionNum vVersion = MptVersion::num;
itHeader.cwtv = 0x5000 | (uint16)((vVersion >> 16) & 0x0FFF); // format: txyy (t = tracker ID, x = version major, yy = version minor), e.g. 0x5117 (OpenMPT = 5, 117 = v1.17)
itHeader.cmwt = 0x0214; // Common compatible tracker :)
@@ -1108,17 +1106,17 @@
if(m_SongFlags[SONG_ITCOMPATGXX]) itHeader.flags |= ITFileHeader::itCompatGxx;
if(m_SongFlags[SONG_EXFILTERRANGE] && !compatibilityExport) itHeader.flags |= ITFileHeader::extendedFilterRange;
- itHeader.globalvol = m_nDefaultGlobalVolume >> 1;
- itHeader.mv = min(m_nSamplePreAmp, 128);
- itHeader.speed = m_nDefaultSpeed;
- itHeader.tempo = min(m_nDefaultTempo, 255); //Limit this one to 255, we save the real one as an extension below.
+ itHeader.globalvol = (uint8)(m_nDefaultGlobalVolume >> 1);
+ itHeader.mv = (uint8)min(m_nSamplePreAmp, 128);
+ itHeader.speed = (uint8)min(m_nDefaultSpeed, 255);
+ itHeader.tempo = (uint8)min(m_nDefaultTempo, 255); //Limit this one to 255, we save the real one as an extension below.
itHeader.sep = 128; // pan separation
// IT doesn't have a per-instrument Pitch Wheel Depth setting, so we just store the first non-zero PWD setting in the header.
for(INSTRUMENTINDEX ins = 1; ins < GetNumInstruments(); ins++)
{
if(Instruments[ins] != nullptr && Instruments[ins]->midiPWD != 0)
{
- itHeader.pwd = abs(Instruments[ins]->midiPWD);
+ itHeader.pwd = (uint8)abs(Instruments[ins]->midiPWD);
break;
}
}
@@ -1130,9 +1128,9 @@
for (CHANNELINDEX ich = 0; ich < min(m_nChannels, 64); ich++) // Header only has room for settings for 64 chans...
{
- itHeader.chnpan[ich] = ChnSettings[ich].nPan >> 2;
+ itHeader.chnpan[ich] = (uint8)(ChnSettings[ich].nPan >> 2);
if (ChnSettings[ich].dwFlags[CHN_SURROUND]) itHeader.chnpan[ich] = 100;
- itHeader.chnvol[ich] = ChnSettings[ich].nVolume;
+ itHeader.chnvol[ich] = (uint8)(ChnSettings[ich].nVolume);
if (ChnSettings[ich].dwFlags[CHN_MUTE]) itHeader.chnpan[ich] |= 0x80;
}
@@ -1176,7 +1174,7 @@
if(m_lpszSongComments)
{
itHeader.special |= ITFileHeader::embedSongMessage;
- itHeader.msglength = min(strlen(m_lpszSongComments) + 1, uint16_max);
+ itHeader.msglength = (uint16)min(strlen(m_lpszSongComments) + 1, uint16_max);
itHeader.msgoffset = dwHdrPos + dwExtra + (itHeader.insnum + itHeader.smpnum + itHeader.patnum) * 4;
}
@@ -1288,29 +1286,31 @@
// Writing Patterns
bool bNeedsMptPatSave = false;
- for (UINT npat=0; npat<itHeader.patnum; npat++)
+ for(PATTERNINDEX pat = 0; pat < itHeader.patnum; pat++)
{
- DWORD dwPatPos = dwPos;
- if (!Patterns[npat]) continue;
+ uint32 dwPatPos = dwPos;
+ if (!Patterns[pat]) continue;
- if(Patterns[npat].GetOverrideSignature())
+ if(Patterns[pat].GetOverrideSignature())
bNeedsMptPatSave = true;
// Check for empty pattern
- if (Patterns[npat].GetNumRows() == 64 && Patterns.IsPatternEmpty(npat))
+ if(Patterns[pat].GetNumRows() == 64 && Patterns.IsPatternEmpty(pat))
{
- patpos[npat] = 0;
+ patpos[pat] = 0;
continue;
}
- patpos[npat] = dwPos;
+ patpos[pat] = dwPos;
// Write pattern header
- WORD patinfo[4];
+ ROWINDEX writeRows = Util::Min(Patterns[pat].GetNumRows(), ROWINDEX(uint16_max));
+ uint16 patinfo[4];
patinfo[0] = 0;
- patinfo[1] = LittleEndianW(Patterns[npat].GetNumRows());
+ patinfo[1] = (uint16)writeRows;
patinfo[2] = 0;
patinfo[3] = 0;
+ SwapBytesLE(patinfo[1]);
fwrite(patinfo, 8, 1, f);
dwPos += 8;
@@ -1319,13 +1319,13 @@
vector<BYTE> chnmask(maxChannels, 0xFF);
vector<ModCommand> lastvalue(maxChannels, ModCommand::Empty());
- for (ROWINDEX row = 0; row<Patterns[npat].GetNumRows(); row++)
+ for(ROWINDEX row = 0; row < writeRows; row++)
{
- UINT len = 0;
- BYTE buf[8 * MAX_BASECHANNELS];
- const ModCommand *m = Patterns[npat].GetRow(row);
+ uint32 len = 0;
+ uint8 buf[8 * MAX_BASECHANNELS];
+ const ModCommand *m = Patterns[pat].GetRow(row);
- for (CHANNELINDEX ch = 0; ch < maxChannels; ch++, m++)
+ for(CHANNELINDEX ch = 0; ch < maxChannels; ch++, m++)
{
// Skip mptm-specific notes.
if(m->IsPcNote())
@@ -1334,7 +1334,7 @@
continue;
}
- BYTE b = 0;
+ uint8 b = 0;
uint8 command = m->command;
uint8 param = m->param;
uint8 vol = 0xFF;
@@ -1438,11 +1438,11 @@
if (b != chnmask[ch])
{
chnmask[ch] = b;
- buf[len++] = (ch+1) | 0x80;
+ buf[len++] = uint8((ch + 1) | 0x80);
buf[len++] = b;
} else
{
- buf[len++] = ch+1;
+ buf[len++] = uint8(ch + 1);
}
if (b & 1) buf[len++] = note;
if (b & 2) buf[len++] = m->instr;
@@ -1461,20 +1461,20 @@
if(GetpModDoc())
{
CString str;
- str.Format("%s (%s %u)\n", str_tooMuchPatternData, str_pattern, npat);
+ str.Format("%s (%s %u)\n", str_tooMuchPatternData, str_pattern, pat);
GetpModDoc()->AddToLog(str);
}
#endif // MODPLUG_TRACKER
break;
- }
- else
+ } else
{
dwPos += len;
- patinfo[0] += len;
+ patinfo[0] += (uint16)len;
fwrite(buf, 1, len, f);
}
}
fseek(f, dwPatPos, SEEK_SET);
+ SwapBytesLE(patinfo[0]);
fwrite(patinfo, 8, 1, f);
fseek(f, dwPos, SEEK_SET);
}
@@ -1527,7 +1527,7 @@
fseek(f, 0, SEEK_END);
std::ofstream fout(f);
- const DWORD MPTStartPos = fout.tellp();
+ const uint32 MPTStartPos = (uint32)fout.tellp();
srlztn::Ssb ssb(fout);
ssb.BeginWrite("mptm", MptVersion::num);
@@ -1570,7 +1570,6 @@
}
-#pragma warning(default:4100)
#endif // MODPLUG_NO_FILESAVE
@@ -1581,15 +1580,11 @@
{
-// -> CODE#0006
-// -> DESC="misc quantity changes"
-// DWORD chinfo[64];
- DWORD chinfo[MAX_BASECHANNELS];
-// -! BEHAVIOUR_CHANGE#0006
+ uint32 chinfo[MAX_BASECHANNELS];
CHAR s[32];
- DWORD nPluginSize;
- UINT nTotalSize = 0;
- UINT nChInfo = 0;
+ uint32 nPluginSize;
+ uint32 nTotalSize = 0;
+ uint32 nChInfo = 0;
for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++)
{
@@ -1672,7 +1667,7 @@
{
if (f)
{
- nPluginSize = 'XFHC';
+ memcpy(&nPluginSize, "CHFX", 4);
fwrite(&nPluginSize, 1, 4, f);
nPluginSize = nChInfo*4;
fwrite(&nPluginSize, 1, 4, f);
@@ -1706,7 +1701,7 @@
{
for (size_t ch = 0; ch < MAX_BASECHANNELS; ch++)
{
- ChnSettings[ch].nMixPlugin = chunk.ReadUint32LE();
+ ChnSettings[ch].nMixPlugin = (uint8)chunk.ReadUint32LE();
}
}
// Plugin Data
@@ -1915,13 +1910,13 @@
fwrite(&code, 1, sizeof(__int32), f);
size = (GetNumChannels() - 64) * 2;
fwrite(&size, 1, sizeof(__int16), f);
- for(UINT ich = 64; ich < m_nChannels; ich++)
+ for(CHANNELINDEX chn = 64; chn < GetNumChannels(); chn++)
{
- BYTE panvol[2];
- panvol[0] = ChnSettings[ich].nPan >> 2;
- if (ChnSettings[ich].dwFlags[CHN_SURROUND]) panvol[0] = 100;
- if (ChnSettings[ich].dwFlags[CHN_MUTE]) panvol[0] |= 0x80;
- panvol[1] = ChnSettings[ich].nVolume;
+ uint8 panvol[2];
+ panvol[0] = (uint8)(ChnSettings[chn].nPan >> 2);
+ if (ChnSettings[chn].dwFlags[CHN_SURROUND]) panvol[0] = 100;
+ if (ChnSettings[chn].dwFlags[CHN_MUTE]) panvol[0] |= 0x80;
+ panvol[1] = (uint8)ChnSettings[chn].nVolume;
fwrite(&panvol, sizeof(panvol), 1, f);
}
}
@@ -2066,14 +2061,14 @@
// Case macros.
#define CASE(id, data) \
- case id: fadr = reinterpret_cast<char *>(&data); maxReadCount = Util::Min(size, sizeof(data)); break;
+ case id: fadr = reinterpret_cast<char *>(&data); maxReadCount = Util::Min(size_t(size), sizeof(data)); break;
#define CASE_NOTXM(id, data) \
- case id: if(modtype != MOD_TYPE_XM) { fadr = reinterpret_cast<char *>(&data); maxReadCount = Util::Min(size, sizeof(data));} break;
+ case id: if(modtype != MOD_TYPE_XM) { fadr = reinterpret_cast<char *>(&data); maxReadCount = Util::Min(size_t(size), sizeof(data));} break;
while(file.BytesLeft() > 6)
{
const uint32 code = file.ReadUint32LE();
- const size_t size = file.ReadUint16LE();
+ const uint16 size = file.ReadUint16LE();
if(!file.CanRead(size))
{
@@ -2104,7 +2099,7 @@
if(size <= (MAX_BASECHANNELS - 64) * 2 && (size % 2u) == 0)
{
STATIC_ASSERT(CountOf(ChnSettings) >= 64);
- const uint16 loopLimit = Util::Min(size / 2, CountOf(ChnSettings) - 64);
+ const CHANNELINDEX loopLimit = Util::Min(uint16(size / 2), uint16(CountOf(ChnSettings) - 64));
for(CHANNELINDEX i = 0; i < loopLimit; i++)
{
Modified: trunk/OpenMPT/soundlib/SampleFormats.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-02-19 02:39:46 UTC (rev 1541)
+++ trunk/OpenMPT/soundlib/SampleFormats.cpp 2013-02-19 18:40:54 UTC (rev 1542)
@@ -25,6 +25,15 @@
#include "ChunkReader.h"
+// Check for valid MPEG header
+static bool IsMPEG(const void *data)
+//----------------------------------
+{
+ const uint8 *header = static_cast<const uint8 *>(data);
+ return header[0] == 0xFF && (header[1] & 0xE0) == 0xE0 && (header[1] & 0x18) != 0x08 && (header[1] & 0x06) != 0x00 && (header[2] & 0xF0) != 0xF0;
+}
+
+
bool CSoundFile::ReadSampleFromFile(SAMPLEINDEX nSample, const LPBYTE lpMemFile, DWORD dwFileLength)
//--------------------------------------------------------------------------------------------------
{
@@ -84,8 +93,7 @@
|| psig[0] == LittleEndian('CaLf') // FLAC signature
#endif // NO_FLAC
#ifndef NO_MP3_SAMPLES
- || (lpMemFile[0] == 0xFF && lpMemFile[1] == 0xFB) // MP2 signature
- || (lpMemFile[0] == 0xFF && lpMemFile[1] == 0xFB) // MP3 signature
+ || IsMPEG(lpMemFile) // MPEG signature
|| (lpMemFile[0] == 'I' && lpMemFile[1] == 'D' && lpMemFile[2] == '3') // MP3 signature
#endif // NO_MP3_SAMPLES
)
@@ -2262,6 +2270,50 @@
#ifndef NO_MP3_SAMPLES
static HMODULE mp3lib = nullptr;
+ // Check file for validity, or else mpg123 will happily munch many files that start looking vaguely resemble an MPEG stream mid-file.
+ file.Rewind();
+ while(file.BytesLeft() > 3)
+ {
+ uint8 header[3];
+ file.ReadArray(header);
+
+ if(!memcmp(header, "ID3", 3))
+ {
+ // Skip ID3 tags
+ uint8 header[7];
+ file.ReadArray(header);
+
+ uint32 size = 0;
+ for(int i = 3; i < 7; i++)
+ {
+ if(header[i] & 0x80)
+ return false;
+ size = (size << 7) | header[i];
+ }
+ file.Skip(size);
+ } else if(!memcmp(header, "APE", 3) && file.ReadMagic("TAGEX"))
+ {
+ // Skip APE tags
+ uint32 size = file.ReadUint32LE();
+ file.Skip(16 + size);
+ } else if(!memcmp(header, "\x00\x00\x00", 3) || !memcmp(header, "\xFF\x00\x00", 3))
+ {
+ // Some MP3 files are padded with zeroes...
+ } else if(header[0] == 0)
+ {
+ // This might be some padding, followed by an MPEG header, so try again.
+ file.SkipBack(2);
+ } else if(IsMPEG(header))
+ {
+ // This is what we want!
+ break;
+ } else
+ {
+ // This, on the other hand, isn't.
+ return false;
+ }
+ }
+
if(!mp3lib)
{
#ifdef MODPLUG_TRACKER
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-02-22 22:55:24
|
Revision: 1545
http://sourceforge.net/p/modplug/code/1545
Author: saga-games
Date: 2013-02-22 22:55:15 +0000 (Fri, 22 Feb 2013)
Log Message:
-----------
[Fix] IT Compatibility: There is no unified effect memory between the volume column effects, and the volume slide commands there also don't share their effect memory with the effect column slides (test case: VolColMemory.it)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ModChannel.h
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/modcommand.h
Modified: trunk/OpenMPT/soundlib/ModChannel.h
===================================================================
--- trunk/OpenMPT/soundlib/ModChannel.h 2013-02-21 15:24:54 UTC (rev 1544)
+++ trunk/OpenMPT/soundlib/ModChannel.h 2013-02-22 22:55:15 UTC (rev 1545)
@@ -84,7 +84,7 @@
uint8 nNewNote, nNewIns, nCommand, nArpeggio;
uint8 nOldVolumeSlide, nOldFineVolUpDown;
uint8 nOldPortaUpDown, nOldFinePortaUpDown, nOldExtraFinePortaUpDown;
- uint8 nOldPanSlide, nOldChnVolSlide;
+ uint8 nOldPanSlide, nOldChnVolSlide, nOldVolColSlide;
uint8 nVibratoType, nVibratoSpeed, nVibratoDepth;
uint8 nTremoloType, nTremoloSpeed, nTremoloDepth;
uint8 nPanbrelloType, nPanbrelloSpeed, nPanbrelloDepth;
@@ -140,7 +140,6 @@
resetSetPosAdvanced = 4, // Reset more runtime channel attributes
resetSetPosFull = resetSetPosBasic | resetSetPosAdvanced | resetChannelSettings, // Reset all runtime channel attributes
resetTotal = resetSetPosFull,
-
};
void Reset(ResetFlags resetMask, const CSoundFile &sndFile, CHANNELINDEX sourceChannel);
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-02-21 15:24:54 UTC (rev 1544)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-02-22 22:55:15 UTC (rev 1545)
@@ -795,6 +795,9 @@
reset = (!pChn->nLength
|| (insNumber && bPorta && m_SongFlags[SONG_ITCOMPATGXX])
|| (insNumber && !bPorta && pChn->dwFlags[CHN_NOTEFADE | CHN_KEYOFF] && m_SongFlags[SONG_ITOLDEFFECTS]));
+ // NOTE: IT2.14 with SB/GUS/etc. output is different. We are going after IT's WAV writer here.
+ // For SB/GUS/etc. emulation, envelope carry should only apply when the NNA isn't set to "Note Cut".
+ // Test case: CarryNNA.it
resetAlways = (instrumentChanged || pChn->dwFlags[CHN_KEYOFF]);
} else
{
@@ -837,7 +840,7 @@
}
}
// Invalid sample ?
- if (!pSmp)
+ if(!pSmp)
{
pChn->pModSample = nullptr;
pChn->nInsVol = 0;
@@ -845,12 +848,12 @@
}
// Tone-Portamento doesn't reset the pingpong direction flag
- if (bPorta && pSmp == pChn->pModSample)
+ if(bPorta && pSmp == pChn->pModSample)
{
// If channel length is 0, we cut a previous sample using SCx. In that case, we have to update sample length, loop points, etc...
if(GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT) && pChn->nLength != 0) return;
pChn->dwFlags.reset(CHN_KEYOFF | CHN_NOTEFADE);
- pChn->dwFlags = (pChn->dwFlags & (CHN_CHANNELFLAGS | CHN_PINGPONGFLAG)) | (static_cast<ChannelFlags>(pSmp->uFlags) & CHN_SAMPLEFLAGS);
+ pChn->dwFlags = (pChn->dwFlags & (CHN_CHANNELFLAGS | CHN_PINGPONGFLAG)) | (pSmp->uFlags & CHN_SAMPLEFLAGS);
} else
{
pChn->dwFlags.reset(CHN_KEYOFF | CHN_NOTEFADE);
@@ -858,12 +861,12 @@
// IT compatibility tentative fix: Don't change bidi loop direction when
// no sample nor instrument is changed.
if(IsCompatibleMode(TRK_ALLTRACKERS) && pSmp == pChn->pModSample && !instrumentChanged)
- pChn->dwFlags = (pChn->dwFlags & (CHN_CHANNELFLAGS | CHN_PINGPONGFLAG)) | (static_cast<ChannelFlags>(pSmp->uFlags) & CHN_SAMPLEFLAGS);
+ pChn->dwFlags = (pChn->dwFlags & (CHN_CHANNELFLAGS | CHN_PINGPONGFLAG)) | (pSmp->uFlags & CHN_SAMPLEFLAGS);
else
- pChn->dwFlags = (pChn->dwFlags & CHN_CHANNELFLAGS) | (static_cast<ChannelFlags>(pSmp->uFlags) & CHN_SAMPLEFLAGS);
+ pChn->dwFlags = (pChn->dwFlags & CHN_CHANNELFLAGS) | (pSmp->uFlags & CHN_SAMPLEFLAGS);
- if (pIns)
+ if(pIns)
{
// Copy envelope flags (we actually only need the "enabled" and "pitch" flag)
pChn->VolEnv.flags = pIns->VolEnv.dwFlags;
@@ -874,11 +877,11 @@
// Test case: FilterEnvReset.it
if((pIns->PitchEnv.dwFlags & (ENV_ENABLED | ENV_FILTER)) == (ENV_ENABLED | ENV_FILTER) && !IsCompatibleMode(TRK_IMPULSETRACKER))
{
- if (!pChn->nCutOff) pChn->nCutOff = 0x7F;
+ if(!pChn->nCutOff) pChn->nCutOff = 0x7F;
}
- if (pIns->IsCutoffEnabled()) pChn->nCutOff = pIns->GetCutoff();
- if (pIns->IsResonanceEnabled()) pChn->nResonance = pIns->GetResonance();
+ if(pIns->IsCutoffEnabled()) pChn->nCutOff = pIns->GetCutoff();
+ if(pIns->IsResonanceEnabled()) pChn->nResonance = pIns->GetResonance();
}
pChn->nVolSwing = pChn->nPanSwing = 0;
pChn->nResSwing = pChn->nCutSwing = 0;
@@ -956,17 +959,17 @@
// save the note that's actually used, as it's necessary to properly calculate PPS and stuff
const int realnote = note;
- if ((pIns) && (note <= 0x80))
+ if((pIns) && (note - NOTE_MIN < CountOf(pIns->Keyboard)))
{
UINT n = pIns->Keyboard[note - NOTE_MIN];
if ((n) && (n < MAX_SAMPLES)) pSmp = &Samples[n];
note = pIns->NoteMap[note-1];
}
// Key Off
- if (note > NOTE_MAX)
+ if(note > NOTE_MAX)
{
// Key Off (+ Invalid Note for XM - TODO is this correct?)
- if (note == NOTE_KEYOFF || !(GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)))
+ if(note == NOTE_KEYOFF || !(GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)))
{
KeyOff(nChn);
}
@@ -1004,9 +1007,9 @@
}
}
- if (!bPorta && (GetType() & (MOD_TYPE_XM | MOD_TYPE_MED | MOD_TYPE_MT2)))
+ if(!bPorta && (GetType() & (MOD_TYPE_XM | MOD_TYPE_MED | MOD_TYPE_MT2)))
{
- if (pSmp)
+ if(pSmp)
{
pChn->nTranspose = pSmp->RelativeTone;
pChn->nFineTune = pSmp->nFineTune;
@@ -1056,10 +1059,10 @@
UINT period = GetPeriodFromNote(note, pChn->nFineTune, pChn->nC5Speed);
- if (!pSmp) return;
- if (period)
+ if(!pSmp) return;
+ if(period)
{
- if ((!bPorta) || (!pChn->nPeriod)) pChn->nPeriod = period;
+ if((!bPorta) || (!pChn->nPeriod)) pChn->nPeriod = period;
if(!newTuning)
{
// FT2 compatibility: Don't reset portamento target with new notes.
@@ -1070,7 +1073,7 @@
}
}
- if (!bPorta || (!pChn->nLength && !(GetType() & MOD_TYPE_S3M)))
+ if(!bPorta || (!pChn->nLength && !(GetType() & MOD_TYPE_S3M)))
{
pChn->pModSample = pSmp;
pChn->pSample = pSmp->pSample;
@@ -1078,14 +1081,14 @@
pChn->nLoopEnd = pSmp->nLength;
pChn->nLoopStart = 0;
pChn->dwFlags = (pChn->dwFlags & CHN_CHANNELFLAGS) | (static_cast<ChannelFlags>(pSmp->uFlags) & CHN_SAMPLEFLAGS);
- if (pChn->dwFlags[CHN_SUSTAINLOOP])
+ if(pChn->dwFlags[CHN_SUSTAINLOOP])
{
pChn->nLoopStart = pSmp->nSustainStart;
pChn->nLoopEnd = pSmp->nSustainEnd;
pChn->dwFlags.set(CHN_PINGPONGLOOP, pChn->dwFlags[CHN_PINGPONGSUSTAIN]);
pChn->dwFlags.set(CHN_LOOP);
if (pChn->nLength > pChn->nLoopEnd) pChn->nLength = pChn->nLoopEnd;
- } else if (pChn->dwFlags[CHN_LOOP])
+ } else if(pChn->dwFlags[CHN_LOOP])
{
pChn->nLoopStart = pSmp->nLoopStart;
pChn->nLoopEnd = pSmp->nLoopEnd;
@@ -1094,7 +1097,7 @@
pChn->nPos = 0;
pChn->nPosLo = 0;
// Handle "retrigger" waveform type
- if (pChn->nVibratoType < 4)
+ if(pChn->nVibratoType < 4)
{
// IT Compatibilty: Slightly different waveform offsets (why does MPT have two different offsets here with IT old effects enabled and disabled?)
if(!IsCompatibleMode(TRK_IMPULSETRACKER) && (GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && !m_SongFlags[SONG_ITOLDEFFECTS])
@@ -1108,9 +1111,8 @@
pChn->nTremoloPos = 0;
}
}
- if (pChn->nPos >= pChn->nLength) pChn->nPos = pChn->nLoopStart;
- }
- else
+ if(pChn->nPos >= pChn->nLength) pChn->nPos = pChn->nLoopStart;
+ } else
{
bPorta = false;
}
@@ -1149,7 +1151,7 @@
pChn->dwFlags.reset(CHN_EXTRALOUD | CHN_KEYOFF);
// Enable Ramping
- if (!bPorta)
+ if(!bPorta)
{
pChn->nVUMeter = 0x100;
pChn->nLeftVU = pChn->nRightVU = 0xFF;
@@ -1172,11 +1174,11 @@
}
}
- if (bResetEnv)
+ if(bResetEnv)
{
pChn->nVolSwing = pChn->nPanSwing = 0;
pChn->nResSwing = pChn->nCutSwing = 0;
- if (pIns)
+ if(pIns)
{
// IT Compatiblity: NNA is reset on every note change, not every instrument change (fixes spx-farspacedance.it).
if(IsCompatibleMode(TRK_IMPULSETRACKER)) pChn->nNNA = pIns->nNNA;
@@ -1188,13 +1190,13 @@
if(GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT))
{
// Volume Swing
- if (pIns->nVolSwing)
+ if(pIns->nVolSwing)
{
const double delta = 2 * (((double) rand()) / RAND_MAX) - 1;
pChn->nVolSwing = static_cast<int32>(std::floor(delta * (IsCompatibleMode(TRK_IMPULSETRACKER) ? pChn->nInsVol : ((pChn->nVolume + 1) / 2)) * pIns->nVolSwing / 100.0));
}
// Pan Swing
- if (pIns->nPanSwing)
+ if(pIns->nPanSwing)
{
const double delta = 2 * (((double) rand()) / RAND_MAX) - 1;
pChn->nPanSwing = static_cast<int32>(std::floor(delta * (IsCompatibleMode(TRK_IMPULSETRACKER) ? 4 : 1) * pIns->nPanSwing));
@@ -1204,14 +1206,14 @@
}
}
// Cutoff Swing
- if (pIns->nCutSwing)
+ if(pIns->nCutSwing)
{
int32 d = ((int32)pIns->nCutSwing * (int32)((rand() & 0xFF) - 0x7F)) / 128;
pChn->nCutSwing = (int16)((d * pChn->nCutOff + 1) / 128);
pChn->nRestoreCutoffOnNewNote = pChn->nCutOff + 1;
}
// Resonance Swing
- if (pIns->nResSwing)
+ if(pIns->nResSwing)
{
int32 d = ((int32)pIns->nResSwing * (int32)((rand() & 0xFF) - 0x7F)) / 128;
pChn->nResSwing = (int16)((d * pChn->nResonance + 1) / 128);
@@ -1230,21 +1232,21 @@
}
}
pChn->nLeftVol = pChn->nRightVol = 0;
- bool bFlt = !m_SongFlags[SONG_MPTFILTERMODE];
+ bool useFilter = !m_SongFlags[SONG_MPTFILTERMODE];
// Setup Initial Filter for this note
- if (pIns)
+ if(pIns)
{
- if (pIns->IsResonanceEnabled())
+ if(pIns->IsResonanceEnabled())
{
pChn->nResonance = pIns->GetResonance();
- bFlt = true;
+ useFilter = true;
}
- if (pIns->IsCutoffEnabled())
+ if(pIns->IsCutoffEnabled())
{
pChn->nCutOff = pIns->GetCutoff();
- bFlt = true;
+ useFilter = true;
}
- if (bFlt && (pIns->nFilterMode != FLTMODE_UNCHANGED))
+ if(useFilter && (pIns->nFilterMode != FLTMODE_UNCHANGED))
{
pChn->nFilterMode = pIns->nFilterMode;
}
@@ -1253,7 +1255,7 @@
pChn->nVolSwing = pChn->nPanSwing = 0;
pChn->nCutSwing = pChn->nResSwing = 0;
}
- if ((pChn->nCutOff < 0x7F || IsCompatibleMode(TRK_IMPULSETRACKER)) && (bFlt))
+ if((pChn->nCutOff < 0x7F || IsCompatibleMode(TRK_IMPULSETRACKER)) && useFilter)
{
SetupChannelFilter(pChn, true);
}
@@ -2040,35 +2042,41 @@
volcmd = VOLCMD_NONE;
}
- } else
+ } else if(!IsCompatibleMode(TRK_IMPULSETRACKER))
{
+ // IT Compatibility: Effects in the volume column don't have an unified memory.
+ // Test case: VolColMemory.it
if(vol) pChn->nOldVolParam = vol; else vol = pChn->nOldVolParam;
}
switch(volcmd)
{
case VOLCMD_VOLSLIDEUP:
- VolumeSlide(pChn, vol << 4);
- break;
-
case VOLCMD_VOLSLIDEDOWN:
- VolumeSlide(pChn, vol);
+ // IT Compatibility: Volume column volume slides have their own memory
+ // Test case: VolColMemory.it
+ if(vol == 0 && IsCompatibleMode(TRK_IMPULSETRACKER))
+ {
+ vol = pChn->nOldVolColSlide;
+ if(vol == 0)
+ break;
+ } else
+ {
+ pChn->nOldVolColSlide = vol;
+ }
+ VolumeSlide(pChn, volcmd == VOLCMD_VOLSLIDEUP ? (vol << 4) : vol);
break;
case VOLCMD_FINEVOLUP:
- if (GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))
- {
- if (m_nTickCount == nStartTick) VolumeSlide(pChn, (vol << 4) | 0x0F);
- } else
- FineVolumeUp(pChn, vol);
+ // IT Compatibility: Volume column volume slides have their own memory
+ // Test case: VolColMemory.it
+ FineVolumeUp(pChn, vol, IsCompatibleMode(TRK_IMPULSETRACKER));
break;
case VOLCMD_FINEVOLDOWN:
- if (GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT))
- {
- if (m_nTickCount == nStartTick) VolumeSlide(pChn, 0xF0 | vol);
- } else
- FineVolumeDown(pChn, vol);
+ // IT Compatibility: Volume column volume slides have their own memory
+ // Test case: VolColMemory.it
+ FineVolumeDown(pChn, vol, IsCompatibleMode(TRK_IMPULSETRACKER));
break;
case VOLCMD_VIBRATOSPEED:
@@ -3069,7 +3077,7 @@
{
if (param & 0xF0) //Fine upslide
{
- FineVolumeUp(pChn, (param >> 4));
+ FineVolumeUp(pChn, (param >> 4), false);
return;
} else //Slide -15
{
@@ -3083,7 +3091,7 @@
{
if (param & 0x0F) //Fine downslide
{
- FineVolumeDown(pChn, (param & 0x0F));
+ FineVolumeDown(pChn, (param & 0x0F), false);
return;
} else //Slide +15
{
@@ -3198,14 +3206,17 @@
}
-void CSoundFile::FineVolumeUp(ModChannel *pChn, UINT param)
-//---------------------------------------------------------
+void CSoundFile::FineVolumeUp(ModChannel *pChn, UINT param, bool volCol)
+//----------------------------------------------------------------------
{
if(GetType() == MOD_TYPE_XM)
{
// FT2 compatibility: EAx / EBx memory is not linked
// Test case: FineVol-LinkMem.xm
if(param) pChn->nOldFineVolUpDown = (param << 4) | (pChn->nOldFineVolUpDown & 0x0F); else param = (pChn->nOldFineVolUpDown >> 4);
+ } else if(volCol)
+ {
+ if(param) pChn->nOldVolColSlide = param; else param = pChn->nOldVolColSlide;
} else
{
if(param) pChn->nOldFineVolUpDown = param; else param = pChn->nOldFineVolUpDown;
@@ -3220,14 +3231,17 @@
}
-void CSoundFile::FineVolumeDown(ModChannel *pChn, UINT param)
-//-----------------------------------------------------------
+void CSoundFile::FineVolumeDown(ModChannel *pChn, UINT param, bool volCol)
+//------------------------------------------------------------------------
{
if(GetType() == MOD_TYPE_XM)
{
// FT2 compatibility: EAx / EBx memory is not linked
// Test case: FineVol-LinkMem.xm
if(param) pChn->nOldFineVolUpDown = param | (pChn->nOldFineVolUpDown & 0xF0); else param = (pChn->nOldFineVolUpDown & 0x0F);
+ } else if(volCol)
+ {
+ if(param) pChn->nOldVolColSlide = param; else param = pChn->nOldVolColSlide;
} else
{
if(param) pChn->nOldFineVolUpDown = param; else param = pChn->nOldFineVolUpDown;
@@ -3339,9 +3353,9 @@
// E9x: Retrig
case 0x90: RetrigNote(nChn, param); break;
// EAx: Fine Volume Up
- case 0xA0: if ((param) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) FineVolumeUp(pChn, param); break;
+ case 0xA0: if ((param) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) FineVolumeUp(pChn, param, false); break;
// EBx: Fine Volume Down
- case 0xB0: if ((param) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) FineVolumeDown(pChn, param); break;
+ case 0xB0: if ((param) || (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))) FineVolumeDown(pChn, param, false); break;
// ECx: Note Cut
case 0xC0: NoteCut(nChn, param); break;
// EDx: Note Delay
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-02-21 15:24:54 UTC (rev 1544)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-02-22 22:55:15 UTC (rev 1545)
@@ -574,8 +574,8 @@
void VolumeSlide(ModChannel *pChn, UINT param);
void PanningSlide(ModChannel *pChn, UINT param, bool memory = true);
void ChannelVolSlide(ModChannel *pChn, UINT param);
- void FineVolumeUp(ModChannel *pChn, UINT param);
- void FineVolumeDown(ModChannel *pChn, UINT param);
+ void FineVolumeUp(ModChannel *pChn, UINT param, bool volCol);
+ void FineVolumeDown(ModChannel *pChn, UINT param, bool volCol);
void Tremolo(ModChannel *pChn, UINT param);
void Panbrello(ModChannel *pChn, UINT param);
void RetrigNote(CHANNELINDEX nChn, int param, UINT offset=0); //rewbs.volOffset: added last param
Modified: trunk/OpenMPT/soundlib/modcommand.h
===================================================================
--- trunk/OpenMPT/soundlib/modcommand.h 2013-02-21 15:24:54 UTC (rev 1544)
+++ trunk/OpenMPT/soundlib/modcommand.h 2013-02-22 22:55:15 UTC (rev 1545)
@@ -62,11 +62,12 @@
void Clear() { memset(this, 0, sizeof(ModCommand)); }
// Returns true if modcommand is empty, false otherwise.
- // If ignoreEffectValues is true (default), effect values are ignored are ignored if there is no effect command present.
+ // If ignoreEffectValues is true (default), effect values are ignored if there is no effect command present.
bool IsEmpty(const bool ignoreEffectValues = true) const
{
if(ignoreEffectValues)
- return (this->note == 0 && this->instr == 0 && this->volcmd == 0 && this->command == 0);
+ return *reinterpret_cast<const uint32 *>(this) == 0; // First four bytes contain note, instr, volcmd and command
+ //return (this->note == 0 && this->instr == 0 && this->volcmd == VOLCMD_NONE && this->command == CMD_NONE);
else
return (*this == Empty());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-03-09 14:21:42
|
Revision: 1551
http://sourceforge.net/p/modplug/code/1551
Author: saga-games
Date: 2013-03-09 14:21:31 +0000 (Sat, 09 Mar 2013)
Log Message:
-----------
[Fix] SCx shouldn't click anymore in IT compatible or S3M playback mode (just like normal note cuts).
[Ref] Removed unused function ModSequence::WriteToByteArray
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ModChannel.h
trunk/OpenMPT/soundlib/ModSequence.cpp
trunk/OpenMPT/soundlib/ModSequence.h
trunk/OpenMPT/soundlib/Snd_fx.cpp
Modified: trunk/OpenMPT/soundlib/ModChannel.h
===================================================================
--- trunk/OpenMPT/soundlib/ModChannel.h 2013-03-06 21:48:34 UTC (rev 1550)
+++ trunk/OpenMPT/soundlib/ModChannel.h 2013-03-09 14:21:31 UTC (rev 1551)
@@ -84,7 +84,7 @@
uint8 nNewNote, nNewIns, nCommand, nArpeggio;
uint8 nOldVolumeSlide, nOldFineVolUpDown;
uint8 nOldPortaUpDown, nOldFinePortaUpDown, nOldExtraFinePortaUpDown;
- uint8 nOldPanSlide, nOldChnVolSlide, nOldVolColSlide;
+ uint8 nOldPanSlide, nOldChnVolSlide;
uint8 nVibratoType, nVibratoSpeed, nVibratoDepth;
uint8 nTremoloType, nTremoloSpeed, nTremoloDepth;
uint8 nPanbrelloType, nPanbrelloSpeed, nPanbrelloDepth;
Modified: trunk/OpenMPT/soundlib/ModSequence.cpp
===================================================================
--- trunk/OpenMPT/soundlib/ModSequence.cpp 2013-03-06 21:48:34 UTC (rev 1550)
+++ trunk/OpenMPT/soundlib/ModSequence.cpp 2013-03-09 14:21:31 UTC (rev 1551)
@@ -638,27 +638,6 @@
}
-size_t ModSequence::WriteToByteArray(BYTE* dest, const UINT numOfBytes, const UINT destSize) const
-//------------------------------------------------------------------------------------------------
-{
- if(numOfBytes > destSize || numOfBytes > MAX_ORDERS) return true;
-
- const size_t limit = min(numOfBytes, GetLength());
-
- size_t i = 0;
- for(i = 0; i < limit; i++)
- {
- dest[i] = static_cast<BYTE>((*this)[i]);
- }
- // Fill non-existing order items with stop indices
- for(i = limit; i < numOfBytes; i++)
- {
- dest[i] = 0xFF;
- }
- return i; //Returns the number of bytes written.
-}
-
-
size_t ModSequence::WriteAsByte(FILE* f, const uint16 count) const
//----------------------------------------------------------------
{
Modified: trunk/OpenMPT/soundlib/ModSequence.h
===================================================================
--- trunk/OpenMPT/soundlib/ModSequence.h 2013-03-06 21:48:34 UTC (rev 1550)
+++ trunk/OpenMPT/soundlib/ModSequence.h 2013-03-09 14:21:31 UTC (rev 1551)
@@ -96,7 +96,6 @@
// Read/write.
size_t WriteAsByte(FILE* f, const uint16 count) const;
- size_t WriteToByteArray(BYTE* dest, const UINT numOfBytes, const UINT destSize) const;
bool ReadAsByte(const BYTE* pFrom, const int howMany, const int memLength);
bool ReadAsByte(FileReader &file, size_t howMany);
template<typename T, size_t arraySize>
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-06 21:48:34 UTC (rev 1550)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-03-09 14:21:31 UTC (rev 1551)
@@ -2057,12 +2057,12 @@
// Test case: VolColMemory.it
if(vol == 0 && IsCompatibleMode(TRK_IMPULSETRACKER))
{
- vol = pChn->nOldVolColSlide;
+ vol = pChn->nOldVolParam;
if(vol == 0)
break;
} else
{
- pChn->nOldVolColSlide = vol;
+ pChn->nOldVolParam = vol;
}
VolumeSlide(pChn, volcmd == VOLCMD_VOLSLIDEUP ? (vol << 4) : vol);
break;
@@ -3216,7 +3216,7 @@
if(param) pChn->nOldFineVolUpDown = (param << 4) | (pChn->nOldFineVolUpDown & 0x0F); else param = (pChn->nOldFineVolUpDown >> 4);
} else if(volCol)
{
- if(param) pChn->nOldVolColSlide = param; else param = pChn->nOldVolColSlide;
+ if(param) pChn->nOldVolParam = param; else param = pChn->nOldVolParam;
} else
{
if(param) pChn->nOldFineVolUpDown = param; else param = pChn->nOldFineVolUpDown;
@@ -3241,7 +3241,7 @@
if(param) pChn->nOldFineVolUpDown = param | (pChn->nOldFineVolUpDown & 0xF0); else param = (pChn->nOldFineVolUpDown & 0x0F);
} else if(volCol)
{
- if(param) pChn->nOldVolColSlide = param; else param = pChn->nOldVolColSlide;
+ if(param) pChn->nOldVolParam = param; else param = pChn->nOldVolParam;
} else
{
if(param) pChn->nOldFineVolUpDown = param; else param = pChn->nOldFineVolUpDown;
@@ -4250,14 +4250,13 @@
if (m_nTickCount == nTick)
{
ModChannel *pChn = &Chn[nChn];
- // if (m_nInstruments) KeyOff(pChn); ?
pChn->nVolume = 0;
// S3M/IT compatibility: Note Cut really cuts notes and does not just mute them (so that following volume commands could restore the sample)
// Test case: scx.it
if(IsCompatibleMode(TRK_IMPULSETRACKER|TRK_SCREAMTRACKER))
{
- pChn->nLength = 0;
- pChn->nPos = pChn->nPosLo = 0;
+ pChn->nFadeOutVol = 0;
+ pChn->dwFlags.set(CHN_NOTEFADE);
}
pChn->dwFlags.set(CHN_FASTVOLRAMP);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-03-16 19:45:55
|
Revision: 1576
http://sourceforge.net/p/modplug/code/1576
Author: saga-games
Date: 2013-03-16 19:45:42 +0000 (Sat, 16 Mar 2013)
Log Message:
-----------
[Imp] WAV loading: Loops that only cover the first sample point are ignored during import now.
[Ref] Small changes.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/SampleIO.cpp
trunk/OpenMPT/soundlib/WAVTools.cpp
trunk/OpenMPT/soundlib/WAVTools.h
Modified: trunk/OpenMPT/soundlib/SampleIO.cpp
===================================================================
--- trunk/OpenMPT/soundlib/SampleIO.cpp 2013-03-16 18:15:17 UTC (rev 1575)
+++ trunk/OpenMPT/soundlib/SampleIO.cpp 2013-03-16 19:45:42 UTC (rev 1576)
@@ -38,16 +38,8 @@
const FileReader::off_t fileSize = file.BytesLeft(), filePosition = file.GetPosition();
FileReader::off_t bytesRead = 0; // Amount of memory that has been read from file
- sample.uFlags &= ~(CHN_16BIT | CHN_STEREO);
- if(GetBitDepth() >= 16)
- {
- sample.uFlags |= CHN_16BIT;
- }
- if(GetChannelFormat() != mono)
- {
- ASSERT(GetNumChannels() == 2);
- sample.uFlags |= CHN_STEREO;
- }
+ sample.uFlags.set(CHN_16BIT, GetBitDepth() >= 16);
+ sample.uFlags.set(CHN_STEREO, GetChannelFormat() != mono);
size_t sampleSize = sample.AllocateSample(); // Target sample size in bytes
if(sampleSize == 0)
@@ -293,9 +285,8 @@
} else if(GetEncoding() == IT214 || GetEncoding() == IT215)
{
// IT 2.14 / 2.15 compressed samples
- size_t startPos = file.GetPosition();
ITDecompression(file, sample, GetEncoding() == IT215);
- bytesRead = file.GetPosition() - startPos;
+ bytesRead = file.GetPosition() - filePosition;
} else if(GetEncoding() == AMS && GetChannelFormat() == mono)
{
// AMS compressed samples
@@ -321,7 +312,8 @@
{
uint32 bitBuf = file.ReadUint32LE(), bitNum = 32;
- uint8 *outBuf = reinterpret_cast<uint8 *>(sample.pSample);
+ uint8 *outBuf8 = reinterpret_cast<uint8 *>(sample.pSample);
+ uint16 *outBuf16 = reinterpret_cast<uint16 *>(sample.pSample);
const uint8 *inBuf = sourceBuf + 4;
uint8 dlt = 0, lowbyte = 0;
@@ -347,11 +339,10 @@
dlt += hibyte;
if(GetBitDepth() != 16)
{
- outBuf[j] = dlt;
+ outBuf8[j] = dlt;
} else
{
- outBuf[j << 1] = lowbyte;
- outBuf[(j << 1) + 1] = dlt;
+ outBuf16[j] = lowbyte | (dlt << 8);
}
}
@@ -509,7 +500,7 @@
{
// Stereo unsigned interleaved
len = numSamples * 2;
- for (UINT j=0; j<len; j++)
+ for(SmpLength j = 0; j < len; j++)
{
*((uint8 *)(&buffer[bufcount])) = *((uint8 *)(&pSample[j])) + 0x80;
bufcount++;
Modified: trunk/OpenMPT/soundlib/WAVTools.cpp
===================================================================
--- trunk/OpenMPT/soundlib/WAVTools.cpp 2013-03-16 18:15:17 UTC (rev 1575)
+++ trunk/OpenMPT/soundlib/WAVTools.cpp 2013-03-16 19:45:42 UTC (rev 1576)
@@ -179,9 +179,15 @@
}
-void WAVSampleLoop::ApplyToSample(SmpLength &start, SmpLength &end, uint32 sampleLength, FlagSet<ChannelFlags, uint16> &flags, ChannelFlags enableFlag, ChannelFlags bidiFlag, bool mptLoopFix) const
-//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+// 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
+//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
{
+ if(loopEnd == 0)
+ {
+ // Some WAV files seem to have loops going from 0 to 0... We should ignore those.
+ return;
+ }
start = Util::Min(static_cast<SmpLength>(loopStart), sampleLength);
end = Clamp(static_cast<SmpLength>(loopEnd), start, sampleLength);
if(!mptLoopFix && end < sampleLength)
@@ -196,3 +202,23 @@
flags.set(bidiFlag);
}
}
+
+
+// Convert internal loop information into a WAV loop.
+void WAVSampleLoop::ConvertToWAV(SmpLength start, SmpLength end, bool bidi)
+//-------------------------------------------------------------------------
+{
+ identifier = 0;
+ loopType = bidi ? loopBidi : loopForward;
+ loopStart = start;
+ // Loop ends are *inclusive* in the RIFF standard, while they're *exclusive* in OpenMPT.
+ if(end > start)
+ {
+ loopEnd = end - 1;
+ } else
+ {
+ loopEnd = start;
+ }
+ fraction = 0;
+ playCount = 0;
+}
Modified: trunk/OpenMPT/soundlib/WAVTools.h
===================================================================
--- trunk/OpenMPT/soundlib/WAVTools.h 2013-03-16 18:15:17 UTC (rev 1575)
+++ trunk/OpenMPT/soundlib/WAVTools.h 2013-03-16 19:45:42 UTC (rev 1576)
@@ -214,25 +214,11 @@
SwapBytesLE(playCount);
}
- void ApplyToSample(SmpLength &start, SmpLength &end, uint32 sampleLength, FlagSet<ChannelFlags, uint16> &flags, ChannelFlags enableFlag, ChannelFlags bidiFlag, bool mptLoopFix) const;
+ // 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;
- // Set up a loop.
- void ConvertToWAV(SmpLength start, SmpLength end, bool bidi)
- {
- identifier = 0;
- loopType = bidi ? loopBidi : loopForward;
- loopStart = start;
- // Loop ends are *inclusive* in the RIFF standard, while they're *exclusive* in OpenMPT.
- if(end > start)
- {
- loopEnd = end - 1;
- } else
- {
- loopEnd = start;
- }
- fraction = 0;
- playCount = 0;
- }
+ // 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...> - 2013-03-17 16:07:06
|
Revision: 1594
http://sourceforge.net/p/modplug/code/1594
Author: saga-games
Date: 2013-03-17 16:07:00 +0000 (Sun, 17 Mar 2013)
Log Message:
-----------
[Mod] XM Loader: Less false positives in MPT 1.09 detection
[Imp] Mod Conversion: 000 (arpeggio with no parameters) commands are now removed when converting from MOD/XM to other formats.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_xm.cpp
trunk/OpenMPT/soundlib/modcommand.cpp
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp 2013-03-17 16:05:52 UTC (rev 1593)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp 2013-03-17 16:07:00 UTC (rev 1594)
@@ -400,8 +400,8 @@
if((sampleHeader.flags & 3) == 3 && madeWith[verNewModPlug])
{
- // MPT 1.09 and maybe newer / older versions set both loop flags for bidi loops
- madeWith = (verModPlug1_09 | verConfirmed);
+ // MPT 1.09 and maybe newer / older versions set both loop flags for bidi loops.
+ madeWith.set(verModPlug1_09);
}
}
}
Modified: trunk/OpenMPT/soundlib/modcommand.cpp
===================================================================
--- trunk/OpenMPT/soundlib/modcommand.cpp 2013-03-17 16:05:52 UTC (rev 1593)
+++ trunk/OpenMPT/soundlib/modcommand.cpp 2013-03-17 16:07:00 UTC (rev 1594)
@@ -24,19 +24,19 @@
command = CMD_S3MCMDEX;
switch(param & 0xF0)
{
- case 0x10: command = CMD_PORTAMENTOUP; param |= 0xF0; break;
- case 0x20: command = CMD_PORTAMENTODOWN; param |= 0xF0; break;
- case 0x30: param = (param & 0x0F) | 0x10; break;
- case 0x40: param = (param & 0x03) | 0x30; break;
- case 0x50: param = (param & 0x0F) | 0x20; break;
- case 0x60: param = (param & 0x0F) | 0xB0; break;
- case 0x70: param = (param & 0x03) | 0x40; break;
- case 0x90: command = CMD_RETRIG; param = (param & 0x0F); break;
- case 0xA0: if (param & 0x0F) { command = CMD_VOLUMESLIDE; param = (param << 4) | 0x0F; } else command = 0; break;
- case 0xB0: if (param & 0x0F) { command = CMD_VOLUMESLIDE; param |= 0xF0; } else command = 0; break;
- case 0xC0: if (param == 0xC0) { command = CMD_NONE; note = NOTE_NOTECUT; } // this does different things in IT and ST3
- case 0xD0: if (param == 0xD0) { command = CMD_NONE; } // dito
- // rest are the same
+ case 0x10: command = CMD_PORTAMENTOUP; param |= 0xF0; break;
+ case 0x20: command = CMD_PORTAMENTODOWN; param |= 0xF0; break;
+ case 0x30: param = (param & 0x0F) | 0x10; break;
+ case 0x40: param = (param & 0x03) | 0x30; break;
+ case 0x50: param = (param & 0x0F) | 0x20; break;
+ case 0x60: param = (param & 0x0F) | 0xB0; break;
+ case 0x70: param = (param & 0x03) | 0x40; break;
+ case 0x90: command = CMD_RETRIG; param = (param & 0x0F); break;
+ case 0xA0: if(param & 0x0F) { command = CMD_VOLUMESLIDE; param = (param << 4) | 0x0F; } else command = 0; break;
+ case 0xB0: if(param & 0x0F) { command = CMD_VOLUMESLIDE; param |= 0xF0; } else command = 0; break;
+ case 0xC0: if(param == 0xC0) { command = CMD_NONE; note = NOTE_NOTECUT; } // this does different things in IT and ST3
+ case 0xD0: if(param == 0xD0) { command = CMD_NONE; } // dito
+ // rest are the same
}
}
@@ -51,17 +51,17 @@
command = CMD_MODCMDEX;
switch(param & 0xF0)
{
- case 0x10: param = (param & 0x0F) | 0x30; break;
- case 0x20: param = (param & 0x0F) | 0x50; break;
- case 0x30: param = (param & 0x0F) | 0x40; break;
- case 0x40: param = (param & 0x0F) | 0x70; break;
+ case 0x10: param = (param & 0x0F) | 0x30; break;
+ case 0x20: param = (param & 0x0F) | 0x50; break;
+ case 0x30: param = (param & 0x0F) | 0x40; break;
+ case 0x40: param = (param & 0x0F) | 0x70; break;
case 0x50:
case 0x60:
case 0x90:
- case 0xA0: command = CMD_XFINEPORTAUPDOWN; break;
- case 0xB0: param = (param & 0x0F) | 0x60; break;
- case 0x70: command = CMD_NONE; // No NNA / envelope control in MOD/XM format
- // rest are the same
+ case 0xA0: command = CMD_XFINEPORTAUPDOWN; break;
+ case 0xB0: param = (param & 0x0F) | 0x60; break;
+ case 0x70: command = CMD_NONE; // No NNA / envelope control in MOD/XM format
+ // rest are the same
}
}
@@ -95,16 +95,14 @@
if(newTypeIsS3M)
{
param = (param + 1) >> 1;
- }
- else if(oldTypeIsS3M)
+ } else if(oldTypeIsS3M)
{
if(param == 0xA4)
{
// surround remap
- command = static_cast<ModCommand::COMMAND>((toType & (MOD_TYPE_IT | MOD_TYPE_MPT)) ? CMD_S3MCMDEX : CMD_XFINEPORTAUPDOWN);
+ command = static_cast<COMMAND>((toType & (MOD_TYPE_IT | MOD_TYPE_MPT)) ? CMD_S3MCMDEX : CMD_XFINEPORTAUPDOWN);
param = 0x91;
- }
- else
+ } else
{
param = min(param << 1, 0xFF);
}
@@ -123,18 +121,18 @@
{
if(IsPcNote())
{
- ModCommand::COMMAND newcommand = static_cast<ModCommand::COMMAND>(note == NOTE_PC ? CMD_MIDI : CMD_SMOOTHMIDI);
- if(!CSoundFile::GetModSpecifications(toType).HasCommand(newcommand))
+ COMMAND newCmd = static_cast<COMMAND>(note == NOTE_PC ? CMD_MIDI : CMD_SMOOTHMIDI);
+ if(!CSoundFile::GetModSpecifications(toType).HasCommand(newCmd))
{
- newcommand = CMD_MIDI; // assuming that this was CMD_SMOOTHMIDI
+ newCmd = CMD_MIDI; // assuming that this was CMD_SMOOTHMIDI
+ if(!CSoundFile::GetModSpecifications(toType).HasCommand(newCmd))
+ {
+ newCmd = CMD_NONE;
+ }
}
- if(!CSoundFile::GetModSpecifications(toType).HasCommand(newcommand))
- {
- newcommand = CMD_NONE;
- }
- param = (BYTE)(min(ModCommand::maxColumnValue, GetValueEffectCol()) * 0x7F / ModCommand::maxColumnValue);
- command = newcommand; // might be removed later
+ param = (BYTE)(min(maxColumnValue, GetValueEffectCol()) * 0x7F / maxColumnValue);
+ command = newCmd; // might be removed later
volcmd = VOLCMD_NONE;
note = NOTE_NONE;
instr = 0;
@@ -148,8 +146,8 @@
if(command == CMD_DELAYCUT)
{
- command = CMD_S3MCMDEX; // when converting to MOD/XM, this will be converted to CMD_MODCMDEX later
- param = 0xD0 | (param >> 4); // preserve delay nibble.
+ command = CMD_S3MCMDEX; // When converting to MOD/XM, this will be converted to CMD_MODCMDEX later
+ param = 0xD0 | (param >> 4); // Preserve delay nibble.
}
} // End if(oldTypeIsMPT)
@@ -159,13 +157,17 @@
{
switch(command)
{
+ case CMD_ARPEGGIO:
+ if(!param) command = CMD_NONE; // 000 does nothing in MOD/XM
+ break;
+
case CMD_MODCMDEX:
ExtendedMODtoS3MEffect();
break;
case CMD_VOLUME:
// Effect column volume command overrides the volume column in XM.
- if (volcmd == VOLCMD_NONE || volcmd == VOLCMD_VOLUME)
+ if(volcmd == VOLCMD_NONE || volcmd == VOLCMD_VOLUME)
{
volcmd = VOLCMD_VOLUME;
vol = param;
@@ -182,11 +184,11 @@
break;
case CMD_PORTAMENTOUP:
- if (param > 0xDF) param = 0xDF;
+ if(param > 0xDF) param = 0xDF;
break;
case CMD_PORTAMENTODOWN:
- if (param > 0xDF) param = 0xDF;
+ if(param > 0xDF) param = 0xDF;
break;
case CMD_XFINEPORTAUPDOWN:
@@ -200,7 +202,7 @@
case 0x90:
case 0xA0:
command = CMD_S3MCMDEX;
- // surround remap (this is the "official" command)
+ // Surround remap (this is the "official" command)
if(toType & MOD_TYPE_S3M && param == 0x91)
{
command = CMD_PANNING8;
@@ -213,7 +215,7 @@
case CMD_KEYOFF:
if(note == NOTE_NONE)
{
- note = (newTypeIsS3M) ? NOTE_NOTECUT : NOTE_KEYOFF;
+ note = newTypeIsS3M ? NOTE_NOTECUT : NOTE_KEYOFF;
command = CMD_S3MCMDEX;
if(param == 0)
instr = 0;
@@ -260,62 +262,63 @@
break;
case CMD_VOLUMESLIDE:
- if ((param & 0xF0) && ((param & 0x0F) == 0x0F))
+ if((param & 0xF0) && ((param & 0x0F) == 0x0F))
{
command = CMD_MODCMDEX;
param = (param >> 4) | 0xA0;
- } else
- if ((param & 0x0F) && ((param & 0xF0) == 0xF0))
- {
- command = CMD_MODCMDEX;
- param = (param & 0x0F) | 0xB0;
- }
- break;
+ } else if((param & 0x0F) && ((param & 0xF0) == 0xF0))
+ {
+ command = CMD_MODCMDEX;
+ param = (param & 0x0F) | 0xB0;
+ }
+ break;
case CMD_PORTAMENTOUP:
- if (param >= 0xF0)
+ if(param >= 0xF0)
{
command = CMD_MODCMDEX;
param = (param & 0x0F) | 0x10;
+ } else if(param >= 0xE0)
+ {
+ if(newTypeIsXM)
+ {
+ command = CMD_XFINEPORTAUPDOWN;
+ param = 0x10 | (param & 0x0F);
+ } else
+ {
+ command = CMD_MODCMDEX;
+ param = (((param & 0x0F) + 3) >> 2) | 0x10;
+ }
} else
- if (param >= 0xE0)
- {
- if(newTypeIsXM)
- {
- command = CMD_XFINEPORTAUPDOWN;
- param = 0x10 | (param & 0x0F);
- } else
- {
- command = CMD_MODCMDEX;
- param = (((param & 0x0F) + 3) >> 2) | 0x10;
- }
- } else command = CMD_PORTAMENTOUP;
+ {
+ command = CMD_PORTAMENTOUP;
+ }
break;
case CMD_PORTAMENTODOWN:
- if (param >= 0xF0)
+ if(param >= 0xF0)
{
command = CMD_MODCMDEX;
param = (param & 0x0F) | 0x20;
+ } else if(param >= 0xE0)
+ {
+ if(newTypeIsXM)
+ {
+ command = CMD_XFINEPORTAUPDOWN;
+ param = 0x20 | (param & 0x0F);
+ } else
+ {
+ command = CMD_MODCMDEX;
+ param = (((param & 0x0F) + 3) >> 2) | 0x20;
+ }
} else
- if (param >= 0xE0)
- {
- if(newTypeIsXM)
- {
- command = CMD_XFINEPORTAUPDOWN;
- param = 0x20 | (param & 0x0F);
- } else
- {
- command = CMD_MODCMDEX;
- param = (((param & 0x0F) + 3) >> 2) | 0x20;
- }
- } else command = CMD_PORTAMENTODOWN;
+ {
+ command = CMD_PORTAMENTODOWN;
+ }
break;
case CMD_SPEED:
- {
- param = min(param, (toType == MOD_TYPE_XM) ? 0x1F : 0x20);
- }
+ param = min(param, (toType == MOD_TYPE_XM) ? 0x1F : 0x20);
break;
case CMD_TEMPO:
@@ -391,7 +394,7 @@
default:
break;
}
- } // End if (oldTypeIsIT_MPT && newTypeIsS3M)
+ } // End if(oldTypeIsIT_MPT && newTypeIsS3M)
//////////////////////
// Convert IT to XM
@@ -440,7 +443,7 @@
///////////////////////////////////////////////////////////////////////
// Convert MOD to anything - adjust effect memory, remove Invert Loop
- if (oldTypeIsMOD)
+ if(oldTypeIsMOD)
{
switch(command)
{
@@ -457,11 +460,11 @@
if((param & 0xF0) == 0xF0) command = CMD_NONE;
break;
}
- } // End if (oldTypeIsMOD && newTypeIsXM)
+ } // End if(oldTypeIsMOD && newTypeIsXM)
/////////////////////////////////////////////////////////////////////
// Convert anything to MOD - remove volume column, remove Set Macro
- if (newTypeIsMOD)
+ if(newTypeIsMOD)
{
// convert note off events
if(note >= NOTE_MIN_SPECIAL)
@@ -556,11 +559,11 @@
}
volcmd = CMD_NONE;
- } // End if (newTypeIsMOD)
+ } // End if(newTypeIsMOD)
///////////////////////////////////////////////////
// Convert anything to S3M - adjust volume column
- if (newTypeIsS3M)
+ if(newTypeIsS3M)
{
if(!command) switch(volcmd)
{
@@ -638,11 +641,11 @@
break;
}
- } // End if (newTypeIsS3M)
+ } // End if(newTypeIsS3M)
////////////////////////////////////////////////////////////////////////
// Convert anything to XM - adjust volume column, breaking EDx command
- if (newTypeIsXM)
+ if(newTypeIsXM)
{
// remove EDx if no note is next to it, or it will retrigger the note in FT2 mode
if(command == CMD_MODCMDEX && (param & 0xF0) == 0xD0 && note == NOTE_NONE)
@@ -686,11 +689,11 @@
break;
}
- } // End if (newTypeIsXM)
+ } // End if(newTypeIsXM)
///////////////////////////////////////////////////
// Convert anything to IT - adjust volume column
- if (newTypeIsIT_MPT)
+ if(newTypeIsIT_MPT)
{
if(!command) switch(volcmd)
{
@@ -726,7 +729,7 @@
break;
}
- } // End if (newTypeIsIT)
+ } // End if(newTypeIsIT_MPT)
if(!CSoundFile::GetModSpecifications(toType).HasNote(note))
note = NOTE_NONE;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-03-25 20:56:00
|
Revision: 1690
http://sourceforge.net/p/modplug/code/1690
Author: manxorist
Date: 2013-03-25 20:55:55 +0000 (Mon, 25 Mar 2013)
Log Message:
-----------
[Ref] Remove unused CSoundFile::gnCPUUsage.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 20:31:52 UTC (rev 1689)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-03-25 20:55:55 UTC (rev 1690)
@@ -247,7 +247,6 @@
static double gdWFIRCutoff;
static BYTE gbWFIRType;
static UINT gnVolumeRampUpSamples, gnVolumeRampUpSamplesTarget, gnVolumeRampDownSamples;
- static UINT gnCPUUsage;
static LPSNDMIXHOOKPROC gpSndMixHook;
static PMIXPLUGINCREATEPROC gpMixPluginCreateProc;
static uint8 s_DefaultPlugVolumeHandling;
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 20:31:52 UTC (rev 1689)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-03-25 20:55:55 UTC (rev 1690)
@@ -49,7 +49,6 @@
UINT CSoundFile::gnVolumeRampUpSamples = 42; //default value
UINT CSoundFile::gnVolumeRampUpSamplesTarget = 42; //default value
UINT CSoundFile::gnVolumeRampDownSamples = 42; //default value
-UINT CSoundFile::gnCPUUsage = 0;
LPSNDMIXHOOKPROC CSoundFile::gpSndMixHook = NULL;
PMIXPLUGINCREATEPROC CSoundFile::gpMixPluginCreateProc = NULL;
LONG gnDryROfsVol = 0;
@@ -174,7 +173,6 @@
#ifndef NO_REVERB
gnRvbROfsVol = gnRvbLOfsVol = 0;
#endif
- if (bReset) gnCPUUsage = 0;
#ifndef NO_REVERB
InitializeReverb(bReset);
#endif
@@ -377,8 +375,7 @@
// Noise Shaping
if (gnBitsPerSample <= 16)
{
- if ((gdwSoundSetup & SNDMIX_HQRESAMPLER)
- && ((gnCPUUsage < 25) || (gdwSoundSetup & SNDMIX_DIRECTTODISK)))
+ if (gdwSoundSetup & SNDMIX_HQRESAMPLER)
X86_Dither(MixSoundBuffer, lTotalSampleCount, gnBitsPerSample);
}
@@ -1607,9 +1604,9 @@
LONG nLeftDelta = ((pChn->nNewLeftVol - pChn->nLeftVol) << VOLUMERAMPPRECISION);
// if ((gdwSoundSetup & SNDMIX_DIRECTTODISK)
// || ((gdwSysInfo & (SYSMIX_ENABLEMMX|SYSMIX_FASTCPU))
-// && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50)))
+// && (gdwSoundSetup & SNDMIX_HQRESAMPLER)))
if((gdwSoundSetup & SNDMIX_DIRECTTODISK)
- || ((gdwSysInfo & (SYSMIX_ENABLEMMX | SYSMIX_FASTCPU)) && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && (gnCPUUsage <= 50) && !enableCustomRamp))
+ || ((gdwSysInfo & (SYSMIX_ENABLEMMX | SYSMIX_FASTCPU)) && (gdwSoundSetup & SNDMIX_HQRESAMPLER) && !enableCustomRamp))
{
if((pChn->nRightVol | pChn->nLeftVol) && (pChn->nNewRightVol | pChn->nNewLeftVol) && !pChn->dwFlags[CHN_FASTVOLRAMP])
{
@@ -2042,7 +2039,7 @@
{
pChn->dwFlags.set(CHN_NOIDO);
} else
- if ((gdwSoundSetup & SNDMIX_HQRESAMPLER) && ((gnCPUUsage < 80) || (gdwSoundSetup & SNDMIX_DIRECTTODISK) || (m_nMixChannels < 8)))
+ if (gdwSoundSetup & SNDMIX_HQRESAMPLER)
{
if ((!(gdwSoundSetup & SNDMIX_DIRECTTODISK)) && (!(gdwSoundSetup & SNDMIX_ULTRAHQSRCMODE)))
{
@@ -2071,8 +2068,7 @@
} else
{
if ((pChn->nInc >= 0x14000)
- || ((pChn->nInc >= 0xFF00) && ((pChn->nInc < 0x10100) || (gdwSysInfo & SYSMIX_SLOWCPU)))
- || ((gnCPUUsage > 80) && (pChn->nNewLeftVol < 0x100) && (pChn->nNewRightVol < 0x100)))
+ || ((pChn->nInc >= 0xFF00) && ((pChn->nInc < 0x10100) || (gdwSysInfo & SYSMIX_SLOWCPU))))
pChn->dwFlags.set(CHN_NOIDO);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-04-02 18:44:40
|
Revision: 1706
http://sourceforge.net/p/modplug/code/1706
Author: manxorist
Date: 2013-04-02 18:44:33 +0000 (Tue, 02 Apr 2013)
Log Message:
-----------
[Mod] Let quad surround always overwrite reverb channel setting.
[Fix] Actually do something sane when NO_REVERB is defined.
[Ref] Add copyright notice and #pragma once to Snd_rvb.h.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/snd_rvb.h
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-02 18:35:55 UTC (rev 1705)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-02 18:44:33 UTC (rev 1706)
@@ -1499,15 +1499,18 @@
pMixFuncTable = gpMixFunctionTable;
}
nsamples = count;
- #ifndef NO_REVERB
- pbuffer = (gdwSoundSetup & SNDMIX_REVERB) ? MixReverbBuffer : MixSoundBuffer;
- if(pChannel->dwFlags[CHN_SURROUND] && gnChannels > 2) pbuffer = MixRearBuffer;
- if(pChannel->dwFlags[CHN_NOREVERB]) pbuffer = MixSoundBuffer;
- #ifdef ENABLE_MMX
+ pbuffer = MixSoundBuffer;
+#ifndef NO_REVERB
+#ifdef ENABLE_MMX
+ if((gdwSoundSetup & SNDMIX_REVERB) && (gdwSysInfo & SYSMIX_ENABLEMMX) && !pChannel->dwFlags[CHN_NOREVERB])
+ pbuffer = MixReverbBuffer;
if(pChannel->dwFlags[CHN_REVERB] && (gdwSysInfo & SYSMIX_ENABLEMMX))
pbuffer = MixReverbBuffer;
- #endif
+#endif
+#endif
+ if(pChannel->dwFlags[CHN_SURROUND] && gnChannels > 2)
+ pbuffer = MixRearBuffer;
//Look for plugins associated with this implicit tracker channel.
PLUGINDEX nMixPlugin = GetBestPlugin(ChnMix[nChn], PrioritiseInstrument, RespectMutes);
@@ -1540,6 +1543,7 @@
}
}
}
+#ifndef NO_REVERB
if (pbuffer == MixReverbBuffer)
{
if (!gnReverbSend)
@@ -1550,10 +1554,8 @@
pOfsR = &gnRvbROfsVol;
pOfsL = &gnRvbLOfsVol;
}
+#endif
bSurround = (pbuffer == MixRearBuffer);
- #else
- pbuffer = MixSoundBuffer;
- #endif
nchused++;
////////////////////////////////////////////////////
SampleLooping:
Modified: trunk/OpenMPT/soundlib/snd_rvb.h
===================================================================
--- trunk/OpenMPT/soundlib/snd_rvb.h 2013-04-02 18:35:55 UTC (rev 1705)
+++ trunk/OpenMPT/soundlib/snd_rvb.h 2013-04-02 18:44:33 UTC (rev 1706)
@@ -1,6 +1,15 @@
-#ifndef _SNDMIX_REVERB_H_
-#define _SNDMIX_REVERB_H_
+/*
+ * Snd_rvb.h
+ * ---------
+ * Purpose: Mixing code for reverb.
+ * Notes : Ugh... This should really be removed at some point.
+ * Authors: Olivier Lapicque
+ * OpenMPT Devs
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+#pragma once
+
/////////////////////////////////////////////////////////////////////////////
//
// SW Reverb structures
@@ -188,6 +197,3 @@
#define SNDMIX_REVERB_PRESET_PLATE \
-1000, -200, 1.30f,0.90f, 0,0.002f, 0,0.010f,100.0f, 75.0f
-
-#endif // _SNDMIX_REVERB_H_
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-04-03 13:08:19
|
Revision: 1716
http://sourceforge.net/p/modplug/code/1716
Author: manxorist
Date: 2013-04-03 13:08:12 +0000 (Wed, 03 Apr 2013)
Log Message:
-----------
[Fix] Probe WASAPI devices for supported sampling rates and only show those in settings dialog.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/SNDDEVX.H
trunk/OpenMPT/soundlib/Snddev.cpp
Modified: trunk/OpenMPT/soundlib/SNDDEVX.H
===================================================================
--- trunk/OpenMPT/soundlib/SNDDEVX.H 2013-04-03 10:18:33 UTC (rev 1715)
+++ trunk/OpenMPT/soundlib/SNDDEVX.H 2013-04-03 13:08:12 UTC (rev 1716)
@@ -286,6 +286,7 @@
float GetCurrentRealLatencyMS();
bool HasGetStreamPosition() const { return false; }
int64 GetStreamPositionSamples() const;
+ bool CanSampleRate(UINT nDevice, std::vector<UINT> &samplerates, std::vector<bool> &result);
int StreamCallback(
const void *input, void *output,
Modified: trunk/OpenMPT/soundlib/Snddev.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snddev.cpp 2013-04-03 10:18:33 UTC (rev 1715)
+++ trunk/OpenMPT/soundlib/Snddev.cpp 2013-04-03 13:08:12 UTC (rev 1716)
@@ -1825,7 +1825,30 @@
}
+bool CPortaudioDevice::CanSampleRate(UINT nDevice, std::vector<UINT> &samplerates, std::vector<bool> &result)
+//-----------------------------------------------------------------------------------------------------------
+{
+ result.clear();
+ for(UINT n=0; n<samplerates.size(); n++)
+ {
+ PaStreamParameters StreamParameters;
+ MemsetZero(StreamParameters);
+ StreamParameters.device = HostApiOutputIndexToGlobalDeviceIndex(nDevice, m_HostApi);
+ if(StreamParameters.device == -1)
+ {
+ result.assign(samplerates.size(), false);
+ return false;
+ }
+ StreamParameters.channelCount = 2;
+ StreamParameters.sampleFormat = paInt16;
+ StreamParameters.suggestedLatency = 0.0;
+ StreamParameters.hostApiSpecificStreamInfo = NULL;
+ result.push_back(Pa_IsFormatSupported(NULL, &StreamParameters, samplerates[n]) == paFormatIsSupported);
+ }
+ return true;
+}
+
int CPortaudioDevice::StreamCallback(
const void *input, void *output,
unsigned long frameCount,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-04-04 15:23:53
|
Revision: 1729
http://sourceforge.net/p/modplug/code/1729
Author: saga-games
Date: 2013-04-04 15:23:39 +0000 (Thu, 04 Apr 2013)
Log Message:
-----------
[Fix] Retrig note was broken in IT compatible mode with VSTis (tx Nahkranoth)
[Imp] Retrig note also works with VSTis on rows without a note, and also with Cxx volume commands in XM (not that it really matters, anyway...).
Modified Paths:
--------------
trunk/OpenMPT/soundlib/ModChannel.h
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/ModChannel.h
===================================================================
--- trunk/OpenMPT/soundlib/ModChannel.h 2013-04-04 13:10:13 UTC (rev 1728)
+++ trunk/OpenMPT/soundlib/ModChannel.h 2013-04-04 15:23:39 UTC (rev 1729)
@@ -150,6 +150,9 @@
typedef uint32 volume_t;
volume_t GetVSTVolume() { return (pModInstrument) ? pModInstrument->nGlobalVol * 4 : nVolume; }
+ // Check if the channel has a valid MIDI output. This function guarantees that pModInstrument != nullptr.
+ bool HasMIDIOutput() const { return pModInstrument != nullptr && pModInstrument->HasValidMIDIChannel(); }
+
//-->Variables used to make user-definable tuning modes work with pattern effects.
bool m_ReCalculateFreqOnFirstTick;
//If true, freq should be recalculated in ReadNote() on first tick.
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-04 13:10:13 UTC (rev 1728)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-04 15:23:39 UTC (rev 1729)
@@ -948,7 +948,7 @@
if((n) && (n < MAX_SAMPLES))
{
pSmp = &Samples[n];
- } else if(IsCompatibleMode(TRK_IMPULSETRACKER) && !pIns->HasValidMIDIChannel())
+ } else if(IsCompatibleMode(TRK_IMPULSETRACKER) && !pChn->HasMIDIOutput())
{
// Impulse Tracker ignores empty slots.
// We won't ignore them if a plugin is assigned to this slot, so that VSTis still work as intended.
@@ -1451,7 +1451,7 @@
// Do we need to apply New/Duplicate Note Action to a VSTi?
bool applyNNAtoPlug = false;
IMixPlugin *pPlugin = NULL;
- if (pChn->pModInstrument && pChn->pModInstrument->HasValidMIDIChannel() && ModCommand::IsNote(pChn->nNote)) // instro sends to a midi chan
+ if(pChn->HasMIDIOutput() && ModCommand::IsNote(pChn->nNote)) // instro sends to a midi chan
{
PLUGINDEX nPlugin = GetBestPlugin(nChn, PrioritiseInstrument, RespectMutes);
@@ -4086,21 +4086,21 @@
//--------------------------------------------------------------------
{
// Retrig: bit 8 is set if it's the new XM retrig
- ModChannel *pChn = &Chn[nChn];
+ ModChannel &chn = Chn[nChn];
int nRetrigSpeed = param & 0x0F;
- int nRetrigCount = pChn->nRetrigCount;
+ int nRetrigCount = chn.nRetrigCount;
bool bDoRetrig = false;
//IT compatibility 15. Retrigger
if(IsCompatibleMode(TRK_IMPULSETRACKER))
{
- if(m_nTickCount == 0 && pChn->rowCommand.note)
+ if(m_nTickCount == 0 && chn.rowCommand.note)
{
- pChn->nRetrigCount = param & 0xf;
+ chn.nRetrigCount = param & 0xf;
}
- else if(!pChn->nRetrigCount || !--pChn->nRetrigCount)
+ else if(!chn.nRetrigCount || !--chn.nRetrigCount)
{
- pChn->nRetrigCount = param & 0xf;
+ chn.nRetrigCount = param & 0xf;
bDoRetrig = true;
}
} else if(IsCompatibleMode(TRK_FASTTRACKER2) && (param & 0x100))
@@ -4109,13 +4109,13 @@
if(m_SongFlags[SONG_FIRSTTICK])
{
// here are some really stupid things FT2 does
- if(pChn->rowCommand.volcmd == VOLCMD_VOLUME) return;
- if(pChn->rowCommand.instr > 0 && pChn->rowCommand.note == NOTE_NONE) nRetrigCount = 1;
- if(pChn->rowCommand.note != NOTE_NONE && pChn->rowCommand.note <= GetModSpecifications().noteMax) nRetrigCount++;
+ if(chn.rowCommand.volcmd == VOLCMD_VOLUME) return;
+ if(chn.rowCommand.instr > 0 && chn.rowCommand.note == NOTE_NONE) nRetrigCount = 1;
+ if(chn.rowCommand.note != NOTE_NONE && chn.rowCommand.note <= GetModSpecifications().noteMax) nRetrigCount++;
}
if (nRetrigCount >= nRetrigSpeed)
{
- if(!m_SongFlags[SONG_FIRSTTICK] || pChn->rowCommand.note == NOTE_NONE)
+ if(!m_SongFlags[SONG_FIRSTTICK] || chn.rowCommand.note == NOTE_NONE)
{
bDoRetrig = true;
nRetrigCount = 0;
@@ -4133,7 +4133,7 @@
{
int realspeed = nRetrigSpeed;
// FT2 bug: if a retrig (Rxy) occours together with a volume command, the first retrig interval is increased by one tick
- if ((param & 0x100) && (pChn->rowCommand.volcmd == VOLCMD_VOLUME) && (pChn->rowCommand.param & 0xF0)) realspeed++;
+ if ((param & 0x100) && (chn.rowCommand.volcmd == VOLCMD_VOLUME) && (chn.rowCommand.param & 0xF0)) realspeed++;
if(!m_SongFlags[SONG_FIRSTTICK] || (param & 0x100))
{
if (!realspeed) realspeed = 1;
@@ -4142,14 +4142,14 @@
} else if (GetType() & (MOD_TYPE_XM|MOD_TYPE_MT2)) nRetrigCount = 0;
if (nRetrigCount >= realspeed)
{
- if ((m_nTickCount) || ((param & 0x100) && (!pChn->rowCommand.note))) bDoRetrig = true;
+ if ((m_nTickCount) || ((param & 0x100) && (!chn.rowCommand.note))) bDoRetrig = true;
}
}
}
// IT compatibility: If a sample is shorter than the retrig time (i.e. it stops before the retrig counter hits zero), it is not retriggered.
// Test case: retrig-short.it
- if(pChn->nLength == 0 && IsCompatibleMode(TRK_IMPULSETRACKER))
+ if(chn.nLength == 0 && IsCompatibleMode(TRK_IMPULSETRACKER) && !chn.HasMIDIOutput())
{
return;
}
@@ -4159,10 +4159,10 @@
UINT dv = (param >> 4) & 0x0F;
if (dv)
{
- int vol = pChn->nVolume;
+ int vol = chn.nVolume;
// FT2 compatibility: Retrig + volume will not change volume of retrigged notes
- if(!IsCompatibleMode(TRK_FASTTRACKER2) || !(pChn->rowCommand.volcmd == VOLCMD_VOLUME))
+ if(!IsCompatibleMode(TRK_FASTTRACKER2) || !(chn.rowCommand.volcmd == VOLCMD_VOLUME))
{
if (retrigTable1[dv])
vol = (vol * retrigTable1[dv]) >> 4;
@@ -4172,18 +4172,18 @@
Limit(vol, 0, 256);
- pChn->nVolume = vol;
- pChn->dwFlags.set(CHN_FASTVOLRAMP);
+ chn.nVolume = vol;
+ chn.dwFlags.set(CHN_FASTVOLRAMP);
}
- UINT nNote = pChn->nNewNote;
- int32 nOldPeriod = pChn->nPeriod;
- if ((nNote) && (nNote <= NOTE_MAX) && (pChn->nLength)) CheckNNA(nChn, 0, nNote, true);
+ UINT nNote = chn.nNewNote;
+ int32 nOldPeriod = chn.nPeriod;
+ if ((nNote) && (nNote <= NOTE_MAX) && (chn.nLength)) CheckNNA(nChn, 0, nNote, true);
bool bResetEnv = false;
if (GetType() & (MOD_TYPE_XM|MOD_TYPE_MT2))
{
- if ((pChn->rowCommand.instr) && (param < 0x100))
+ if ((chn.rowCommand.instr) && (param < 0x100))
{
- InstrumentChange(pChn, pChn->rowCommand.instr, false, false);
+ InstrumentChange(&chn, chn.rowCommand.instr, false, false);
bResetEnv = true;
}
if (param < 0x100) bResetEnv = true;
@@ -4191,19 +4191,20 @@
// IT compatibility: Really weird combination of envelopes and retrigger (see Storlek's q.it testcase)
// Test case: retrig.it
NoteChange(nChn, nNote, IsCompatibleMode(TRK_IMPULSETRACKER), bResetEnv);
- if (m_nInstruments)
+ if(m_nInstruments)
{
+ chn.rowCommand.note = nNote; // No retrig without note...
ProcessMidiOut(nChn); //Send retrig to Midi
}
- if ((GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) && (!pChn->rowCommand.note) && (nOldPeriod)) pChn->nPeriod = nOldPeriod;
+ if ((GetType() & (MOD_TYPE_IT|MOD_TYPE_MPT)) && (!chn.rowCommand.note) && (nOldPeriod)) chn.nPeriod = nOldPeriod;
if (!(GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT))) nRetrigCount = 0;
// IT compatibility: see previous IT compatibility comment =)
- if(IsCompatibleMode(TRK_IMPULSETRACKER)) pChn->nPos = pChn->nPosLo = 0;
+ if(IsCompatibleMode(TRK_IMPULSETRACKER)) chn.nPos = chn.nPosLo = 0;
if (offset) //rewbs.volOffset: apply offset on retrig
{
- if (pChn->pModSample)
- pChn->nLength = pChn->pModSample->nLength;
+ if (chn.pModSample)
+ chn.nLength = chn.pModSample->nLength;
SampleOffset(nChn, offset);
}
}
@@ -4213,7 +4214,7 @@
// Now we can also store the retrig value for IT...
if(!IsCompatibleMode(TRK_IMPULSETRACKER))
- pChn->nRetrigCount = nRetrigCount;
+ chn.nRetrigCount = nRetrigCount;
}
@@ -4771,9 +4772,9 @@
return nullptr;
}
- const ModInstrument *pIns = Chn[chn].pModInstrument;
- if(pIns != nullptr && pIns->HasValidMIDIChannel())
+ if(Chn[chn].HasMIDIOutput())
{
+ const ModInstrument *pIns = Chn[chn].pModInstrument;
// Instrument sends to a MIDI channel
if(pIns->nMixPlug != 0 && pIns->nMixPlug <= MAX_MIXPLUGINS)
{
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-04 13:10:13 UTC (rev 1728)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-04 15:23:39 UTC (rev 1729)
@@ -2141,47 +2141,44 @@
void CSoundFile::ProcessMidiOut(CHANNELINDEX nChn)
//------------------------------------------------
{
- ModChannel *pChn = &Chn[nChn];
+ ModChannel &chn = Chn[nChn];
- // Do we need to process midi?
+ // Do we need to process MIDI?
// For now there is no difference between mute and sync mute with VSTis.
- if(pChn->dwFlags[CHN_MUTE | CHN_SYNCMUTE]) return;
- if(!m_nInstruments
- || m_nPattern >= Patterns.Size()
- || m_nRow >= Patterns[m_nPattern].GetNumRows()
- || !Patterns[m_nPattern])
+ if(chn.dwFlags[CHN_MUTE | CHN_SYNCMUTE] || !chn.HasMIDIOutput()) return;
+
+ // Get instrument info and plugin reference
+ const ModInstrument *pIns = chn.pModInstrument; // Can't be nullptr at this point, as we have valid MIDI output.
+
+ // No instrument or muted instrument?
+ if(pIns->dwFlags[INS_MUTE])
{
return;
}
- const ModCommand::NOTE note = pChn->rowCommand.note;
- const ModCommand::VOL vol = pChn->rowCommand.vol;
- const ModCommand::VOLCMD volcmd = pChn->rowCommand.volcmd;
-
- // Get instrument info and plugin reference
- ModInstrument *pIns = pChn->pModInstrument;
- PLUGINDEX nPlugin = 0;
+ // Check instrument plugins
+ const PLUGINDEX nPlugin = GetBestPlugin(nChn, PrioritiseInstrument, RespectMutes);
IMixPlugin *pPlugin = nullptr;
-
- if (pIns)
+ if(nPlugin > 0 && nPlugin <= MAX_MIXPLUGINS)
{
- // Check instrument plugins
- if (pIns->HasValidMIDIChannel())
- {
- nPlugin = GetBestPlugin(nChn, PrioritiseInstrument, RespectMutes);
- if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS))
- {
- pPlugin = m_MixPlugins[nPlugin-1].pMixPlugin;
- }
- }
-
- // Muted instrument?
- if(pIns != nullptr && pIns->dwFlags[INS_MUTE]) return;
+ pPlugin = m_MixPlugins[nPlugin - 1].pMixPlugin;
}
// Couldn't find a valid plugin
- if (pPlugin == nullptr) return;
+ if(pPlugin == nullptr) return;
+ const ModCommand::NOTE note = chn.rowCommand.note;
+ // Check for volume commands
+ uint8 vol = 0xFF;
+ if(chn.rowCommand.volcmd == VOLCMD_VOLUME)
+ {
+ vol = Util::Min(chn.rowCommand.vol, uint8(64));
+ } else if(chn.rowCommand.command == CMD_VOLUME)
+ {
+ vol = Util::Min(chn.rowCommand.param, uint8(64));
+ }
+ const bool hasVolCommand = (vol != 0xFF);
+
if(GetModFlag(MSF_MIDICC_BUGEMULATION))
{
if(note != NOTE_NONE)
@@ -2189,18 +2186,15 @@
ModCommand::NOTE realNote = note;
if(ModCommand::IsNote(note))
realNote = pIns->NoteMap[note - 1];
- pPlugin->MidiCommand(GetBestMidiChannel(nChn), pIns->nMidiProgram, pIns->wMidiBank, realNote, static_cast<uint16>(pChn->nVolume), nChn);
- } else if (volcmd == VOLCMD_VOLUME)
+ pPlugin->MidiCommand(GetBestMidiChannel(nChn), pIns->nMidiProgram, pIns->wMidiBank, realNote, static_cast<uint16>(chn.nVolume), nChn);
+ } else if(hasVolCommand)
{
pPlugin->MidiCC(GetBestMidiChannel(nChn), MIDIEvents::MIDICC_Volume_Fine, vol, nChn);
}
return;
}
-
- const bool hasVolCommand = (volcmd == VOLCMD_VOLUME);
- const UINT defaultVolume = pIns->nGlobalVol;
-
+ const uint32 defaultVolume = pIns->nGlobalVol;
//If new note, determine notevelocity to use.
if(note != NOTE_NONE)
@@ -2209,7 +2203,7 @@
switch(pIns->nPluginVelocityHandling)
{
case PLUGIN_VELOCITYHANDLING_CHANNEL:
- velocity = static_cast<uint16>(pChn->nVolume);
+ velocity = static_cast<uint16>(chn.nVolume);
break;
}
@@ -2229,7 +2223,7 @@
switch(pIns->nPluginVolumeHandling)
{
case PLUGIN_VOLUMEHANDLING_DRYWET:
- if(hasVolCommand) pPlugin->SetDryRatio(2*vol);
+ if(hasVolCommand) pPlugin->SetDryRatio(2 * vol);
else pPlugin->SetDryRatio(2 * defaultVolume);
break;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-04-12 14:03:20
|
Revision: 1856
http://sourceforge.net/p/modplug/code/1856
Author: manxorist
Date: 2013-04-12 14:03:13 +0000 (Fri, 12 Apr 2013)
Log Message:
-----------
[Ref] Make the non-parametrized downsample tables in CResampler static in MODPLUG_TRACKER builds.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Resampler.h
trunk/OpenMPT/soundlib/Tables.cpp
Modified: trunk/OpenMPT/soundlib/Resampler.h
===================================================================
--- trunk/OpenMPT/soundlib/Resampler.h 2013-04-12 13:49:50 UTC (rev 1855)
+++ trunk/OpenMPT/soundlib/Resampler.h 2013-04-12 14:03:13 UTC (rev 1856)
@@ -48,8 +48,15 @@
CResamplerSettings m_Settings;
CWindowedFIR m_WindowedFIR;
short int gKaiserSinc[SINC_PHASES*8]; // Upsampling
+#ifdef MODPLUG_TRACKER
+ static bool StaticTablesInitialized;
+ static short int gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
+ static short int gDownsample2x[SINC_PHASES*8]; // Downsample 2x
+#else
+ // no global data which has to be initialized by hand in the library
short int gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
short int gDownsample2x[SINC_PHASES*8]; // Downsample 2x
+#endif
private:
CResamplerSettings m_OldSettings;
public:
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2013-04-12 13:49:50 UTC (rev 1855)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2013-04-12 14:03:13 UTC (rev 1856)
@@ -692,17 +692,34 @@
}
+#ifdef MODPLUG_TRACKER
+bool CResampler::StaticTablesInitialized = false;
+short int CResampler::gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
+short int CResampler::gDownsample2x[SINC_PHASES*8]; // Downsample 2x
+#endif
+
+
void CResampler::InitializeTables(bool force)
{
+ #ifdef MODPLUG_TRACKER
+ if(!StaticTablesInitialized)
+ {
+ //ericus' downsampling improvement.
+ //getsinc(gDownsample13x, 8.5, 3.0/4.0);
+ //getdownsample2x(gDownsample2x);
+ getsinc(gDownsample13x, 8.5, 0.5);
+ getsinc(gDownsample2x, 2.7625, 0.425);
+ //end ericus' downsampling improvement.
+ StaticTablesInitialized = true;
+ }
+ #endif
if((m_OldSettings == m_Settings) && !force) return;
m_WindowedFIR.InitTable(m_Settings.gdWFIRCutoff, m_Settings.gbWFIRType);
getsinc(gKaiserSinc, 9.6377, m_Settings.gdWFIRCutoff);
- //ericus' downsampling improvement.
- //getsinc(gDownsample13x, 8.5, 3.0/4.0);
- //getdownsample2x(gDownsample2x);
- getsinc(gDownsample13x, 8.5, 0.5);
- getsinc(gDownsample2x, 2.7625, 0.425);
- //end ericus' downsampling improvement.
+ #ifndef MODPLUG_TRACKER
+ getsinc(gDownsample13x, 8.5, 0.5);
+ getsinc(gDownsample2x, 2.7625, 0.425);
+ #endif
m_OldSettings = m_Settings;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-04-12 14:22:04
|
Revision: 1857
http://sourceforge.net/p/modplug/code/1857
Author: manxorist
Date: 2013-04-12 14:21:57 +0000 (Fri, 12 Apr 2013)
Log Message:
-----------
[Ref] Make the fast sinc table const.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Mmx_mix.cpp
trunk/OpenMPT/soundlib/Resampler.h
trunk/OpenMPT/soundlib/Tables.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-12 14:03:13 UTC (rev 1856)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-12 14:21:57 UTC (rev 1857)
@@ -20,7 +20,7 @@
// 4x256 taps polyphase FIR resampling filter
-extern short int gFastSinc[];
+#define gFastSinc CResampler::FastSincTable
/////////////////////////////////////////////////////
Modified: trunk/OpenMPT/soundlib/Mmx_mix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-04-12 14:03:13 UTC (rev 1856)
+++ trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-04-12 14:21:57 UTC (rev 1857)
@@ -24,8 +24,6 @@
#include "sndfile.h"
#include "../common/Reporting.h"
-extern short int gFastSinc[];
-
#define PROCSUPPORT_CPUID 0x01
#define PROCSUPPORT_MMX 0x02
#define PROCSUPPORT_MMXEX 0x04
Modified: trunk/OpenMPT/soundlib/Resampler.h
===================================================================
--- trunk/OpenMPT/soundlib/Resampler.h 2013-04-12 14:03:13 UTC (rev 1856)
+++ trunk/OpenMPT/soundlib/Resampler.h 2013-04-12 14:21:57 UTC (rev 1857)
@@ -47,6 +47,7 @@
public:
CResamplerSettings m_Settings;
CWindowedFIR m_WindowedFIR;
+ static const short int FastSincTable[256*4];
short int gKaiserSinc[SINC_PHASES*8]; // Upsampling
#ifdef MODPLUG_TRACKER
static bool StaticTablesInitialized;
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2013-04-12 14:03:13 UTC (rev 1856)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2013-04-12 14:21:57 UTC (rev 1857)
@@ -552,7 +552,7 @@
// Reversed sinc coefficients
-short int gFastSinc[256*4] =
+const short int CResampler::FastSincTable[256*4] =
{ // Cubic Spline
0, 16384, 0, 0, -31, 16383, 32, 0, -63, 16381, 65, 0, -93, 16378, 100, -1,
-124, 16374, 135, -1, -153, 16368, 172, -3, -183, 16361, 209, -4, -211, 16353, 247, -5,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-04-12 15:13:21
|
Revision: 1859
http://sourceforge.net/p/modplug/code/1859
Author: manxorist
Date: 2013-04-12 15:13:14 +0000 (Fri, 12 Apr 2013)
Log Message:
-----------
[Ref] Only use X86_Dither if compiled with ENABLE_X86.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Fastmix.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
trunk/OpenMPT/soundlib/Waveform.cpp
Modified: trunk/OpenMPT/soundlib/Fastmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-12 14:57:05 UTC (rev 1858)
+++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-12 15:13:14 UTC (rev 1859)
@@ -2069,6 +2069,8 @@
#pragma warning(disable:4731) // ebp modified
+
+#ifdef ENABLE_X86
void MPPASMCALL X86_Dither(int *pBuffer, UINT nSamples, UINT nBits)
//-----------------------------------------------------------------
{
@@ -2116,6 +2118,7 @@
mov gDitherB, ebx
}
}
+#endif
void MPPASMCALL X86_InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nSamples)
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-12 14:57:05 UTC (rev 1858)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-12 15:13:14 UTC (rev 1859)
@@ -40,8 +40,9 @@
extern DWORD MPPASMCALL X86_Convert32To24(LPVOID lpBuffer, int *, DWORD nSamples);
extern DWORD MPPASMCALL X86_Convert32To32(LPVOID lpBuffer, int *, DWORD nSamples);
extern DWORD MPPASMCALL Convert32ToFloat32(LPVOID lpBuffer, int *pBuffer, DWORD lSampleCount);
-extern UINT MPPASMCALL X86_AGC(int *pBuffer, UINT nSamples, UINT nAGC);
+#ifdef ENABLE_X86
extern VOID MPPASMCALL X86_Dither(int *pBuffer, UINT nSamples, UINT nBits);
+#endif
extern VOID MPPASMCALL X86_InterleaveFrontRear(int *pFrontBuf, int *pRearBuf, DWORD nSamples);
extern VOID MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs);
extern VOID MPPASMCALL X86_MonoFromStereo(int *pMixBuf, UINT nSamples);
@@ -330,12 +331,14 @@
lTotalSampleCount *= 2;
}
+#ifdef ENABLE_X86
// Noise Shaping
if (m_MixerSettings.GetBitsPerSample() <= 16)
{
if(m_Resampler.IsHQ())
X86_Dither(MixSoundBuffer, lTotalSampleCount, m_MixerSettings.GetBitsPerSample());
}
+#endif
#ifdef MODPLUG_TRACKER
// Hook Function
Modified: trunk/OpenMPT/soundlib/Waveform.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Waveform.cpp 2013-04-12 14:57:05 UTC (rev 1858)
+++ trunk/OpenMPT/soundlib/Waveform.cpp 2013-04-12 15:13:14 UTC (rev 1859)
@@ -12,7 +12,7 @@
#include "stdafx.h"
#include "sndfile.h"
-#ifdef ENABLE_ASM
+#ifdef ENABLE_X86
#pragma warning(disable:4100)
#pragma warning(disable:4731)
@@ -53,7 +53,9 @@
#endif
+#ifdef ENABLE_X86
extern void MPPASMCALL X86_Dither(int *pBuffer, UINT nSamples, UINT nBits);
+#endif
extern DWORD MPPASMCALL X86_Convert32To8(LPVOID lpBuffer, int *, DWORD nSamples);
extern DWORD MPPASMCALL X86_Convert32To16(LPVOID lpBuffer, int *, DWORD nSamples);
extern DWORD MPPASMCALL X86_Convert32To24(LPVOID lpBuffer, int *, DWORD nSamples);
@@ -61,7 +63,7 @@
UINT CSoundFile::Normalize24BitBuffer(LPBYTE pbuffer, UINT dwSize, DWORD lmax24, DWORD dwByteInc)
//-----------------------------------------------------------------------------------------------
{
-#ifdef ENABLE_ASM
+#ifdef ENABLE_X86
int * const tempbuf = MixSoundBuffer;
int n = dwSize / 3;
while (n > 0)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-04-12 15:47:37
|
Revision: 1861
http://sourceforge.net/p/modplug/code/1861
Author: manxorist
Date: 2013-04-12 15:47:28 +0000 (Fri, 12 Apr 2013)
Log Message:
-----------
[Ref] Calculate MIXING_CLIPMAX and MIXING_CLIPMIN based on MIXING_ATTENUATION and move definitions right next to each other.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Snd_defs.h
trunk/OpenMPT/soundlib/Sndfile.h
trunk/OpenMPT/soundlib/SoundFilePlayConfig.h
Modified: trunk/OpenMPT/soundlib/Snd_defs.h
===================================================================
--- trunk/OpenMPT/soundlib/Snd_defs.h 2013-04-12 15:30:19 UTC (rev 1860)
+++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-04-12 15:47:28 UTC (rev 1861)
@@ -303,6 +303,15 @@
#define SNDMIX_MUTECHNMODE 0x100000 // Notes are not played on muted channels
+enum { MIXING_ATTENUATION = 4, };
+
+enum
+{
+ MIXING_CLIPMAX = ((1<<(32-MIXING_ATTENUATION-1))-1),
+ MIXING_CLIPMIN = -(MIXING_CLIPMAX),
+};
+
+
#define MAX_GLOBAL_VOLUME 256u
// Resampling modes
Modified: trunk/OpenMPT/soundlib/Sndfile.h
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-12 15:30:19 UTC (rev 1860)
+++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-12 15:47:28 UTC (rev 1861)
@@ -760,7 +760,6 @@
// Low-level Mixing functions
#define SCRATCH_BUFFER_SIZE 64 //Used for plug's final processing (cleanup)
-#define MIXING_ATTENUATION 4
#define VOLUMERAMPPRECISION 12
#define FADESONGDELAY 100
Modified: trunk/OpenMPT/soundlib/SoundFilePlayConfig.h
===================================================================
--- trunk/OpenMPT/soundlib/SoundFilePlayConfig.h 2013-04-12 15:30:19 UTC (rev 1860)
+++ trunk/OpenMPT/soundlib/SoundFilePlayConfig.h 2013-04-12 15:47:28 UTC (rev 1861)
@@ -14,8 +14,6 @@
enum
{
NO_ATTENUATION = 1,
- MIXING_CLIPMIN = -0x07FFFFFF,
- MIXING_CLIPMAX = 0x07FFFFFF,
};
enum tempoMode
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-04-12 17:05:25
|
Revision: 1865
http://sourceforge.net/p/modplug/code/1865
Author: manxorist
Date: 2013-04-12 17:05:17 +0000 (Fri, 12 Apr 2013)
Log Message:
-----------
[Ref] Remove pointless __cdecl in CDLSBank.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Dlsbank.cpp
trunk/OpenMPT/soundlib/Dlsbank.h
Modified: trunk/OpenMPT/soundlib/Dlsbank.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-04-12 16:58:11 UTC (rev 1864)
+++ trunk/OpenMPT/soundlib/Dlsbank.cpp 2013-04-12 17:05:17 UTC (rev 1865)
@@ -363,8 +363,8 @@
/////////////////////////////////////////////////////////////////////
// Unit conversion
-LONG __cdecl CDLSBank::DLS32BitTimeCentsToMilliseconds(LONG lTimeCents)
-//---------------------------------------------------------------------
+LONG CDLSBank::DLS32BitTimeCentsToMilliseconds(LONG lTimeCents)
+//-------------------------------------------------------------
{
// tc = log2(time[secs]) * 1200*65536
// time[secs] = 2^(tc/(1200*65536))
@@ -377,16 +377,16 @@
// 0dB = 0x10000
-LONG __cdecl CDLSBank::DLS32BitRelativeGainToLinear(LONG lCentibels)
-//------------------------------------------------------------------
+LONG CDLSBank::DLS32BitRelativeGainToLinear(LONG lCentibels)
+//----------------------------------------------------------
{
// v = 10^(cb/(200*65536)) * V
return (LONG)(65536.0 * pow(10.0, ((double)lCentibels)/(200*65536.0)) );
}
-LONG __cdecl CDLSBank::DLS32BitRelativeLinearToGain(LONG lGain)
-//-------------------------------------------------------------
+LONG CDLSBank::DLS32BitRelativeLinearToGain(LONG lGain)
+//-----------------------------------------------------
{
// cb = log10(v/V) * 200 * 65536
if (lGain <= 0) return -960 * 65536;
@@ -394,8 +394,8 @@
}
-LONG __cdecl CDLSBank::DLSMidiVolumeToLinear(UINT nMidiVolume)
-//------------------------------------------------------------
+LONG CDLSBank::DLSMidiVolumeToLinear(UINT nMidiVolume)
+//----------------------------------------------------
{
return (nMidiVolume * nMidiVolume << 16) / (127*127);
}
Modified: trunk/OpenMPT/soundlib/Dlsbank.h
===================================================================
--- trunk/OpenMPT/soundlib/Dlsbank.h 2013-04-12 16:58:11 UTC (rev 1864)
+++ trunk/OpenMPT/soundlib/Dlsbank.h 2013-04-12 17:05:17 UTC (rev 1865)
@@ -144,8 +144,8 @@
public:
// DLS Unit conversion
- static LONG __cdecl DLS32BitTimeCentsToMilliseconds(LONG lTimeCents);
- static LONG __cdecl DLS32BitRelativeGainToLinear(LONG lCentibels); // 0dB = 0x10000
- static LONG __cdecl DLS32BitRelativeLinearToGain(LONG lGain); // 0dB = 0x10000
- static LONG __cdecl DLSMidiVolumeToLinear(UINT nMidiVolume); // [0-127] -> [0-0x10000]
+ static LONG DLS32BitTimeCentsToMilliseconds(LONG lTimeCents);
+ static LONG DLS32BitRelativeGainToLinear(LONG lCentibels); // 0dB = 0x10000
+ static LONG DLS32BitRelativeLinearToGain(LONG lGain); // 0dB = 0x10000
+ static LONG DLSMidiVolumeToLinear(UINT nMidiVolume); // [0-127] -> [0-0x10000]
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <man...@us...> - 2013-04-16 23:28:12
|
Revision: 1897
http://sourceforge.net/p/modplug/code/1897
Author: manxorist
Date: 2013-04-16 23:28:01 +0000 (Tue, 16 Apr 2013)
Log Message:
-----------
[Ref] Remove CTuning::MessageHandler and call Reporting::Error directly at the only call site.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/tuning.cpp
trunk/OpenMPT/soundlib/tuningbase.cpp
trunk/OpenMPT/soundlib/tuningbase.h
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-16 22:11:50 UTC (rev 1896)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-16 23:28:01 UTC (rev 1897)
@@ -1490,13 +1490,6 @@
#endif
-void SimpleMessageBox(const char* message, const char* title)
-//-----------------------------------------------------------
-{
- Reporting::Information(message, title);
-}
-
-
#ifdef MODPLUG_TRACKER
bool CSoundFile::LoadStaticTunings()
//----------------------------------
@@ -1505,8 +1498,6 @@
//For now not allowing to reload tunings(one should be careful when reloading them
//since various parts may use addresses of the tuningobjects).
- CTuning::MessageHandler = &SimpleMessageBox;
-
s_pTuningsSharedBuiltIn = new CTuningCollection;
s_pTuningsSharedLocal = new CTuningCollection("Local tunings");
Modified: trunk/OpenMPT/soundlib/tuning.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuning.cpp 2013-04-16 22:11:50 UTC (rev 1896)
+++ trunk/OpenMPT/soundlib/tuning.cpp 2013-04-16 23:28:01 UTC (rev 1897)
@@ -12,6 +12,7 @@
#include "tuning.h"
#include "../common/serialization_utils.h"
+#include "../common/Reporting.h"
#include <string>
typedef CTuningRTI::RATIOTYPE RATIOTYPE;
@@ -398,7 +399,7 @@
pTuning->m_EditMask = EM_ALLOWALL; //Allowing all while processing data.
if (pTuning->ProProcessUnserializationdata())
{
- MessageHandler(("Processing loaded data for tuning \"" + pTuning->GetName() + "\" failed.").c_str(), "Tuning load failure");
+ Reporting::Error(("Processing loaded data for tuning \"" + pTuning->GetName() + "\" failed.").c_str(), "Tuning load failure");
delete pTuning; pTuning = nullptr;
}
else
Modified: trunk/OpenMPT/soundlib/tuningbase.cpp
===================================================================
--- trunk/OpenMPT/soundlib/tuningbase.cpp 2013-04-16 22:11:50 UTC (rev 1896)
+++ trunk/OpenMPT/soundlib/tuningbase.cpp 2013-04-16 23:28:01 UTC (rev 1897)
@@ -45,9 +45,6 @@
TEMPLATEDEC
-TYPENAME CTUNINGBASE::MESSAGEHANDLER CTUNINGBASE::MessageHandler = &(CTUNINGBASE::DefaultMessageHandler);
-
-TEMPLATEDEC
const TYPENAME CTUNINGBASE::SERIALIZATION_RETURN_TYPE CTUNINGBASE::SERIALIZATION_SUCCESS = false;
TEMPLATEDEC
Modified: trunk/OpenMPT/soundlib/tuningbase.h
===================================================================
--- trunk/OpenMPT/soundlib/tuningbase.h 2013-04-16 22:11:50 UTC (rev 1896)
+++ trunk/OpenMPT/soundlib/tuningbase.h 2013-04-16 23:28:01 UTC (rev 1897)
@@ -311,8 +311,6 @@
static const char* s_TuningTypeStrGroupGeometric;
static const char* s_TuningTypeStrGeometric;
- static MESSAGEHANDLER MessageHandler;
-
private:
static void DefaultMessageHandler(const char*, const char*) {}
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sag...@us...> - 2013-04-17 23:47:40
|
Revision: 1903
http://sourceforge.net/p/modplug/code/1903
Author: saga-games
Date: 2013-04-17 23:47:30 +0000 (Wed, 17 Apr 2013)
Log Message:
-----------
[Mod] Invalid instrument numbers in IT / MPTM files that use the old non-compatible play behaviour are now fixed automatically.
[Mod] Updated LUT types to not use WinAPI types.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Resampler.h
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndfile.cpp
trunk/OpenMPT/soundlib/Tables.cpp
trunk/OpenMPT/soundlib/Tables.h
Modified: trunk/OpenMPT/soundlib/Resampler.h
===================================================================
--- trunk/OpenMPT/soundlib/Resampler.h 2013-04-17 23:31:23 UTC (rev 1902)
+++ trunk/OpenMPT/soundlib/Resampler.h 2013-04-17 23:47:30 UTC (rev 1903)
@@ -47,16 +47,16 @@
public:
CResamplerSettings m_Settings;
CWindowedFIR m_WindowedFIR;
- static const short int FastSincTable[256*4];
- short int gKaiserSinc[SINC_PHASES*8]; // Upsampling
+ static const int16 FastSincTable[256*4];
+ int16 gKaiserSinc[SINC_PHASES*8]; // Upsampling
#ifdef MODPLUG_TRACKER
static bool StaticTablesInitialized;
- static short int gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
- static short int gDownsample2x[SINC_PHASES*8]; // Downsample 2x
+ static int16 gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
+ static int16 gDownsample2x[SINC_PHASES*8]; // Downsample 2x
#else
// no global data which has to be initialized by hand in the library
- short int gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
- short int gDownsample2x[SINC_PHASES*8]; // Downsample 2x
+ int16 gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
+ int16 gDownsample2x[SINC_PHASES*8]; // Downsample 2x
#endif
private:
CResamplerSettings m_OldSettings;
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-17 23:31:23 UTC (rev 1902)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-04-17 23:47:30 UTC (rev 1903)
@@ -1728,7 +1728,7 @@
if(triggerNote)
{
UINT note = pChn->rowCommand.note;
- if (instr) pChn->nNewIns = instr;
+ if(instr) pChn->nNewIns = instr;
if(ModCommand::IsNote(note) && IsCompatibleMode(TRK_FASTTRACKER2))
{
@@ -1763,7 +1763,7 @@
{
note = NOTE_NONE;
}
- } else if(IsCompatibleMode(TRK_IMPULSETRACKER) && GetNumInstruments() != 0 && ModCommand::IsNoteOrEmpty(note))
+ } else if((GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) && GetNumInstruments() != 0 && ModCommand::IsNoteOrEmpty(note))
{
// IT compatibility: Invalid instrument numbers do nothing, but they are remembered for upcoming notes and do not trigger a note in that case.
// Test case: InstrumentNumberChange.it
Modified: trunk/OpenMPT/soundlib/Sndfile.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-17 23:31:23 UTC (rev 1902)
+++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-04-17 23:47:30 UTC (rev 1903)
@@ -1892,24 +1892,20 @@
struct UpgradePatternData
//=======================
{
- UpgradePatternData(CSoundFile *pSndFile)
- {
- this->pSndFile = pSndFile;
- chn = 0;
- }
+ UpgradePatternData(CSoundFile &sf) : sndFile(sf), chn(0) { }
void operator()(ModCommand& m)
{
- if(pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 03, 02) ||
- (!pSndFile->IsCompatibleMode(TRK_ALLTRACKERS) && pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)))
+ if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 17, 03, 02) ||
+ (!sndFile.IsCompatibleMode(TRK_ALLTRACKERS) && sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)))
{
if(m.command == CMD_GLOBALVOLUME)
{
// Out-of-range global volume commands should be ignored.
// OpenMPT 1.17.03.02 fixed this in compatible mode, OpenMPT 1.20 fixes it in normal mode as well.
// So for tracks made with older versions than OpenMPT 1.17.03.02 or tracks made with 1.17.03.02 <= version < 1.20, we limit invalid global volume commands.
- LimitMax(m.param, (pSndFile->GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) ? BYTE(128): BYTE(64));
- } else if(m.command == CMD_S3MCMDEX && (pSndFile->GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)))
+ LimitMax(m.param, (sndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) ? BYTE(128): BYTE(64));
+ } else if(m.command == CMD_S3MCMDEX && (sndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)))
{
// SC0 and SD0 should be interpreted as SC1 and SD1 in IT files.
// OpenMPT 1.17.03.02 fixed this in compatible mode, OpenMPT 1.20 fixes it in normal mode as well.
@@ -1924,19 +1920,19 @@
}
}
- if((pSndFile->GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)))
+ if((sndFile.GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)))
{
// In the IT format, slide commands with both nibbles set should be ignored.
// For note volume slides, OpenMPT 1.18 fixes this in compatible mode, OpenMPT 1.20 fixes this in normal mode as well.
const bool noteVolSlide =
- (pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 18, 00, 00) ||
- (!pSndFile->IsCompatibleMode(TRK_IMPULSETRACKER) && pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)))
+ (sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 18, 00, 00) ||
+ (!sndFile.IsCompatibleMode(TRK_IMPULSETRACKER) && sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)))
&&
(m.command == CMD_VOLUMESLIDE || m.command == CMD_VIBRATOVOL || m.command == CMD_TONEPORTAVOL || m.command == CMD_PANNINGSLIDE);
// OpenMPT 1.20 also fixes this for global volume and channel volume slides.
const bool chanVolSlide =
- (pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00))
+ (sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00))
&&
(m.command == CMD_GLOBALVOLSLIDE || m.command == CMD_CHANNELVOLSLIDE);
@@ -1947,9 +1943,19 @@
m.param &= 0x0F;
}
}
+
+ if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 22, 01, 04) && sndFile.m_dwLastSavedWithVersion != MAKE_VERSION_NUMERIC(1, 22, 00, 00))
+ {
+ // OpenMPT 1.22.01.04 fixes illegal (out of range) instrument numbers; they should do nothing. In previous versions, they stopped the playing sample.
+ if(sndFile.GetNumInstruments() && m.instr > sndFile.GetNumInstruments())
+ {
+ m.volcmd = VOLCMD_VOLUME;
+ m.vol = 0;
+ }
+ }
}
- if(pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00))
+ if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00))
{
// Pattern Delay fixes
@@ -1957,7 +1963,7 @@
// We also fix X6x commands in hacked XM files, since they are treated identically to the S6x command in IT/S3M files.
// We don't treat them in files made with OpenMPT 1.18+ that have compatible play enabled, though, since they are ignored there anyway.
const bool fixX6x = (m.command == CMD_XFINEPORTAUPDOWN && (m.param & 0xF0) == 0x60
- && (!pSndFile->IsCompatibleMode(TRK_FASTTRACKER2) || pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 18, 00, 00)));
+ && (!sndFile.IsCompatibleMode(TRK_FASTTRACKER2) || sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 18, 00, 00)));
if(fixS6x || fixX6x)
{
@@ -1989,10 +1995,10 @@
}
}
- if(pSndFile->GetType() == MOD_TYPE_XM)
+ if(sndFile.GetType() == MOD_TYPE_XM)
{
- if(pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 19, 00, 00)
- || (!pSndFile->IsCompatibleMode(TRK_FASTTRACKER2) && pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)))
+ if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 19, 00, 00)
+ || (!sndFile.IsCompatibleMode(TRK_FASTTRACKER2) && sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 00, 00)))
{
if(m.command == CMD_OFFSET && m.volcmd == VOLCMD_TONEPORTAMENTO)
{
@@ -2002,10 +2008,10 @@
}
}
- if(pSndFile->m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 01, 10)
- && pSndFile->m_dwLastSavedWithVersion != MAKE_VERSION_NUMERIC(1, 20, 00, 00) // Ignore compatibility export
+ if(sndFile.m_dwLastSavedWithVersion < MAKE_VERSION_NUMERIC(1, 20, 01, 10)
+ && sndFile.m_dwLastSavedWithVersion != MAKE_VERSION_NUMERIC(1, 20, 00, 00) // Ignore compatibility export
&& m.volcmd == VOLCMD_TONEPORTAMENTO && m.command == CMD_TONEPORTAMENTO
- && (m.vol != 0 || pSndFile->IsCompatibleMode(TRK_FASTTRACKER2)) && m.param != 0)
+ && (m.vol != 0 || sndFile.IsCompatibleMode(TRK_FASTTRACKER2)) && m.param != 0)
{
// Mx and 3xx on the same row does weird things in FT2: 3xx is completely ignored and the Mx parameter is doubled. Fixed in revision 1312 / OpenMPT 1.20.01.10
// Previously the values were just added up, so let's fix this!
@@ -2016,14 +2022,14 @@
}
chn++;
- if(chn >= pSndFile->GetNumChannels())
+ if(chn >= sndFile.GetNumChannels())
{
chn = 0;
}
}
- CSoundFile *pSndFile;
+ CSoundFile &sndFile;
CHANNELINDEX chn;
};
@@ -2089,5 +2095,5 @@
}
}
- Patterns.ForEachModCommand(UpgradePatternData(this));
+ Patterns.ForEachModCommand(UpgradePatternData(*this));
}
\ No newline at end of file
Modified: trunk/OpenMPT/soundlib/Tables.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Tables.cpp 2013-04-17 23:31:23 UTC (rev 1902)
+++ trunk/OpenMPT/soundlib/Tables.cpp 2013-04-17 23:47:30 UTC (rev 1903)
@@ -116,14 +116,14 @@
///////////////////////////////////////////////////////////////////////
-const BYTE ImpulseTrackerPortaVolCmd[16] =
+const uint8 ImpulseTrackerPortaVolCmd[16] =
{
0x00, 0x01, 0x04, 0x08, 0x10, 0x20, 0x40, 0x60,
0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
};
// Period table for Protracker octaves 0-5:
-const WORD ProTrackerPeriodTable[6*12] =
+const uint16 ProTrackerPeriodTable[6*12] =
{
1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907,
856,808,762,720,678,640,604,570,538,508,480,453,
@@ -134,7 +134,7 @@
};
-const WORD ProTrackerTunedPeriods[16*12] =
+const uint16 ProTrackerTunedPeriods[16*12] =
{
1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,907,
1700,1604,1514,1430,1348,1274,1202,1134,1070,1010,954,900,
@@ -155,14 +155,14 @@
};
// Table for Invert Loop and Funk Repeat effects (EFx, .MOD only)
-const BYTE ModEFxTable[16] =
+const uint8 ModEFxTable[16] =
{
0, 5, 6, 7, 8, 10, 11, 13,
16, 19, 22, 26, 32, 43, 64, 128
};
// S3M C-4 periods
-const WORD FreqS3MTable[16] =
+const uint16 FreqS3MTable[16] =
{
1712,1616,1524,1440,1356,1280,
1208,1140,1076,1016,960,907,
@@ -170,7 +170,7 @@
};
// S3M FineTune frequencies
-const WORD S3MFineTuneTable[16] =
+const uint16 S3MFineTuneTable[16] =
{
7895,7941,7985,8046,8107,8169,8232,8280,
8363,8413,8463,8529,8581,8651,8723,8757, // 8363*2^((i-8)/(12*8))
@@ -178,7 +178,7 @@
// Sinus table
-const short int ModSinusTable[64] =
+const int8 ModSinusTable[64] =
{
0,12,25,37,49,60,71,81,90,98,106,112,117,122,125,126,
127,126,125,122,117,112,106,98,90,81,71,60,49,37,25,12,
@@ -187,7 +187,7 @@
};
// Triangle wave table (ramp down)
-const short int ModRampDownTable[64] =
+const int8 ModRampDownTable[64] =
{
0,-4,-8,-12,-16,-20,-24,-28,-32,-36,-40,-44,-48,-52,-56,-60,
-64,-68,-72,-76,-80,-84,-88,-92,-96,-100,-104,-108,-112,-116,-120,-124,
@@ -196,7 +196,7 @@
};
// Square wave table
-const short int ModSquareTable[64] =
+const int8 ModSquareTable[64] =
{
127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,
127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,127,
@@ -205,7 +205,7 @@
};
// Random wave table
-short int ModRandomTable[64] =
+const int8 ModRandomTable[64] =
{
98,-127,-43,88,102,41,-65,-94,125,20,-71,-86,-70,-32,-16,-96,
17,72,107,-5,116,-69,-62,-40,10,-61,65,109,-18,-38,-13,-76,
@@ -216,7 +216,7 @@
// Impulse Tracker tables (ITTECH.TXT)
// Sinus table
-const short int ITSinusTable[256] =
+const int8 ITSinusTable[256] =
{
0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 16, 17, 19, 20, 22, 23,
24, 26, 27, 29, 30, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44,
@@ -237,7 +237,7 @@
};
// Triangle wave table (ramp down)
-const short int ITRampDownTable[256] =
+const int8 ITRampDownTable[256] =
{
64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56,
56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50, 49, 49, 48,
@@ -258,7 +258,7 @@
};
// Square wave table
-const short int ITSquareTable[256] =
+const int8 ITSquareTable[256] =
{
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
@@ -279,16 +279,16 @@
};
// volume fade tables for Retrig Note:
-const signed char retrigTable1[16] =
+const int8 retrigTable1[16] =
{ 0, 0, 0, 0, 0, 0, 10, 8, 0, 0, 0, 0, 0, 0, 24, 32 };
-const signed char retrigTable2[16] =
+const int8 retrigTable2[16] =
{ 0, -1, -2, -4, -8, -16, 0, 0, 0, 1, 2, 4, 8, 16, 0, 0 };
-const WORD XMPeriodTable[104] =
+const uint16 XMPeriodTable[104] =
{
907,900,894,887,881,875,868,862,856,850,844,838,832,826,820,814,
808,802,796,791,785,779,774,768,762,757,752,746,741,736,730,725,
@@ -300,7 +300,7 @@
};
-const UINT XMLinearTable[768] =
+const uint32 XMLinearTable[768] =
{
535232,534749,534266,533784,533303,532822,532341,531861,
531381,530902,530423,529944,529466,528988,528511,528034,
@@ -401,7 +401,7 @@
};
-const signed char ft2VibratoTable[256] =
+const int8 ft2VibratoTable[256] =
{
0,-2,-3,-5,-6,-8,-9,-11,-12,-14,-16,-17,-19,-20,-22,-23,
-24,-26,-27,-29,-30,-32,-33,-34,-36,-37,-38,-39,-41,-42,
@@ -423,21 +423,21 @@
-const DWORD FineLinearSlideUpTable[16] =
+const uint32 FineLinearSlideUpTable[16] =
{
65536, 65595, 65654, 65714, 65773, 65832, 65892, 65951,
66011, 66071, 66130, 66190, 66250, 66309, 66369, 66429
};
-const DWORD FineLinearSlideDownTable[16] =
+const uint32 FineLinearSlideDownTable[16] =
{
65535, 65477, 65418, 65359, 65300, 65241, 65182, 65123,
65065, 65006, 64947, 64888, 64830, 64772, 64713, 64645
};
-const DWORD LinearSlideUpTable[256] =
+const uint32 LinearSlideUpTable[256] =
{
65536, 65773, 66010, 66249, 66489, 66729, 66971, 67213,
67456, 67700, 67945, 68190, 68437, 68685, 68933, 69182,
@@ -475,7 +475,7 @@
-const DWORD LinearSlideDownTable[256] =
+const uint32 LinearSlideDownTable[256] =
{
65536, 65299, 65064, 64830, 64596, 64363, 64131, 63900,
63670, 63440, 63212, 62984, 62757, 62531, 62305, 62081,
@@ -552,7 +552,7 @@
// Reversed sinc coefficients
-const short int CResampler::FastSincTable[256*4] =
+const int16 CResampler::FastSincTable[256*4] =
{ // Cubic Spline
0, 16384, 0, 0, -31, 16383, 32, 0, -63, 16381, 65, 0, -93, 16378, 100, -1,
-124, 16374, 135, -1, -153, 16368, 172, -3, -183, 16361, 209, -4, -211, 16353, 247, -5,
@@ -694,8 +694,8 @@
#ifdef MODPLUG_TRACKER
bool CResampler::StaticTablesInitialized = false;
-short int CResampler::gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
-short int CResampler::gDownsample2x[SINC_PHASES*8]; // Downsample 2x
+int16 CResampler::gDownsample13x[SINC_PHASES*8]; // Downsample 1.333x
+int16 CResampler::gDownsample2x[SINC_PHASES*8]; // Downsample 2x
#endif
Modified: trunk/OpenMPT/soundlib/Tables.h
===================================================================
--- trunk/OpenMPT/soundlib/Tables.h 2013-04-17 23:31:23 UTC (rev 1902)
+++ trunk/OpenMPT/soundlib/Tables.h 2013-04-17 23:47:30 UTC (rev 1903)
@@ -12,26 +12,26 @@
#pragma once
-extern const BYTE ImpulseTrackerPortaVolCmd[16];
-extern const WORD ProTrackerPeriodTable[6*12];
-extern const WORD ProTrackerTunedPeriods[16*12];
-extern const BYTE ModEFxTable[16];
-extern const WORD FreqS3MTable[16];
-extern const WORD S3MFineTuneTable[16];
-extern const short int ModSinusTable[64];
-extern const short int ModRampDownTable[64];
-extern const short int ModSquareTable[64];
-extern short int ModRandomTable[64];
-extern const short int ITSinusTable[256];
-extern const short int ITRampDownTable[256];
-extern const short int ITSquareTable[256];
-extern const signed char retrigTable1[16];
-extern const signed char retrigTable2[16];
-extern const WORD XMPeriodTable[104];
-extern const UINT XMLinearTable[768];
-extern const signed char ft2VibratoTable[256];
-extern const DWORD FineLinearSlideUpTable[16];
-extern const DWORD FineLinearSlideDownTable[16];
-extern const DWORD LinearSlideUpTable[256];
-extern const DWORD LinearSlideDownTable[256];
+extern const uint8 ImpulseTrackerPortaVolCmd[16];
+extern const uint16 ProTrackerPeriodTable[6*12];
+extern const uint16 ProTrackerTunedPeriods[16*12];
+extern const uint8 ModEFxTable[16];
+extern const uint16 FreqS3MTable[16];
+extern const uint16 S3MFineTuneTable[16];
+extern const int8 ModSinusTable[64];
+extern const int8 ModRampDownTable[64];
+extern const int8 ModSquareTable[64];
+extern const int8 ModRandomTable[64];
+extern const int8 ITSinusTable[256];
+extern const int8 ITRampDownTable[256];
+extern const int8 ITSquareTable[256];
+extern const int8 retrigTable1[16];
+extern const int8 retrigTable2[16];
+extern const uint16 XMPeriodTable[104];
+extern const uint32 XMLinearTable[768];
+extern const int8 ft2VibratoTable[256];
+extern const uint32 FineLinearSlideUpTable[16];
+extern const uint32 FineLinearSlideDownTable[16];
+extern const uint32 LinearSlideUpTable[256];
+extern const uint32 LinearSlideDownTable[256];
extern const float ITResonanceTable[128];
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|