From: <sv...@op...> - 2024-11-30 13:50:53
|
Author: sagamusix Date: Sat Nov 30 14:50:41 2024 New Revision: 22356 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22356 Log: [Ref] Pass ModChannel instead of whole PlayState to GetChannelPlugin/GetBestPlugin. Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp ============================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp Sat Nov 30 12:48:47 2024 (r22355) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp Sat Nov 30 14:50:41 2024 (r22356) @@ -680,7 +680,7 @@ if(chn != CHANNELINDEX_INVALID) { const uint8 macroIndex = sndFile.m_PlayState.Chn[chn].nActiveMacro; - const PLUGINDEX plugin = sndFile.GetBestPlugin(sndFile.m_PlayState, chn, PrioritiseChannel, EvenIfMuted) - 1; + const PLUGINDEX plugin = sndFile.GetBestPlugin(sndFile.m_PlayState.Chn[chn], chn, PrioritiseChannel, EvenIfMuted) - 1; IMixPlugin *pPlugin = (plugin < MAX_MIXPLUGINS ? sndFile.m_MixPlugins[plugin].pMixPlugin : nullptr); pszName.Format(_T("SFx MIDI Macro z=%d (SF%X: %s)"), param, macroIndex, sndFile.m_MidiCfg.GetParameteredMacroName(macroIndex, pPlugin).GetString()); } else Modified: trunk/OpenMPT/mptrack/Moddoc.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp Sat Nov 30 12:48:47 2024 (r22355) +++ trunk/OpenMPT/mptrack/Moddoc.cpp Sat Nov 30 14:50:41 2024 (r22356) @@ -1329,25 +1329,24 @@ { const ChannelFlags muteType = CSoundFile::GetChannelMuteFlag(); - if (nChn >= m_SndFile.GetNumChannels()) - { + if(nChn >= m_SndFile.GetNumChannels()) return false; - } + ModChannel &chn = m_SndFile.m_PlayState.Chn[nChn]; const bool doMute = m_SndFile.ChnSettings[nChn].dwFlags[CHN_MUTE]; - - // Mute pattern channel - if (doMute) + if(doMute) { - m_SndFile.m_PlayState.Chn[nChn].dwFlags.set(muteType); - if(m_SndFile.m_opl) m_SndFile.m_opl->NoteCut(nChn); + // Mute pattern channel + chn.dwFlags.set(muteType); + if(m_SndFile.m_opl) + m_SndFile.m_opl->NoteCut(nChn); // Kill VSTi notes on muted channel. - PLUGINDEX nPlug = m_SndFile.GetBestPlugin(m_SndFile.m_PlayState, nChn, PrioritiseInstrument, EvenIfMuted); - if ((nPlug) && (nPlug<=MAX_MIXPLUGINS)) + PLUGINDEX nPlug = m_SndFile.GetBestPlugin(chn, nChn, PrioritiseInstrument, EvenIfMuted); + if(nPlug > 0 && nPlug <= MAX_MIXPLUGINS) { IMixPlugin *pPlug = m_SndFile.m_MixPlugins[nPlug - 1].pMixPlugin; - const ModInstrument* pIns = m_SndFile.m_PlayState.Chn[nChn].pModInstrument; - if (pPlug && pIns) + const ModInstrument* pIns = chn.pModInstrument; + if(pPlug && pIns) { pPlug->MidiCommand(*pIns, NOTE_KEYOFF, 0, nChn); } @@ -1355,7 +1354,7 @@ } else { // On unmute alway cater for both mute types - this way there's no probs if user changes mute mode. - m_SndFile.m_PlayState.Chn[nChn].dwFlags.reset(CHN_SYNCMUTE | CHN_MUTE); + chn.dwFlags.reset(CHN_SYNCMUTE | CHN_MUTE); } // Mute any NNA'd channels Modified: trunk/OpenMPT/soundlib/Fastmix.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp Sat Nov 30 12:48:47 2024 (r22355) +++ trunk/OpenMPT/soundlib/Fastmix.cpp Sat Nov 30 14:50:41 2024 (r22356) @@ -353,7 +353,7 @@ //Look for plugins associated with this implicit tracker channel. #ifndef NO_PLUGINS - PLUGINDEX nMixPlugin = GetBestPlugin(m_PlayState, m_PlayState.ChnMix[nChn], PrioritiseInstrument, RespectMutes); + PLUGINDEX nMixPlugin = GetBestPlugin(chn, m_PlayState.ChnMix[nChn], PrioritiseInstrument, RespectMutes); if ((nMixPlugin > 0) && (nMixPlugin <= MAX_MIXPLUGINS) && m_MixPlugins[nMixPlugin - 1].pMixPlugin != nullptr) { Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp Sat Nov 30 12:48:47 2024 (r22355) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp Sat Nov 30 14:50:41 2024 (r22356) @@ -2449,7 +2449,7 @@ IMixPlugin *pPlugin = nullptr; if(srcChn.HasMIDIOutput() && ModCommand::IsNote(srcChn.nNote)) // instro sends to a midi chan { - PLUGINDEX plugin = GetBestPlugin(m_PlayState, nChn, PrioritiseInstrument, RespectMutes); + PLUGINDEX plugin = GetBestPlugin(m_PlayState.Chn[nChn], nChn, PrioritiseInstrument, RespectMutes); if(plugin > 0 && plugin <= MAX_MIXPLUGINS) { @@ -5515,7 +5515,7 @@ isNibble = true; data = 0xFF; #ifndef NO_PLUGINS - const PLUGINDEX plug = (plugin != 0) ? plugin : GetBestPlugin(playState, nChn, PrioritiseChannel, EvenIfMuted); + const PLUGINDEX plug = (plugin != 0) ? plugin : GetBestPlugin(chn, nChn, PrioritiseChannel, EvenIfMuted); if(plug > 0 && plug <= MAX_MIXPLUGINS) { auto midiPlug = dynamic_cast<const IMidiPlugin *>(m_MixPlugins[plug - 1u].pMixPlugin); @@ -5751,7 +5751,7 @@ } else if(macroCode == 0x03 && !isExtended) { // F0.F0.03.xx: Set plug dry/wet - PLUGINDEX plug = (plugin != 0) ? plugin : GetBestPlugin(playState, nChn, PrioritiseChannel, EvenIfMuted); + PLUGINDEX plug = (plugin != 0) ? plugin : GetBestPlugin(chn, nChn, PrioritiseChannel, EvenIfMuted); if(plug > 0 && plug <= MAX_MIXPLUGINS && param < 0x80) { plug--; @@ -5769,7 +5769,7 @@ } else if((macroCode & 0x80) || isExtended) { // F0.F0.{80|n}.xx / F0.F1.n.xx: Set VST effect parameter n to xx - PLUGINDEX plug = (plugin != 0) ? plugin : GetBestPlugin(playState, nChn, PrioritiseChannel, EvenIfMuted); + PLUGINDEX plug = (plugin != 0) ? plugin : GetBestPlugin(chn, nChn, PrioritiseChannel, EvenIfMuted); if(plug > 0 && plug <= MAX_MIXPLUGINS && param < 0x80) { plug--; @@ -5797,7 +5797,7 @@ PLUGINDEX plug = 0; if(!chn.dwFlags[CHN_NOFX]) { - plug = (plugin != 0) ? plugin : GetBestPlugin(playState, nChn, PrioritiseChannel, EvenIfMuted); + plug = (plugin != 0) ? plugin : GetBestPlugin(chn, nChn, PrioritiseChannel, EvenIfMuted); } if(plug > 0 && plug <= MAX_MIXPLUGINS) @@ -6776,35 +6776,30 @@ } -PLUGINDEX CSoundFile::GetBestPlugin(const PlayState &playState, CHANNELINDEX nChn, PluginPriority priority, PluginMutePriority respectMutes) const +PLUGINDEX CSoundFile::GetBestPlugin(const ModChannel &channel, CHANNELINDEX nChn, PluginPriority priority, PluginMutePriority respectMutes) const { - if (nChn >= playState.Chn.size()) //Check valid channel number - { - return 0; - } - //Define search source order PLUGINDEX plugin = 0; - switch (priority) + switch(priority) { case ChannelOnly: - plugin = GetChannelPlugin(playState, nChn, respectMutes); + plugin = GetChannelPlugin(channel, nChn, respectMutes); break; case InstrumentOnly: - plugin = GetActiveInstrumentPlugin(playState.Chn[nChn], respectMutes); + plugin = GetActiveInstrumentPlugin(channel, respectMutes); break; case PrioritiseInstrument: - plugin = GetActiveInstrumentPlugin(playState.Chn[nChn], respectMutes); + plugin = GetActiveInstrumentPlugin(channel, respectMutes); if(!plugin || plugin > MAX_MIXPLUGINS) { - plugin = GetChannelPlugin(playState, nChn, respectMutes); + plugin = GetChannelPlugin(channel, nChn, respectMutes); } break; case PrioritiseChannel: - plugin = GetChannelPlugin(playState, nChn, respectMutes); + plugin = GetChannelPlugin(channel, nChn, respectMutes); if(!plugin || plugin > MAX_MIXPLUGINS) { - plugin = GetActiveInstrumentPlugin(playState.Chn[nChn], respectMutes); + plugin = GetActiveInstrumentPlugin(channel, respectMutes); } break; } @@ -6813,10 +6808,8 @@ } -PLUGINDEX CSoundFile::GetChannelPlugin(const PlayState &playState, CHANNELINDEX nChn, PluginMutePriority respectMutes) const +PLUGINDEX CSoundFile::GetChannelPlugin(const ModChannel &channel, CHANNELINDEX nChn, PluginMutePriority respectMutes) const { - const ModChannel &channel = playState.Chn[nChn]; - PLUGINDEX plugin; if((respectMutes == RespectMutes && channel.dwFlags[CHN_MUTE | CHN_SYNCMUTE]) || channel.dwFlags[CHN_NOFX]) { Modified: trunk/OpenMPT/soundlib/Sndfile.h ============================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h Sat Nov 30 12:48:47 2024 (r22355) +++ trunk/OpenMPT/soundlib/Sndfile.h Sat Nov 30 14:50:41 2024 (r22356) @@ -1271,12 +1271,12 @@ void ProcessStereoSeparation(samplecount_t countChunk); private: - PLUGINDEX GetChannelPlugin(const PlayState &playState, CHANNELINDEX nChn, PluginMutePriority respectMutes) const; + PLUGINDEX GetChannelPlugin(const ModChannel &channel, CHANNELINDEX nChn, PluginMutePriority respectMutes) const; static PLUGINDEX GetActiveInstrumentPlugin(const ModChannel &chn, PluginMutePriority respectMutes); IMixPlugin *GetChannelInstrumentPlugin(const ModChannel &chn) const; public: - PLUGINDEX GetBestPlugin(const PlayState &playState, CHANNELINDEX nChn, PluginPriority priority, PluginMutePriority respectMutes) const; + PLUGINDEX GetBestPlugin(const ModChannel &channel, CHANNELINDEX nChn, PluginPriority priority, PluginMutePriority respectMutes) const; PlaybackTest CreatePlaybackTest(PlaybackTestSettings settings); }; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp ============================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp Sat Nov 30 12:48:47 2024 (r22355) +++ trunk/OpenMPT/soundlib/Sndmix.cpp Sat Nov 30 14:50:41 2024 (r22356) @@ -2645,7 +2645,7 @@ } // Check instrument plugins - const PLUGINDEX nPlugin = GetBestPlugin(m_PlayState, nChn, PrioritiseInstrument, RespectMutes); + const PLUGINDEX nPlugin = GetBestPlugin(chn, nChn, PrioritiseInstrument, RespectMutes); IMixPlugin *pPlugin = nullptr; if(nPlugin > 0 && nPlugin <= MAX_MIXPLUGINS) { |