// After adding new plugins, check if they were missing in any open songs. void CSelectPluginDlg::ReloadMissingPlugins(const VSTPluginLib *lib) const //------------------------------------------------------------------------ { CVstPluginManager *pManager = theApp.GetPluginManager(); auto docs = theApp.GetOpenDocuments(); for(size_t i = 0; i < docs.size(); i++) { CModDoc &doc = *docs[i]; CSoundFile &sndFile = doc.GetrSoundFile(); bool updateDoc = false; for(PLUGINDEX plug = 0; plug < MAX_MIXPLUGINS; plug++) { SNDMIXPLUGIN &plugin = sndFile.m_MixPlugins[plug]; if(plugin.pMixPlugin == nullptr && plugin.Info.dwPluginId1 == lib->pluginId1 && plugin.Info.dwPluginId2 == lib->pluginId2) { pManager->CreateMixPlugin(plugin, sndFile); if(plugin.pMixPlugin) { plugin.pMixPlugin->RestoreAllParameters(plugin.defaultProgram); } } } if(updateDoc) { doc.UpdateAllViews(nullptr, PluginHint().Info().Names()); CMainFrame::GetMainFrame()->UpdateTree(&doc, PluginHint().Info().Names()); } } }
bool CVstPluginManager::CreateMixPluginProc(SNDMIXPLUGIN &mixPlugin, CSoundFile &sndFile) //--------------------------------------------------------------------------------------- { CVstPluginManager *that = theApp.GetPluginManager(); if(that) { return that->CreateMixPlugin(mixPlugin, sndFile); } return false; }
void CSelectPluginDlg::OnOK() //--------------------------- { if(m_pPlugin==nullptr) { CDialog::OnOK(); return; } bool changed = false; CVstPluginManager *pManager = theApp.GetPluginManager(); VSTPluginLib *pNewPlug = GetSelectedPlugin(); VSTPluginLib *pFactory = nullptr; IMixPlugin *pCurrentPlugin = nullptr; if (m_pPlugin) pCurrentPlugin = m_pPlugin->pMixPlugin; if ((pManager) && (pManager->IsValidPlugin(pNewPlug))) pFactory = pNewPlug; if (pFactory) { // Plugin selected if ((!pCurrentPlugin) || &pCurrentPlugin->GetPluginFactory() != pFactory) { CriticalSection cs; // Destroy old plugin, if there was one. m_pPlugin->Destroy(); // Initialize plugin info MemsetZero(m_pPlugin->Info); m_pPlugin->Info.dwPluginId1 = pFactory->pluginId1; m_pPlugin->Info.dwPluginId2 = pFactory->pluginId2; m_pPlugin->editorX = m_pPlugin->editorY = int32_min; #ifndef NO_VST if(m_pPlugin->Info.dwPluginId1 == kEffectMagic) { switch(m_pPlugin->Info.dwPluginId2) { // Enable drymix by default for these known plugins case CCONST('S', 'c', 'o', 'p'): m_pPlugin->SetWetMix(); break; } } #endif // NO_VST mpt::String::Copy(m_pPlugin->Info.szName, pFactory->libraryName.ToLocale().c_str()); mpt::String::Copy(m_pPlugin->Info.szLibraryName, pFactory->libraryName.ToUTF8().c_str()); cs.Leave(); // Now, create the new plugin if(pManager && m_pModDoc) { pManager->CreateMixPlugin(*m_pPlugin, m_pModDoc->GetrSoundFile()); if (m_pPlugin->pMixPlugin) { IMixPlugin *p = m_pPlugin->pMixPlugin; const CString name = p->GetDefaultEffectName(); if(!name.IsEmpty()) { mpt::String::Copy(m_pPlugin->Info.szName, name.GetString()); } // Check if plugin slot is already assigned to any instrument, and if not, create one. if(p->IsInstrument() && m_pModDoc->HasInstrumentForPlugin(m_nPlugSlot) == INSTRUMENTINDEX_INVALID) { m_pModDoc->InsertInstrumentForPlugin(m_nPlugSlot); } } else { MemsetZero(m_pPlugin->Info); } } changed = true; } } else if(m_pPlugin->IsValidPlugin()) { // No effect CriticalSection cs; m_pPlugin->Destroy(); // Clear plugin info MemsetZero(m_pPlugin->Info); changed = true; } //remember window size: SaveWindowPos(); if(changed) { if(m_pPlugin->Info.dwPluginId2) TrackerSettings::Instance().gnPlugWindowLast = m_pPlugin->Info.dwPluginId2; if(m_pModDoc) { m_pModDoc->UpdateAllViews(nullptr, PluginHint(static_cast<PLUGINDEX>(m_nPlugSlot + 1)).Info().Names()); } CDialog::OnOK(); } else { CDialog::OnCancel(); } }