From: <sv...@op...> - 2024-10-20 14:42:03
|
Author: sagamusix Date: Sun Oct 20 16:41:56 2024 New Revision: 21897 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21897 Log: [Ref] Unify time signature handling between GetLength and normal playing. Modified: trunk/OpenMPT/soundlib/PlayState.cpp trunk/OpenMPT/soundlib/PlayState.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/soundlib/PlayState.cpp ============================================================================== --- trunk/OpenMPT/soundlib/PlayState.cpp Sun Oct 20 16:29:47 2024 (r21896) +++ trunk/OpenMPT/soundlib/PlayState.cpp Sun Oct 20 16:41:56 2024 (r21897) @@ -34,6 +34,20 @@ } +void PlayState::UpdateTimeSignature(const CSoundFile &sndFile) noexcept +{ + if(!sndFile.Patterns.IsValidIndex(m_nPattern) || !sndFile.Patterns[m_nPattern].GetOverrideSignature()) + { + m_nCurrentRowsPerBeat = sndFile.m_nDefaultRowsPerBeat; + m_nCurrentRowsPerMeasure = sndFile.m_nDefaultRowsPerMeasure; + } else + { + m_nCurrentRowsPerBeat = sndFile.Patterns[m_nPattern].GetRowsPerBeat(); + m_nCurrentRowsPerMeasure = sndFile.Patterns[m_nPattern].GetRowsPerMeasure(); + } +} + + mpt::span<ModChannel> PlayState::PatternChannels(const CSoundFile &sndFile) noexcept { return mpt::as_span(Chn).subspan(0, std::min(Chn.size(), static_cast<size_t>(sndFile.GetNumChannels()))); Modified: trunk/OpenMPT/soundlib/PlayState.h ============================================================================== --- trunk/OpenMPT/soundlib/PlayState.h Sun Oct 20 16:29:47 2024 (r21896) +++ trunk/OpenMPT/soundlib/PlayState.h Sun Oct 20 16:41:56 2024 (r21897) @@ -88,6 +88,8 @@ void ResetGlobalVolumeRamping() noexcept; + void UpdateTimeSignature(const CSoundFile &sndFile) noexcept; + constexpr uint32 TicksOnRow() const noexcept { return (m_nMusicSpeed + m_nFrameDelay) * std::max(m_nPatternDelay, uint32(1)); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp Sun Oct 20 16:29:47 2024 (r21896) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp Sun Oct 20 16:41:56 2024 (r21897) @@ -555,6 +555,8 @@ playState.m_nRow = 0; } + playState.UpdateTimeSignature(*this); + if(ignoreRow) continue; @@ -1060,12 +1062,6 @@ continue; } - playState.m_nCurrentRowsPerBeat = m_nDefaultRowsPerBeat; - if(Patterns[playState.m_nPattern].GetOverrideSignature()) - { - playState.m_nCurrentRowsPerBeat = Patterns[playState.m_nPattern].GetRowsPerBeat(); - } - const uint32 tickDuration = GetTickDuration(playState); const uint32 rowDuration = tickDuration * numTicks; memory.elapsedTime += static_cast<double>(rowDuration) / static_cast<double>(m_MixerSettings.gdwMixingFreq); @@ -6903,21 +6899,6 @@ #endif // MODPLUG_TRACKER -// Update time signatures (global or pattern-specific). Don't forget to call this when changing the RPB/RPM settings anywhere! -void CSoundFile::UpdateTimeSignature() -{ - if(!Patterns.IsValidIndex(m_PlayState.m_nPattern) || !Patterns[m_PlayState.m_nPattern].GetOverrideSignature()) - { - m_PlayState.m_nCurrentRowsPerBeat = m_nDefaultRowsPerBeat; - m_PlayState.m_nCurrentRowsPerMeasure = m_nDefaultRowsPerMeasure; - } else - { - m_PlayState.m_nCurrentRowsPerBeat = Patterns[m_PlayState.m_nPattern].GetRowsPerBeat(); - m_PlayState.m_nCurrentRowsPerMeasure = Patterns[m_PlayState.m_nPattern].GetRowsPerMeasure(); - } -} - - void CSoundFile::PortamentoMPT(ModChannel &chn, int param) const { //Behavior: Modifies portamento by param-steps on every tick. Modified: trunk/OpenMPT/soundlib/Sndfile.h ============================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h Sun Oct 20 16:29:47 2024 (r21896) +++ trunk/OpenMPT/soundlib/Sndfile.h Sun Oct 20 16:41:56 2024 (r21897) @@ -1131,8 +1131,6 @@ int SetupChannelFilter(ModChannel &chn, bool bReset, int envModifier = 256) const; int HandleNoteChangeFilter(ModChannel &chn) const; - void UpdateTimeSignature(); - public: void DoFreqSlide(ModChannel &chn, int32 &period, int32 amount, bool isTonePorta = false) const; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp Sun Oct 20 16:29:47 2024 (r21896) +++ trunk/OpenMPT/soundlib/Sndmix.cpp Sun Oct 20 16:41:56 2024 (r21897) @@ -225,7 +225,6 @@ while(!m_PlayState.m_flags[SONG_ENDREACHED] && countToRender > 0) { - // Update Channel Data if(!m_PlayState.m_nBufferCount) { @@ -719,7 +718,7 @@ } // Now that we know which pattern we're on, we can update time signatures (global or pattern-specific) - UpdateTimeSignature(); + m_PlayState.UpdateTimeSignature(*this); if(ignoreRow) { |