From: <sag...@us...> - 2011-10-21 17:25:33
|
Revision: 1115 http://modplug.svn.sourceforge.net/modplug/?rev=1115&view=rev Author: saga-games Date: 2011-10-21 17:25:25 +0000 (Fri, 21 Oct 2011) Log Message: ----------- [Mod] Changes to VST bypass handling code. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_gen.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-10-21 15:35:19 UTC (rev 1114) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-10-21 17:25:25 UTC (rev 1115) @@ -201,7 +201,7 @@ { if (m_pVstPlugin) { - m_pVstPlugin->Bypass(); + m_pVstPlugin->ToggleBypass(); } } Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2011-10-21 15:35:19 UTC (rev 1114) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2011-10-21 17:25:25 UTC (rev 1115) @@ -426,7 +426,7 @@ PSNDMIXPLUGIN pPlugin = &(pSndFile->m_MixPlugins[m_nCurrentPlugin]); SetDlgItemText(IDC_EDIT13, pPlugin->Info.szName); CheckDlgButton(IDC_CHECK9, (pPlugin->Info.dwInputRouting & MIXPLUG_INPUTF_MASTEREFFECT) ? TRUE : FALSE); - CheckDlgButton(IDC_CHECK10, (pPlugin->Info.dwInputRouting & MIXPLUG_INPUTF_BYPASS) ? TRUE : FALSE); + CheckDlgButton(IDC_CHECK10, (pPlugin->IsBypassed()) ? TRUE : FALSE); CheckDlgButton(IDC_CHECK11, (pPlugin->Info.dwInputRouting & MIXPLUG_INPUTF_WETMIX) ? TRUE : FALSE); CVstPlugin *pVstPlugin = (pPlugin->pMixPlugin) ? (CVstPlugin *)pPlugin->pMixPlugin : NULL; m_BtnEdit.EnableWindow(((pVstPlugin) && ((pVstPlugin->HasEditor()) || (pVstPlugin->GetNumCommands()))) ? TRUE : FALSE); @@ -465,7 +465,7 @@ if (pVstPlugin) { - UINT nParams = pVstPlugin->GetNumParameters(); + const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); m_CbnParam.SetRedraw(FALSE); m_CbnParam.ResetContent(); if (m_nCurrentParam >= nParams) m_nCurrentParam = 0; @@ -727,7 +727,7 @@ if (pPlugin->pMixPlugin) { CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; - UINT nParams = pVstPlugin->GetNumParameters(); + const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); if (m_nCurrentParam < nParams) { FLOAT fValue = 0.01f * n; @@ -1069,7 +1069,6 @@ //--------------------------------- { CModDoc *pModDoc = GetDocument(); - CHAR s[256]; PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; @@ -1079,7 +1078,8 @@ if (pPlugin->pMixPlugin) { CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; - UINT nParams = pVstPlugin->GetNumParameters(); + const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); + CHAR s[32]; GetDlgItemText(IDC_EDIT14, s, sizeof(s)); if ((m_nCurrentParam < nParams) && (s[0])) { @@ -1176,13 +1176,7 @@ if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (IsDlgButtonChecked(IDC_CHECK10)) - { - pPlugin->Info.dwInputRouting |= MIXPLUG_INPUTF_BYPASS; - } else - { - pPlugin->Info.dwInputRouting &= ~MIXPLUG_INPUTF_BYPASS; - } + pPlugin->Bypass(IsDlgButtonChecked(IDC_CHECK10) != FALSE); if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); Modified: trunk/OpenMPT/mptrack/View_gen.h =================================================================== --- trunk/OpenMPT/mptrack/View_gen.h 2011-10-21 15:35:19 UTC (rev 1114) +++ trunk/OpenMPT/mptrack/View_gen.h 2011-10-21 17:25:25 UTC (rev 1115) @@ -30,7 +30,7 @@ CButton m_BtnSelect, m_BtnEdit; int m_nActiveTab, m_nLockCount; PLUGINDEX m_nCurrentPlugin; - UINT m_nCurrentParam; + PlugParamIndex m_nCurrentParam; // -> CODE#0002 // -> DESC="VST plugins presets" UINT m_nCurrentPreset; Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2011-10-21 15:35:19 UTC (rev 1114) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2011-10-21 17:25:25 UTC (rev 1115) @@ -2499,9 +2499,9 @@ CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; if (pSndFile) { PSNDMIXPLUGIN pPlugin = &pSndFile->m_MixPlugins[modItemID]; - if (pPlugin) { - bool bypassed = ((pPlugin->Info.dwInputRouting&MIXPLUG_INPUTF_BYPASS) != 0); - AppendMenu(hMenu, (bypassed?MF_CHECKED:0)|MF_STRING, ID_MODTREE_MUTE, "&Bypass"); + if (pPlugin) + { + AppendMenu(hMenu, (pPlugin->IsBypassed() ? MF_CHECKED : 0) | MF_STRING, ID_MODTREE_MUTE, "&Bypass"); } } } @@ -2875,7 +2875,7 @@ CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; if(pVstPlugin == nullptr) return; - pVstPlugin->Bypass(); + pVstPlugin->ToggleBypass(); pModDoc->SetModified(); //UpdateView(GetDocumentIDFromModDoc(pModDoc), HINT_MIXPLUGINS); } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-21 15:35:19 UTC (rev 1114) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2011-10-21 17:25:25 UTC (rev 1115) @@ -1896,7 +1896,7 @@ CString name; if(paramName.IsEmpty()) { - name.Format("Parameter %02d", param); + name.Format("%02d: Parameter %02d", param, param); } else { name.Format("%02d: %s", param, paramName); @@ -2094,7 +2094,7 @@ m_pProcessFP(m_pEffect, m_pInputs, m_pOutputs, nSamples); } catch (...) { - m_pMixStruct->Info.dwInputRouting |= MIXPLUG_INPUTF_BYPASS; + Bypass(); CString processMethod = (m_pEffect->flags & effFlagsCanReplacing) ? "processReplacing" : "process"; CVstPluginManager::ReportPlugException("The plugin %s threw an exception in %s. It has automatically been set to \"Bypass\".", m_pMixStruct->Info.szName, processMethod); ClearVSTEvents(); @@ -2962,6 +2962,7 @@ return 0; } + //rewbs.defaultPlugGui CAbstractVstEditor* CVstPlugin::GetEditor() //----------------------------------------- @@ -2969,6 +2970,7 @@ return m_pEditor; } + bool CVstPlugin::Bypass(bool bypass) //----------------------------------- { @@ -2977,6 +2979,8 @@ else m_pMixStruct->Info.dwInputRouting &= ~MIXPLUG_INPUTF_BYPASS; + Dispatch(effSetBypass, bypass ? 1 : 0, nullptr, nullptr, 0.0f); + #ifdef MODPLUG_TRACKER if (m_pModDoc) m_pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); @@ -2984,17 +2988,7 @@ return bypass; } -bool CVstPlugin::Bypass() -//----------------------- -{ - return Bypass(!IsBypassed()); -} -bool CVstPlugin::IsBypassed() -//--------------------------- -{ - return ((m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_BYPASS) != 0); -} //end rewbs.defaultPlugGui //rewbs.defaultPlugGui: CVstEditor now COwnerVstEditor @@ -4082,7 +4076,7 @@ const char* SNDMIXPLUGIN::GetLibraryName() //------------------------------------ { - Info.szLibraryName[63] = 0; + StringFixer::SetNullTerminator(Info.szLibraryName); if(Info.szLibraryName[0]) return Info.szLibraryName; else return 0; } @@ -4099,3 +4093,24 @@ else return CString(); } + + +bool SNDMIXPLUGIN::Bypass(bool bypass) +//------------------------------------ +{ + if(pMixPlugin) + { + return pMixPlugin->Bypass(bypass); + } else + { + // No plugin loaded, just toggle the flags. + if(bypass) + { + Info.dwInputRouting |= MIXPLUG_INPUTF_BYPASS; + } else + { + Info.dwInputRouting &= ~MIXPLUG_INPUTF_BYPASS; + } + return bypass; + } +} Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2011-10-21 15:35:19 UTC (rev 1114) +++ trunk/OpenMPT/mptrack/Vstplug.h 2011-10-21 17:25:25 UTC (rev 1115) @@ -152,10 +152,10 @@ BOOL ExecuteCommand(UINT nIndex); CAbstractVstEditor* GetEditor(); //rewbs.defaultPlugGUI BOOL GetSpeakerArrangement(); //rewbs.VSTCompliance - bool Bypass(bool); //rewbs.defaultPlugGUI - bool Bypass(); //rewbs.defaultPlugGUI - bool IsBypassed(); //rewbs.defaultPlugGUI + bool Bypass(bool bypass = true); //rewbs.defaultPlugGUI + bool IsBypassed() const { return m_pMixStruct->IsBypassed(); }; //rewbs.defaultPlugGUI + bool isInstrument(); // ericus 18/02/2005 bool CanRecieveMidiEvents(); @@ -193,7 +193,6 @@ void SetDryRatio(UINT param); void AutomateParameter(PlugParamIndex param); - void SetZxxParameter(UINT nParam, UINT nValue); UINT GetZxxParameter(UINT nParam); //rewbs.smoothVST @@ -219,6 +218,7 @@ void SetParameter(PlugParamIndex, PlugParamValue) {} CString GetFormattedParamName(PlugParamIndex) { return ""; }; + CString GetFormattedParamValue(PlugParamIndex){ return ""; }; CString GetParamName(PlugParamIndex) { return ""; }; CString GetParamLabel(PlugParamIndex) { return ""; }; CString GetParamDisplay(PlugParamIndex) { return ""; }; @@ -230,8 +230,10 @@ BOOL ExecuteCommand(UINT) {return FALSE;} void SetSlot(UINT) {} void UpdateMixStructPtr(void*) {} - bool Bypass() {return false;} + bool Bypass(bool) { return false; } + bool IsBypassed() const { return false; } + #endif // NO_VST }; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-10-21 15:35:19 UTC (rev 1114) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-10-21 17:25:25 UTC (rev 1115) @@ -384,15 +384,19 @@ virtual PlugParamValue GetParameter(PlugParamIndex nIndex) = 0; virtual UINT GetZxxParameter(UINT nParam) = 0; //rewbs.smoothVST virtual void ModifyParameter(PlugParamIndex nIndex, PlugParamValue diff); + virtual void AutomateParameter(PlugParamIndex param) = 0; virtual VstIntPtr Dispatch(VstInt32 opCode, VstInt32 index, VstIntPtr value, void *ptr, float opt) =0; //rewbs.VSTCompliance - virtual void NotifySongPlaying(bool)=0; //rewbs.VSTCompliance - virtual bool IsSongPlaying()=0; - virtual bool IsResumed()=0; - virtual void Resume()=0; - virtual void Suspend()=0; - virtual bool isInstrument()=0; - virtual bool CanRecieveMidiEvents()=0; - virtual void SetDryRatio(UINT param)=0; + virtual void NotifySongPlaying(bool) = 0; //rewbs.VSTCompliance + virtual bool IsSongPlaying() = 0; + virtual bool IsResumed() = 0; + virtual void Resume() = 0; + virtual void Suspend() = 0; + virtual bool Bypass(bool = true) = 0; + virtual bool IsBypassed() const = 0; + bool ToggleBypass() { return Bypass(!IsBypassed()); }; + virtual bool isInstrument() = 0; + virtual bool CanRecieveMidiEvents() = 0; + virtual void SetDryRatio(UINT param) = 0; }; @@ -445,6 +449,8 @@ const char* GetName() const {return Info.szName;} const char* GetLibraryName(); CString GetParamName(const UINT index) const; + bool Bypass(bool bypass); + bool IsBypassed() const { return (Info.dwInputRouting & MIXPLUG_INPUTF_BYPASS) != 0; }; IMixPlugin *pMixPlugin; PSNDMIXPLUGINSTATE pMixState; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |