Skip to content

Commit

Permalink
Merged revision(s) 21572 from trunk/OpenMPT:
Browse files Browse the repository at this point in the history
[Imp] MED: Tempo commands > 255 BPM were not imported properly if the files was imported as MOD instead of XM. Fixes OSS.Mad Frenchman (https://www.un4seen.com/forum/?topic=15448.msg143478#msg143478).
........


git-svn-id: https://source.openmpt.org/svn/openmpt/branches/OpenMPT-1.31@21573 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Sep 8, 2024
1 parent c29642f commit a94a61c
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions soundlib/Snd_fx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3216,18 +3216,16 @@ bool CSoundFile::ProcessEffects()
if(m_playBehaviour[kMODVBlankTiming])
{
// ProTracker MODs with VBlank timing: All Fxx parameters set the tick count.
if(m_SongFlags[SONG_FIRSTTICK] && param != 0) SetSpeed(m_PlayState, param);
break;
}
if(m_SongFlags[SONG_FIRSTTICK] && param != 0)
SetSpeed(m_PlayState, param);
} else
{
param = CalculateXParam(m_PlayState.m_nPattern, m_PlayState.m_nRow, nChn);
if (GetType() & (MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT))
if (GetType() & (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT))
{
if (param) chn.nOldTempo = static_cast<ModCommand::PARAM>(param); else param = chn.nOldTempo;
}
TEMPO t(param, 0);
LimitMax(t, GetModSpecifications().GetTempoMax());
SetTempo(t);
SetTempo(TEMPO(param, 0));
}
break;

Expand Down Expand Up @@ -5978,17 +5976,24 @@ void CSoundFile::SetTempo(TEMPO param, bool setFromUI)

// Anything lower than the minimum tempo is considered to be a tempo slide
const TEMPO minTempo = GetMinimumTempoParam(GetType());
TEMPO maxTempo = specs.GetTempoMax();
// MED files may be imported with #xx parameter extension for tempos above 255, but they may be imported as either MOD or XM.
// As regular MOD files cannot contain effect #xx, the tempo parameter cannot exceed 255 anyway, so we simply ignore their max tempo in CModSpecifications here.
if(!(GetType() & (MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT)))
maxTempo = GetModSpecifications(MOD_TYPE_MPT).GetTempoMax();
if(m_playBehaviour[kTempoClamp])
maxTempo.Set(255);

if(setFromUI)
{
// Set tempo from UI - ignore slide commands and such.
m_PlayState.m_nMusicTempo = Clamp(param, specs.GetTempoMin(), specs.GetTempoMax());
m_PlayState.m_nMusicTempo = Clamp(param, specs.GetTempoMin(), maxTempo);
} else if(param >= minTempo && m_SongFlags[SONG_FIRSTTICK] == !m_playBehaviour[kMODTempoOnSecondTick])
{
// ProTracker sets the tempo after the first tick.
// Note: The case of one tick per row is handled in ProcessRow() instead.
// Test case: TempoChange.mod
m_PlayState.m_nMusicTempo = std::min(param, specs.GetTempoMax());
m_PlayState.m_nMusicTempo = std::min(param, maxTempo);
} else if(param < minTempo && !m_SongFlags[SONG_FIRSTTICK])
{
// Tempo Slide
Expand All @@ -5998,12 +6003,8 @@ void CSoundFile::SetTempo(TEMPO param, bool setFromUI)
else
m_PlayState.m_nMusicTempo -= tempDiff;

TEMPO tempoMin = specs.GetTempoMin(), tempoMax = specs.GetTempoMax();
if(m_playBehaviour[kTempoClamp]) // clamp tempo correctly in compatible mode
{
tempoMax.Set(255);
}
Limit(m_PlayState.m_nMusicTempo, tempoMin, tempoMax);
TEMPO tempoMin = specs.GetTempoMin();
Limit(m_PlayState.m_nMusicTempo, tempoMin, maxTempo);
}
}

Expand Down

0 comments on commit a94a61c

Please sign in to comment.