summaryrefslogtreecommitdiff
path: root/soundlib
diff options
context:
space:
mode:
Diffstat (limited to 'soundlib')
-rw-r--r--soundlib/ITTools.cpp40
-rw-r--r--soundlib/ITTools.h3
-rw-r--r--soundlib/Load_it.cpp25
-rw-r--r--soundlib/Load_itp.cpp48
-rw-r--r--soundlib/Load_mtm.cpp2
-rw-r--r--soundlib/Load_psm.cpp12
-rw-r--r--soundlib/Load_s3m.cpp11
-rw-r--r--soundlib/S3MTools.h5
-rw-r--r--soundlib/Snd_fx.cpp1
-rw-r--r--soundlib/Sndfile.cpp13
-rw-r--r--soundlib/Sndfile.h16
-rw-r--r--soundlib/Tables.cpp11
-rw-r--r--soundlib/modcommand.cpp1
-rw-r--r--soundlib/plugins/LFOPlugin.h2
-rw-r--r--soundlib/tuning.h2
15 files changed, 116 insertions, 76 deletions
diff --git a/soundlib/ITTools.cpp b/soundlib/ITTools.cpp
index 56cce3e..13a3923 100644
--- a/soundlib/ITTools.cpp
+++ b/soundlib/ITTools.cpp
@@ -637,12 +637,15 @@ void ITHistoryStruct::ConvertToMPT(FileHistory &mptHistory) const
{
// Decode FAT date and time
MemsetZero(mptHistory.loadDate);
- mptHistory.loadDate.tm_year = ((fatdate >> 9) & 0x7F) + 80;
- mptHistory.loadDate.tm_mon = Clamp((fatdate >> 5) & 0x0F, 1, 12) - 1;
- mptHistory.loadDate.tm_mday = Clamp(fatdate & 0x1F, 1, 31);
- mptHistory.loadDate.tm_hour = Clamp((fattime >> 11) & 0x1F, 0, 23);
- mptHistory.loadDate.tm_min = Clamp((fattime >> 5) & 0x3F, 0, 59);
- mptHistory.loadDate.tm_sec = Clamp((fattime & 0x1F) * 2, 0, 59);
+ if(fatdate != 0 || fattime != 0)
+ {
+ mptHistory.loadDate.tm_year = ((fatdate >> 9) & 0x7F) + 80;
+ mptHistory.loadDate.tm_mon = Clamp((fatdate >> 5) & 0x0F, 1, 12) - 1;
+ mptHistory.loadDate.tm_mday = Clamp(fatdate & 0x1F, 1, 31);
+ mptHistory.loadDate.tm_hour = Clamp((fattime >> 11) & 0x1F, 0, 23);
+ mptHistory.loadDate.tm_min = Clamp((fattime >> 5) & 0x3F, 0, 59);
+ mptHistory.loadDate.tm_sec = Clamp((fattime & 0x1F) * 2, 0, 59);
+ }
mptHistory.openTime = static_cast<uint32>(runtime * (HISTORY_TIMER_PRECISION / 18.2));
}
@@ -651,10 +654,31 @@ void ITHistoryStruct::ConvertToMPT(FileHistory &mptHistory) const
void ITHistoryStruct::ConvertToIT(const FileHistory &mptHistory)
{
// Create FAT file dates
- fatdate = static_cast<uint16>(mptHistory.loadDate.tm_mday | ((mptHistory.loadDate.tm_mon + 1) << 5) | ((mptHistory.loadDate.tm_year - 80) << 9));
- fattime = static_cast<uint16>((mptHistory.loadDate.tm_sec / 2) | (mptHistory.loadDate.tm_min << 5) | (mptHistory.loadDate.tm_hour << 11));
+ if(mptHistory.HasValidDate())
+ {
+ fatdate = static_cast<uint16>(mptHistory.loadDate.tm_mday | ((mptHistory.loadDate.tm_mon + 1) << 5) | ((mptHistory.loadDate.tm_year - 80) << 9));
+ fattime = static_cast<uint16>((mptHistory.loadDate.tm_sec / 2) | (mptHistory.loadDate.tm_min << 5) | (mptHistory.loadDate.tm_hour << 11));
+ } else
+ {
+ fatdate = 0;
+ fattime = 0;
+ }
runtime = static_cast<uint32>(mptHistory.openTime * (18.2 / HISTORY_TIMER_PRECISION));
}
+uint32 DecodeITEditTimer(uint16 cwtv, uint32 editTime)
+{
+ if((cwtv & 0xFFF) >= 0x0208)
+ {
+ editTime ^= 0x4954524B; // 'ITRK'
+ editTime = (editTime >> 7) | (editTime << (32 - 7));
+ editTime = -(int32)editTime;
+ editTime = (editTime << 4) | (editTime >> (32 - 4));
+ editTime ^= 0x4A54484C; // 'JTHL'
+ }
+ return editTime;
+}
+
+
OPENMPT_NAMESPACE_END
diff --git a/soundlib/ITTools.h b/soundlib/ITTools.h
index d2b3a1a..66759f2 100644
--- a/soundlib/ITTools.h
+++ b/soundlib/ITTools.h
@@ -317,4 +317,7 @@ struct SchismVersionFromDate
}
};
+
+uint32 DecodeITEditTimer(uint16 cwtv, uint32 editTime);
+
OPENMPT_NAMESPACE_END
diff --git a/soundlib/Load_it.cpp b/soundlib/Load_it.cpp
index 069e4a4..e149e1d 100644
--- a/soundlib/Load_it.cpp
+++ b/soundlib/Load_it.cpp
@@ -344,19 +344,19 @@ static void CopyPatternName(CPattern &pattern, FileReader &file)
// Get version of Schism Tracker that was used to create an IT/S3M file.
-mpt::ustring CSoundFile::GetSchismTrackerVersion(uint16 cwtv)
+mpt::ustring CSoundFile::GetSchismTrackerVersion(uint16 cwtv, uint32 reserved)
{
// Schism Tracker version information in a nutshell:
// < 0x020: a proper version (files saved by such versions are likely very rare)
// = 0x020: any version between the 0.2a release (2005-04-29?) and 2007-04-17
// = 0x050: anywhere from 2007-04-17 to 2009-10-31
// > 0x050: the number of days since 2009-10-31
+ // = 0xFFF: any version starting from 2020-10-28 (exact version stored in reserved value)
cwtv &= 0xFFF;
- mpt::ustring version;
if(cwtv > 0x050)
{
- int32 date = SchismVersionFromDate<2009, 10, 31>::date + cwtv - 0x050;
+ int32 date = SchismVersionFromDate<2009, 10, 31>::date + (cwtv < 0xFFF ? cwtv - 0x050 : reserved);
int32 y = static_cast<int32>((Util::mul32to64(10000, date) + 14780) / 3652425);
int32 ddd = date - (365 * y + y / 4 - y / 100 + y / 400);
if(ddd < 0)
@@ -365,15 +365,14 @@ mpt::ustring CSoundFile::GetSchismTrackerVersion(uint16 cwtv)
ddd = date - (365 * y + y / 4 - y / 100 + y / 400);
}
int32 mi = (100 * ddd + 52) / 3060;
- version = mpt::format(U_("Schism Tracker %1-%2-%3"))(
+ return mpt::format(U_("Schism Tracker %1-%2-%3"))(
mpt::ufmt::dec0<4>(y + (mi + 2) / 12),
mpt::ufmt::dec0<2>((mi + 2) % 12 + 1),
mpt::ufmt::dec0<2>(ddd - (mi * 306 + 5) / 10 + 1));
} else
{
- version = mpt::format(U_("Schism Tracker 0.%1"))(mpt::ufmt::hex(cwtv));
+ return mpt::format(U_("Schism Tracker 0.%1"))(mpt::ufmt::hex0<2>(cwtv));
}
- return version;
}
@@ -1197,16 +1196,8 @@ bool CSoundFile::ReadIT(FileReader &file, ModLoadingFlags loadFlags)
}
if(m_FileHistory.empty() && fileHeader.reserved != 0)
{
- // Starting from version 2.07, IT encrypts the total edit time of a module in the "reserved" field
- uint32 editTime = fileHeader.reserved;
- if(fileHeader.cwtv >= 0x0208)
- {
- editTime ^= 0x4954524B; // 'ITRK'
- editTime = (editTime >> 7) | (editTime << (32 - 7));
- editTime = -(int32)editTime;
- editTime = (editTime << 4) | (editTime >> (32 - 4));
- editTime ^= 0x4A54484C; // 'JTHL'
- }
+ // Starting from version 2.07, IT stores the total edit time of a module in the "reserved" field
+ uint32 editTime = DecodeITEditTimer(fileHeader.cwtv, fileHeader.reserved);
FileHistory hist;
hist.openTime = static_cast<uint32>(editTime * (HISTORY_TIMER_PRECISION / 18.2));
@@ -1215,7 +1206,7 @@ bool CSoundFile::ReadIT(FileReader &file, ModLoadingFlags loadFlags)
}
break;
case 1:
- madeWithTracker = GetSchismTrackerVersion(fileHeader.cwtv);
+ madeWithTracker = GetSchismTrackerVersion(fileHeader.cwtv, fileHeader.reserved);
// Hertz in linear mode: Added 2015-01-29, https://github.com/schismtracker/schismtracker/commit/671b30311082a0e7df041fca25f989b5d2478f69
if(fileHeader.cwtv < SchismVersionFromDate<2015, 01, 29>::Version())
m_playBehaviour.reset(kHertzInLinearMode);
diff --git a/soundlib/Load_itp.cpp b/soundlib/Load_itp.cpp
index 053a26a..7c4f982 100644
--- a/soundlib/Load_itp.cpp
+++ b/soundlib/Load_itp.cpp
@@ -116,13 +116,13 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags)
enum ITPSongFlags
{
- ITP_EMBEDMIDICFG = 0x00001, // Embed macros in file
- ITP_ITOLDEFFECTS = 0x00004, // Old Impulse Tracker effect implementations
- ITP_ITCOMPATGXX = 0x00008, // IT "Compatible Gxx" (IT's flag to behave more like other trackers w/r/t portamento effects)
- ITP_LINEARSLIDES = 0x00010, // Linear slides vs. Amiga slides
- ITP_EXFILTERRANGE = 0x08000, // Cutoff Filter has double frequency range (up to ~10Khz)
- ITP_ITPROJECT = 0x20000, // Is a project file
- ITP_ITPEMBEDIH = 0x40000, // Embed instrument headers in project file
+ ITP_EMBEDMIDICFG = 0x00001, // Embed macros in file
+ ITP_ITOLDEFFECTS = 0x00004, // Old Impulse Tracker effect implementations
+ ITP_ITCOMPATGXX = 0x00008, // IT "Compatible Gxx" (IT's flag to behave more like other trackers w/r/t portamento effects)
+ ITP_LINEARSLIDES = 0x00010, // Linear slides vs. Amiga slides
+ ITP_EXFILTERRANGE = 0x08000, // Cutoff Filter has double frequency range (up to ~10Khz)
+ ITP_ITPROJECT = 0x20000, // Is a project file
+ ITP_ITPEMBEDIH = 0x40000, // Embed instrument headers in project file
};
file.Rewind();
@@ -145,8 +145,7 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags)
return true;
}
- uint32 version, size;
- version = hdr.version;
+ const uint32 version = hdr.version;
InitializeGlobals(MOD_TYPE_IT);
m_playBehaviour.reset();
@@ -161,10 +160,14 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags)
{
return false;
}
- if(songFlags & ITP_ITOLDEFFECTS) m_SongFlags.set(SONG_ITOLDEFFECTS);
- if(songFlags & ITP_ITCOMPATGXX) m_SongFlags.set(SONG_ITCOMPATGXX);
- if(songFlags & ITP_LINEARSLIDES) m_SongFlags.set(SONG_LINEARSLIDES);
- if(songFlags & ITP_EXFILTERRANGE) m_SongFlags.set(SONG_EXFILTERRANGE);
+ if(songFlags & ITP_ITOLDEFFECTS)
+ m_SongFlags.set(SONG_ITOLDEFFECTS);
+ if(songFlags & ITP_ITCOMPATGXX)
+ m_SongFlags.set(SONG_ITCOMPATGXX);
+ if(songFlags & ITP_LINEARSLIDES)
+ m_SongFlags.set(SONG_LINEARSLIDES);
+ if(songFlags & ITP_EXFILTERRANGE)
+ m_SongFlags.set(SONG_EXFILTERRANGE);
m_nDefaultGlobalVolume = file.ReadUint32LE();
m_nSamplePreAmp = file.ReadUint32LE();
@@ -177,7 +180,7 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags)
}
// channel name string length (=MAX_CHANNELNAME)
- size = file.ReadUint32LE();
+ uint32 size = file.ReadUint32LE();
// Channels' data
for(CHANNELINDEX chn = 0; chn < m_nChannels; chn++)
@@ -210,7 +213,7 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags)
}
// Instruments' paths
- if(version <= 0x00000102)
+ if(version <= 0x102)
{
size = file.ReadUint32LE(); // path string length
}
@@ -218,14 +221,14 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags)
std::vector<mpt::PathString> instrPaths(GetNumInstruments());
for(INSTRUMENTINDEX ins = 0; ins < GetNumInstruments(); ins++)
{
- if(version > 0x00000102)
+ if(version > 0x102)
{
size = file.ReadUint32LE(); // path string length
}
std::string path;
file.ReadString<mpt::String::maybeNullTerminated>(path, size);
#ifdef MODPLUG_TRACKER
- if(version <= 0x00000102)
+ if(version <= 0x102)
{
instrPaths[ins] = mpt::PathString::FromLocaleSilent(path);
} else
@@ -256,7 +259,7 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags)
// modcommand data length
size = file.ReadUint32LE();
- if(size != 6)
+ if(size != sizeof(ITPModCommand))
{
return false;
}
@@ -318,7 +321,10 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags)
file.ReadStruct(sampleHeader);
FileReader sampleData = file.ReadChunk(file.ReadUint32LE());
- if(realSample >= 1 && realSample <= GetNumSamples() && !memcmp(sampleHeader.id, "IMPS", 4) && (loadFlags & loadSampleData))
+ if((loadFlags & loadSampleData)
+ && realSample >= 1 && realSample <= GetNumSamples()
+ && Samples[realSample].pData.pSample == nullptr
+ && !memcmp(sampleHeader.id, "IMPS", 4))
{
sampleHeader.ConvertToMPT(Samples[realSample]);
mpt::String::Read<mpt::String::nullTerminated>(m_szNames[realSample], sampleHeader.name);
@@ -342,7 +348,7 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags)
AddToLog(LogWarning, U_("Unable to open instrument: ") + instrPaths[ins].ToUnicode());
}
#else
- AddToLog(LogWarning, mpt::format(U_("Loading external instrument %1 ('%2') failed: External instruments are not supported."))(ins, instrPaths[ins].ToUnicode()));
+ AddToLog(LogWarning, mpt::format(U_("Loading external instrument %1 ('%2') failed: External instruments are not supported."))(ins + 1, instrPaths[ins].ToUnicode()));
#endif // MPT_EXTERNAL_SAMPLES
}
@@ -350,7 +356,7 @@ bool CSoundFile::ReadITP(FileReader &file, ModLoadingFlags loadFlags)
uint32 code = file.ReadUint32LE();
// Embed instruments' header [v1.01]
- if(version >= 0x00000101 && (songFlags & ITP_ITPEMBEDIH) && code == MagicBE("EBIH"))
+ if(version >= 0x101 && (songFlags & ITP_ITPEMBEDIH) && code == MagicBE("EBIH"))
{
code = file.ReadUint32LE();
diff --git a/soundlib/Load_mtm.cpp b/soundlib/Load_mtm.cpp
index 3819602..0c2231a 100644
--- a/soundlib/Load_mtm.cpp
+++ b/soundlib/Load_mtm.cpp
@@ -54,7 +54,7 @@ struct MTMSampleHeader
{
mptSmp.nLength = length;
mptSmp.nLoopStart = loopStart;
- mptSmp.nLoopEnd = loopEnd;
+ mptSmp.nLoopEnd = std::max(loopEnd.get(), uint32(1)) - 1;
LimitMax(mptSmp.nLoopEnd, mptSmp.nLength);
if(mptSmp.nLoopStart + 4 >= mptSmp.nLoopEnd) mptSmp.nLoopStart = mptSmp.nLoopEnd = 0;
if(mptSmp.nLoopEnd) mptSmp.uFlags.set(CHN_LOOP);
diff --git a/soundlib/Load_psm.cpp b/soundlib/Load_psm.cpp
index 3f96802..d03f092 100644
--- a/soundlib/Load_psm.cpp
+++ b/soundlib/Load_psm.cpp
@@ -107,10 +107,12 @@ struct PSMSampleHeader
mptSmp.nC5Speed = c5Freq;
mptSmp.nLength = sampleLength;
mptSmp.nLoopStart = loopStart;
- // It is not entirely clear if/when we should add +1 to the loopEnd value.
- // Sample 8 in the medieval table music of Extreme Pinball and CONVERT.EXE v1.36 suggest that we should do so.
- // But for other tunes it's not correct, e.g. the OMF 2097 music!
- mptSmp.nLoopEnd = loopEnd;
+ // Note that we shouldn't add + 1 for MTM conversions here (e.g. the OMF 2097 music),
+ // but I think there is no way to figure out the original format, and in the case of the OMF 2097 soundtrack
+ // it doesn't make a huge audible difference anyway (no chip samples are used).
+ // On the other hand, sample 8 of MUSIC_A.PSM from Extreme Pinball will sound detuned if we don't adjust the loop end here.
+ if(loopEnd)
+ mptSmp.nLoopEnd = loopEnd + 1;
mptSmp.nVolume = (defaultVolume + 1) * 2;
mptSmp.uFlags.set(CHN_LOOP, (flags & 0x80) != 0);
LimitMax(mptSmp.nLoopEnd, mptSmp.nLength);
@@ -189,7 +191,7 @@ static uint8 ConvertPSMPorta(uint8 param, bool sinariaFormat)
}
-// Read a Pattern ID (something like "P0 " or "P13 " in the old format, or "PATT0 " in Sinaria)
+// Read a Pattern ID (something like "P0 " or "P13 ", or "PATT0 " in Sinaria)
static PATTERNINDEX ReadPSMPatternIndex(FileReader &file, bool &sinariaFormat)
{
char patternID[5];
diff --git a/soundlib/Load_s3m.cpp b/soundlib/Load_s3m.cpp
index f5faa90..5171166 100644
--- a/soundlib/Load_s3m.cpp
+++ b/soundlib/Load_s3m.cpp
@@ -277,6 +277,15 @@ bool CSoundFile::ReadS3M(FileReader &file, ModLoadingFlags loadFlags)
{
madeWithTracker = mpt::format(U_("Impulse Tracker 2.14p%1"))(fileHeader.cwtv - S3MFileHeader::trkIT2_14);
}
+ if(fileHeader.cwtv >= S3MFileHeader::trkIT2_07 && fileHeader.reserved3 != 0)
+ {
+ // Starting from version 2.07, IT stores the total edit time of a module in the "reserved" field
+ uint32 editTime = DecodeITEditTimer(fileHeader.cwtv, fileHeader.reserved3);
+
+ FileHistory hist;
+ hist.openTime = static_cast<uint32>(editTime * (HISTORY_TIMER_PRECISION / 18.2));
+ m_FileHistory.push_back(hist);
+ }
nonCompatTracker = true;
m_nMinPeriod = 1;
break;
@@ -287,7 +296,7 @@ bool CSoundFile::ReadS3M(FileReader &file, ModLoadingFlags loadFlags)
m_playBehaviour.set(kST3LimitPeriod);
} else
{
- madeWithTracker = GetSchismTrackerVersion(fileHeader.cwtv);
+ madeWithTracker = GetSchismTrackerVersion(fileHeader.cwtv, fileHeader.reserved2);
m_nMinPeriod = 1;
isSchism = true;
}
diff --git a/soundlib/S3MTools.h b/soundlib/S3MTools.h
index 00753aa..c27e707 100644
--- a/soundlib/S3MTools.h
+++ b/soundlib/S3MTools.h
@@ -44,6 +44,7 @@ struct S3MFileHeader
trkCreamTracker = 0x7000,
trkST3_20 = 0x1320,
+ trkIT2_07 = 0x3207,
trkIT2_14 = 0x3214,
trkBeRoTrackerOld = 0x4100, // Used from 2004 to 2012
trkCamoto = 0xCA00,
@@ -82,7 +83,9 @@ struct S3MFileHeader
uint8le masterVolume; // Sample Volume (0...127, stereo if high bit is set)
uint8le ultraClicks; // Number of channels used for ultra click removal
uint8le usePanningTable; // 0xFC => read extended panning table
- char reserved2[8]; // More reserved bytes
+ uint16le reserved2; // Schism Tracker uses this for its extended version information
+ uint32le reserved3; // Impulse Tracker hides its edit timer here
+ uint16le reserved4;
uint16le special; // Pointer to special custom data (unused)
uint8le channels[32]; // Channel setup
};
diff --git a/soundlib/Snd_fx.cpp b/soundlib/Snd_fx.cpp
index 3252d3c..77f86ea 100644
--- a/soundlib/Snd_fx.cpp
+++ b/soundlib/Snd_fx.cpp
@@ -1257,6 +1257,7 @@ std::vector<GetLengthType> CSoundFile::GetLength(enmGetLengthResetMode adjustMod
{
// Target found, or there is no target (i.e. play whole song)...
m_PlayState = std::move(playState);
+ m_PlayState.ResetGlobalVolumeRamping();
m_PlayState.m_nNextRow = m_PlayState.m_nRow;
m_PlayState.m_nFrameDelay = m_PlayState.m_nPatternDelay = 0;
m_PlayState.m_nTickCount = Util::MaxValueOfType(m_PlayState.m_nTickCount) - 1;
diff --git a/soundlib/Sndfile.cpp b/soundlib/Sndfile.cpp
index 45e0ed6..cce5e50 100644
--- a/soundlib/Sndfile.cpp
+++ b/soundlib/Sndfile.cpp
@@ -536,10 +536,7 @@ bool CSoundFile::Create(FileReader file, ModLoadingFlags loadFlags)
m_PlayState.m_nCurrentRowsPerBeat = m_nDefaultRowsPerBeat;
m_PlayState.m_nCurrentRowsPerMeasure = m_nDefaultRowsPerMeasure;
m_PlayState.m_nGlobalVolume = static_cast<int32>(m_nDefaultGlobalVolume);
- m_PlayState.m_lHighResRampingGlobalVolume = m_PlayState.m_nGlobalVolume<<VOLUMERAMPPRECISION;
- m_PlayState.m_nGlobalVolumeDestination = m_PlayState.m_nGlobalVolume;
- m_PlayState.m_nSamplesToGlobalVolRampDest = 0;
- m_PlayState.m_nGlobalVolumeRampAmount = 0;
+ m_PlayState.ResetGlobalVolumeRamping();
m_PlayState.m_nNextOrder = 0;
m_PlayState.m_nCurrentOrder = 0;
m_PlayState.m_nPattern = 0;
@@ -766,11 +763,8 @@ void CSoundFile::ResetPlayPos()
m_PlayState.m_nMusicSpeed = m_nDefaultSpeed;
m_PlayState.m_nMusicTempo = m_nDefaultTempo;
- // do not ramp global volume when starting playback
- m_PlayState.m_lHighResRampingGlobalVolume = m_PlayState.m_nGlobalVolume<<VOLUMERAMPPRECISION;
- m_PlayState.m_nGlobalVolumeDestination = m_PlayState.m_nGlobalVolume;
- m_PlayState.m_nSamplesToGlobalVolRampDest = 0;
- m_PlayState.m_nGlobalVolumeRampAmount = 0;
+ // Do not ramp global volume when starting playback
+ m_PlayState.ResetGlobalVolumeRamping();
m_PlayState.m_nNextOrder = 0;
m_PlayState.m_nNextRow = 0;
@@ -780,7 +774,6 @@ void CSoundFile::ResetPlayPos()
m_PlayState.m_nFrameDelay = 0;
m_PlayState.m_nNextPatStartRow = 0;
m_PlayState.m_lTotalSampleCount = 0;
- //m_nSeqOverride = 0;
}
diff --git a/soundlib/Sndfile.h b/soundlib/Sndfile.h
index 5b55043..26ffafe 100644
--- a/soundlib/Sndfile.h
+++ b/soundlib/Sndfile.h
@@ -225,13 +225,15 @@ class CModDoc;
struct FileHistory
{
- FileHistory() : openTime(0) { MemsetZero(loadDate); }
+ FileHistory() { MemsetZero(loadDate); }
// Date when the file was loaded in the the tracker or created.
tm loadDate;
// Time the file was open in the editor, in 1/18.2th seconds (frequency of a standard DOS timer, to keep compatibility with Impulse Tracker easy).
- uint32 openTime;
+ uint32 openTime = 0;
// Return the date as a (possibly truncated if not enough precision is available) ISO 8601 formatted date.
mpt::ustring AsISO8601() const;
+ // Returns true if the date component is valid. Some formats only store edit time, not edit date.
+ bool HasValidDate() const { return loadDate.tm_mday != 0; }
};
@@ -506,6 +508,14 @@ public:
{
std::fill(std::begin(Chn), std::end(Chn), ModChannel());
}
+
+ void ResetGlobalVolumeRamping()
+ {
+ m_lHighResRampingGlobalVolume = m_nGlobalVolume << VOLUMERAMPPRECISION;
+ m_nGlobalVolumeDestination = m_nGlobalVolume;
+ m_nSamplesToGlobalVolRampDest = 0;
+ m_nGlobalVolumeRampAmount = 0;
+ }
};
PlayState m_PlayState;
@@ -820,7 +830,7 @@ public:
void LoadExtendedSongProperties(FileReader &file, bool ignoreChannelCount, bool* pInterpretMptMade = nullptr);
void LoadMPTMProperties(FileReader &file, uint16 cwtv);
- mpt::ustring GetSchismTrackerVersion(uint16 cwtv);
+ static mpt::ustring GetSchismTrackerVersion(uint16 cwtv, uint32 reserved);
// Reads extended instrument properties(XM/IT/MPTM).
// Returns true if extended instrument properties were found.
diff --git a/soundlib/Tables.cpp b/soundlib/Tables.cpp
index 3a701b2..fc0f3fd 100644
--- a/soundlib/Tables.cpp
+++ b/soundlib/Tables.cpp
@@ -765,12 +765,9 @@ void CResampler::InitializeTablesFromScratch(bool force)
{
initParameterIndependentTables = true;
}
- #ifdef MODPLUG_TRACKER
- if(!StaticTablesInitialized)
- {
- initParameterIndependentTables = true;
- }
- #endif // MODPLUG_TRACKER
+#ifdef MODPLUG_TRACKER
+ initParameterIndependentTables = !StaticTablesInitialized;
+#endif // MODPLUG_TRACKER
MPT_MAYBE_CONSTANT_IF(initParameterIndependentTables)
{
@@ -802,7 +799,7 @@ void CResampler::InitializeTablesFromScratch(bool force)
static const CResampler & GetCachedResampler()
{
static CResampler s_CachedResampler(true);
- return s_CachedResampler;
+ return s_CachedResampler;
}
diff --git a/soundlib/modcommand.cpp b/soundlib/modcommand.cpp
index 1c9217d..99a4fc2 100644
--- a/soundlib/modcommand.cpp
+++ b/soundlib/modcommand.cpp
@@ -308,6 +308,7 @@ void ModCommand::Convert(MODTYPE fromType, MODTYPE toType, const CSoundFile &snd
{
param = 0x0F | (std::min<PARAM>(0x0E, param & 0x0F) << 4);
}
+ break;
default:
break;
diff --git a/soundlib/plugins/LFOPlugin.h b/soundlib/plugins/LFOPlugin.h
index 2a44474..7301070 100644
--- a/soundlib/plugins/LFOPlugin.h
+++ b/soundlib/plugins/LFOPlugin.h
@@ -145,7 +145,7 @@ protected:
public:
static LFOWaveform ParamToWaveform(float param) { return static_cast<LFOWaveform>(mpt::saturate_round<int>(param * 32.0f)); }
- static float WaveformToParam(LFOWaveform waveform) { return waveform / 32.0f; }
+ static float WaveformToParam(LFOWaveform waveform) { return static_cast<int>(waveform) / 32.0f; }
};
OPENMPT_NAMESPACE_END
diff --git a/soundlib/tuning.h b/soundlib/tuning.h
index 050e6a1..828f2e3 100644
--- a/soundlib/tuning.h
+++ b/soundlib/tuning.h
@@ -140,7 +140,7 @@ public:
{
CTuningRTI *pT = new CTuningRTI();
pT->SetName(name);
- VRPAIR range = std::make_pair(s_StepMinDefault, static_cast<NOTEINDEXTYPE>(s_StepMinDefault + s_RatioTableSizeDefault - 1));
+ VRPAIR range = std::make_pair(s_StepMinDefault, static_cast<NOTEINDEXTYPE>(static_cast<NOTEINDEXTYPE>(s_StepMinDefault) + static_cast<NOTEINDEXTYPE>(s_RatioTableSizeDefault) - 1));
range.second = std::max(range.second, mpt::saturate_cast<NOTEINDEXTYPE>(ratios.size() - 1));
range.first = 0 - range.second - 1;
if(pT->CreateGroupGeometric(ratios, groupratio, range, 0) != false)