|
From: <sag...@us...> - 2013-07-28 14:05:25
|
Revision: 2547
http://sourceforge.net/p/modplug/code/2547
Author: saga-games
Date: 2013-07-28 14:05:17 +0000 (Sun, 28 Jul 2013)
Log Message:
-----------
[Fix] STM: Improved support for ST2-style arpeggio (libopenmpt only, no change in OpenMPT)
Modified Paths:
--------------
trunk/OpenMPT/soundlib/Load_stm.cpp
trunk/OpenMPT/soundlib/Snd_fx.cpp
trunk/OpenMPT/soundlib/Sndmix.cpp
Modified: trunk/OpenMPT/soundlib/Load_stm.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Load_stm.cpp 2013-07-27 19:21:51 UTC (rev 2546)
+++ trunk/OpenMPT/soundlib/Load_stm.cpp 2013-07-28 14:05:17 UTC (rev 2547)
@@ -142,11 +142,15 @@
m_nChannels = 4;
m_nMinPeriod = 64;
m_nMaxPeriod = 0x7FFF;
+#ifdef MODPLUG_TRACKER
+ m_nDefaultTempo = 125;
m_nDefaultSpeed = fileHeader.initTempo >> 4;
+#else
+ m_nDefaultTempo = 125 * 16;
+ m_nDefaultSpeed = fileHeader.initTempo;
+#endif // MODPLUG_TRACKER
if(m_nDefaultSpeed < 1) m_nDefaultSpeed = 1;
- m_nDefaultTempo = 125;
- m_nDefaultGlobalVolume = fileHeader.globalVolume * 4;
- LimitMax(m_nDefaultGlobalVolume, MAX_GLOBAL_VOLUME);
+ m_nDefaultGlobalVolume = std::min<uint8>(fileHeader.globalVolume, 64) * 4;
// Setting up channels
for(CHANNELINDEX chn = 0; chn < 4; chn++)
@@ -226,13 +230,15 @@
switch(m->command)
{
+#ifdef MODPLUG_TRACKER
case CMD_SPEED:
// ST2 assumes that the tempo is 125 * 16 BPM, and effects are updated
- // on every 16th tick of a row. This is pretty hard to handle, so we just
- // assume the tempo is 125 and divide the speed by 16 instead.
+ // on every 16th tick of a row. This is pretty hard to handle in the tracker,
+ // so we just assume the tempo is 125 and divide the speed by 16 instead.
// Parameters below 10 might behave weird.
m->param >>= 4;
break;
+#endif // MODPLUG_TRACKER
case CMD_PATTERNBREAK:
m->param = (m->param & 0xF0) * 10 + (m->param & 0x0F);
Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-27 19:21:51 UTC (rev 2546)
+++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2013-07-28 14:05:17 UTC (rev 2547)
@@ -35,39 +35,6 @@
// Length
-/*
-void CSoundFile::GenerateSamplePosMap() {
-
-
-
-
-
- double accurateBufferCount =
-
- long lSample = 0;
- nPattern
-
- //for each order
- //get pattern for this order
- //if pattern if duff: break, we're done.
- //for each row in this pattern
- //get ticks for this row
- //get ticks per row and tempo for this row
- //for each tick
-
- //Recalc if ticks per row or tempo has changed
-
- samplesPerTick = (double)gdwMixingFreq * (60.0/(double)m_nMusicTempo / ((double)m_nMusicSpeed * (double)m_nRowsPerBeat));
- lSample += samplesPerTick;
-
-
- nPattern = ++nOrder;
- }
-
-}
-*/
-
-
// Memory class for GetLength() code
class GetLengthMemory
{
@@ -782,7 +749,7 @@
}
// Default sample panning
- if(pSmp->uFlags[CHN_PANNING] && (bUpdVol || GetType() != MOD_TYPE_XM))
+ if(pSmp->uFlags[CHN_PANNING] && (bUpdVol || !(GetType() & (MOD_TYPE_XM | MOD_TYPE_MT2))))
{
// FT2 compatibility: Only reset panning on instrument numbers, not notes (bUpdVol condition)
// Test case: PanMemory.xm
@@ -1597,10 +1564,16 @@
//-------------------------------
{
ModChannel *pChn = Chn;
- ROWINDEX nBreakRow = ROWINDEX_INVALID; // Is changed if a break to row command is encountere.d
+ ROWINDEX nBreakRow = ROWINDEX_INVALID; // Is changed if a break to row command is encountered
ROWINDEX nPatLoopRow = ROWINDEX_INVALID; // Is changed if a pattern loop jump-back is executed
ORDERINDEX nPosJump = ORDERINDEX_INVALID;
+ // ScreamTracker 2 only updates effects on every 16th tick.
+ if((m_nTickCount & 0x0F) != 0 && GetType() == MOD_TYPE_STM)
+ {
+ return TRUE;
+ }
+
// -> CODE#0010
// -> DESC="add extended parameter mechanism to pattern effects"
ModCommand *m = nullptr;
@@ -2719,7 +2692,7 @@
// Channels effects
-// Update the effect memory of all S3M effects that use the last non-zero effect parameter ot show up (Dxy, Exx, Fxx, Ixy, Jxy, Kxy, Lxy, Qxy, Rxy, Sxy)
+// Update the effect memory of all S3M effects that use the last non-zero effect parameter as memory (Dxy, Exx, Fxx, Ixy, Jxy, Kxy, Lxy, Qxy, Rxy, Sxy)
// Test case: ParamMemory.s3m
void CSoundFile::UpdateS3MEffectMemory(ModChannel *pChn, UINT param) const
//------------------------------------------------------------------------
Modified: trunk/OpenMPT/soundlib/Sndmix.cpp
===================================================================
--- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-27 19:21:51 UTC (rev 2546)
+++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-07-28 14:05:17 UTC (rev 2547)
@@ -1283,6 +1283,7 @@
arpPos = m_nMusicSpeed - (m_nTickCount % m_nMusicSpeed);
// The fact that arpeggio behaves in a totally fucked up way at 16 ticks/row or more is that the arpeggio offset LUT only has 16 entries in FT2.
// At more than 16 ticks/row, FT2 reads into the vibrato table, which is placed right after the arpeggio table.
+ // Test case: Arpeggio.xm
if(arpPos > 16) arpPos = 2;
else if(arpPos == 16) arpPos = 0;
else arpPos %= 3;
@@ -1302,13 +1303,19 @@
// Other trackers
else
{
+ uint32 tick = m_nTickCount;
+ // ScreamTracker 2 only updates effects on every 16th tick.
+ if(GetType() == MOD_TYPE_STM)
+ {
+ tick >>= 4;
+ }
int note = pChn->nNote;
- switch(m_nTickCount % 3)
+ switch(tick % 3)
{
case 1: note += (pChn->nArpeggio >> 4); break;
case 2: note += (pChn->nArpeggio & 0x0F); break;
}
- if(note != pChn->nNote)
+ if(note != pChn->nNote || GetType() == MOD_TYPE_STM)
{
if(m_SongFlags[SONG_PT1XMODE] && note >= NOTE_MIDDLEC + 24)
{
@@ -1317,6 +1324,13 @@
note -= 37;
}
period = GetPeriodFromNote(note, pChn->nFineTune, pChn->nC5Speed);
+
+ // The arpeggio note offset remains effective after the end of the current row in ScreamTracker 2.
+ // This fixes the flute lead in MORPH.STM by Skaven, pattern 27.
+ if(GetType() == MOD_TYPE_STM)
+ {
+ pChn->nPeriod = period;
+ }
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|