From: <sag...@us...> - 2012-03-03 15:14:45
|
Revision: 1201 http://modplug.svn.sourceforge.net/modplug/?rev=1201&view=rev Author: saga-games Date: 2012-03-03 15:14:35 +0000 (Sat, 03 Mar 2012) Log Message: ----------- [Ref] Encapsulated various SNDMIXPLUGININFO variables in getter / setter functions as access to them was not very intuitive most of the time. [Ref] Made exception handler use the already existing GetOpenDocuments function. [Ref] Removed NO_FILTER #ifdefs from player engine (still preset in mixing engine). Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp trunk/OpenMPT/mptrack/MPTHacks.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.h trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp trunk/OpenMPT/mptrack/SoundFilePlayConfig.h trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/PlugInterface.h trunk/OpenMPT/soundlib/Sampleio.cpp trunk/OpenMPT/soundlib/Snd_flt.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -291,13 +291,12 @@ if (m_pVstPlugin && m_pVstPlugin->m_pMixStruct) { CString Title; - Title.Format("FX %02d: ", m_pVstPlugin->m_nSlot+1); + Title.Format("FX %02d: ", m_pVstPlugin->m_nSlot + 1); - if (m_pVstPlugin->m_pMixStruct->Info.szName[0]) { - Title.Append(m_pVstPlugin->m_pMixStruct->Info.szName); - } else { - Title.Append(m_pVstPlugin->m_pMixStruct->Info.szLibraryName); - } + if (strcmp(m_pVstPlugin->m_pMixStruct->GetName(), "")) + Title.Append(m_pVstPlugin->m_pMixStruct->GetName()); + else + Title.Append(m_pVstPlugin->m_pMixStruct->GetLibraryName()); SetWindowText(Title); } @@ -495,8 +494,8 @@ m_pVstPlugin->GetInputPlugList(inputPlugs); for (int nPlug=0; nPlug<inputPlugs.GetSize(); nPlug++) { - name.Format("FX%02d: %s", inputPlugs[nPlug]->m_nSlot+1, inputPlugs[nPlug]->m_pMixStruct->Info.szName); - m_pInputMenu->AppendMenu(MF_STRING, ID_PLUGSELECT+inputPlugs[nPlug]->m_nSlot, name); + name.Format("FX%02d: %s", inputPlugs[nPlug]->m_nSlot + 1, inputPlugs[nPlug]->m_pMixStruct->GetName()); + m_pInputMenu->AppendMenu(MF_STRING, ID_PLUGSELECT + inputPlugs[nPlug]->m_nSlot, name); } CArray<UINT, UINT> inputChannels; @@ -555,12 +554,13 @@ m_pVstPlugin->GetOutputPlugList(outputPlugs); CString name; - for (int nPlug = 0; nPlug < outputPlugs.GetSize(); nPlug++ - ) { - if (outputPlugs[nPlug] != NULL) { - name.Format("FX%02d: %s", outputPlugs[nPlug]->m_nSlot+1, - outputPlugs[nPlug]->m_pMixStruct->Info.szName); - m_pOutputMenu->AppendMenu(MF_STRING, ID_PLUGSELECT+outputPlugs[nPlug]->m_nSlot, name); + for (int nPlug = 0; nPlug < outputPlugs.GetSize(); nPlug++) + { + if (outputPlugs[nPlug] != nullptr) + { + name.Format("FX%02d: %s", outputPlugs[nPlug]->m_nSlot + 1, + outputPlugs[nPlug]->m_pMixStruct->GetName()); + m_pOutputMenu->AppendMenu(MF_STRING, ID_PLUGSELECT + outputPlugs[nPlug]->m_nSlot, name); } else { name = "Master Output"; @@ -772,8 +772,8 @@ ModInstrument *pIns = pSndFile->Instruments[nIns]; m_nInstrument = nIns; - _snprintf(pIns->name, CountOf(pIns->name) - 1, _T("%d: %s"), m_pVstPlugin->GetSlot() + 1, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].Info.szName); - strncpy(pIns->filename, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].Info.szLibraryName, CountOf(pIns->filename) - 1); + _snprintf(pIns->name, CountOf(pIns->name) - 1, _T("%d: %s"), m_pVstPlugin->GetSlot() + 1, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].GetName()); + strncpy(pIns->filename, pSndFile->m_MixPlugins[m_pVstPlugin->GetSlot()].GetLibraryName(), CountOf(pIns->filename) - 1); pIns->nMixPlug = (PLUGINDEX)m_pVstPlugin->GetSlot() + 1; pIns->nMidiChannel = 1; // People will forget to change this anyway, so the following lines can lead to some bad surprises after re-opening the module. Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -833,11 +833,11 @@ vector<bool> usedmap(MAX_MIXPLUGINS, false); - for (PLUGINDEX nPlug = 0; nPlug < MAX_MIXPLUGINS; nPlug++) + for(PLUGINDEX nPlug = 0; nPlug < MAX_MIXPLUGINS; nPlug++) { // Is the plugin assigned to a channel? - for (CHANNELINDEX nChn = 0; nChn < pSndFile->GetNumChannels(); nChn++) + for(CHANNELINDEX nChn = 0; nChn < pSndFile->GetNumChannels(); nChn++) { if (pSndFile->ChnSettings[nChn].nMixPlugin == nPlug + 1) { @@ -847,7 +847,7 @@ } // Is the plugin used by an instrument? - for (INSTRUMENTINDEX nIns = 1; nIns <= pSndFile->GetNumInstruments(); nIns++) + for(INSTRUMENTINDEX nIns = 1; nIns <= pSndFile->GetNumInstruments(); nIns++) { if (pSndFile->Instruments[nIns] && (pSndFile->Instruments[nIns]->nMixPlug == nPlug + 1)) { @@ -857,16 +857,19 @@ } // Is the plugin assigned to master? - if (pSndFile->m_MixPlugins[nPlug].Info.dwInputRouting & MIXPLUG_INPUTF_MASTEREFFECT) + if(pSndFile->m_MixPlugins[nPlug].IsMasterEffect()) usedmap[nPlug] = true; // All outputs of used plugins count as used - if (usedmap[nPlug] != false) + if(usedmap[nPlug] != false) { - if (pSndFile->m_MixPlugins[nPlug].Info.dwOutputRouting & 0x80) + if(!pSndFile->m_MixPlugins[nPlug].IsOutputToMaster()) { - int output = pSndFile->m_MixPlugins[nPlug].Info.dwOutputRouting & 0x7f; - usedmap[output] = true; + PLUGINDEX output = pSndFile->m_MixPlugins[nPlug].GetOutputPlugin(); + if(output < MAX_MIXPLUGINS) + { + usedmap[output] = true; + } } } Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -1229,7 +1229,7 @@ // MIDI Channel // XM has no "mapped" MIDI channels. m_CbnMidiCh.ResetContent(); - for (UINT ich = MidiNoChannel; ich <= (bITandMPT ? MidiMappedChannel : MidiLastChannel); ich++) + for(int ich = MidiNoChannel; ich <= (bITandMPT ? MidiMappedChannel : MidiLastChannel); ich++) { CString s; if (ich == MidiNoChannel) @@ -2141,12 +2141,13 @@ m_CbnPluginVelocityHandling.SetCurSel(pIns->nPluginVelocityHandling); m_CbnPluginVolumeHandling.SetCurSel(pIns->nPluginVolumeHandling); - if (pIns->nMixPlug) //if we have not just set to no plugin + if (pIns->nMixPlug) { - PSNDMIXPLUGIN pPlug = &(m_pSndFile->m_MixPlugins[pIns->nMixPlug - 1]); - if ((pPlug == nullptr || pPlug->pMixPlugin == nullptr) && !IsLocked()) + // we have selected a plugin that's not "no plugin" + const SNDMIXPLUGIN &plugin = m_pSndFile->m_MixPlugins[pIns->nMixPlug - 1]; + if(!plugin.IsValidPlugin() && !IsLocked()) { - // No plugin in this slot: Ask user to add one. + // No plugin in this slot yet: Ask user to add one. #ifndef NO_VST CSelectPluginDlg dlg(m_pModDoc, nPlug - 1, this); if (dlg.DoModal() == IDOK) @@ -2161,13 +2162,13 @@ #endif // NO_VST } - if (pPlug && pPlug->pMixPlugin) + if(plugin.pMixPlugin) { ::EnableWindow(::GetDlgItem(m_hWnd, IDC_INSVIEWPLG), true); // if this plug can recieve MIDI events and we have no MIDI channel // selected for this instrument, automatically select MIDI channel 1. - if (pPlug->pMixPlugin->isInstrument() && pIns->nMidiChannel == 0) + if(plugin.pMixPlugin->isInstrument() && pIns->nMidiChannel == 0) { pIns->nMidiChannel = 1; UpdateView((m_nInstrument << HINT_SHIFT_INS) | HINT_INSTRUMENT, NULL); @@ -2855,16 +2856,15 @@ CHAR s[64]; for (PLUGINDEX nPlug = 0; nPlug <= MAX_MIXPLUGINS; nPlug++) { - if (!nPlug) + if(!nPlug) { strcpy(s, "No plugin"); } else { - PSNDMIXPLUGIN p = &(m_pSndFile->m_MixPlugins[nPlug - 1]); - p->Info.szLibraryName[63] = 0; - if (p->Info.szLibraryName[0]) - wsprintf(s, "FX%d: %s", nPlug, p->Info.szName); + const SNDMIXPLUGIN &plugin = m_pSndFile->m_MixPlugins[nPlug - 1]; + if(plugin.IsValidPlugin()) + wsprintf(s, "FX%d: %s", nPlug, plugin.GetName()); else wsprintf(s, "FX%d: undefined", nPlug); } Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -1232,15 +1232,16 @@ void CCtrlPatterns::TogglePluginEditor() //-------------------------------------- { - if(m_nInstrument && m_pModDoc && m_pSndFile && m_pSndFile->Instruments[m_nInstrument]) + if(m_nInstrument && m_pModDoc && m_pSndFile && m_pSndFile->Instruments[m_nInstrument] != nullptr) { - UINT nPlug = m_pSndFile->Instruments[m_nInstrument]->nMixPlug; - if (nPlug) //if not no plugin + PLUGINDEX nPlug = m_pSndFile->Instruments[m_nInstrument]->nMixPlug; + if(nPlug) { - PSNDMIXPLUGIN pPlug = &(m_pSndFile->m_MixPlugins[nPlug-1]); - if (pPlug && pPlug->pMixPlugin) //if has valid plugin + // Has a plugin assigned + if(m_pSndFile->m_MixPlugins[nPlug - 1].pMixPlugin != nullptr) { - m_pModDoc->TogglePluginEditor(nPlug-1); + // Has a valid plugin assigned + m_pModDoc->TogglePluginEditor(nPlug - 1); } } } @@ -1250,16 +1251,13 @@ bool CCtrlPatterns::HasValidPlug(UINT instr) //------------------------------------------ { - if ((instr) && (instr<MAX_INSTRUMENTS) && (m_pSndFile) && m_pSndFile->Instruments[instr]) + if ((instr) && (instr < MAX_INSTRUMENTS) && (m_pSndFile) && m_pSndFile->Instruments[instr] != nullptr) { - UINT nPlug = m_pSndFile->Instruments[instr]->nMixPlug; - if (nPlug) //if not no plugin + PLUGINDEX nPlug = m_pSndFile->Instruments[instr]->nMixPlug; + if(nPlug) { - PSNDMIXPLUGIN pPlug = &(m_pSndFile->m_MixPlugins[nPlug-1]); - if (pPlug && pPlug->pMixPlugin) //if has valid plugin - { - return true ; - } + // Has a plugin assigned + return (m_pSndFile->m_MixPlugins[nPlug - 1].pMixPlugin != nullptr); } } return false; Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -631,7 +631,7 @@ rect.bottom+=PLUGNAME_HEIGHT; mixPlug=pSndFile->ChnSettings[ncolhdr].nMixPlugin; if (mixPlug) { - wsprintf(s, "%d: %s", mixPlug, (pSndFile->m_MixPlugins[mixPlug-1]).pMixPlugin?(pSndFile->m_MixPlugins[mixPlug-1]).Info.szName:"[empty]"); + wsprintf(s, "%d: %s", mixPlug, (pSndFile->m_MixPlugins[mixPlug - 1]).pMixPlugin ? (pSndFile->m_MixPlugins[mixPlug - 1]).GetName() : "[empty]"); } else { wsprintf(s, "---"); } Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -53,8 +53,13 @@ // Shut down audio device... if(pMainFrame) { - if(pMainFrame->gpSoundDevice) pMainFrame->gpSoundDevice->Reset(); - pMainFrame->audioCloseDevice(); + try + { + if(pMainFrame->gpSoundDevice) pMainFrame->gpSoundDevice->Reset(); + pMainFrame->audioCloseDevice(); + } catch(...) + { + } } CString errorMessage; @@ -106,41 +111,34 @@ } // Rescue modified files... - CDocTemplate *pDocTmpl = theApp.GetModDocTemplate(); - if(pDocTmpl) + int numFiles = 0; + vector<CModDoc *> documents = theApp.GetOpenDocuments(); + for(vector<CModDoc *>::iterator doc = documents.begin(); doc != documents.end(); doc++) { - POSITION pos = pDocTmpl->GetFirstDocPosition(); - CDocument *pDoc; - - int numFiles = 0; - - while((pos != NULL) && ((pDoc = pDocTmpl->GetNextDoc(pos)) != NULL)) + CModDoc *pModDoc = *doc; + if(pModDoc->IsModified() && pModDoc->GetSoundFile() != nullptr) { - CModDoc *pModDoc = (CModDoc *)pDoc; - if(pModDoc->IsModified() && pModDoc->GetSoundFile() != nullptr) + if(numFiles == 0) { - if(numFiles == 0) - { - // Show the rescue directory in Explorer... - CTrackApp::OpenDirectory(baseRescuePath); - } - CString filename; - filename.Format("%s%d_%s.%s", baseRescuePath, ++numFiles, pModDoc->GetTitle(), pModDoc->GetSoundFile()->GetModSpecifications().fileExtension); + // Show the rescue directory in Explorer... + CTrackApp::OpenDirectory(baseRescuePath); + } + CString filename; + filename.Format("%s%d_%s.%s", baseRescuePath, ++numFiles, pModDoc->GetTitle(), pModDoc->GetSoundFile()->GetModSpecifications().fileExtension); - try - { - pModDoc->OnSaveDocument(filename); - } catch(...) - { - continue; - } + try + { + pModDoc->OnSaveDocument(filename); + } catch(...) + { + continue; } } + } - if(numFiles > 0) - { - errorMessage.AppendFormat("\n\n%d modified file%s been rescued, but it cannot be guaranteed that %s still intact.", numFiles, (numFiles == 1 ? " has" : "s have"), (numFiles == 1 ? "it is" : "they are")); - } + if(numFiles > 0) + { + errorMessage.AppendFormat("\n\n%d modified file%s been rescued, but it cannot be guaranteed that %s still intact.", numFiles, (numFiles == 1 ? " has" : "s have"), (numFiles == 1 ? "it is" : "they are")); } Reporting::Error(errorMessage, "OpenMPT Crash", pMainFrame); Modified: trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -126,14 +126,14 @@ } UpdateMacroList(); - for(PLUGINDEX plug = 0; plug < MAX_MIXPLUGINS; plug++) + for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++) { - PSNDMIXPLUGIN p = &(m_SndFile.m_MixPlugins[plug]); - StringFixer::SetNullTerminator(p->Info.szLibraryName); - if (p->Info.szLibraryName[0]) + const SNDMIXPLUGIN &plugin = m_SndFile.m_MixPlugins[i]; + + if(plugin.IsValidPlugin()) { - wsprintf(s, "FX%d: %s", plug + 1, p->Info.szName); - m_CbnMacroPlug.SetItemData(m_CbnMacroPlug.AddString(s), plug); + wsprintf(s, "FX%d: %s", i + 1, plugin.GetName()); + m_CbnMacroPlug.SetItemData(m_CbnMacroPlug.AddString(s), i); } } m_CbnMacroPlug.SetCurSel(0); @@ -369,7 +369,7 @@ for(PLUGINDEX plug = 0; plug < MAX_MIXPLUGINS; plug++) { - plugName = m_SndFile.m_MixPlugins[plug].Info.szName; + plugName = m_SndFile.m_MixPlugins[plug].GetName(); if(m_SndFile.m_MixPlugins[plug].Info.dwPluginId1 != 0) { pVstPlugin = (CVstPlugin*) m_SndFile.m_MixPlugins[plug].pMixPlugin; @@ -392,10 +392,9 @@ if (plug < 0 || plug > MAX_MIXPLUGINS) return; - PSNDMIXPLUGIN pPlugin = &m_SndFile.m_MixPlugins[plug]; - CVstPlugin *pVstPlugin = (pPlugin->pMixPlugin) ? (CVstPlugin *)pPlugin->pMixPlugin : NULL; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(m_SndFile.m_MixPlugins[plug].pMixPlugin); - if (pVstPlugin) + if (pVstPlugin != nullptr) { m_CbnMacroParam.SetRedraw(FALSE); m_CbnMacroParam.Clear(); Modified: trunk/OpenMPT/mptrack/MPTHacks.cpp =================================================================== --- trunk/OpenMPT/mptrack/MPTHacks.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/MPTHacks.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -182,7 +182,7 @@ foundHere = false; for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; i++) { - if(m_SndFile.m_MixPlugins[i].pMixPlugin != nullptr || m_SndFile.m_MixPlugins[i].Info.dwPluginId1 || m_SndFile.m_MixPlugins[i].Info.dwPluginId2) + if(m_SndFile.m_MixPlugins[i].IsValidPlugin()) { foundHere = foundHacks = true; break; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -1895,16 +1895,16 @@ { CSoundFile *pSndFile = pModDoc->GetSoundFile(); //Find empty plugin slot - for (int nPlug=0; nPlug<MAX_MIXPLUGINS; nPlug++) + for (PLUGINDEX nPlug = 0; nPlug < MAX_MIXPLUGINS; nPlug++) { - PSNDMIXPLUGIN pCandidatePlugin = &pSndFile->m_MixPlugins[nPlug]; - if (pCandidatePlugin->pMixPlugin == NULL) + if (pSndFile->m_MixPlugins[nPlug].pMixPlugin == NULL) { - nPlugslot=nPlug; + nPlugslot = nPlug; break; } } } + CSelectPluginDlg dlg(GetActiveDoc(), nPlugslot, this); if(dlg.DoModal() == IDOK && pModDoc) { @@ -2681,12 +2681,12 @@ { for (PLUGINDEX iPlug = 0; iPlug < MAX_MIXPLUGINS; iPlug++) { - PSNDMIXPLUGIN p = &plugarray[iPlug]; + const SNDMIXPLUGIN &plugin = plugarray[iPlug]; CString str; str.Preallocate(80); str.Format(_T("FX%d: "), iPlug + 1); const int size0 = str.GetLength(); - str += (librarynames) ? p->GetLibraryName() : p->GetName(); + str += (librarynames) ? plugin.GetLibraryName() : plugin.GetName(); if(str.GetLength() <= size0) str += _T("undefined"); CBox.SetItemData(CBox.AddString(str), iPlug + 1); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -2511,12 +2511,11 @@ void CModDoc::TogglePluginEditor(UINT m_nCurrentPlugin) //----------------------------------------------------- { - PSNDMIXPLUGIN pPlugin; + SNDMIXPLUGIN &plugin = m_SndFile.m_MixPlugins[m_nCurrentPlugin]; - pPlugin = &m_SndFile.m_MixPlugins[m_nCurrentPlugin]; - if (m_nCurrentPlugin<MAX_MIXPLUGINS && pPlugin && pPlugin->pMixPlugin) + if (m_nCurrentPlugin < MAX_MIXPLUGINS && plugin.pMixPlugin) { - CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(plugin.pMixPlugin); pVstPlugin->ToggleEditor(); } Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -14,6 +14,7 @@ #include "Mainfrm.h" #include "Moddoc.h" #include "SelectPluginDialog.h" +#include "../common/StringFixer.h" #ifndef NO_VST @@ -139,12 +140,14 @@ { // Enable drymix by default for these known plugins case CCONST('S', 'c', 'o', 'p'): - m_pPlugin->Info.dwInputRouting |= MIXPLUG_INPUTF_WETMIX; + m_pPlugin->SetWetMix(); break; } lstrcpyn(m_pPlugin->Info.szName, pFactory->szLibraryName, 32); lstrcpyn(m_pPlugin->Info.szLibraryName, pFactory->szLibraryName, 64); + StringFixer::SetNullTerminator(m_pPlugin->Info.szName); + StringFixer::SetNullTerminator(m_pPlugin->Info.szLibraryName); cs.Leave(); Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.h =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.h 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.h 2012-03-03 15:14:35 UTC (rev 1201) @@ -21,7 +21,7 @@ { protected: int m_nPlugSlot; - PSNDMIXPLUGIN m_pPlugin; + SNDMIXPLUGIN *m_pPlugin; CModDoc *m_pModDoc; CTreeCtrl m_treePlugins; CString m_sNameFilter; Modified: trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp =================================================================== --- trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/SoundFilePlayConfig.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -113,23 +113,6 @@ setExtraSampleAttenuation(1); break; - // FOR TEST PURPOSES ONLY: - /* - case mixLevels_Test: - setVSTiAttenuation(1.0f); - setIntToFloat(1.0f/static_cast<float>(MIXING_CLIPMAX)); - setFloatToInt(static_cast<float>(MIXING_CLIPMAX)); - setGlobalVolumeAppliesToMaster(true); - setUseGlobalPreAmp(false); - setForceSoftPanning(true); - setDisplayDBValues(true); - setNormalSamplePreAmp(128.0); - setNormalVSTiVol(128.0); - setNormalGlobalVol(256.0); - setExtraAttenuation(0); - break; - */ - } return; Modified: trunk/OpenMPT/mptrack/SoundFilePlayConfig.h =================================================================== --- trunk/OpenMPT/mptrack/SoundFilePlayConfig.h 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/SoundFilePlayConfig.h 2012-03-03 15:14:35 UTC (rev 1201) @@ -25,14 +25,13 @@ tempo_mode_modern = 2, }; -enum +enum mixLevels { mixLevels_original = 0, mixLevels_117RC1 = 1, mixLevels_117RC2 = 2, mixLevels_117RC3 = 3, mixLevels_compatible = 4, - mixLevels_Test = 5, }; enum forcePanningMode Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -238,7 +238,7 @@ } -VOID CViewGlobals::OnDestroy() +void CViewGlobals::OnDestroy() //---------------------------- { CChildFrame *pFrame = (CChildFrame *)GetParentFrame(); @@ -391,12 +391,11 @@ int fxsel = 0; for (UINT ifx=0; ifx<MAX_MIXPLUGINS; ifx++) { - if ((pSndFile->m_MixPlugins[ifx].Info.dwPluginId1) - || (pSndFile->m_MixPlugins[ifx].Info.dwPluginId2) - || (pSndFile->m_MixPlugins[ifx].Info.szName[0] - || (pSndFile->ChnSettings[nChn].nMixPlugin == ifx+1))) + if (pSndFile->m_MixPlugins[ifx].IsValidPlugin() + || (strcmp(pSndFile->m_MixPlugins[ifx].GetName(), "") + || (pSndFile->ChnSettings[nChn].nMixPlugin == ifx + 1))) { - wsprintf(s, "FX%d: %s", ifx+1, pSndFile->m_MixPlugins[ifx].Info.szName); + wsprintf(s, "FX%d: %s", ifx + 1, pSndFile->m_MixPlugins[ifx].GetName()); int n = m_CbnEffects[ichn].AddString(s); m_CbnEffects[ichn].SetItemData(n, ifx+1); if (pSndFile->ChnSettings[nChn].nMixPlugin == ifx+1) fxsel = n; @@ -434,16 +433,16 @@ m_CbnPlugin.SetRedraw(TRUE); m_CbnPlugin.SetCurSel(m_nCurrentPlugin); if (m_nCurrentPlugin >= MAX_MIXPLUGINS) m_nCurrentPlugin = 0; - 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->IsBypassed()) ? TRUE : FALSE); - CheckDlgButton(IDC_CHECK11, (pPlugin->Info.dwInputRouting & MIXPLUG_INPUTF_WETMIX) ? TRUE : FALSE); + SNDMIXPLUGIN *pPlugin = &(pSndFile->m_MixPlugins[m_nCurrentPlugin]); + SetDlgItemText(IDC_EDIT13, pPlugin->GetName()); + CheckDlgButton(IDC_CHECK9, pPlugin->IsMasterEffect() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_CHECK10, pPlugin->IsBypassed() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_CHECK11, pPlugin->IsWetMix() ? BST_CHECKED : BST_UNCHECKED); CVstPlugin *pVstPlugin = (pPlugin->pMixPlugin) ? (CVstPlugin *)pPlugin->pMixPlugin : NULL; m_BtnEdit.EnableWindow(((pVstPlugin) && ((pVstPlugin->HasEditor()) || (pVstPlugin->GetNumCommands()))) ? TRUE : FALSE); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_MOVEFXSLOT), (pVstPlugin)?TRUE:FALSE); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_INSERTFXSLOT), (pVstPlugin)?TRUE:FALSE); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CLONEPLUG), (pVstPlugin)?TRUE:FALSE); + ::EnableWindow(::GetDlgItem(m_hWnd, IDC_MOVEFXSLOT), (pVstPlugin) ? TRUE : FALSE); + ::EnableWindow(::GetDlgItem(m_hWnd, IDC_INSERTFXSLOT), (pVstPlugin) ? TRUE : FALSE); + ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CLONEPLUG), (pVstPlugin) ? TRUE : FALSE); //rewbs.DryRatio int n = static_cast<int>(pPlugin->fDryRatio*100); wsprintf(s, "(%d%% wet, %d%% dry)", 100-n, n); @@ -462,14 +461,14 @@ else{ ::EnableWindow(::GetDlgItem(m_hWnd, IDC_COMBO9), TRUE); ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK12), TRUE); - m_CbnSpecialMixProcessing.SetCurSel( (pPlugin->Info.dwInputRouting>>8) & 0xff ); // update#02 (fix) - CheckDlgButton(IDC_CHECK12, (pPlugin->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND) ? TRUE : FALSE); + m_CbnSpecialMixProcessing.SetCurSel(pPlugin->GetMixMode()); // update#02 (fix) + CheckDlgButton(IDC_CHECK12, pPlugin->IsExpandedMix() ? BST_CHECKED : BST_UNCHECKED); } // update#02 - DWORD gain = (pPlugin->Info.dwInputRouting>>16) & 0xff; + int gain = pPlugin->GetGain(); if(gain == 0) gain = 10; float value = 0.1f * (float)gain; - sprintf(s,"Gain: x %1.1f",value); + sprintf(s,"Gain: x %1.1f", value); SetDlgItemText(IDC_STATIC2, s); m_SpinMixGain.SetPos(gain); // -! BEHAVIOUR_CHANGE#0028 @@ -537,21 +536,21 @@ m_CbnOutput.SetItemData(m_CbnOutput.AddString("Default"), 0); for (PLUGINDEX iOut = m_nCurrentPlugin + 1; iOut < MAX_MIXPLUGINS; iOut++) { - PSNDMIXPLUGIN p = &pSndFile->m_MixPlugins[iOut]; - if (p->Info.dwPluginId1) + const SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[iOut]; + if(plugin.IsValidPlugin()) { - if(!strcmp(p->Info.szLibraryName, p->Info.szName) || strlen(p->Info.szName) == 0) + if(!strcmp(plugin.GetLibraryName(), plugin.GetName()) || !strcmp(plugin.GetName(), "")) { - wsprintf(s, "FX%d: %s", iOut + 1, p->Info.szLibraryName); + wsprintf(s, "FX%d: %s", iOut + 1, plugin.GetLibraryName()); } else { - wsprintf(s, "FX%d: %s (%s)", iOut + 1, p->Info.szLibraryName, p->Info.szName); + wsprintf(s, "FX%d: %s (%s)", iOut + 1, plugin.GetLibraryName(), plugin.GetName()); } int n = m_CbnOutput.AddString(s); - m_CbnOutput.SetItemData(n, 0x80|iOut); - if ((pSndFile->m_MixPlugins[m_nCurrentPlugin].Info.dwOutputRouting & 0x80) - && ((pSndFile->m_MixPlugins[m_nCurrentPlugin].Info.dwOutputRouting & 0x7f) == iOut)) + m_CbnOutput.SetItemData(n, 0x80 + iOut); + if (!pSndFile->m_MixPlugins[m_nCurrentPlugin].IsOutputToMaster() + && (pSndFile->m_MixPlugins[m_nCurrentPlugin].GetOutputPlugin() == iOut)) { outputsel = n; } @@ -708,14 +707,13 @@ if ((n >= 0) && (n <= 100) && (m_nCurrentPlugin < MAX_MIXPLUGINS)) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); - PSNDMIXPLUGIN pPlugin; + SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (pPlugin->pMixPlugin) + if (plugin.pMixPlugin) { - wsprintf(s, "(%d%% wet, %d%% dry)", 100-n, n); + wsprintf(s, "(%d%% wet, %d%% dry)", 100 - n, n); SetDlgItemText(IDC_STATIC8, s); - pPlugin->fDryRatio = static_cast<float>(n)/100.0f; + plugin.fDryRatio = static_cast<float>(n) / 100.0f; if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); } @@ -732,12 +730,11 @@ if ((n >= 0) && (n <= 100) && (m_nCurrentPlugin < MAX_MIXPLUGINS)) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); - PSNDMIXPLUGIN pPlugin; + SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (pPlugin->pMixPlugin) + if (plugin.pMixPlugin) { - CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(plugin.pMixPlugin); const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); if (m_nCurrentParam < nParams) { @@ -765,24 +762,22 @@ // -> CODE#0028 update#02 // -> DESC="effect plugin mixing mode combo" CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; - CSoundFile *pSndFile; + CSoundFile *pSndFile = pModDoc->GetSoundFile(); CHAR s[32]; if((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; - if(nSBCode != SB_ENDSCROLL && pScrollBar && pScrollBar == (CScrollBar*)&m_SpinMixGain){ + if(nSBCode != SB_ENDSCROLL && pScrollBar && pScrollBar == (CScrollBar*)&m_SpinMixGain) + { - pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; + SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if(pPlugin->pMixPlugin) + if(plugin.pMixPlugin) { DWORD gain = nPos; if(gain == 0) gain = 1; - pPlugin->Info.dwInputRouting = (pPlugin->Info.dwInputRouting & 0xff00ffff) | (gain<<16); - pPlugin->pMixPlugin->RecalculateGain(); + plugin.SetGain(gain); float fValue = 0.1f * (float)gain; sprintf(s,"Gain: x %1.1f",fValue); @@ -858,18 +853,18 @@ void CViewGlobals::OnPluginNameChanged() //-------------------------------------- { - CHAR s[64]; + CHAR s[32]; CModDoc *pModDoc = GetDocument(); if ((pModDoc) && (m_nCurrentPlugin < MAX_MIXPLUGINS)) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); - memset(s, 0, 32); + GetDlgItemText(IDC_EDIT13, s, 32); - s[31] = 0; - if (strcmp(s, pSndFile->m_MixPlugins[m_nCurrentPlugin].Info.szName)) + StringFixer::SetNullTerminator(s); + if (strcmp(s, pSndFile->m_MixPlugins[m_nCurrentPlugin].GetName())) { - memcpy(pSndFile->m_MixPlugins[m_nCurrentPlugin].Info.szName, s, 32); + lstrcpyn(pSndFile->m_MixPlugins[m_nCurrentPlugin].Info.szName, s, 32); if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); pModDoc->UpdateAllViews(NULL, HINT_MODCHANNELS | (m_nActiveTab << HINT_SHIFT_CHNTAB)); @@ -965,15 +960,15 @@ int cursel = m_CbnParam.GetItemData(m_CbnParam.GetCurSel()); CModDoc *pModDoc = GetDocument(); CHAR s[256]; - PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (pPlugin->pMixPlugin && cursel != CB_ERR) + SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; + + if (plugin.pMixPlugin && cursel != CB_ERR) { - CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(plugin.pMixPlugin); const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); if ((cursel >= 0) && (cursel < nParams)) m_nCurrentParam = cursel; if (m_nCurrentParam < nParams) @@ -1000,15 +995,15 @@ { int cursel = m_CbnPreset.GetCurSel(); CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (pPlugin->pMixPlugin) + SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; + + if (plugin.pMixPlugin) { - CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(plugin.pMixPlugin); UINT nParams = pVstPlugin->GetNumPrograms(); if ((cursel > 0) && (cursel <= (int)nParams)) m_nCurrentPreset = cursel; if (m_nCurrentPreset > 0 && m_nCurrentPreset <= nParams) @@ -1026,13 +1021,19 @@ //------------------------------ { CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - PSNDMIXPLUGIN pPlugin = pSndFile ? &pSndFile->m_MixPlugins[m_nCurrentPlugin] : NULL; - CVstPlugin *pVstPlugin = pPlugin ? (CVstPlugin *)pPlugin->pMixPlugin : NULL; + CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : nullptr; + if(pSndFile == nullptr) + { + return; + } - //rewbs.fxpPresets: changed Eric's code to use fxp load/save - if(pVstPlugin == NULL) return; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[m_nCurrentPlugin].pMixPlugin); + if(pVstPlugin == nullptr) + { + return; + } + FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "fxp", "", "VST FX Program (*.fxp)|*.fxp||", CMainFrame::GetSettings().GetDefaultDirectory(DIR_PLUGINPRESETS)); @@ -1055,13 +1056,18 @@ //------------------------------ { CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - PSNDMIXPLUGIN pPlugin = pSndFile ? &pSndFile->m_MixPlugins[m_nCurrentPlugin] : NULL; - CVstPlugin *pVstPlugin = pPlugin ? (CVstPlugin *)pPlugin->pMixPlugin : NULL; + CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : nullptr; + if(pSndFile == nullptr) + { + return; + } - if(pVstPlugin == NULL) return; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[m_nCurrentPlugin].pMixPlugin); - //rewbs.fxpPresets: changed Eric's code to use fxp load/save + if(pVstPlugin == nullptr) + { + return; + } FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "fxp", "", "VST Program (*.fxp)|*.fxp||", CMainFrame::GetSettings().GetDefaultDirectory(DIR_PLUGINPRESETS)); @@ -1076,19 +1082,19 @@ // -! NEW_FEATURE#0002 -VOID CViewGlobals::OnSetParameter() +void CViewGlobals::OnSetParameter() //--------------------------------- { CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (pPlugin->pMixPlugin) + SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; + + if (plugin.pMixPlugin != nullptr) { - CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(plugin.pMixPlugin); const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); CHAR s[32]; GetDlgItemText(IDC_EDIT14, s, sizeof(s)); @@ -1106,89 +1112,55 @@ // -> CODE#0014 // -> DESC="vst wet/dry slider" -VOID CViewGlobals::OnSetWetDry() +void CViewGlobals::OnSetWetDry() //------------------------------ { CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (pPlugin->pMixPlugin){ + SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; + + if (plugin.pMixPlugin != nullptr) + { //CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; UINT value = GetDlgItemIntEx(IDC_EDIT15); - pPlugin->fDryRatio = (float)value / 100.0f; + plugin.fDryRatio = (float)value / 100.0f; if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); //OnWetDryChanged(); } } -/* -void CViewGlobals::OnWetDryChanged() -{ - CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; - CSoundFile *pSndFile; - CHAR s[32]; - - if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; - pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - - if (pPlugin->pMixPlugin){ - CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; - UINT value = (UINT)(pPlugin->fDryRatio * 100.0f); - wsprintf(s, "%d", value); - SetDlgItemText(IDC_EDIT15, s); - m_sbWetDry.SetPos(value); - return; - } - - SetDlgItemText(IDC_EDIT15, ""); - m_sbWetDry.SetPos(0); -} -// -! NEW_FEATURE#0014 -*/ - -VOID CViewGlobals::OnMixModeChanged() +void CViewGlobals::OnMixModeChanged() //----------------------------------- { CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (IsDlgButtonChecked(IDC_CHECK9)) - { - pPlugin->Info.dwInputRouting |= MIXPLUG_INPUTF_MASTEREFFECT; - } else - { - pPlugin->Info.dwInputRouting &= ~MIXPLUG_INPUTF_MASTEREFFECT; - } + + pSndFile->m_MixPlugins[m_nCurrentPlugin].SetMasterEffect(IsDlgButtonChecked(IDC_CHECK9) != BST_UNCHECKED); if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); } -VOID CViewGlobals::OnBypassChanged() +void CViewGlobals::OnBypassChanged() //---------------------------------- { CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - pPlugin->Bypass(IsDlgButtonChecked(IDC_CHECK10) != FALSE); + pSndFile->m_MixPlugins[m_nCurrentPlugin].SetBypass(IsDlgButtonChecked(IDC_CHECK10) != BST_UNCHECKED); + if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); } @@ -1200,63 +1172,51 @@ //---------------------------------------- { CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (IsDlgButtonChecked(IDC_CHECK12)) - { - pPlugin->Info.dwInputRouting |= MIXPLUG_INPUTF_MIXEXPAND; - } else - { - pPlugin->Info.dwInputRouting &= ~MIXPLUG_INPUTF_MIXEXPAND; - } + pSndFile->m_MixPlugins[m_nCurrentPlugin].SetExpandedMix(IsDlgButtonChecked(IDC_CHECK12) != BST_UNCHECKED); + if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); } -VOID CViewGlobals::OnSpecialMixProcessingChanged() + +void CViewGlobals::OnSpecialMixProcessingChanged() //------------------------------------------------ { CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - PSNDMIXPLUGIN pPlugin = m_nCurrentPlugin < MAX_MIXPLUGINS && pSndFile ? &pSndFile->m_MixPlugins[m_nCurrentPlugin] : NULL; + CSoundFile *pSndFile; - if(!pPlugin) return; - pPlugin->Info.dwInputRouting = (pPlugin->Info.dwInputRouting & 0xffff00ff) | (m_CbnSpecialMixProcessing.GetCurSel()<<8); // update#02 (fix) + if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; + pSndFile = pModDoc->GetSoundFile(); + + pSndFile->m_MixPlugins[m_nCurrentPlugin].SetMixMode(m_CbnSpecialMixProcessing.GetCurSel()); // update#02 (fix) if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); } // -! BEHAVIOUR_CHANGE#0028 -VOID CViewGlobals::OnDryMixChanged() +void CViewGlobals::OnDryMixChanged() //---------------------------------- { CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (IsDlgButtonChecked(IDC_CHECK11)) - { - pPlugin->Info.dwInputRouting |= MIXPLUG_INPUTF_WETMIX; - } else - { - pPlugin->Info.dwInputRouting &= ~MIXPLUG_INPUTF_WETMIX; - } + pSndFile->m_MixPlugins[m_nCurrentPlugin].SetWetMix(IsDlgButtonChecked(IDC_CHECK11) != BST_UNCHECKED); + if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); } -VOID CViewGlobals::OnEditPlugin() +void CViewGlobals::OnEditPlugin() //------------------------------- { CModDoc *pModDoc = GetDocument(); @@ -1266,20 +1226,20 @@ } -VOID CViewGlobals::OnFxCommands(UINT id) +void CViewGlobals::OnFxCommands(UINT id) //-------------------------------------- { CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; UINT nIndex = id - ID_FXCOMMANDS_BASE; if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (pPlugin->pMixPlugin) + SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; + + if (plugin.pMixPlugin != nullptr) { - CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(plugin.pMixPlugin); pVstPlugin->ExecuteCommand(nIndex); if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); @@ -1287,19 +1247,23 @@ } -VOID CViewGlobals::OnOutputRoutingChanged() +void CViewGlobals::OnOutputRoutingChanged() //----------------------------------------- { CModDoc *pModDoc = GetDocument(); - PSNDMIXPLUGIN pPlugin; CSoundFile *pSndFile; int nroute; if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - pPlugin = &pSndFile->m_MixPlugins[m_nCurrentPlugin]; + SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; nroute = m_CbnOutput.GetItemData(m_CbnOutput.GetCurSel()); - pPlugin->Info.dwOutputRouting = nroute; + + if(!nroute) + plugin.SetOutputToMaster(); + else + plugin.SetOutputPlugin(static_cast<PLUGINDEX>(nroute - 0x80)); + if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); } @@ -1335,8 +1299,7 @@ { for(PLUGINDEX i = 0; i < m_nCurrentPlugin; i++) { - const DWORD toPlug = pSndFile->m_MixPlugins[i].Info.dwOutputRouting; - if((toPlug & 0x80) && (toPlug & 0x7F) == m_nCurrentPlugin) + if(pSndFile->m_MixPlugins[i].GetOutputPlugin() == m_nCurrentPlugin) { defaultIndex = i + 1; } @@ -1386,42 +1349,52 @@ CriticalSection cs; // Move plug data - memcpy(&(pSndFile->m_MixPlugins[dest]), &(pSndFile->m_MixPlugins[src]), sizeof(SNDMIXPLUGIN)); + MemCopy(pSndFile->m_MixPlugins[dest], pSndFile->m_MixPlugins[src]); MemsetZero(pSndFile->m_MixPlugins[src]); //Prevent plug from pointing backwards. - if (pSndFile->m_MixPlugins[dest].Info.dwOutputRouting & 0x80) { - UINT nOutput = pSndFile->m_MixPlugins[dest].Info.dwOutputRouting & 0x7f; - if (nOutput<=dest) { - pSndFile->m_MixPlugins[dest].Info.dwOutputRouting = 0; + if(!pSndFile->m_MixPlugins[dest].IsOutputToMaster()) + { + PLUGINDEX nOutput = pSndFile->m_MixPlugins[dest].GetOutputPlugin(); + if (nOutput <= dest) + { + pSndFile->m_MixPlugins[dest].SetOutputToMaster(); } } // Update current plug - if (pSndFile->m_MixPlugins[dest].pMixPlugin) { + if(pSndFile->m_MixPlugins[dest].pMixPlugin) + { ((CVstPlugin*)pSndFile->m_MixPlugins[dest].pMixPlugin)->SetSlot(dest); ((CVstPlugin*)pSndFile->m_MixPlugins[dest].pMixPlugin)->UpdateMixStructPtr(&(pSndFile->m_MixPlugins[dest])); } // Update all other plugs' outputs - for (PLUGINDEX nPlug=0; nPlug<src; nPlug++) { - if (pSndFile->m_MixPlugins[nPlug].Info.dwOutputRouting & 0x80) { - if ((pSndFile->m_MixPlugins[nPlug].Info.dwOutputRouting & 0x7f) == src) { - pSndFile->m_MixPlugins[nPlug].Info.dwOutputRouting = ((BYTE)dest)|0x80; + for (PLUGINDEX nPlug = 0; nPlug < src; nPlug++) + { + if(!pSndFile->m_MixPlugins[nPlug].IsOutputToMaster()) + { + if(pSndFile->m_MixPlugins[nPlug].GetOutputPlugin() == src) + { + pSndFile->m_MixPlugins[nPlug].SetOutputPlugin(dest); } } } // Update channels - for (CHANNELINDEX nChn=0; nChn<pSndFile->m_nChannels; nChn++) { - if (pSndFile->ChnSettings[nChn].nMixPlugin == src+1) { - pSndFile->ChnSettings[nChn].nMixPlugin = dest+1; + for (CHANNELINDEX nChn = 0; nChn < pSndFile->GetNumChannels(); nChn++) + { + if (pSndFile->ChnSettings[nChn].nMixPlugin == src + 1u) + { + pSndFile->ChnSettings[nChn].nMixPlugin = dest + 1u; } } // Update instruments - for (INSTRUMENTINDEX nIns=1; nIns<=pSndFile->m_nInstruments; nIns++) { - if (pSndFile->Instruments[nIns] && (pSndFile->Instruments[nIns]->nMixPlug == src+1)) { - pSndFile->Instruments[nIns]->nMixPlug = static_cast<BYTE>(dest+1); + for (INSTRUMENTINDEX nIns = 1; nIns <= pSndFile->GetNumInstruments(); nIns++) + { + if (pSndFile->Instruments[nIns] && (pSndFile->Instruments[nIns]->nMixPlug == src + 1)) + { + pSndFile->Instruments[nIns]->nMixPlug = dest + 1u; } } @@ -1522,8 +1495,7 @@ CSoundFile *pSndFile = GetDocument()->GetSoundFile(); if(pSndFile == nullptr) return; if (m_nCurrentPlugin >= MAX_MIXPLUGINS) m_nCurrentPlugin = 0; - PSNDMIXPLUGIN pPlugin = &(pSndFile->m_MixPlugins[m_nCurrentPlugin]); - CVstPlugin *pVstPlugin = (pPlugin->pMixPlugin) ? (CVstPlugin *)pPlugin->pMixPlugin : nullptr; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[m_nCurrentPlugin].pMixPlugin); if(pVstPlugin == nullptr) return; const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); @@ -1553,8 +1525,7 @@ CSoundFile *pSndFile = GetDocument()->GetSoundFile(); if(pSndFile == nullptr) return; if (m_nCurrentPlugin >= MAX_MIXPLUGINS) m_nCurrentPlugin = 0; - PSNDMIXPLUGIN pPlugin = &(pSndFile->m_MixPlugins[m_nCurrentPlugin]); - CVstPlugin *pVstPlugin = (pPlugin->pMixPlugin) ? (CVstPlugin *)pPlugin->pMixPlugin : nullptr; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[m_nCurrentPlugin].pMixPlugin); if(pVstPlugin == nullptr) return; UINT nProg = pVstPlugin->GetNumPrograms(); Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -5138,23 +5138,23 @@ bool CViewPattern::BuildPluginCtxMenu(HMENU hMenu, UINT nChn, CSoundFile *pSndFile) const //--------------------------------------------------------------------------------------- { - for (UINT plug=0; plug<=MAX_MIXPLUGINS; plug++) + for(PLUGINDEX plug = 0; plug <= MAX_MIXPLUGINS; plug++) { bool itemFound = false; CHAR s[64]; - if (!plug) + if(!plug) { strcpy(s, "No plugin"); itemFound = true; } else { - PSNDMIXPLUGIN p = &(pSndFile->m_MixPlugins[plug - 1]); - if (p->Info.szLibraryName[0]) + const SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[plug - 1]; + if(plugin.IsValidPlugin()) { - wsprintf(s, "FX%d: %s", plug, p->Info.szName); + wsprintf(s, "FX%d: %s", plug, plugin.GetName()); itemFound = true; } } Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -693,16 +693,16 @@ } for (UINT iFx=0; iFx<MAX_MIXPLUGINS; iFx++) { - PSNDMIXPLUGIN pPlugin = &pSndFile->m_MixPlugins[iFx]; - if (pPlugin->Info.dwPluginId1) + const SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[iFx]; + if (plugin.IsValidPlugin()) { if (!pInfo->hEffects) { pInfo->hEffects = InsertItem("Plugins", IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); } - wsprintf(s, "FX%d: %s", iFx+1, pPlugin->Info.szName); + wsprintf(s, "FX%d: %s", iFx + 1, plugin.GetName()); int nImage = IMAGE_NOPLUGIN; - if(pPlugin->pMixPlugin != nullptr) nImage = (pPlugin->pMixPlugin->isInstrument()) ? IMAGE_PLUGININSTRUMENT : IMAGE_EFFECTPLUGIN; + if(plugin.pMixPlugin != nullptr) nImage = (plugin.pMixPlugin->isInstrument()) ? IMAGE_PLUGININSTRUMENT : IMAGE_EFFECTPLUGIN; pInfo->tiEffects[iFx] = InsertItem(s, nImage, nImage, pInfo->hEffects, TVI_LAST); nFx++; } @@ -2508,12 +2508,9 @@ CModDoc *pModDoc = GetDocumentFromItem(hItem); CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : NULL; - if (pSndFile) { - PSNDMIXPLUGIN pPlugin = &pSndFile->m_MixPlugins[modItemID]; - if (pPlugin) - { - AppendMenu(hMenu, (pPlugin->IsBypassed() ? MF_CHECKED : 0) | MF_STRING, ID_MODTREE_MUTE, "&Bypass"); - } + if (pSndFile) + { + AppendMenu(hMenu, (pSndFile->m_MixPlugins[modItemID].IsBypassed() ? MF_CHECKED : 0) | MF_STRING, ID_MODTREE_MUTE, "&Bypass"); } } break; @@ -2880,10 +2877,7 @@ CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : nullptr; if (pSndFile == nullptr) return; - PSNDMIXPLUGIN pPlugin = &pSndFile->m_MixPlugins[modItemID]; - if(pPlugin == nullptr) - return; - CVstPlugin *pVstPlugin = (CVstPlugin *)pPlugin->pMixPlugin; + CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[modItemID].pMixPlugin); if(pVstPlugin == nullptr) return; pVstPlugin->ToggleBypass(); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2012-03-03 15:00:41 UTC (rev 1200) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2012-03-03 15:14:35 UTC (rev 1201) @@ -76,7 +76,7 @@ } -BOOL CVstPluginManager::CreateMixPluginProc(PSNDMIXPLUGIN pMixPlugin, CSoundFile* pSndFile) +BOOL CVstPluginManager::CreateMixPluginProc(SNDMIXPLUGIN *pMixPlugin, CSoundFile* pSndFile) //----------------------------------------------------------------------------------------- { CVstPluginManager *that = theApp.GetPluginManager(); @@ -501,11 +501,11 @@ } -BOOL CVstPluginManager::CreateMixPlugin(PSNDMIXPLUGIN pMixPlugin, CSoundFile* pSndFile) +BOOL CVstPluginManager::CreateMixPlugin(SNDMIXPLUGIN *pMixPlugin, CSoundFile* pSndFile) //------------------------------------------------------------------------------------- { UINT nMatch = 0; - PVSTPLUGINLIB pFound = NULL; + PVSTPLUGINLIB pFound = nullptr; if (pMixPlugin) { @@ -521,7 +521,7 @@ { b1 = true; } - if (!_strnicmp(p->szLibraryName, pMixPlugin->Info.szLibraryName, 64)) + if (!_strnicmp(p->szLibraryName, pMixPlugin->GetLibraryName(), 64)) { b2 = true; } @@ -563,22 +563,22 @@ return bOk; } } - if ((!pFound) && (pMixPlugin->Info.szLibraryName[0])) + if ((!pFound) && strcmp(pMixPlugin->GetLibraryName(), "")) { CHAR s[_MAX_PATH], dir[_MAX_PATH]; _splitpath(theApp.GetConfigFileName(), s, dir, NULL, NULL); strcat(s, dir); int len = strlen(s); - if ((len > 0) && (s[len-1] != '\\')) strcat(s, "\\"); - strncat(s, "plugins\\", _MAX_PATH-1); - strncat(s, pMixPlugin->Info.szLibraryName, _MAX_PATH-1); + if ((len > 0) && (s[len - 1] != '\\')) strcat(s, "\\"); + strncat(s, "plugins\\", _MAX_PATH - 1); + strncat(s, pMixPlugin->GetLibraryName(), _MAX_PATH - 1); strncat(s, ".dll", _MAX_PATH-1); pFound = AddPlugin(s); if (!pFound) { CString cacheSection = "PluginCache"; CString cacheFile = theApp.GetPluginCacheFileName(); - CString IDs = CMainFrame::GetPrivateProfileCString(cacheSection, pMixPlugin->Info.szLibraryName, "", cacheFile); + CString IDs = CMainFrame::GetPrivateProfileCString(cacheSection, pMixPlugin->GetLibraryName(), "", cacheFile); if (IDs.GetLength() >= 16) { CString strFullPath = CMainFrame::GetPrivateProfileCString(cacheSection, IDs, "", cacheFile); @@ -1329,7 +1329,7 @@ // CVstPlugin // -CVstPlugin::CVstPlugin(HMODULE hLibrary, PVSTPLUGINLIB pFactory, PSNDMIXPLUGIN pMixStruct, AEffect *pEffect) +CVstPlugin::CVstPlugin(HMODULE hLibrary, VSTPLUGINLIB *pFactory, SNDMIXPLUGIN *pMixStruct, AEffect *pEffect) //---------------------------------------------------------------------------------------------------------- { m_hLibrary = hLibrary; @@ -1490,7 +1490,7 @@ //rewbs.VSTcompliance m_bIsInstrument = isInstrument(); RecalculateGain(); - m_pProcessFP = (m_pEffect->flags & effFlagsCanReplacing) ? m_pEffect->processReplacing : m_pEffect->process; + m_pProcessFP = (m_pEffect->flags & effFlagsCanReplacing) ? m_pEffect->processReplacing : m_pEffect->process; // issue samplerate again here, cos some plugs like it before the block size, other like it right at the end. Dispatch(effSetSampleRate, 0, 0, NULL, static_cast<float>(CSoundFile::gdwMixingFreq)); @@ -1664,8 +1664,8 @@ } -bool CVstPlugin::RandomizeParams(VstInt32 minParam, VstInt32 maxParam) -//-------------------------------------------------------------------- +bool CVstPlugin::RandomizeParams(PlugParamIndex minParam, PlugParamIndex maxParam) +//-------------------------------------------------------------------------------- { if (!(m_pEffect)) return false; @@ -1675,10 +1675,10 @@ maxParam = m_pEffect->numParams; } - LimitMax(maxParam, m_pEffect->numParams); + LimitMax(maxParam, PlugParamIndex(m_pEffect->numParams)); - for (VstInt32 p = minParam; p < maxParam; p++) - SetParameter(p, (rand() / float(RAND_MAX))); + for(PlugParamIndex p = minParam; p < maxParam; p++) + SetParameter(p, (float(rand()) / float(RAND_MAX))); return true; } @@ -1691,26 +1691,26 @@ return false; bool success; - //Collect required data + // Collect required data long ID = GetUID(); long plugVersion = GetVersion(); Cfxp* fxp = nullptr; - //Construct & save fxp + // Construct & save fxp // try chunk-based preset: - if(m_pEffect->flags & effFlagsProgramChunks) + if((m_pEffect->flags & effFlagsProgramChunks) != 0) { void *chunk = NULL; long chunkSize = Dispatch(effGetChunk, 1,0, &chunk, 0); - if (chunkSize && chunk) + if(chunkSize && chunk) fxp = new Cfxp(ID, plugVersion, 1, chunkSize, chunk); } // fall back on parameter based preset: - if (fxp == nullptr) + if(fxp == nullptr) { - //Collect required data + // Collect required data PlugParamIndex numParams = GetNumParameters(); float *params = new float[numParams]; GetParams(params, 0, numParams); @@ -1721,7 +1721,7 @@ } success = fxp->Save(fileName); - if (fxp) + if(fxp) delete fxp; return success; @@ -1735,20 +1735,19 @@ if (!(m_pEffect)) return false; - Cfxp fxp(fileName); //load from file + Cfxp fxp(fileName); // load from file - //Verify + // Verify if (m_pEffect->uniqueID != fxp.fxID) return false; - if (fxp.fxMagic == fMagic) //Load preset based fxp + if (fxp.fxMagic == fMagic) // Load preset based fxp { if (m_pEffect->numParams != fxp.numParams) return false; for (int p=0; p<fxp.numParams; p++) SetParameter(p, fxp.params[p]); - } - else if (fxp.fxMagic == chunkPresetMagic) + } else if (fxp.fxMagic == chunkPresetMagic) { Dispatch(effSetChunk, 1, fxp.chunkSize, (BYTE*)fxp.chunk, 0); } @@ -1792,8 +1791,8 @@ } -bool CVstPlugin::GetProgramNameIndexed(long index, long category, char *text) -//--------------------------------------------------------------------------- +bool CVstPlugin::GetProgramNameIndexed(VstInt32 index, VstIntPtr category, char *text) +//------------------------------------------------------------------------------------ { if ((m_pEffect) && (m_pEffect->numPrograms > 0)) { @@ -1806,7 +1805,7 @@ CString CVstPlugin::GetFormattedProgramName(VstInt32 index, bool allowFallback) //----------------------------------------------------------------------------- { - char rawname[256]; // kVstMaxProgNameLen is 24... + char rawname[max(kVstMaxProgNameLen, 256)]; // kVstMaxProgNameLen is 24... if(!GetProgramNameIndexed(index, -1, rawname)) { // Fallback: Try to get current program name. @@ -2040,7 +2039,7 @@ void CVstPlugin::RecalculateGain() //-------------------------------- { - float gain = 0.1f * (float)( m_pMixStruct ? (m_pMixStruct->Info.dwInputRouting>>16) & 0xff : 10 ); + float gain = 0.1f * static_cast<float>(m_pMixStruct ? m_pMixStruct->GetGain() : 10); if(gain < 0.1f) gain = 1.0f; if (m_bIsInstrument && m_pSndFile) @@ -2093,7 +2092,7 @@ { 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); + CVstPluginManager::ReportPlugException("The plugin %s threw an exception in %s. It has automatically been set to \"Bypass\".", m_pMixStruct->GetName(), processMethod); ClearVSTEvents(); // SetEvent(processCalled); } @@ -2134,7 +2133,7 @@ // If dry mix is ticked, we add the unprocessed buffer, // except if this is an instrument since this it has already been done: - if((m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_WETMIX) && !m_bIsInstrument) + if(m_pMixStruct->IsWetMix() && !m_bIsInstrument) { for(size_t i = 0; i < nSamples; i++) { @@ -2178,19 +2177,20 @@ // MIX_R += dryRatio * (WET_L - DRY_L) + wetRatio * (DRY_R - WET_R) int mixop; - if(m_bIsInstrument) + if(m_bIsInstrument || m_pMixStruct == nullptr) { - mixop = 0; // Force normal mix mode for instruments + // Force normal mix mode for instruments + mixop = 0; } else { - mixop = m_pMixStruct ? (m_pMixStruct->Info.dwInputRouting >> 8) & 0xFF : 0; + mixop = m_pMixStruct->GetMixMode(); } float wetRatio = 1 - m_pMixStruct->fDryRatio; float dryRatio = m_bIsInstrument ? 1 : m_pMixStruct->fDryRatio; // Always mix full dry if this is an instrument // Wet / Dry range expansion [0,1] -> [-1,1] - if(m_pEffect->numInputs > 0 && m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND) + if(m_pEffect->numInputs > 0 && m_pMixStruct->IsExpandedMix()) { wetRatio = 2.0f * wetRatio - 1.0f; dryRatio = -wetRatio; @@ -2252,7 +2252,7 @@ // Left / Right balance case 5: - if(m_pMixStruct->Info.dwInputRouting & MIXPLUG_INPUTF_MIXEXPAND) + if(m_pMixStruct->IsExpandedMix()) { wetRatio /= 2.0f; dryRatio /= 2.0f; @@ -2861,13 +2861,10 @@ } -bool CVstPlugin::Bypass(bool bypass) -//----------------------------------- +void CVstPlugin::Bypass(bool bypass) +//---------------------------------- { - if (bypass) - m_pMixStruct->Info.dwInputRouting |= MIXPLUG_INPUTF_BYPASS; - else - m_pMixStruct->Info.dwInputRouting &= ~MIXPLUG_INPUTF_BYPASS; + m_pMixStruct->Info.SetBypass(bypass); Dispatch(effSetBypass, bypass ? 1 : 0, nullptr, nullptr, 0.0f); @@ -2875,8 +2872,6 @@ if (m_pModDoc) m_pModDoc->UpdateAllViews(NULL, HINT_MIXPLUGINS, NULL); #endif // MODPLUG_TRACKER - - return bypass; } @@ -2936,7 +2931,7 @@ } -void CVstPlugin::UpdateMixStructPtr(PSNDMIXPLUGIN p) +void CVstPlugin::UpdateMixStructPtr(SNDMIXPLUGIN *p) //-------------------------------------------------- { m_pMixStruct = p; @@ -2967,9 +2962,9 @@ list.RemoveAll(); CVstPlugin *pOutputPlug = NULL; - if (m_pMixStruct->Info.dwOutputRouting & 0x80) + if (!m_pMixStruct->IsOutputToMaster()) { - UINT nOutput = m_pMixStruct->Info.dwOutputRouting & 0x7f; + PLUGINDEX nOutput = m_pMixStruct->GetOutputPlugin(); if (m_pSndFile && (nOutput > m_nSlot) && (nOutput < MAX_MIXPLUGINS)) { pOutputPlug = reinterpret_cast<CVstPlugin *>(m_pSndFile->m_MixPlugins[nOutput].pMixPlugin); @@ -3667,6 +3662,7 @@ } break; + case MPT_INT: default: wsprintf(pszName, "%d", (int)md); break; @@ -3695,7 +3691,7 @@ mt.bFixedSizeSamples = TRUE; mt.bTemporalCompression = FALSE; mt.formattype = FORMAT_WaveFormatEx; - mt.pUnk = NULL; + mt.pUnk = nullptr; mt.pbFormat = (LPBYTE)&wfx; mt.cbFormat = sizeof(WAVEFORMATEX); mt.lSampleSize = 2 * sizeof(float); @@ -3706,8 +3702,8 @@ wfx.nBlockAlign = wfx.nChannels * (wfx.wBitsPerSample >> 3); wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign; wfx.cbSize = 0; - if ((FAILED(m_pMediaObject->SetInputType(0, &mt, 0))) - || (FAILED(m_pMediaObject->SetOutputType(0, &mt, 0)))) + if (FAILED(m_pMediaObject->SetInputType(0, &mt, 0)) + || FAILED(m_pMediaObject->SetOutputType(0, &mt, 0))) { #ifdef DMO_LOG Log("DMO: Failed to set I/O media type\n"); @@ -3717,8 +3713,8 @@ } else { m_pMediaObject->Flush(); - m_pMediaObject->SetInputType(0, NULL, DMO_SET_TYPEF_CLEAR); - m_pMediaObject->SetOutputType(0, NULL, DMO_SET_TYPEF_CLEAR); + m_pMediaObject->SetInputType(0, nullptr, DMO_SET_TYPEF_CLEAR); + m_pMediaObject->SetOutputType(0, nullptr, DMO_SET_TYPEF_CLEAR); m_DataTime = 0; } break; @@ -3767,8 +3763,8 @@ MemsetZero(mpi); md = 0; ... [truncated message content] |