Skip to content

Commit

Permalink
[Fix] Don't execute sample cues when a channel is actually an Adlib c…
Browse files Browse the repository at this point in the history
…hannel. Sample cues share memory with the OPL patch data.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22864 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Feb 7, 2025
1 parent 629aedb commit 8b910c6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions soundlib/Snd_fx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ std::vector<GetLengthType> CSoundFile::GetLength(enmGetLengthResetMode adjustMod
startTick = playState.m_nMusicSpeed - 1;
} else if(m.volcmd == VOLCMD_OFFSET)
{
if(chn.pModSample != nullptr && m.vol <= std::size(chn.pModSample->cues))
if(chn.pModSample != nullptr && !chn.pModSample->uFlags[CHN_ADLIB] && m.vol <= std::size(chn.pModSample->cues))
{
SmpLength offset;
if(m.vol == 0)
Expand Down Expand Up @@ -3343,7 +3343,7 @@ bool CSoundFile::ProcessEffects()
break;

case VOLCMD_OFFSET:
if(triggerNote && chn.pModSample && vol <= std::size(chn.pModSample->cues))
if(triggerNote && chn.pModSample && !chn.pModSample->uFlags[CHN_ADLIB] && vol <= std::size(chn.pModSample->cues))
{
SmpLength offset;
if(vol == 0)
Expand Down Expand Up @@ -5668,7 +5668,7 @@ void CSoundFile::ProcessSampleOffset(ModChannel &chn, CHANNELINDEX nChn, const P
{
if(m.vol == 0)
offset = Util::muldivr_unsigned(chn.nLength, offset, 256u << (8u * std::max(uint32(1), extendedRows))); // o00 + Oxx = Percentage Offset
else if(m.vol <= std::size(ModSample().cues) && chn.pModSample != nullptr)
else if(m.vol <= std::size(ModSample().cues) && chn.pModSample != nullptr && !chn.pModSample->uFlags[CHN_ADLIB])
offset += chn.pModSample->cues[m.vol - 1]; // Offset relative to cue point
chn.oldOffset = offset;
}
Expand Down Expand Up @@ -5993,7 +5993,7 @@ void CSoundFile::RetrigNote(CHANNELINDEX nChn, int param, int offset)
chn.position.Set(0);

offset--;
if(chn.pModSample != nullptr && offset >= 0 && offset <= static_cast<int>(std::size(chn.pModSample->cues)))
if(chn.pModSample != nullptr && !chn.pModSample->uFlags[CHN_ADLIB] && offset >= 0 && offset <= static_cast<int>(std::size(chn.pModSample->cues)))
{
if(offset == 0)
offset = chn.oldOffset;
Expand Down

0 comments on commit 8b910c6

Please sign in to comment.