From: <sag...@us...> - 2013-02-17 20:55:11
|
Revision: 1536 http://sourceforge.net/p/modplug/code/1536 Author: saga-games Date: 2013-02-17 20:55:03 +0000 (Sun, 17 Feb 2013) Log Message: ----------- [Imp] VST: If no default preset directory is specified, the plugin's directory is suggested by default. [Imp] VST: If no preset data is on the clipboard, the paste menu is greyed out. [Imp] VST: Better preset list creation for plugins that don't support retrieval of indexed program names (such as VOPM). Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_gen.h trunk/OpenMPT/mptrack/VstPresets.cpp trunk/OpenMPT/mptrack/VstPresets.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-02-17 15:07:52 UTC (rev 1535) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-02-17 20:55:03 UTC (rev 1536) @@ -106,28 +106,10 @@ void CAbstractVstEditor::OnLoadPreset() //------------------------------------- { - if(!m_pVstPlugin) return; - - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "fxp", "", - "VST Plugin Programs and Banks (*.fxp,*.fxb)|*.fxp;*.fxb|" - "VST Plugin Programs (*.fxp)|*.fxp|" - "VST Plugin Banks (*.fxb)|*.fxb|" - "All Files|*.*||", - CMainFrame::GetSettings().GetWorkingDirectory(DIR_PLUGINPRESETS)); - if(files.abort) return; - - CMainFrame::GetSettings().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_PLUGINPRESETS, true); - - const char *retVal = m_pVstPlugin->LoadProgram(files.first_file.c_str()); - if(retVal == nullptr) + if(m_pVstPlugin && m_pVstPlugin->LoadProgram()) { - if(m_pVstPlugin->GetModDoc() != nullptr) - m_pVstPlugin->GetModDoc()->SetModified(); UpdatePresetMenu(true); UpdatePresetField(); - } else - { - Reporting::Error(retVal, "Plugin Preset"); } } @@ -135,20 +117,10 @@ void CAbstractVstEditor::OnSavePreset() //------------------------------------- { - if(!m_pVstPlugin) return; - - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "fxp", "", - "VST Plugin Programs (*.fxp)|*.fxp|" - "VST Plugin Banks (*.fxb)|*.fxb||", - CMainFrame::GetSettings().GetWorkingDirectory(DIR_PLUGINPRESETS)); - if(files.abort) return; - - CMainFrame::GetSettings().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_PLUGINPRESETS, true); - - //TODO: exception handling - if (!(m_pVstPlugin->SaveProgram(files.first_file.c_str()))) - Reporting::Error("Error saving preset."); - + if(m_pVstPlugin) + { + m_pVstPlugin->SaveProgram(); + } } @@ -187,7 +159,7 @@ if(m_pVstPlugin == nullptr || CMainFrame::GetMainFrame() == nullptr) return; BeginWaitCursor(); - if (CMainFrame::GetMainFrame()->OpenClipboard()) + if(CMainFrame::GetMainFrame()->OpenClipboard()) { HGLOBAL hCpy = ::GetClipboardData(clipboardFormat); const char *p; @@ -195,7 +167,8 @@ if(hCpy != nullptr && (p = static_cast<const char *>(GlobalLock(hCpy))) != nullptr) { FileReader file(p, GlobalSize(hCpy)); - if(VSTPresets::LoadFile(file, *m_pVstPlugin) == VSTPresets::noError) + VSTPresets::ErrorCode error = VSTPresets::LoadFile(file, *m_pVstPlugin); + if(error == VSTPresets::noError) { CSoundFile *pSndFile = m_pVstPlugin->m_pSndFile; CModDoc *pModDoc; @@ -205,7 +178,7 @@ } } else { - Reporting::Error("Error loading preset from clipboard. Are you sure it is for this plugin?"); + Reporting::Error(VSTPresets::GetErrorMessage(error)); } GlobalUnlock(hCpy); } @@ -258,7 +231,7 @@ m_pMenu->AppendMenu(MF_BYPOSITION|MF_DISABLED, 0, TEXT("")); } - m_pMenu->ModifyMenu(8, MF_BYPOSITION, 0, m_pVstPlugin->GetFormattedProgramName(m_pVstPlugin->GetCurrentProgram(), true)); + m_pMenu->ModifyMenu(8, MF_BYPOSITION, 0, m_pVstPlugin->GetFormattedProgramName(m_pVstPlugin->GetCurrentProgram())); } DrawMenuBar(); @@ -434,7 +407,7 @@ return false; if(!m_pVstPlugin->isInstrument() || pModDoc->GetSoundFile()->GetModSpecifications().instrumentsMax == 0 || - Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false, this) == cnfNo) + Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false) == cnfNo) { return false; } else @@ -457,10 +430,24 @@ void CAbstractVstEditor::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU) //--------------------------------------------------------------------- { - if((nFlags & MF_POPUP) && nItemID == 1) + if(!(nFlags & MF_POPUP)) { + return; + } + switch(nItemID) + { + case 0: + // Grey out paste menu item. + if(CMainFrame::GetMainFrame() && CMainFrame::GetMainFrame()->OpenClipboard()) + { + m_pMenu->EnableMenuItem(ID_EDIT_PASTE, MF_BYCOMMAND | (::GetClipboardData(clipboardFormat) != nullptr ? 0 : MF_GRAYED)); + CloseClipboard(); + } + break; + case 1: // Generate preset menu on click. FillPresetMenu(); + break; } } @@ -506,7 +493,7 @@ for(VstInt32 p = 0; p < numProgs; p++) { - CString programName = m_pVstPlugin->GetFormattedProgramName(p, p == curProg); + CString programName = m_pVstPlugin->GetFormattedProgramName(p); UINT splitMenuFlag = 0; if(entryInThisMenu++ == PRESETS_PER_GROUP) Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2013-02-17 15:07:52 UTC (rev 1535) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2013-02-17 20:55:03 UTC (rev 1536) @@ -561,6 +561,20 @@ } +CVstPlugin *CViewGlobals::GetCurrentPlugin() const +//------------------------------------------------ +{ + CModDoc *pModDoc = GetDocument(); + CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : nullptr; + if(pSndFile == nullptr || m_nCurrentPlugin >= MAX_MIXPLUGINS) + { + return nullptr; + } + + return dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[m_nCurrentPlugin].pMixPlugin); +} + + void CViewGlobals::OnTabSelchange(NMHDR*, LRESULT* pResult) //--------------------------------------------------------- { @@ -568,6 +582,7 @@ if (pResult) *pResult = 0; } + void CViewGlobals::OnMute(const CHANNELINDEX chnMod4, const UINT itemID) //---------------------------------------------------------------------- { @@ -708,7 +723,7 @@ CSoundFile *pSndFile = pModDoc->GetSoundFile(); SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; - if (plugin.pMixPlugin) + if(plugin.pMixPlugin) { wsprintf(s, "(%d%% wet, %d%% dry)", 100 - n, n); SetDlgItemText(IDC_STATIC8, s); @@ -729,13 +744,12 @@ if ((n >= 0) && (n <= 100) && (m_nCurrentPlugin < MAX_MIXPLUGINS)) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); - SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; + CVstPlugin *pVstPlugin = GetCurrentPlugin(); - if (plugin.pMixPlugin) + if(pVstPlugin != nullptr) { - CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(plugin.pMixPlugin); const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); - if (m_nCurrentParam < nParams) + if(m_nCurrentParam < nParams) { FLOAT fValue = 0.01f * n; wsprintf(s, "%d.%02d", n/100, n%100); @@ -957,20 +971,15 @@ //--------------------------------- { int cursel = m_CbnParam.GetItemData(m_CbnParam.GetCurSel()); - CModDoc *pModDoc = GetDocument(); CHAR s[256]; - CSoundFile *pSndFile; - if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; - pSndFile = pModDoc->GetSoundFile(); - SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; + CVstPlugin *pVstPlugin = GetCurrentPlugin(); - if (plugin.pMixPlugin && cursel != CB_ERR) + if(pVstPlugin != nullptr && cursel != CB_ERR) { - CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(plugin.pMixPlugin); const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); - if ((cursel >= 0) && (cursel < nParams)) m_nCurrentParam = cursel; - if (m_nCurrentParam < nParams) + if(cursel >= 0 && cursel < nParams) m_nCurrentParam = cursel; + if(m_nCurrentParam < nParams) { wsprintf(s, "Value: %s", pVstPlugin->GetFormattedParamValue(m_nCurrentParam)); SetDlgItemText(IDC_TEXT5, s); @@ -998,14 +1007,13 @@ if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; + CVstPlugin *pVstPlugin = GetCurrentPlugin(); - if (plugin.pMixPlugin) + if(pVstPlugin != nullptr) { - 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) + if(cursel > 0 && cursel <= (int)nParams) m_nCurrentPreset = cursel; + if(m_nCurrentPreset > 0 && m_nCurrentPreset <= nParams) { pVstPlugin->SetCurrentProgram(m_nCurrentPreset - 1); // Update parameter display @@ -1019,68 +1027,27 @@ void CViewGlobals::OnLoadParam() //------------------------------ { - CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : nullptr; - if(pSndFile == nullptr) + CVstPlugin *pVstPlugin = GetCurrentPlugin(); + if(pVstPlugin != nullptr && pVstPlugin->LoadProgram()) { - return; + m_nCurrentPreset = 0; + m_CbnPreset.SetRedraw(FALSE); + m_CbnPreset.ResetContent(); + m_CbnPreset.SetItemData(m_CbnPreset.AddString(_T("current")), 0); + m_CbnPreset.SetRedraw(TRUE); + m_CbnPreset.SetCurSel(0); } - - CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[m_nCurrentPlugin].pMixPlugin); - - if(pVstPlugin == nullptr) - { - return; - } - - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "fxp", "", - "VST Plugin Programs and Banks (*.fxp,*.fxb)|*.fxp;*.fxb|" - "VST Plugin Programs (*.fxp)|*.fxp|" - "VST Plugin Banks (*.fxb)|*.fxb|" - "All Files|*.*||", - CMainFrame::GetSettings().GetDefaultDirectory(DIR_PLUGINPRESETS)); - if(files.abort) return; - - const char *retVal = pVstPlugin->LoadProgram(files.first_file.c_str()); - if(retVal == nullptr) - { - if(pSndFile->GetModSpecifications().supportsPlugins) - pModDoc->SetModified(); - } else - { - Reporting::Error(retVal, "Plugin Preset"); - } } void CViewGlobals::OnSaveParam() //------------------------------ { - CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile = pModDoc ? pModDoc->GetSoundFile() : nullptr; - if(pSndFile == nullptr) + CVstPlugin *pVstPlugin = GetCurrentPlugin(); + if(pVstPlugin != nullptr) { - return; + pVstPlugin->SaveProgram(); } - - CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[m_nCurrentPlugin].pMixPlugin); - - if(pVstPlugin == nullptr) - { - return; - } - FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "fxp", "", - "VST Plugin Programs (*.fxp)|*.fxp|" - "VST Plugin Banks (*.fxb)|*.fxb||", - CMainFrame::GetSettings().GetDefaultDirectory(DIR_PLUGINPRESETS)); - if(files.abort) return; - - //TODO: exception handling - if (!(pVstPlugin->SaveProgram(files.first_file.c_str()))) - Reporting::Error("Error saving preset."); - //end rewbs.fxpPresets - } -// -! NEW_FEATURE#0002 void CViewGlobals::OnSetParameter() @@ -1091,11 +1058,10 @@ if ((m_nCurrentPlugin >= MAX_MIXPLUGINS) || (!pModDoc)) return; pSndFile = pModDoc->GetSoundFile(); - SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[m_nCurrentPlugin]; + CVstPlugin *pVstPlugin = GetCurrentPlugin(); - if (plugin.pMixPlugin != nullptr) + if(pVstPlugin != nullptr) { - CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(plugin.pMixPlugin); const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); CHAR s[32]; GetDlgItemText(IDC_EDIT14, s, sizeof(s)); @@ -1103,7 +1069,7 @@ { FLOAT fValue = (FLOAT)atof(s); pVstPlugin->SetParameter(m_nCurrentParam, fValue); - OnParamChanged(); + OnParamChanged(); if(pSndFile->GetModSpecifications().supportsPlugins) pModDoc->SetModified(); } @@ -1488,11 +1454,7 @@ if(m_CbnParam.GetCount() > 1) return; - if(GetDocument() == nullptr) return; - CSoundFile *pSndFile = GetDocument()->GetSoundFile(); - if(pSndFile == nullptr) return; - if (m_nCurrentPlugin >= MAX_MIXPLUGINS) m_nCurrentPlugin = 0; - CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[m_nCurrentPlugin].pMixPlugin); + CVstPlugin *pVstPlugin = GetCurrentPlugin(); if(pVstPlugin == nullptr) return; const PlugParamIndex nParams = pVstPlugin->GetNumParameters(); @@ -1518,21 +1480,16 @@ if(m_CbnPreset.GetCount() > 1) return; - if(GetDocument() == nullptr) return; - CSoundFile *pSndFile = GetDocument()->GetSoundFile(); - if(pSndFile == nullptr) return; - if (m_nCurrentPlugin >= MAX_MIXPLUGINS) m_nCurrentPlugin = 0; - CVstPlugin *pVstPlugin = dynamic_cast<CVstPlugin *>(pSndFile->m_MixPlugins[m_nCurrentPlugin].pMixPlugin); + CVstPlugin *pVstPlugin = GetCurrentPlugin(); if(pVstPlugin == nullptr) return; UINT nProg = pVstPlugin->GetNumPrograms(); - UINT curProg = pVstPlugin->GetCurrentProgram(); m_CbnPreset.SetRedraw(FALSE); m_CbnPreset.ResetContent(); m_CbnPreset.SetItemData(m_CbnPreset.AddString(_T("current")), 0); for (UINT i = 0; i < nProg; i++) { - m_CbnPreset.SetItemData(m_CbnPreset.AddString(pVstPlugin->GetFormattedProgramName(i, i == curProg)), i + 1); + m_CbnPreset.SetItemData(m_CbnPreset.AddString(pVstPlugin->GetFormattedProgramName(i)), i + 1); } m_nCurrentPreset = 0; m_CbnPreset.SetRedraw(TRUE); Modified: trunk/OpenMPT/mptrack/View_gen.h =================================================================== --- trunk/OpenMPT/mptrack/View_gen.h 2013-02-17 15:07:52 UTC (rev 1535) +++ trunk/OpenMPT/mptrack/View_gen.h 2013-02-17 20:55:03 UTC (rev 1536) @@ -94,6 +94,8 @@ void OnEditName(const CHANNELINDEX chnMod4, const UINT itemID); void OnFxChanged(const CHANNELINDEX chnMod4); + CVstPlugin *GetCurrentPlugin() const; + protected: //{{AFX_MSG(CViewGlobals) afx_msg void OnMute1(); Modified: trunk/OpenMPT/mptrack/VstPresets.cpp =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.cpp 2013-02-17 15:07:52 UTC (rev 1535) +++ trunk/OpenMPT/mptrack/VstPresets.cpp 2013-02-17 20:55:03 UTC (rev 1536) @@ -243,4 +243,23 @@ WriteBE(u.i, f); } + +// Translate error code to string. Returns nullptr if there was no error. +const char *VSTPresets::GetErrorMessage(ErrorCode code) +//----------------------------------------------------- +{ + switch(code) + { + case VSTPresets::invalidFile: + return "This does not appear to be a valid preset file."; + case VSTPresets::wrongPlugin: + return "This file appears to be for a different plugin."; + case VSTPresets::outdatedPlugin: + return "This file is for a newer version of this plugin."; + case VSTPresets::wrongParameters: + return "The number of parameters in this file is incompatible with the current plugin."; + } + return nullptr; +} + #endif // NO_VST Modified: trunk/OpenMPT/mptrack/VstPresets.h =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.h 2013-02-17 15:07:52 UTC (rev 1535) +++ trunk/OpenMPT/mptrack/VstPresets.h 2013-02-17 20:55:03 UTC (rev 1536) @@ -27,6 +27,7 @@ #ifndef NO_VST static ErrorCode LoadFile(FileReader &file, CVstPlugin &plugin); static bool SaveFile(std::ostream &, CVstPlugin &plugin, bool bank); + static const char *GetErrorMessage(ErrorCode code); protected: static void SaveProgram(std::ostream &f, CVstPlugin &plugin); @@ -43,5 +44,6 @@ #else static ErrorCode LoadFile(FileReader &, CVstPlugin &) { return invalidFile; } static bool SaveFile(std::ostream &, CVstPlugin &, bool) { return false; } + static const char *GetErrorMessage(ErrorCode); #endif // NO_VST }; Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-02-17 15:07:52 UTC (rev 1535) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-02-17 20:55:03 UTC (rev 1536) @@ -1653,47 +1653,95 @@ } -bool CVstPlugin::SaveProgram(const char *filename) -//------------------------------------------------ +bool CVstPlugin::SaveProgram() +//---------------------------- { - char ext[_MAX_EXT]; - _splitpath(filename, nullptr, nullptr, nullptr, ext); + std::string defaultDir = CMainFrame::GetSettings().GetWorkingDirectory(DIR_PLUGINPRESETS); + bool useDefaultDir = !defaultDir.empty(); + if(!useDefaultDir) + { + defaultDir = m_pFactory->szDllPath; + defaultDir = defaultDir.substr(0, defaultDir.find_last_of("\\/")); + } + FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(false, "fxp", "", + "VST Plugin Programs (*.fxp)|*.fxp|" + "VST Plugin Banks (*.fxb)|*.fxb||", + defaultDir); + if(files.abort) return false; + + if(useDefaultDir) + { + CMainFrame::GetSettings().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_PLUGINPRESETS, true); + } + + bool bank = !_strnicmp(files.first_file.substr(files.first_file.length() - 3).c_str(), "fxb", 3); + std::fstream f; - f.open(filename, std::ios::out | std::ios::trunc | std::ios::binary); - return f.good() && VSTPresets::SaveFile(f, *this, !_strnicmp(ext, ".fxb", 4)); + f.open(files.first_file, std::ios::out | std::ios::trunc | std::ios::binary); + if(f.good() && VSTPresets::SaveFile(f, *this, bank)) + { + return true; + } else + { + Reporting::Error("Error saving preset."); + return false; + } + } -const char *CVstPlugin::LoadProgram(const char *filename) -//------------------------------------------------------- +bool CVstPlugin::LoadProgram() +//---------------------------- { - CMappedFile f; - if(!f.Open(filename)) + std::string defaultDir = CMainFrame::GetSettings().GetWorkingDirectory(DIR_PLUGINPRESETS); + bool useDefaultDir = !defaultDir.empty(); + if(!useDefaultDir) { - return "Can't open file."; + defaultDir = m_pFactory->szDllPath; + defaultDir = defaultDir.substr(0, defaultDir.find_last_of("\\/")); } - size_t len = f.GetLength(); - const char *data = reinterpret_cast<const char *>(f.Lock(len)); - FileReader file(data, len); - VSTPresets::ErrorCode error = VSTPresets::LoadFile(file, *this); - f.Close(); + FileDlgResult files = CTrackApp::ShowOpenSaveFileDialog(true, "fxp", "", + "VST Plugin Programs and Banks (*.fxp,*.fxb)|*.fxp;*.fxb|" + "VST Plugin Programs (*.fxp)|*.fxp|" + "VST Plugin Banks (*.fxb)|*.fxb|" + "All Files|*.*||", + defaultDir); + if(files.abort) return false; - switch(error) + if(useDefaultDir) { - case VSTPresets::noError: - default: - return nullptr; - case VSTPresets::invalidFile: - return "This does not appear to be a valid preset file."; - case VSTPresets::wrongPlugin: - return "This file appears to be for a different plugin."; - case VSTPresets::outdatedPlugin: - return "This file is for a newer version of this plugin."; - case VSTPresets::wrongParameters: - return "The number of parameters in this file is incompatible with the current plugin."; + CMainFrame::GetSettings().SetWorkingDirectory(files.workingDirectory.c_str(), DIR_PLUGINPRESETS, true); } + + CMappedFile f; + const char *errorStr = nullptr; + if(f.Open(files.first_file.c_str())) + { + size_t len = f.GetLength(); + const char *data = reinterpret_cast<const char *>(f.Lock(len)); + FileReader file(data, len); + + errorStr = VSTPresets::GetErrorMessage(VSTPresets::LoadFile(file, *this)); + f.Close(); + } else + { + errorStr = "Can't open file."; + } + + if(errorStr == nullptr) + { + if(GetModDoc() != nullptr && GetSoundFile() != nullptr && GetSoundFile()->GetModSpecifications().supportsPlugins) + { + GetModDoc()->SetModified(); + } + return true; + } else + { + Reporting::Error(errorStr); + return false; + } } @@ -1742,18 +1790,24 @@ } -CString CVstPlugin::GetFormattedProgramName(VstInt32 index, bool allowFallback) -//----------------------------------------------------------------------------- +CString CVstPlugin::GetFormattedProgramName(VstInt32 index) +//--------------------------------------------------------- { char rawname[max(kVstMaxProgNameLen + 1, 256)]; // kVstMaxProgNameLen is 24... if(!GetProgramNameIndexed(index, -1, rawname)) { // Fallback: Try to get current program name. strcpy(rawname, ""); - if(allowFallback) + VstInt32 curProg = GetCurrentProgram(); + if(index != curProg) { - Dispatch(effGetProgramName, 0, 0, rawname, 0); + SetCurrentProgram(index); } + Dispatch(effGetProgramName, 0, 0, rawname, 0); + if(index != curProg) + { + SetCurrentProgram(curProg); + } } StringFixer::SetNullTerminator(rawname); Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2013-02-17 15:07:52 UTC (rev 1535) +++ trunk/OpenMPT/mptrack/Vstplug.h 2013-02-17 20:55:03 UTC (rev 1536) @@ -179,9 +179,9 @@ PlugParamIndex GetNumParameters(); VstInt32 GetCurrentProgram(); VstInt32 GetNumProgramCategories(); - CString GetFormattedProgramName(VstInt32 index, bool allowFallback = false); - const char *LoadProgram(const char *filename); - bool SaveProgram(const char *filename); + CString GetFormattedProgramName(VstInt32 index); + bool LoadProgram(); + bool SaveProgram(); VstInt32 GetUID() const; VstInt32 GetVersion() const; // Check if programs should be stored as chunks or parameters @@ -292,7 +292,7 @@ VstInt32 GetNumPrograms() { return 0; } VstInt32 GetCurrentProgram() { return 0; } bool GetProgramNameIndexed(long, long, char*) { return false; } - CString GetFormattedProgramName(VstInt32, bool = false) { return ""; } + CString GetFormattedProgramName(VstInt32) { return ""; } void SetParameter(PlugParamIndex, PlugParamValue) {} VstInt32 GetUID() const { return 0; } VstInt32 GetVersion() const { return 0; } @@ -306,8 +306,8 @@ CString GetParamDisplay(PlugParamIndex) { return ""; }; PlugParamValue GetParameter(PlugParamIndex) { return 0; } - const char *LoadProgram(const char *) { return false; } - bool SaveProgram(const char *) { return false; } + bool LoadProgram() { return false; } + bool SaveProgram() { return false; } void SetCurrentProgram(UINT) {} void SetSlot(UINT) {} void UpdateMixStructPtr(void*) {} Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-02-17 15:07:52 UTC (rev 1535) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-02-17 20:55:03 UTC (rev 1536) @@ -2761,8 +2761,8 @@ MENUITEM SEPARATOR MENUITEM "&Load Preset / Bank...", ID_PRESET_LOAD MENUITEM "&Save Preset / Bank...", ID_PRESET_SAVE + MENUITEM SEPARATOR MENUITEM "Create &instrument from plugin", ID_PLUGINTOINSTRUMENT - MENUITEM SEPARATOR MENUITEM "&Randomize Parameters", ID_PRESET_RANDOM END POPUP "&Info" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-01 16:45:45
|
Revision: 1546 http://sourceforge.net/p/modplug/code/1546 Author: saga-games Date: 2013-03-01 16:45:36 +0000 (Fri, 01 Mar 2013) Log Message: ----------- [New] Added hidden setting "RowDisplayOffset" in [Pattern Editor] to specify displayed row offset in the pattern editor (does not affect goto or pattern effects) (patch by coda) Modified Paths: -------------- trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-02-22 22:55:15 UTC (rev 1545) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-03-01 16:45:36 UTC (rev 1546) @@ -825,8 +825,13 @@ for (UINT row=startRow; row<numRows; row++) { UINT col, xbmp, nbmp, oldrowcolor; - - wsprintf(s, (CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_HEXDISPLAY) ? "%02X" : "%d", row); + const int compRow = row + CMainFrame::GetSettings().rowDisplayOffset; + + if((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_HEXDISPLAY)) + wsprintf(s, "%s%02X", compRow < 0 ? "-" : "", abs(compRow)); + else + wsprintf(s, "%d", compRow); + rect.left = 0; rect.top = ypaint; rect.right = rcClient.right; @@ -855,16 +860,16 @@ if ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_2NDHIGHLIGHT) && (nBeat) && (nBeat < numRows)) { - if (!(row % nBeat)) + if(!(compRow % nBeat)) { row_bkcol = MODCOLOR_2NDHIGHLIGHT; } } // primary highlight (measures) - if ((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_STDHIGHLIGHT) - && (nMeasure) && (nMeasure < numRows)) + if((CMainFrame::GetSettings().m_dwPatternSetup & PATTERN_STDHIGHLIGHT) + && (nMeasure) && (nMeasure < numRows)) { - if (!(row % nMeasure)) + if(!(compRow % nMeasure)) { row_bkcol = MODCOLOR_BACKHILIGHT; } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-02-22 22:55:15 UTC (rev 1545) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-01 16:45:36 UTC (rev 1546) @@ -88,6 +88,7 @@ m_nRowHighlightMeasures = 16; m_nRowHighlightBeats = 4; recordQuantizeRows = 0; + rowDisplayOffset = 0; m_nSampleUndoMaxBuffer = 0; // Real sample buffer undo size will be set later. @@ -386,6 +387,7 @@ gbPatternRecord = CMainFrame::GetPrivateProfileDWord("Pattern Editor", "Record", gbPatternRecord, iniFile); gnAutoChordWaitTime = CMainFrame::GetPrivateProfileDWord("Pattern Editor", "AutoChordWaitTime", gnAutoChordWaitTime, iniFile); orderlistMargins = GetPrivateProfileInt("Pattern Editor", "DefaultSequenceMargins", orderlistMargins, iniFile); + rowDisplayOffset = GetPrivateProfileInt("Pattern Editor", "RowDisplayOffset", rowDisplayOffset, iniFile); recordQuantizeRows = CMainFrame::GetPrivateProfileDWord("Pattern Editor", "RecordQuantize", recordQuantizeRows, iniFile); gbShowHackControls = (0 != CMainFrame::GetPrivateProfileDWord("Misc", "ShowHackControls", gbShowHackControls ? 1 : 0, iniFile)); CSoundFile::s_DefaultPlugVolumeHandling = static_cast<uint8>(GetPrivateProfileInt("Misc", "DefaultPlugVolumeHandling", CSoundFile::s_DefaultPlugVolumeHandling, iniFile)); Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-02-22 22:55:15 UTC (rev 1545) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-01 16:45:36 UTC (rev 1546) @@ -76,6 +76,7 @@ ROWINDEX recordQuantizeRows; bool m_bHideUnavailableCtxMenuItems; int orderlistMargins; + int rowDisplayOffset; // Sample Editor Setup UINT m_nSampleUndoMaxBuffer; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-03 18:25:58
|
Revision: 1548 http://sourceforge.net/p/modplug/code/1548 Author: saga-games Date: 2013-03-03 18:25:51 +0000 (Sun, 03 Mar 2013) Log Message: ----------- [Imp] Plugin Selection Dialog: Selectin "no plugin" no longer makes OpenMPT forget the last used plugin. [Ref] Rewrote raw sample loading code a bit. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Ctrl_smp.h trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp trunk/OpenMPT/mptrack/SampleEditorDialogs.h trunk/OpenMPT/mptrack/SelectPluginDialog.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-03-01 16:47:30 UTC (rev 1547) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-03-03 18:25:51 UTC (rev 1548) @@ -169,11 +169,12 @@ m_nStretchProcessStepLength(nDefaultStretchChunkSize), m_nSequenceMs(DEFAULT_SEQUENCE_MS), m_nSeekWindowMs(DEFAULT_SEEKWINDOW_MS), - m_nOverlapMs(DEFAULT_OVERLAP_MS) + m_nOverlapMs(DEFAULT_OVERLAP_MS), + m_nPreviousRawFormat(SampleIO::_8bit, SampleIO::mono, SampleIO::littleEndian, SampleIO::unsignedPCM) { m_nSample = 1; m_nLockCount = 1; - m_nPreviousRawFormat = 0; + rememberRawFormat = false; } @@ -772,15 +773,16 @@ if (!bOk) { CRawSampleDlg dlg(this); - if(m_nPreviousRawFormat != 0) + if(rememberRawFormat) { dlg.SetSampleFormat(m_nPreviousRawFormat); dlg.SetRememberFormat(true); } EndWaitCursor(); - if ((m_nPreviousRawFormat != 0) || (dlg.DoModal() == IDOK)) + if(rememberRawFormat || dlg.DoModal() == IDOK) { - m_nPreviousRawFormat = (dlg.GetRemeberFormat() ? dlg.GetSampleFormat() : 0); + m_nPreviousRawFormat = dlg.GetSampleFormat(); + rememberRawFormat = dlg.GetRemeberFormat(); BeginWaitCursor(); ModSample &sample = m_pSndFile->GetSample(m_nSample); @@ -788,42 +790,30 @@ m_pSndFile->DestroySampleThreadsafe(m_nSample); sample.nLength = len; - SampleIO sampleIO( - SampleIO::_8bit, - SampleIO::mono, - SampleIO::littleEndian, - (dlg.GetSampleFormat() & ER_UNSIGNED) ? SampleIO::unsignedPCM : SampleIO::signedPCM); + SampleIO sampleIO = dlg.GetSampleFormat(); - if(dlg.GetSampleFormat() & ER_16BIT) + if(sampleIO.GetBitDepth() != 8) { sample.nLength /= 2; - sampleIO |= SampleIO::_16bit; } // Interleaved Stereo Sample - if(dlg.GetSampleFormat() & ER_STEREO) + if(sampleIO.GetChannelFormat() != SampleIO::mono) { sample.nLength /= 2; - sampleIO |= SampleIO::stereoInterleaved; } - LPSTR p16 = (LPSTR)lpFile; - DWORD l16 = len; - if ((sample.uFlags & CHN_16BIT) && (len & 1)) + if (sampleIO.ReadSample(sample, lpFile, len)) { - p16++; - l16--; - } - - if (sampleIO.ReadSample(sample, p16, l16)) - { bOk = true; sample.nGlobalVol = 64; sample.nVolume = 256; sample.nPan = 128; - sample.filename[0] = 0; - if (!sample.nC5Speed) sample.nC5Speed = 22050; + sample.uFlags.reset(CHN_LOOP | CHN_SUSTAINLOOP); + sample.filename[0] = '\0'; + m_pSndFile->m_szNames[m_nSample][0] = '\0'; + if(!sample.nC5Speed) sample.nC5Speed = 22050; } else { m_pModDoc->GetSampleUndo().Undo(m_nSample); Modified: trunk/OpenMPT/mptrack/Ctrl_smp.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.h 2013-03-01 16:47:30 UTC (rev 1547) +++ trunk/OpenMPT/mptrack/Ctrl_smp.h 2013-03-03 18:25:51 UTC (rev 1548) @@ -41,7 +41,8 @@ uint32 m_nOverlapMs; uint16 m_nFinetuneStep; // Increment finetune by x when using spin control. Default = 25 enum {nDefaultStretchChunkSize = 8192}; - UINT m_nPreviousRawFormat; + SampleIO m_nPreviousRawFormat; + bool rememberRawFormat; CComboBox m_ComboPitch, m_ComboQuality, m_ComboFFT; Modified: trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp 2013-03-01 16:47:30 UTC (rev 1547) +++ trunk/OpenMPT/mptrack/SampleEditorDialogs.cpp 2013-03-03 18:25:51 UTC (rev 1548) @@ -59,7 +59,7 @@ ////////////////////////////////////////////////////////////// // Sample import dialog -UINT CRawSampleDlg::m_nFormat = ER_8BIT | ER_UNSIGNED | ER_MONO; +SampleIO CRawSampleDlg::m_nFormat(SampleIO::_8bit, SampleIO::mono, SampleIO::littleEndian, SampleIO::unsignedPCM); BOOL CRawSampleDlg::OnInitDialog() //-------------------------------- @@ -73,13 +73,12 @@ void CRawSampleDlg::OnOK() //------------------------ { - m_nFormat = 0; - if(IsDlgButtonChecked(IDC_RADIO1)) m_nFormat |= ER_8BIT; - if(IsDlgButtonChecked(IDC_RADIO2)) m_nFormat |= ER_16BIT; - if(IsDlgButtonChecked(IDC_RADIO3)) m_nFormat |= ER_UNSIGNED; - if(IsDlgButtonChecked(IDC_RADIO4)) m_nFormat |= ER_SIGNED; - if(IsDlgButtonChecked(IDC_RADIO5)) m_nFormat |= ER_MONO; - if(IsDlgButtonChecked(IDC_RADIO6)) m_nFormat |= ER_STEREO; + if(IsDlgButtonChecked(IDC_RADIO1)) m_nFormat |= SampleIO::_8bit; + if(IsDlgButtonChecked(IDC_RADIO2)) m_nFormat |= SampleIO::_16bit; + if(IsDlgButtonChecked(IDC_RADIO3)) m_nFormat |= SampleIO::unsignedPCM; + if(IsDlgButtonChecked(IDC_RADIO4)) m_nFormat |= SampleIO::signedPCM; + if(IsDlgButtonChecked(IDC_RADIO5)) m_nFormat |= SampleIO::mono; + if(IsDlgButtonChecked(IDC_RADIO6)) m_nFormat |= SampleIO::stereoInterleaved; m_bRememberFormat = IsDlgButtonChecked(IDC_CHK_REMEMBERSETTINGS) != BST_UNCHECKED; CDialog::OnOK(); } @@ -88,9 +87,9 @@ void CRawSampleDlg::UpdateDialog() //-------------------------------- { - CheckRadioButton(IDC_RADIO1, IDC_RADIO2, (m_nFormat & ER_8BIT) ? IDC_RADIO1 : IDC_RADIO2 ); - CheckRadioButton(IDC_RADIO3, IDC_RADIO4, (m_nFormat & ER_UNSIGNED) ? IDC_RADIO3 : IDC_RADIO4); - CheckRadioButton(IDC_RADIO5, IDC_RADIO6, (m_nFormat & ER_MONO) ? IDC_RADIO5 : IDC_RADIO6); + CheckRadioButton(IDC_RADIO1, IDC_RADIO2, (m_nFormat.GetBitDepth() == 8) ? IDC_RADIO1 : IDC_RADIO2 ); + CheckRadioButton(IDC_RADIO3, IDC_RADIO4, (m_nFormat.GetEncoding() == SampleIO::unsignedPCM) ? IDC_RADIO3 : IDC_RADIO4); + CheckRadioButton(IDC_RADIO5, IDC_RADIO6, (m_nFormat.GetChannelFormat() == SampleIO::mono) ? IDC_RADIO5 : IDC_RADIO6); CheckDlgButton(IDC_CHK_REMEMBERSETTINGS, (m_bRememberFormat) ? MF_CHECKED : MF_UNCHECKED); } @@ -242,4 +241,4 @@ m_nSamples = GetDlgItemInt(IDC_EDIT1, NULL, FALSE); LimitMax(m_nSamples, m_nMaxSamples); CDialog::OnOK(); -} +} \ No newline at end of file Modified: trunk/OpenMPT/mptrack/SampleEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/SampleEditorDialogs.h 2013-03-01 16:47:30 UTC (rev 1547) +++ trunk/OpenMPT/mptrack/SampleEditorDialogs.h 2013-03-03 18:25:51 UTC (rev 1548) @@ -32,26 +32,17 @@ ////////////////////////////////////////////////////////////////////////// // Sample import dialog -#define ER_8BIT 0x01 -#define ER_16BIT 0x02 - -#define ER_SIGNED 0x10 -#define ER_UNSIGNED 0x20 - -#define ER_MONO 0x0100 -#define ER_STEREO 0x0200 - //================================= class CRawSampleDlg: public CDialog //================================= { protected: - static UINT m_nFormat; + static SampleIO m_nFormat; bool m_bRememberFormat; public: - static const UINT GetSampleFormat() { return m_nFormat; } - static void SetSampleFormat(UINT nFormat) { m_nFormat = nFormat; } + static const SampleIO GetSampleFormat() { return m_nFormat; } + static void SetSampleFormat(SampleIO nFormat) { m_nFormat = nFormat; } const bool GetRemeberFormat() { return m_bRememberFormat; }; void SetRememberFormat(bool bRemember) { m_bRememberFormat = bRemember; }; Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-03-01 16:47:30 UTC (rev 1547) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-03-03 18:25:51 UTC (rev 1548) @@ -210,7 +210,8 @@ if (changed) { - CMainFrame::GetSettings().gnPlugWindowLast = m_pPlugin->Info.dwPluginId2; + if(m_pPlugin->Info.dwPluginId2) + CMainFrame::GetSettings().gnPlugWindowLast = m_pPlugin->Info.dwPluginId2; CDialog::OnOK(); } else @@ -335,7 +336,7 @@ { currentPlug = h; } - } else if (p->dwPluginId2 == CMainFrame::GetSettings().gnPlugWindowLast) + } else if(p->dwPluginId2 == CMainFrame::GetSettings().gnPlugWindowLast) { // Previously selected plugin currentPlug = h; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-06 21:48:40
|
Revision: 1550 http://sourceforge.net/p/modplug/code/1550 Author: saga-games Date: 2013-03-06 21:48:34 +0000 (Wed, 06 Mar 2013) Log Message: ----------- [Fix] Sample Editor: Selection length display didn't show the correct in length in seconds for long samples. [New] Added keyboard shortcut: Play song from start of pattern (same as play pattern from start, but doesn't loop the pattern). Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/View_smp.cpp Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2013-03-03 21:14:29 UTC (rev 1549) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2013-03-06 21:48:34 UTC (rev 1550) @@ -104,8 +104,8 @@ DefineKeyCommand(kcViewSamples, 1023, _T("View Samples")); DefineKeyCommand(kcViewInstruments, 1024, _T("View Instruments")); DefineKeyCommand(kcViewComments, 1025, _T("View Comments")); - DefineKeyCommand(kcPlayPatternFromCursor, 1026, _T("Play pattern from cursor")); - DefineKeyCommand(kcPlayPatternFromStart, 1027, _T("Play pattern from start")); + DefineKeyCommand(kcPlayPatternFromCursor, 1026, _T("Play Pattern from Cursor")); + DefineKeyCommand(kcPlayPatternFromStart, 1027, _T("Play Pattern from Start")); DefineKeyCommand(kcPlaySongFromCursor, 1028, _T("Play Song from Cursor")); DefineKeyCommand(kcPlaySongFromStart, 1029, _T("Play Song from Start")); DefineKeyCommand(kcPlayPauseSong, 1030, _T("Play Song / Pause song")); @@ -650,6 +650,7 @@ DefineKeyCommand(kcToggleNoteOffRecordPC, 1895, _T("Toggle Note Off record (PC keyboard)")); DefineKeyCommand(kcToggleNoteOffRecordMIDI, 1896, _T("Toggle Note Off record (MIDI)")); DefineKeyCommand(kcFindInstrument, 1897, _T("Pick up nearest instrument number")); + DefineKeyCommand(kcPlaySongFromPattern, 1898, _T("Play Song from Pattern Start")); // Add new key commands here. @@ -696,10 +697,10 @@ } } //Check that this keycombination isn't already assigned (in this context), except for dummy keys - for (int curCmd=0; curCmd<kcNumCommands; curCmd++) + for (int curCmd=0; curCmd<kcNumCommands; curCmd++) { //search all commands if (IsDummyCommand(cmd)) // no need to search if we are adding a dummy key - break; + break; if (IsDummyCommand((CommandID)curCmd)) //no need to check against a dummy key continue; for (int k=0; k<commands[curCmd].kcList.GetSize(); k++) @@ -1390,15 +1391,15 @@ CArray<InputTargetContext, InputTargetContext> contexts; //Clear map - memset(km, -1, sizeof(KeyMap)); + memset(km, kcNull, sizeof(KeyMap)); //Copy commandlist content into map: - for (UINT cmd=0; cmd<kcNumCommands; cmd++) + for(UINT cmd=0; cmd<kcNumCommands; cmd++) { - if (IsDummyCommand((CommandID)cmd)) + if(IsDummyCommand((CommandID)cmd)) continue; - for (INT_PTR k=0; k<commands[cmd].kcList.GetSize(); k++) + for(INT_PTR k=0; k<commands[cmd].kcList.GetSize(); k++) { contexts.RemoveAll(); eventTypes.RemoveAll(); @@ -1432,8 +1433,10 @@ } //long label = 0; - for (int cx=0; cx<contexts.GetSize(); cx++) { - for (int ke=0; ke<eventTypes.GetSize(); ke++) { + for (int cx=0; cx<contexts.GetSize(); cx++) + { + for (int ke=0; ke<eventTypes.GetSize(); ke++) + { km[contexts[cx]][curKc.mod][curKc.code][eventTypes[ke]] = (CommandID)cmd; } } @@ -1443,25 +1446,6 @@ } -DWORD CCommandSet::GetKeymapLabel(InputTargetContext ctx, UINT mod, UINT code, KeyEventType ke) -//--------------------------------------------------------------------------------------------- -{ //Unused - ASSERT((long)ctx<0xFF); - ASSERT((long)mod<0xFF); - ASSERT((long)code<0xFF); - ASSERT((long)ke<0xFF); - - BYTE ctxCode = (BYTE)ctx; - BYTE modCode = (BYTE)mod; - BYTE codeCode = (BYTE)code; - //BYTE keCode = (BYTE)ke; - - DWORD label = ctxCode | (modCode<<8) | (codeCode<<16) | (ke<<24); - - return label; -} - - void CCommandSet::Copy(CCommandSet *source) //----------------------------------------- { Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2013-03-03 21:14:29 UTC (rev 1549) +++ trunk/OpenMPT/mptrack/CommandSet.h 2013-03-06 21:48:34 UTC (rev 1550) @@ -88,6 +88,7 @@ kcPlaySongFromCursor, kcPlayPatternFromStart, kcPlayPatternFromCursor, + kcPlaySongFromPattern, kcPanic, kcEstimateSongLength, kcApproxRealBPM, @@ -1260,8 +1261,6 @@ bool LoadFile(std::istream& iStrm, LPCTSTR szFilename); bool LoadDefaultKeymap(); void UpgradeKeymap(CCommandSet *pCommands, int oldVersion); - - static DWORD GetKeymapLabel(InputTargetContext ctx, UINT mod, UINT code, KeyEventType ke); }; //end rewbs.customKeys Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-03-03 21:14:29 UTC (rev 1549) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-03-06 21:48:34 UTC (rev 1550) @@ -2259,8 +2259,8 @@ // Playback -void CModDoc::OnPatternRestart() -//------------------------------ +void CModDoc::OnPatternRestart(bool loop) +//--------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); CChildFrame *pChildFrm = (CChildFrame *) GetChildFrame(); @@ -2270,7 +2270,7 @@ if (strcmp("CViewPattern", pChildFrm->GetCurrentViewClassName()) == 0) { //User has sent play pattern command: set loop pattern checkbox to true. - pChildFrm->SendViewMessage(VIEWMSG_PATTERNLOOP, 1); + pChildFrm->SendViewMessage(VIEWMSG_PATTERNLOOP, loop ? 1 : 0); } CSoundFile *pSndFile = GetSoundFile(); @@ -2296,7 +2296,10 @@ } if ((nOrd < m_SndFile.Order.size()) && (pSndFile->Order[nOrd] == nPat)) pSndFile->m_nCurrentOrder = pSndFile->m_nNextOrder = nOrd; pSndFile->m_SongFlags.reset(SONG_PAUSED | SONG_STEP); - pSndFile->LoopPattern(nPat); + if(loop) + pSndFile->LoopPattern(nPat); + else + pSndFile->LoopPattern(PATTERNINDEX_INVALID); pSndFile->m_nNextRow = 0; // set playback timer in the status bar (and update channel status) @@ -2492,6 +2495,7 @@ case kcPlaySongFromCursor: OnPatternPlayNoLoop(); break; case kcPlaySongFromStart: OnPlayerPlayFromStart(); break; case kcPlayPauseSong: OnPlayerPlay(); break; + case kcPlaySongFromPattern: OnPatternRestart(false); break; case kcStopSong: OnPlayerStop(); break; case kcPanic: OnPanic(); break; // case kcPauseSong: OnPlayerPause(); break; Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-03-03 21:14:29 UTC (rev 1549) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-03-06 21:48:34 UTC (rev 1550) @@ -391,7 +391,8 @@ afx_msg void OnUpdateHasMIDIMappings(CCmdUI *p); afx_msg void OnUpdateMP3Encode(CCmdUI *pCmdUI); afx_msg void OnUpdateCompatExportableOnly(CCmdUI *p); - afx_msg void OnPatternRestart(); //rewbs.customKeys + afx_msg void OnPatternRestart() { OnPatternRestart(true); } //rewbs.customKeys + afx_msg void OnPatternRestart(bool loop); //rewbs.customKeys afx_msg void OnPatternPlay(); //rewbs.customKeys afx_msg void OnPatternPlayNoLoop(); //rewbs.customKeys afx_msg void OnViewEditHistory(); Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-03-03 21:14:29 UTC (rev 1549) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-03-06 21:48:34 UTC (rev 1550) @@ -309,25 +309,25 @@ if (rect.right > m_rcClient.right) rect.right = m_rcClient.right; if (rect.right > rect.left) InvalidateRect(&rect, FALSE); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (pMainFrm) + if(pMainFrm) { CHAR s[64]; s[0] = 0; - if (m_dwEndSel > m_dwBeginSel) + if(m_dwEndSel > m_dwBeginSel) { const SmpLength selLength = m_dwEndSel - m_dwBeginSel; - wsprintf(s, "[%d,%d] (%d sample%s, ", m_dwBeginSel, m_dwEndSel, selLength, (selLength == 1) ? "" : "s"); + wsprintf(s, "[%u,%u] (%u sample%s, ", m_dwBeginSel, m_dwEndSel, selLength, (selLength == 1) ? "" : "s"); uint32 lSampleRate = pSndFile->GetSample(m_nSample).nC5Speed; - if (pSndFile->GetType() & (MOD_TYPE_MOD|MOD_TYPE_XM)) + if(pSndFile->GetType() & (MOD_TYPE_MOD|MOD_TYPE_XM)) { lSampleRate = ModSample::TransposeToFrequency(pSndFile->GetSample(m_nSample).RelativeTone, pSndFile->GetSample(m_nSample).nFineTune); } if (!lSampleRate) lSampleRate = 8363; - ULONG msec = ((ULONG)selLength * 1000) / lSampleRate; - if (msec < 1000) - wsprintf(s+strlen(s), "%lums)", msec); + uint64 msec = (uint64(selLength) * 1000) / lSampleRate; + if(msec < 1000) + wsprintf(s + strlen(s), "%lums)", msec); else - wsprintf(s+strlen(s), "%lu.%lus)", msec/1000, (msec/100) % 10); + wsprintf(s + strlen(s), "%lu.%lus)", msec / 1000, (msec / 100) % 10); } pMainFrm->SetInfoText(s); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-10 15:57:56
|
Revision: 1557 http://sourceforge.net/p/modplug/code/1557 Author: saga-games Date: 2013-03-10 15:57:47 +0000 (Sun, 10 Mar 2013) Log Message: ----------- [New] VST Editor: Added option to route a plugin's MIDI output to the pattern/sample/instrument editor. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.h trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-03-09 22:44:19 UTC (rev 1556) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-03-10 15:57:47 UTC (rev 1557) @@ -33,6 +33,7 @@ ON_COMMAND(ID_PRESET_LOAD, OnLoadPreset) ON_COMMAND(ID_PLUG_BYPASS, OnBypassPlug) ON_COMMAND(ID_PLUG_RECORDAUTOMATION,OnRecordAutomation) + ON_COMMAND(ID_PLUG_RECORD_MIDIOUT, OnRecordMIDIOut) ON_COMMAND(ID_PLUG_PASSKEYS, OnPassKeypressesToPlug) ON_COMMAND(ID_PRESET_SAVE, OnSavePreset) ON_COMMAND(ID_PRESET_RANDOM, OnRandomizePreset) @@ -168,6 +169,8 @@ { FileReader file(p, GlobalSize(hCpy)); VSTPresets::ErrorCode error = VSTPresets::LoadFile(file, *m_pVstPlugin); + GlobalUnlock(hCpy); + if(error == VSTPresets::noError) { CSoundFile *pSndFile = m_pVstPlugin->m_pSndFile; @@ -180,7 +183,6 @@ { Reporting::Error(VSTPresets::GetErrorMessage(error)); } - GlobalUnlock(hCpy); } CloseClipboard(); } @@ -280,6 +282,16 @@ } +void CAbstractVstEditor::OnRecordMIDIOut() +//---------------------------------------- +{ + if(m_pVstPlugin) + { + m_pVstPlugin->m_bRecordMIDIOut = !m_pVstPlugin->m_bRecordMIDIOut; + } +} + + void CAbstractVstEditor::OnPassKeypressesToPlug() //----------------------------------------------- { @@ -312,7 +324,7 @@ // If we successfully mapped to a command and plug does not listen for keypresses, no need to pass message on. if(ih->KeyEvent(kCtxVSTGUI, nChar, nRepCnt, nFlags, kT, (CWnd*)this) != kcNull) { - return true; + return true; } // Don't forward key repeats if plug does not listen for keypresses @@ -673,7 +685,7 @@ } CMenu *pInfoMenu = m_pMenu->GetSubMenu(2); - pInfoMenu->DeleteMenu(2, MF_BYPOSITION); + pInfoMenu->DeleteMenu(2, MF_BYPOSITION); if(m_pMacroMenu->m_hMenu) { @@ -731,6 +743,9 @@ //Record Params m_pOptionsMenu->AppendMenu(MF_STRING | m_pVstPlugin->m_bRecordAutomation ? MF_CHECKED : 0, ID_PLUG_RECORDAUTOMATION, "Record &Parameter Changes\t" + ih->GetKeyTextFromCommand(kcVSTGUIToggleRecordParams)); + //Record MIDI Out + m_pOptionsMenu->AppendMenu(MF_STRING | m_pVstPlugin->m_bRecordMIDIOut ? MF_CHECKED : 0, + ID_PLUG_RECORD_MIDIOUT, "Record &MIDI Out to Pattern Editor\t" + ih->GetKeyTextFromCommand(kcVSTGUIToggleRecordMIDIOut)); //Pass on keypresses m_pOptionsMenu->AppendMenu(MF_STRING | m_pVstPlugin->m_bPassKeypressesToPlug ? MF_CHECKED : 0, ID_PLUG_PASSKEYS, "Pass &Keys to Plugin\t" + ih->GetKeyTextFromCommand(kcVSTGUIToggleSendKeysToPlug)); Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2013-03-09 22:44:19 UTC (rev 1556) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2013-03-10 15:57:47 UTC (rev 1557) @@ -42,6 +42,7 @@ afx_msg void OnSetPreset(UINT nID); afx_msg void OnBypassPlug(); afx_msg void OnRecordAutomation(); + afx_msg void OnRecordMIDIOut(); afx_msg void OnPassKeypressesToPlug(); afx_msg void OnSetPreviousVSTPreset(); afx_msg void OnSetNextVSTPreset(); Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2013-03-09 22:44:19 UTC (rev 1556) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2013-03-10 15:57:47 UTC (rev 1557) @@ -591,9 +591,9 @@ DefineKeyCommand(kcPatternEditPCNotePlugin, 1836, _T("Edit Plugin assigned to PC Event")); DefineKeyCommand(kcInstrumentEnvelopeZoomIn, 1837, _T("Zoom In")); DefineKeyCommand(kcInstrumentEnvelopeZoomOut, 1838, _T("Zoom Out")); - DefineKeyCommand(kcVSTGUIToggleRecordParams, 1839, _T("Toggle parameter recording")); - DefineKeyCommand(kcVSTGUIToggleSendKeysToPlug, 1840, _T("Pass key presses to plugin")); - DefineKeyCommand(kcVSTGUIBypassPlug, 1841, _T("Bypass plugin")); + DefineKeyCommand(kcVSTGUIToggleRecordParams, 1839, _T("Toggle Parameter Recording")); + DefineKeyCommand(kcVSTGUIToggleSendKeysToPlug, 1840, _T("Pass Key Presses to Plugin")); + DefineKeyCommand(kcVSTGUIBypassPlug, 1841, _T("Bypass Plugin")); DefineKeyCommand(kcInsNoteMapTransposeDown, 1842, _T("Transpose -1 (Note Map)")); DefineKeyCommand(kcInsNoteMapTransposeUp, 1843, _T("Transpose +1 (Note Map)")); DefineKeyCommand(kcInsNoteMapTransposeOctDown, 1844, _T("Transpose -12 (Note Map)")); @@ -651,6 +651,7 @@ DefineKeyCommand(kcToggleNoteOffRecordMIDI, 1896, _T("Toggle Note Off record (MIDI)")); DefineKeyCommand(kcFindInstrument, 1897, _T("Pick up nearest instrument number")); DefineKeyCommand(kcPlaySongFromPattern, 1898, _T("Play Song from Pattern Start")); + DefineKeyCommand(kcVSTGUIToggleRecordMIDIOut, 1899, _T("Record MIDI Out to Pattern Editor")); // Add new key commands here. Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2013-03-09 22:44:19 UTC (rev 1556) +++ trunk/OpenMPT/mptrack/CommandSet.h 2013-03-10 15:57:47 UTC (rev 1557) @@ -1052,6 +1052,7 @@ kcVSTGUINextPresetJump, kcVSTGUIRandParams, kcVSTGUIToggleRecordParams, + kcVSTGUIToggleRecordMIDIOut, kcVSTGUIToggleSendKeysToPlug, kcVSTGUIBypassPlug, kcEndVSTGUICommands=kcVSTGUIBypassPlug, Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-03-09 22:44:19 UTC (rev 1556) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-03-10 15:57:47 UTC (rev 1557) @@ -1346,9 +1346,10 @@ void CVstPlugin::Initialize(CSoundFile* pSndFile) //----------------------------------------------- { - m_bNeedIdle=false; - m_bRecordAutomation=false; - m_bPassKeypressesToPlug=false; + m_bNeedIdle = false; + m_bRecordAutomation = false; + m_bPassKeypressesToPlug = false; + m_bRecordMIDIOut = false; //rewbs.VSTcompliance //Store a pointer so we can get the CVstPlugin object from the basic VST effect object. @@ -2068,6 +2069,20 @@ } } } + + if(m_bRecordMIDIOut) + { + // Spam MIDI data to all views + for(VstInt32 i = 0; i < events->numEvents; i++) + { + // Let's do some dispatching, because the VST SDK doesn't do it for us. :-( + if(events->events[i]->type == kVstMidiType) + { + VstMidiEvent *event = reinterpret_cast<VstMidiEvent *>(events->events[i]); + ::PostMessage(CMainFrame::GetMainFrame()->GetMidiRecordWnd(), WM_MOD_MIDIMSG, *reinterpret_cast<uint32 *>(event->midiData), reinterpret_cast<LPARAM>(this)); + } + } + } } Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2013-03-09 22:44:19 UTC (rev 1556) +++ trunk/OpenMPT/mptrack/Vstplug.h 2013-03-10 15:57:47 UTC (rev 1557) @@ -168,6 +168,12 @@ PluginEventQueue<vstNumProcessEvents> vstEvents; // MIDI events that should be sent to the plugin public: + bool m_bNeedIdle; //rewbs.VSTCompliance + bool m_bRecordAutomation; + bool m_bPassKeypressesToPlug; + bool m_bRecordMIDIOut; + +public: CVstPlugin(HINSTANCE hLibrary, VSTPluginLib *pFactory, SNDMIXPLUGIN *pMixPlugin, AEffect *pEffect); virtual ~CVstPlugin(); void Initialize(CSoundFile* pSndFile); @@ -190,8 +196,10 @@ bool RandomizeParams(PlugParamIndex minParam = 0, PlugParamIndex maxParam = 0); #ifdef MODPLUG_TRACKER inline CModDoc *GetModDoc() { return m_pModDoc; } + inline const CModDoc *GetModDoc() const { return m_pModDoc; } #endif // MODPLUG_TRACKER inline CSoundFile *GetSoundFile() { return m_pSndFile; } + inline const CSoundFile *GetSoundFile() const { return m_pSndFile; } PLUGINDEX FindSlot(); void SetSlot(PLUGINDEX slot); PLUGINDEX GetSlot(); @@ -243,9 +251,6 @@ void HardAllNotesOff(); //rewbs.VSTiNoteHoldonStopFix bool isPlaying(UINT note, UINT midiChn, UINT trackerChn); //rewbs.instroVST bool MoveNote(UINT note, UINT midiChn, UINT sourceTrackerChn, UINT destTrackerChn); //rewbs.instroVST - bool m_bNeedIdle; //rewbs.VSTCompliance - bool m_bRecordAutomation; - bool m_bPassKeypressesToPlug; void NotifySongPlaying(bool playing); //rewbs.VSTCompliance bool IsSongPlaying() {return m_bSongPlaying;} //rewbs.VSTCompliance bool IsResumed() {return m_bPlugResumed;} Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2013-03-09 22:44:19 UTC (rev 1556) +++ trunk/OpenMPT/mptrack/resource.h 2013-03-10 15:57:47 UTC (rev 1557) @@ -1209,6 +1209,7 @@ #define ID_SAMPLE_MONOCONVERT_RIGHT 44607 #define ID_SAMPLE_MONOCONVERT_SPLIT 44608 #define ID_SETQUANTIZE 44609 +#define ID_PLUG_RECORD_MIDIOUT 44610 // Next default values for new objects // @@ -1216,7 +1217,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 536 -#define _APS_NEXT_COMMAND_VALUE 44610 +#define _APS_NEXT_COMMAND_VALUE 44611 #define _APS_NEXT_CONTROL_VALUE 2441 #define _APS_NEXT_SYMED_VALUE 901 #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-12 01:57:01
|
Revision: 1563 http://sourceforge.net/p/modplug/code/1563 Author: saga-games Date: 2013-03-12 01:56:50 +0000 (Tue, 12 Mar 2013) Log Message: ----------- [Ref] More include file juggling [Fix] Accidentally broke version comparison when loading ini file in previous commit. Modified Paths: -------------- trunk/OpenMPT/mptrack/PatternClipboard.h trunk/OpenMPT/mptrack/PatternCursor.h trunk/OpenMPT/mptrack/TrackerSettings.cpp Modified: trunk/OpenMPT/mptrack/PatternClipboard.h =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.h 2013-03-12 01:41:35 UTC (rev 1562) +++ trunk/OpenMPT/mptrack/PatternClipboard.h 2013-03-12 01:56:50 UTC (rev 1563) @@ -11,10 +11,11 @@ #pragma once #include <deque> -#include "Sndfile.h" +#include "Snd_defs.h" #include "PatternCursor.h" struct ModCommandPos; +class CSoundFile; //=========================== class PatternClipboardElement Modified: trunk/OpenMPT/mptrack/PatternCursor.h =================================================================== --- trunk/OpenMPT/mptrack/PatternCursor.h 2013-03-12 01:41:35 UTC (rev 1562) +++ trunk/OpenMPT/mptrack/PatternCursor.h 2013-03-12 01:56:50 UTC (rev 1563) @@ -187,8 +187,10 @@ { chn = maxChans - 1; col = lastColumn; + } else if(col > lastColumn) + { + col = lastColumn; } - LimitMax(col, lastColumn); Set(row, chn, col); }; Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-12 01:41:35 UTC (rev 1562) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-12 01:56:50 UTC (rev 1563) @@ -231,11 +231,10 @@ void TrackerSettings::LoadINISettings(const CString &iniFile) //---------------------------------------------------------- { - //CHAR collectedString[INIBUFFERSIZE]; MptVersion::VersionNum vIniVersion; vIniVersion = gcsPreviousVersion = MptVersion::ToNum(CMainFrame::GetPrivateProfileCString("Version", "Version", "", iniFile)); - if(vIniVersion = 0) + if(vIniVersion == 0) vIniVersion = MptVersion::num; gcsInstallGUID = CMainFrame::GetPrivateProfileCString("Version", "InstallGUID", "", iniFile); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-12 02:33:36
|
Revision: 1564 http://sourceforge.net/p/modplug/code/1564 Author: saga-games Date: 2013-03-12 02:33:25 +0000 (Tue, 12 Mar 2013) Log Message: ----------- [Ref] Be even smarter and use static functions for less typing and less implicit parameters that we don't need anyway. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/PatternClipboard.cpp trunk/OpenMPT/mptrack/PatternClipboard.h trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/View_pat.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-03-12 01:56:50 UTC (rev 1563) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-03-12 02:33:25 UTC (rev 1564) @@ -585,8 +585,8 @@ { const OrdSelection ordsel = GetCurSel(false); BeginWaitCursor(); - PatternClipboard::Instance().Copy(*m_pModDoc->GetSoundFile(), ordsel.firstOrd, ordsel.lastOrd); - PatternClipboardDialog::Instance().UpdateList(); + PatternClipboard::Copy(*m_pModDoc->GetSoundFile(), ordsel.firstOrd, ordsel.lastOrd); + PatternClipboardDialog::UpdateList(); EndWaitCursor(); } Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-12 01:56:50 UTC (rev 1563) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-12 02:33:25 UTC (rev 1564) @@ -1933,7 +1933,7 @@ void CMainFrame::OnClipboardManager() //----------------------------------- { - PatternClipboardDialog::Instance().Show(); + PatternClipboardDialog::Show(); } Modified: trunk/OpenMPT/mptrack/PatternClipboard.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.cpp 2013-03-12 01:56:50 UTC (rev 1563) +++ trunk/OpenMPT/mptrack/PatternClipboard.cpp 2013-03-12 02:33:25 UTC (rev 1564) @@ -31,10 +31,10 @@ * Pattern data... */ -PatternClipboard PatternClipboard::patternClipboard; +PatternClipboard PatternClipboard::instance; -CString PatternClipboard::GetFileExtension(const char *ext) const -//--------------------------------------------------------------- +CString PatternClipboard::GetFileExtension(const char *ext) +//--------------------------------------------------------- { CString format(ext); if(format.GetLength() > 3) @@ -105,12 +105,12 @@ } data.Append("\r\n" + patternData); - if(activeClipboard < clipboards.size()) + if(instance.activeClipboard < instance.clipboards.size()) { // Copy to internal clipboard CString desc; desc.Format("%u Patterns (%u to %u)", last - first + 1, first, last); - clipboards[activeClipboard] = PatternClipboardElement(data, desc); + instance.clipboards[instance.activeClipboard] = PatternClipboardElement(data, desc); } return ToSystemClipboard(data); @@ -130,12 +130,12 @@ // Set up clipboard header. data = "ModPlug Tracker " + GetFileExtension(sndFile.GetModSpecifications().fileExtension) + "\r\n" + data; - if(activeClipboard < clipboards.size()) + if(instance.activeClipboard < instance.clipboards.size()) { // Copy to internal clipboard CString desc; desc.Format("%u rows, %u channels (pattern %u)", selection.GetNumRows(), selection.GetNumChannels(), pattern); - clipboards[activeClipboard] = PatternClipboardElement(data, desc); + instance.clipboards[instance.activeClipboard] = PatternClipboardElement(data, desc); } return ToSystemClipboard(data); @@ -288,7 +288,7 @@ if(!FromSystemClipboard(data) || !HandlePaste(sndFile, pastePos, mode, data, curOrder)) { // Fall back to internal clipboard if there's no valid pattern data in the system clipboard. - return Paste(sndFile, pastePos, mode, curOrder, activeClipboard); + return Paste(sndFile, pastePos, mode, curOrder, instance.activeClipboard); } return true; } @@ -298,11 +298,11 @@ bool PatternClipboard::Paste(CSoundFile &sndFile, ModCommandPos &pastePos, PasteModes mode, ORDERINDEX curOrder, clipindex_t internalClipboard) //--------------------------------------------------------------------------------------------------------------------------------------------- { - if(internalClipboard >= clipboards.size()) + if(internalClipboard >= instance.clipboards.size()) { return false; } - return HandlePaste(sndFile, pastePos, mode, clipboards[internalClipboard].content, curOrder); + return HandlePaste(sndFile, pastePos, mode, instance.clipboards[internalClipboard].content, curOrder); } @@ -788,8 +788,8 @@ bool PatternClipboard::SelectClipboard(clipindex_t which) //------------------------------------------------------- { - activeClipboard = which; - return ToSystemClipboard(clipboards[activeClipboard]); + instance.activeClipboard = which; + return ToSystemClipboard(instance.clipboards[instance.activeClipboard]); } @@ -797,13 +797,13 @@ bool PatternClipboard::CycleForward() //----------------------------------- { - activeClipboard++; - if(activeClipboard >= clipboards.size()) + instance.activeClipboard++; + if(instance.activeClipboard >= instance.clipboards.size()) { - activeClipboard = 0; + instance.activeClipboard = 0; } - return SelectClipboard(activeClipboard); + return SelectClipboard(instance.activeClipboard); } @@ -811,15 +811,15 @@ bool PatternClipboard::CycleBackward() //------------------------------------ { - if(activeClipboard == 0) + if(instance.activeClipboard == 0) { - activeClipboard = clipboards.size() - 1; + instance.activeClipboard = instance.clipboards.size() - 1; } else { - activeClipboard--; + instance.activeClipboard--; } - return SelectClipboard(activeClipboard); + return SelectClipboard(instance.activeClipboard); } @@ -827,8 +827,8 @@ void PatternClipboard::SetClipboardSize(clipindex_t maxEntries) //------------------------------------------------------------- { - clipboards.resize(maxEntries, PatternClipboardElement("", "unused")); - LimitMax(activeClipboard, maxEntries - 1); + instance.clipboards.resize(maxEntries, PatternClipboardElement("", "unused")); + LimitMax(instance.activeClipboard, maxEntries - 1); } @@ -894,7 +894,7 @@ ON_LBN_SELCHANGE(IDC_LIST1, OnSelectClipboard) END_MESSAGE_MAP() -PatternClipboardDialog PatternClipboardDialog::patternClipboardDialog(PatternClipboard::patternClipboard); +PatternClipboardDialog PatternClipboardDialog::instance; void PatternClipboardDialog::DoDataExchange(CDataExchange* pDX) //------------------------------------------------------------- @@ -904,8 +904,8 @@ } -PatternClipboardDialog::PatternClipboardDialog(PatternClipboard &c) : clipboards(c), isLocked(true), isCreated(false), posX(-1) -//----------------------------------------------------------------------------------------------------------------------------- +PatternClipboardDialog::PatternClipboardDialog() : isLocked(true), isCreated(false), posX(-1) +//------------------------------------------------------------------------------------------- { } @@ -913,18 +913,18 @@ void PatternClipboardDialog::Show() //--------------------------------- { - isLocked = true; - if(!isCreated) + instance.isLocked = true; + if(!instance.isCreated) { - Create(IDD_CLIPBOARD, CMainFrame::GetMainFrame()); - numClipboardsSpin.SetRange(0, int16_max); + instance.Create(IDD_CLIPBOARD, CMainFrame::GetMainFrame()); + instance.numClipboardsSpin.SetRange(0, int16_max); } - SetDlgItemInt(IDC_EDIT1, clipboards.GetClipboardSize(), FALSE); - isLocked = false; - isCreated = true; - UpdateList(); + instance.SetDlgItemInt(IDC_EDIT1, PatternClipboard::GetClipboardSize(), FALSE); + instance.isLocked = false; + instance.isCreated = true; + instance.UpdateList(); - SetWindowPos(nullptr, posX, posY, 0, 0, SWP_SHOWWINDOW | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER | (posX == -1 ? SWP_NOMOVE : 0)); + instance.SetWindowPos(nullptr, instance.posX, instance.posY, 0, 0, SWP_SHOWWINDOW | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_NOZORDER | (instance.posX == -1 ? SWP_NOMOVE : 0)); } @@ -935,7 +935,7 @@ { return; } - clipboards.SetClipboardSize(GetDlgItemInt(IDC_EDIT1, nullptr, FALSE)); + PatternClipboard::SetClipboardSize(GetDlgItemInt(IDC_EDIT1, nullptr, FALSE)); UpdateList(); } @@ -943,19 +943,19 @@ void PatternClipboardDialog::UpdateList() //--------------------------------------- { - if(isLocked) + if(instance.isLocked) { return; } - clipList.ResetContent(); + instance.clipList.ResetContent(); PatternClipboard::clipindex_t i = 0; - for(std::deque<PatternClipboardElement>::const_iterator clip = clipboards.clipboards.cbegin(); clip != clipboards.clipboards.cend(); clip++, i++) + for(std::deque<PatternClipboardElement>::const_iterator clip = PatternClipboard::instance.clipboards.cbegin(); clip != PatternClipboard::instance.clipboards.cend(); clip++, i++) { - const int item = clipList.AddString(clip->description); - clipList.SetItemDataPtr(item, reinterpret_cast<void *>(i)); - if(clipboards.activeClipboard == i) + const int item = instance.clipList.AddString(clip->description); + instance.clipList.SetItemDataPtr(item, reinterpret_cast<void *>(i)); + if(PatternClipboard::instance.activeClipboard == i) { - clipList.SetCurSel(item); + instance.clipList.SetCurSel(item); } } } @@ -969,7 +969,7 @@ return; } PatternClipboard::clipindex_t item = reinterpret_cast<PatternClipboard::clipindex_t>(clipList.GetItemDataPtr(clipList.GetCurSel())); - clipboards.SelectClipboard(item); + PatternClipboard::SelectClipboard(item); } Modified: trunk/OpenMPT/mptrack/PatternClipboard.h =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.h 2013-03-12 01:56:50 UTC (rev 1563) +++ trunk/OpenMPT/mptrack/PatternClipboard.h 2013-03-12 02:33:25 UTC (rev 1564) @@ -56,7 +56,7 @@ protected: // The one and only pattern clipboard object. - static PatternClipboard patternClipboard; + static PatternClipboard instance; // Active internal clipboard index clipindex_t activeClipboard; @@ -65,43 +65,41 @@ public: - PatternClipboard() : activeClipboard(0) { SetClipboardSize(1); }; - // Copy a range of patterns to both the system clipboard and the internal clipboard. - bool Copy(CSoundFile &sndFile, ORDERINDEX first, ORDERINDEX last); + static bool Copy(CSoundFile &sndFile, ORDERINDEX first, ORDERINDEX last); // Copy a pattern selection to both the system clipboard and the internal clipboard. - bool Copy(CSoundFile &sndFile, PATTERNINDEX pattern, PatternRect selection); + static bool Copy(CSoundFile &sndFile, PATTERNINDEX pattern, PatternRect selection); // Try pasting a pattern selection from the system clipboard. - bool Paste(CSoundFile &sndFile, ModCommandPos &pastePos, PasteModes mode, ORDERINDEX curOrder); + static bool Paste(CSoundFile &sndFile, ModCommandPos &pastePos, PasteModes mode, ORDERINDEX curOrder); // Try pasting a pattern selection from an internal clipboard. - bool Paste(CSoundFile &sndFile, ModCommandPos &pastePos, PasteModes mode, ORDERINDEX curOrder, clipindex_t internalClipboard); + static bool Paste(CSoundFile &sndFile, ModCommandPos &pastePos, PasteModes mode, ORDERINDEX curOrder, clipindex_t internalClipboard); // Copy one of the internal clipboards to the system clipboard. - bool SelectClipboard(clipindex_t which); + static bool SelectClipboard(clipindex_t which); // Switch to the next internal clipboard. - bool CycleForward(); + static bool CycleForward(); // Switch to the previous internal clipboard. - bool CycleBackward(); + static bool CycleBackward(); // Set the maximum number of internal clipboards. - void SetClipboardSize(clipindex_t maxEntries); + static void SetClipboardSize(clipindex_t maxEntries); // Return the current number of clipboards. - clipindex_t GetClipboardSize() const { return clipboards.size(); }; + static clipindex_t GetClipboardSize() { return instance.clipboards.size(); }; - // Get the pattern clipboard singleton - static PatternClipboard &Instance() { return patternClipboard; } - protected: + PatternClipboard() : activeClipboard(0) { SetClipboardSize(1); }; + + static CString GetFileExtension(const char *ext); + // Create the clipboard text for a pattern selection - CString CreateClipboardString(CSoundFile &sndFile, PATTERNINDEX pattern, PatternRect selection); + static CString CreateClipboardString(CSoundFile &sndFile, PATTERNINDEX pattern, PatternRect selection); - CString GetFileExtension(const char *ext) const; // Parse clipboard string and perform the pasting operation. - bool HandlePaste(CSoundFile &sndFile, ModCommandPos &pastePos, PasteModes mode, const CString &data, ORDERINDEX curOrder); + static bool HandlePaste(CSoundFile &sndFile, ModCommandPos &pastePos, PasteModes mode, const CString &data, ORDERINDEX curOrder); // System-specific clipboard functions - bool ToSystemClipboard(const PatternClipboardElement &clipboard) { return ToSystemClipboard(clipboard.content); }; - bool ToSystemClipboard(const CString &data); - bool FromSystemClipboard(CString &data); + static bool ToSystemClipboard(const PatternClipboardElement &clipboard) { return ToSystemClipboard(clipboard.content); }; + static bool ToSystemClipboard(const CString &data); + static bool FromSystemClipboard(CString &data); }; @@ -112,9 +110,8 @@ protected: // The one and only pattern clipboard dialog object - static PatternClipboardDialog patternClipboardDialog; + static PatternClipboardDialog instance; - PatternClipboard &clipboards; CSpinButtonCtrl numClipboardsSpin; CListBox clipList; int posX, posY; @@ -122,16 +119,14 @@ public: - PatternClipboardDialog(PatternClipboard &c); - void UpdateList(); - void Show(); - void Toggle() { if(isCreated) OnCancel(); else Show(); } + static void UpdateList(); + static void Show(); + static void Toggle() { if(instance.isCreated) instance.OnCancel(); else instance.Show(); } - // Get the pattern clipboard dialog singleton - static PatternClipboardDialog &Instance() { return patternClipboardDialog; } - protected: + PatternClipboardDialog(); + virtual void DoDataExchange(CDataExchange* pDX); DECLARE_MESSAGE_MAP(); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-12 01:56:50 UTC (rev 1563) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-12 02:33:25 UTC (rev 1564) @@ -395,7 +395,7 @@ m_nSampleUndoMaxBuffer = CMainFrame::GetPrivateProfileLong("Sample Editor" , "UndoBufferSize", m_nSampleUndoMaxBuffer >> 20, iniFile); m_nSampleUndoMaxBuffer = max(1, m_nSampleUndoMaxBuffer) << 20; - PatternClipboard::Instance().SetClipboardSize(GetPrivateProfileInt("Pattern Editor", "NumClipboards", PatternClipboard::Instance().GetClipboardSize(), iniFile)); + PatternClipboard::SetClipboardSize(GetPrivateProfileInt("Pattern Editor", "NumClipboards", PatternClipboard::GetClipboardSize(), iniFile)); // Default Paths TCHAR szPath[_MAX_PATH] = ""; @@ -754,7 +754,7 @@ CMainFrame::WritePrivateProfileDWord("Pattern Editor", "AutoChordWaitTime", gnAutoChordWaitTime, iniFile); CMainFrame::WritePrivateProfileDWord("Pattern Editor", "RecordQuantize", recordQuantizeRows, iniFile); - CMainFrame::WritePrivateProfileDWord("Pattern Editor", "NumClipboards", PatternClipboard::Instance().GetClipboardSize(), iniFile); + CMainFrame::WritePrivateProfileDWord("Pattern Editor", "NumClipboards", PatternClipboard::GetClipboardSize(), iniFile); // Write default paths const bool bConvertPaths = theApp.IsPortableMode(); Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-12 01:56:50 UTC (rev 1563) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-12 02:33:25 UTC (rev 1564) @@ -4366,15 +4366,15 @@ // Clipboard Manager case kcToggleClipboardManager: - PatternClipboardDialog::Instance().Toggle(); + PatternClipboardDialog::Toggle(); break; case kcClipboardPrev: - PatternClipboard::Instance().CycleBackward(); - PatternClipboardDialog::Instance().UpdateList(); + PatternClipboard::CycleBackward(); + PatternClipboardDialog::UpdateList(); break; case kcClipboardNext: - PatternClipboard::Instance().CycleForward(); - PatternClipboardDialog::Instance().UpdateList(); + PatternClipboard::CycleForward(); + PatternClipboardDialog::UpdateList(); break; } @@ -6664,9 +6664,9 @@ //--------------------------------------------------------------------------------- { BeginWaitCursor(); - bool result = PatternClipboard::Instance().Copy(*GetSoundFile(), nPattern, selection); + bool result = PatternClipboard::Copy(*GetSoundFile(), nPattern, selection); EndWaitCursor(); - PatternClipboardDialog::Instance().UpdateList(); + PatternClipboardDialog::UpdateList(); return result; } @@ -6680,7 +6680,7 @@ pos.pattern = nPattern; pos.row = pastePos.GetRow(); pos.channel = pastePos.GetChannel(); - bool result = PatternClipboard::Instance().Paste(*GetSoundFile(), pos, mode, SendCtrlMessage(CTRLMSG_GETCURRENTORDER)); + bool result = PatternClipboard::Paste(*GetSoundFile(), pos, mode, SendCtrlMessage(CTRLMSG_GETCURRENTORDER)); EndWaitCursor(); if(pos.pattern != nPattern) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-16 23:32:32
|
Revision: 1583 http://sourceforge.net/p/modplug/code/1583 Author: saga-games Date: 2013-03-16 23:32:19 +0000 (Sat, 16 Mar 2013) Log Message: ----------- [Imp] Pattern Editor: Chord mode does now also work if no record channels are selected. [Fix] Pattern Editor: Note stops didn't work with "Play Whole Row" mode. [Fix] Pattern Editor: When entering a chord, notes played via instrument plugins were not stopped on key-up. [Ref] Boy, that chord entering code was UGLY! Modified Paths: -------------- trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-03-16 21:03:51 UTC (rev 1582) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-03-16 23:32:19 UTC (rev 1583) @@ -886,8 +886,8 @@ } -UINT CModDoc::PlayNote(UINT note, INSTRUMENTINDEX nins, SAMPLEINDEX nsmp, bool pause, LONG nVol, SmpLength loopStart, SmpLength loopEnd, CHANNELINDEX nCurrentChn, const SmpLength sampleOffset) //rewbs.vstiLive: added current chan param -//---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +CHANNELINDEX CModDoc::PlayNote(UINT note, INSTRUMENTINDEX nins, SAMPLEINDEX nsmp, bool pause, LONG nVol, SmpLength loopStart, SmpLength loopEnd, CHANNELINDEX nCurrentChn, const SmpLength sampleOffset) +//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); CHANNELINDEX nChn = GetNumChannels(); @@ -1038,30 +1038,32 @@ } -BOOL CModDoc::NoteOff(UINT note, bool fade, INSTRUMENTINDEX nins, CHANNELINDEX nCurrentChn) //rewbs.vstiLive: added chan and nins -//----------------------------------------------------------------------------------------- +bool CModDoc::NoteOff(UINT note, bool fade, INSTRUMENTINDEX ins, CHANNELINDEX currentChn, CHANNELINDEX stopChn) +//------------------------------------------------------------------------------------------------------------- { CriticalSection cs; //rewbs.vstiLive - if((nins != INSTRUMENTINDEX_INVALID) && (nins <= m_SndFile.GetNumInstruments()) && (note >= NOTE_MIN) && (note <= NOTE_MAX)) + if(ins != INSTRUMENTINDEX_INVALID && ins <= m_SndFile.GetNumInstruments() && ModCommand::IsNote(note)) { - ModInstrument *pIns = m_SndFile.Instruments[nins]; - if (pIns && pIns->HasValidMIDIChannel()) // instro sends to a midi chan + ModInstrument *pIns = m_SndFile.Instruments[ins]; + if(pIns && pIns->HasValidMIDIChannel()) // instro sends to a midi chan { - UINT nPlugin = pIns->nMixPlug; // First try intrument VST - if (((!nPlugin) || (nPlugin > MAX_MIXPLUGINS)) && //no good plug yet - (nCurrentChn < MAX_BASECHANNELS)) // chan OK - nPlugin = m_SndFile.ChnSettings[nCurrentChn].nMixPlugin;// Then try Channel VST + PLUGINDEX plug = pIns->nMixPlug; // First try intrument VST + if((!plug || plug > MAX_MIXPLUGINS) // No good plug yet + && currentChn < MAX_BASECHANNELS) // Chan OK + { + plug = m_SndFile.ChnSettings[currentChn].nMixPlugin;// Then try Channel VST + } - if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS)) + if(plug && plug <= MAX_MIXPLUGINS) { - IMixPlugin *pPlugin = m_SndFile.m_MixPlugins[nPlugin - 1].pMixPlugin; - if (pPlugin) + IMixPlugin *pPlugin = m_SndFile.m_MixPlugins[plug - 1].pMixPlugin; + if(pPlugin) { - pPlugin->MidiCommand(GetPlaybackMidiChannel(pIns, nCurrentChn), pIns->nMidiProgram, pIns->wMidiBank, pIns->NoteMap[note - 1] + NOTE_KEYOFF, 0, MAX_BASECHANNELS); + pPlugin->MidiCommand(GetPlaybackMidiChannel(pIns, currentChn), pIns->nMidiProgram, pIns->wMidiBank, pIns->NoteMap[note - 1] + NOTE_KEYOFF, 0, MAX_BASECHANNELS); } } } @@ -1069,8 +1071,8 @@ //end rewbs.vstiLive const ChannelFlags mask = (fade ? CHN_NOTEFADE : (CHN_NOTEFADE | CHN_KEYOFF)); - ModChannel *pChn = &m_SndFile.Chn[m_SndFile.m_nChannels]; - for (CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++, pChn++) if (!pChn->nMasterChn) + ModChannel *pChn = &m_SndFile.Chn[stopChn != CHANNELINDEX_INVALID ? stopChn : m_SndFile.m_nChannels]; + for(CHANNELINDEX i = m_SndFile.GetNumChannels(); i < MAX_CHANNELS; i++, pChn++) if (!pChn->nMasterChn) { // Fade all channels > m_nChannels which are playing this note. @@ -1084,7 +1086,7 @@ } } - return TRUE; + return true; } @@ -1982,16 +1984,13 @@ pChildFrm->SendViewMessage(VIEWMSG_PATTERNLOOP, 0); } - + CriticalSection cs; pMainFrm->PauseMod(); m_SndFile.m_SongFlags.reset(SONG_STEP | SONG_PATTERNLOOP); m_SndFile.SetCurrentPos(0); - m_SndFile.visitedSongRows.Initialize(true); + //m_SndFile.visitedSongRows.Initialize(true); m_SndFile.m_lTotalSampleCount = 0; - m_SndFile.m_bPositionChanged = true; - CriticalSection cs; - m_SndFile.m_bPositionChanged = true; m_SndFile.ResumePlugins(); Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-03-16 21:03:51 UTC (rev 1582) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-03-16 23:32:19 UTC (rev 1583) @@ -249,8 +249,8 @@ bool RemoveSample(SAMPLEINDEX nSmp); bool RemoveInstrument(INSTRUMENTINDEX nIns); - UINT PlayNote(UINT note, INSTRUMENTINDEX nins, SAMPLEINDEX nsmp, bool pause, LONG nVol=-1, SmpLength loopStart = 0, SmpLength loopEnd = 0, CHANNELINDEX nCurrentChn = CHANNELINDEX_INVALID, const SmpLength sampleOffset = 0); //rewbs.vstiLive: added current chan param - BOOL NoteOff(UINT note, bool fade = false, INSTRUMENTINDEX nins = INSTRUMENTINDEX_INVALID, CHANNELINDEX nCurrentChn = CHANNELINDEX_INVALID); //rewbs.vstiLive: add params + CHANNELINDEX PlayNote(UINT note, INSTRUMENTINDEX nins, SAMPLEINDEX nsmp, bool pause, LONG nVol=-1, SmpLength loopStart = 0, SmpLength loopEnd = 0, CHANNELINDEX nCurrentChn = CHANNELINDEX_INVALID, const SmpLength sampleOffset = 0); + bool NoteOff(UINT note, bool fade = false, INSTRUMENTINDEX ins = INSTRUMENTINDEX_INVALID, CHANNELINDEX currentChn = CHANNELINDEX_INVALID, CHANNELINDEX stopChn = CHANNELINDEX_INVALID); //rewbs.vstiLive: add params bool IsNotePlaying(UINT note, SAMPLEINDEX nsmp = 0, INSTRUMENTINDEX nins = 0); bool MuteChannel(CHANNELINDEX nChn, bool bMute); Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-16 21:03:51 UTC (rev 1582) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-16 23:32:19 UTC (rev 1583) @@ -173,7 +173,7 @@ AppendNotesToControlEx(*combo, pSndFile); UINT ncount = combo->GetCount(); - for (UINT i=0; i<ncount; i++) if (m_nNote == combo->GetItemData(i)) + for (UINT i=0; i<ncount; i++) if (m_Cmd.note == combo->GetItemData(i)) { combo->SetCurSel(i); break; @@ -202,7 +202,7 @@ UINT ncount = combo->GetCount(); for (UINT i=0; i<ncount; i++) { - if (m_nInstr == combo->GetItemData(i) || (cInstrRelChange == -1 && combo->GetItemData(i) == replaceInstrumentMinusOne) || (cInstrRelChange == 1 && combo->GetItemData(i) == replaceInstrumentPlusOne)) + if (m_Cmd.instr == combo->GetItemData(i) || (cInstrRelChange == -1 && combo->GetItemData(i) == replaceInstrumentMinusOne) || (cInstrRelChange == 1 && combo->GetItemData(i) == replaceInstrumentPlusOne)) { combo->SetCurSel(i); break; @@ -223,7 +223,7 @@ } } combo->SetCurSel(0); - UINT fxndx = effectInfo.GetIndexFromVolCmd(ModCommand::VOLCMD(m_nVolCmd)); + UINT fxndx = effectInfo.GetIndexFromVolCmd(ModCommand::VOLCMD(m_Cmd.volcmd)); for (UINT i=0; i<=count; i++) if (fxndx == combo->GetItemData(i)) { combo->SetCurSel(i); @@ -240,7 +240,7 @@ combo->SetItemData(combo->AddString(s), n); } UINT ncount = combo->GetCount(); - for (UINT i=0; i<ncount; i++) if (m_nVol == combo->GetItemData(i)) + for (UINT i=0; i<ncount; i++) if (m_Cmd.vol == combo->GetItemData(i)) { combo->SetCurSel(i); break; @@ -260,7 +260,7 @@ } } combo->SetCurSel(0); - UINT fxndx = effectInfo.GetIndexFromEffect(ModCommand::COMMAND(m_nCommand), ModCommand::PARAM(m_nParam)); + UINT fxndx = effectInfo.GetIndexFromEffect(ModCommand::COMMAND(m_Cmd.command), ModCommand::PARAM(m_Cmd.param)); for (UINT i=0; i<=count; i++) if (fxndx == combo->GetItemData(i)) { combo->SetCurSel(i); @@ -292,7 +292,7 @@ { CHAR s[16]; int newpos; - if (oldcount) newpos = combo->GetCurSel() % newcount; else newpos = m_nParam % newcount; + if (oldcount) newpos = combo->GetCurSel() % newcount; else newpos = m_Cmd.param % newcount; combo->ResetContent(); combo->InitStorage(newcount, 4); for (UINT i=0; i<newcount; i++) @@ -330,7 +330,7 @@ { CHAR s[16]; int newpos; - if (oldcount) newpos = combo->GetCurSel() % newcount; else newpos = m_nParam % newcount; + if (oldcount) newpos = combo->GetCurSel() % newcount; else newpos = m_Cmd.param % newcount; combo->ResetContent(); for (UINT i = rangeMin; i <= rangeMax; i++) { @@ -381,12 +381,12 @@ // Note if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) { - m_nNote = combo->GetItemData(combo->GetCurSel()); + m_Cmd.note = static_cast<ModCommand::NOTE>(combo->GetItemData(combo->GetCurSel())); } // Instrument if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO2)) != NULL) { - m_nInstr = 0; + m_Cmd.instr = 0; cInstrRelChange = 0; switch(combo->GetItemData(combo->GetCurSel())) { @@ -397,19 +397,19 @@ cInstrRelChange = 1; break; default: - m_nInstr = combo->GetItemData(combo->GetCurSel()); + m_Cmd.instr = static_cast<ModCommand::INSTR>(combo->GetItemData(combo->GetCurSel())); break; } } // Volume Command if (((combo = (CComboBox *)GetDlgItem(IDC_COMBO3)) != NULL)) { - m_nVolCmd = effectInfo.GetVolCmdFromIndex(combo->GetItemData(combo->GetCurSel())); + m_Cmd.volcmd = effectInfo.GetVolCmdFromIndex(combo->GetItemData(combo->GetCurSel())); } // Volume if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO4)) != NULL) { - m_nVol = combo->GetItemData(combo->GetCurSel()); + m_Cmd.vol = static_cast<ModCommand::VOL>(combo->GetItemData(combo->GetCurSel())); } // Effect int effectIndex = -1; @@ -417,18 +417,18 @@ { int n = -1; // unused parameter adjustment effectIndex = combo->GetItemData(combo->GetCurSel()); - m_nCommand = effectInfo.GetEffectFromIndex(effectIndex, n); + m_Cmd.command = effectInfo.GetEffectFromIndex(effectIndex, n); } // Param - m_nParam = 0; + m_Cmd.param = 0; if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO6)) != NULL) { - m_nParam = combo->GetItemData(combo->GetCurSel()); + m_Cmd.param = static_cast<ModCommand::PARAM>(combo->GetItemData(combo->GetCurSel())); // Apply parameter value mask if required (e.g. SDx has mask D0). if (effectIndex > -1) { - m_nParam |= effectInfo.GetEffectMaskFromIndex(effectIndex); + m_Cmd.param |= effectInfo.GetEffectMaskFromIndex(effectIndex); } } // Min/Max channels @@ -1663,6 +1663,7 @@ } } + // Show channel properties for a given channel at a given screen position. void QuickChannelProperties::Show(CModDoc *modDoc, CHANNELINDEX chn, PATTERNINDEX ptn, CPoint position) //----------------------------------------------------------------------------------------------------- @@ -1710,7 +1711,7 @@ //------------------------------------------ { // Set up channel properties - settingsChanged = true; + visible = false; const ModChannelSettings &settings = document->GetSoundFile()->ChnSettings[channel]; SetDlgItemInt(IDC_EDIT1, settings.nVolume, FALSE); SetDlgItemInt(IDC_EDIT2, settings.nPan, FALSE); @@ -1726,6 +1727,7 @@ nameEdit.SetWindowText(settings.szName); settingsChanged = false; + visible = true; ::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON1), channel > 0 ? TRUE : FALSE); ::EnableWindow(::GetDlgItem(m_hWnd, IDC_BUTTON2), channel < document->GetNumChannels() - 1 ? TRUE : FALSE); @@ -1750,6 +1752,7 @@ { return; } + uint16 volume = static_cast<uint16>(GetDlgItemInt(IDC_EDIT1)); if(volume >= 0 && volume <= 64) { @@ -1768,6 +1771,7 @@ { return; } + uint16 panning = static_cast<uint16>(GetDlgItemInt(IDC_EDIT2)); if(panning >= 0 && panning <= 256) { @@ -1827,6 +1831,7 @@ { return; } + document->MuteChannel(channel, IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED); document->UpdateAllViews(nullptr, HINT_MODCHANNELS); } @@ -1839,6 +1844,7 @@ { return; } + PrepareUndo(); document->SurroundChannel(channel, IsDlgButtonChecked(IDC_CHECK2) != BST_UNCHECKED); document->UpdateAllViews(nullptr, HINT_MODCHANNELS); @@ -1896,7 +1902,7 @@ if(pMsg) { //We handle keypresses before Windows has a chance to handle them (for alt etc..) - if((pMsg->message == WM_SYSKEYUP) || (pMsg->message == WM_KEYUP) || + if((pMsg->message == WM_SYSKEYUP) || (pMsg->message == WM_KEYUP) || (pMsg->message == WM_SYSKEYDOWN) || (pMsg->message == WM_KEYDOWN)) { CInputHandler* ih = (CMainFrame::GetMainFrame())->GetInputHandler(); Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2013-03-16 21:03:51 UTC (rev 1582) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2013-03-16 23:32:19 UTC (rev 1583) @@ -30,7 +30,7 @@ public: FlagSet<FindReplace::Flags> m_Flags; - UINT m_nNote, m_nInstr, m_nVolCmd, m_nVol, m_nCommand, m_nParam; + ModCommand m_Cmd; CHANNELINDEX m_nMinChannel, m_nMaxChannel; signed char cInstrRelChange; bool m_bPatSel; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-16 21:03:51 UTC (rev 1582) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-16 23:32:19 UTC (rev 1583) @@ -186,6 +186,7 @@ m_nFoundInstrument = 0; m_nLastPlayedRow = 0; m_nLastPlayedOrder = 0; + prevChordNote = 0; } @@ -270,10 +271,10 @@ } else if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) { - ORDERINDEX nCurOrder = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); - if ((nCurOrder > 0) && (nCurOrder < pSndFile->Order.size()) && (m_nPattern == pSndFile->Order[nCurOrder])) + ORDERINDEX curOrder = GetCurrentOrder(); + if ((curOrder > 0) && (curOrder < pSndFile->Order.size()) && (m_nPattern == pSndFile->Order[curOrder])) { - const ORDERINDEX prevOrd = pSndFile->Order.GetPreviousOrderIgnoringSkips(nCurOrder); + const ORDERINDEX prevOrd = pSndFile->Order.GetPreviousOrderIgnoringSkips(curOrder); const PATTERNINDEX nPrevPat = pSndFile->Order[prevOrd]; if ((nPrevPat < pSndFile->Patterns.Size()) && (pSndFile->Patterns[nPrevPat].GetNumRows())) { @@ -297,7 +298,7 @@ row = pSndFile->Patterns[m_nPattern].GetNumRows()-1; } else if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) { - ORDERINDEX curOrder = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); + ORDERINDEX curOrder = GetCurrentOrder(); if(curOrder + 1 < pSndFile->Order.size() && m_nPattern == pSndFile->Order[curOrder]) { const ORDERINDEX nextOrder = pSndFile->Order.GetNextOrderIgnoringSkips(curOrder); @@ -1496,13 +1497,13 @@ if (!pModDoc) return; m_nDragItem = GetDragItem(point, &m_rcDragItem); - DWORD nItemNo = m_nDragItem & DRAGITEM_VALUEMASK; + CHANNELINDEX nItemNo = static_cast<CHANNELINDEX>(m_nDragItem & DRAGITEM_VALUEMASK); switch(m_nDragItem & DRAGITEM_MASK) { case DRAGITEM_CHNHEADER: - if (nFlags & MK_SHIFT) + if(nFlags & MK_SHIFT) { - if (nItemNo < MAX_BASECHANNELS) + if(nItemNo < MAX_BASECHANNELS) { pModDoc->Record2Channel(nItemNo); InvalidateChannelsHeaders(); @@ -1926,22 +1927,12 @@ CFindReplaceTab pageReplace(IDD_EDIT_REPLACE, true, pModDoc); CPropertySheet dlg("Find/Replace"); - pageFind.m_nNote = m_findReplace.cmdFind.note; - pageFind.m_nInstr = m_findReplace.cmdFind.instr; - pageFind.m_nVolCmd = m_findReplace.cmdFind.volcmd; - pageFind.m_nVol = m_findReplace.cmdFind.vol; - pageFind.m_nCommand = m_findReplace.cmdFind.command; - pageFind.m_nParam = m_findReplace.cmdFind.param; + pageFind.m_Cmd = m_findReplace.cmdFind; pageFind.m_Flags = m_findReplace.findFlags; pageFind.m_nMinChannel = m_findReplace.findMinChn; pageFind.m_nMaxChannel = m_findReplace.findMaxChn; pageFind.m_bPatSel = (m_Selection.GetUpperLeft() != m_Selection.GetLowerRight()); - pageReplace.m_nNote = m_findReplace.cmdReplace.note; - pageReplace.m_nInstr = m_findReplace.cmdReplace.instr; - pageReplace.m_nVolCmd = m_findReplace.cmdReplace.volcmd; - pageReplace.m_nVol = m_findReplace.cmdReplace.vol; - pageReplace.m_nCommand = m_findReplace.cmdReplace.command; - pageReplace.m_nParam = m_findReplace.cmdReplace.param; + pageReplace.m_Cmd = m_findReplace.cmdReplace; pageReplace.m_Flags = m_findReplace.replaceFlags; pageReplace.cInstrRelChange = m_findReplace.instrRelChange; if(m_Selection.GetUpperLeft() != m_Selection.GetLowerRight()) @@ -1953,21 +1944,11 @@ dlg.AddPage(&pageReplace); if(dlg.DoModal() == IDOK) { - m_findReplace.cmdFind.note = pageFind.m_nNote; - m_findReplace.cmdFind.instr = pageFind.m_nInstr; - m_findReplace.cmdFind.volcmd = pageFind.m_nVolCmd; - m_findReplace.cmdFind.vol = pageFind.m_nVol; - m_findReplace.cmdFind.command = pageFind.m_nCommand; - m_findReplace.cmdFind.param = pageFind.m_nParam; + m_findReplace.cmdFind = pageFind.m_Cmd; m_findReplace.findMinChn = pageFind.m_nMinChannel; m_findReplace.findMaxChn = pageFind.m_nMaxChannel; m_findReplace.findFlags = pageFind.m_Flags; - m_findReplace.cmdReplace.note = pageReplace.m_nNote; - m_findReplace.cmdReplace.instr = pageReplace.m_nInstr; - m_findReplace.cmdReplace.volcmd = pageReplace.m_nVolCmd; - m_findReplace.cmdReplace.vol = pageReplace.m_nVol; - m_findReplace.cmdReplace.command = pageReplace.m_nCommand; - m_findReplace.cmdReplace.param = pageReplace.m_nParam; + m_findReplace.cmdReplace = pageReplace.m_Cmd; m_findReplace.replaceFlags = pageReplace.m_Flags; m_findReplace.instrRelChange = pageReplace.cInstrRelChange; m_findReplace.selection = m_Selection; @@ -1994,10 +1975,10 @@ if (m_pGotoWnd) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); - ORDERINDEX nCurrentOrder = static_cast<ORDERINDEX>(SendCtrlMessage(CTRLMSG_GETCURRENTORDER)); - CHANNELINDEX nCurrentChannel = GetCurrentChannel() + 1; + ORDERINDEX curOrder = GetCurrentOrder(); + CHANNELINDEX curChannel = GetCurrentChannel() + 1; - m_pGotoWnd->UpdatePos(GetCurrentRow(), nCurrentChannel, m_nPattern, nCurrentOrder, pSndFile); + m_pGotoWnd->UpdatePos(GetCurrentRow(), curChannel, m_nPattern, curOrder, pSndFile); if (m_pGotoWnd->DoModal() == IDOK) { @@ -2006,10 +1987,10 @@ if (m_pGotoWnd->m_nPattern != m_nPattern) SetCurrentPattern(m_pGotoWnd->m_nPattern); - if (m_pGotoWnd->m_nOrder != nCurrentOrder) + if (m_pGotoWnd->m_nOrder != curOrder) SendCtrlMessage(CTRLMSG_SETCURRENTORDER, m_pGotoWnd->m_nOrder); - if (m_pGotoWnd->m_nChannel != nCurrentChannel) + if (m_pGotoWnd->m_nChannel != curChannel) SetCurrentColumn(m_pGotoWnd->m_nChannel - 1); if (m_pGotoWnd->m_nRow != GetCurrentRow()) @@ -2194,7 +2175,7 @@ SendCtrlMessage(CTRLMSG_PAT_FOLLOWSONG, 0); } // This doesn't find the order if it's in another sequence :( - ORDERINDEX matchingOrder = pSndFile->Order.FindOrder(pat, static_cast<ORDERINDEX>(SendCtrlMessage(CTRLMSG_GETCURRENTORDER))); + ORDERINDEX matchingOrder = pSndFile->Order.FindOrder(pat, GetCurrentOrder()); if(matchingOrder != ORDERINDEX_INVALID) { SendCtrlMessage(CTRLMSG_SETCURRENTORDER, matchingOrder); @@ -3290,7 +3271,7 @@ if(pat != m_nPattern) { // Find pattern in sequence. - ORDERINDEX matchingOrder = GetSoundFile()->Order.FindOrder(pat, static_cast<ORDERINDEX>(SendCtrlMessage(CTRLMSG_GETCURRENTORDER))); + ORDERINDEX matchingOrder = GetSoundFile()->Order.FindOrder(pat, GetCurrentOrder()); if(matchingOrder != ORDERINDEX_INVALID) { SendCtrlMessage(CTRLMSG_SETCURRENTORDER, matchingOrder); @@ -4037,7 +4018,7 @@ pState->cursor = m_Cursor; pState->selection = m_Selection; pState->nDetailLevel = m_nDetailLevel; - pState->nOrder = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); //rewbs.playSongFromCursor + pState->nOrder = GetCurrentOrder(); } break; @@ -4254,7 +4235,7 @@ case kcNextPattern: { PATTERNINDEX n = m_nPattern + 1; while ((n < pSndFile->Patterns.Size()) && !pSndFile->Patterns.IsValidPat(n)) n++; SetCurrentPattern((n < pSndFile->Patterns.Size()) ? n : 0); - ORDERINDEX currentOrder = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); + ORDERINDEX currentOrder = GetCurrentOrder(); ORDERINDEX newOrder = pSndFile->Order.FindOrder(m_nPattern, currentOrder, true); SendCtrlMessage(CTRLMSG_SETCURRENTORDER, newOrder); return wParam; @@ -4262,7 +4243,7 @@ case kcPrevPattern: { PATTERNINDEX n = (m_nPattern) ? m_nPattern - 1 : pSndFile->Patterns.Size() - 1; while (n > 0 && !pSndFile->Patterns.IsValidPat(n)) n--; SetCurrentPattern(n); - ORDERINDEX currentOrder = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); + ORDERINDEX currentOrder = GetCurrentOrder(); ORDERINDEX newOrder = pSndFile->Order.FindOrder(m_nPattern, currentOrder, false); SendCtrlMessage(CTRLMSG_SETCURRENTORDER, newOrder); return wParam; @@ -4709,30 +4690,42 @@ const UINT nTick = pSndFile->m_nTickCount; const PATTERNINDEX nPatPlayback = pSndFile->m_nPattern; + const bool liveRecord = IsLiveRecord(); const bool isSplit = IsNoteSplit(note); + const CHANNELINDEX nChnCursor = GetCurrentChannel(); UINT ins = 0; + + BYTE *activeNoteMap = isSplit ? splitActiveNoteChannel : activeNoteChannel; + const CHANNELINDEX nChn = (activeNoteMap[note] < pSndFile->GetNumChannels()) ? activeNoteMap[note] : nChnCursor; + if(pModDoc) { if(isSplit) { ins = pModDoc->GetSplitKeyboardSettings().splitInstrument; - if (pModDoc->GetSplitKeyboardSettings().octaveLink) note += 12 *pModDoc->GetSplitKeyboardSettings().octaveModifier; - if (note > NOTE_MAX && note < NOTE_MIN_SPECIAL) note = NOTE_MAX; - if (note < 0) note = NOTE_MIN; + if(pModDoc->GetSplitKeyboardSettings().octaveLink) note += 12 *pModDoc->GetSplitKeyboardSettings().octaveModifier; + if(note > NOTE_MAX && note < NOTE_MIN_SPECIAL) note = NOTE_MAX; + if(note < 0) note = NOTE_MIN; } if(!ins) ins = GetCurrentInstrument(); if(!ins) ins = m_nFoundInstrument; + const bool playWholeRow = ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord); if(bChordMode == true) { m_Status.reset(psChordPlaying); - pModDoc->NoteOff(0, true, ins, GetCurrentChannel()); // XXX this doesn't stop VSTi notes! - } - else + + ModCommand::NOTE notes[4]; + int numNotes = ConstructChord(note, notes); + for(int i = 0; i < numNotes; i++) + { + pModDoc->NoteOff(notes[i], true, ins, GetCurrentChannel(), playWholeRow ? chordPlayChannels[i] : CHANNELINDEX_INVALID); + } + } else { - pModDoc->NoteOff(note, ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOTEFADE) || pSndFile->GetNumInstruments() == 0), ins, GetCurrentChannel()); + pModDoc->NoteOff(note, ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOTEFADE) || pSndFile->GetNumInstruments() == 0), ins, nChnCursor, playWholeRow ? nChn : CHANNELINDEX_INVALID); } } @@ -4744,13 +4737,6 @@ if (!pModDoc || !pMainFrm || !(IsEditingEnabled())) return; - const bool liveRecord = IsLiveRecord(); - - const CHANNELINDEX nChnCursor = GetCurrentChannel(); - - BYTE *activeNoteMap = isSplit ? splitActiveNoteChannel : activeNoteChannel; - const CHANNELINDEX nChn = (activeNoteMap[note] < pSndFile->GetNumChannels()) ? activeNoteMap[note] : nChnCursor; - activeNoteMap[note] = 0xFF; //unlock channel if(!((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_KBDNOTEOFF) || fromMidi)) @@ -5057,7 +5043,7 @@ } // -- write note and instrument data. - HandleSplit(&newcmd, note); + HandleSplit(newcmd, note); // Nice idea actually: Use lower section of the keyboard to play chords (but it won't work 100% correctly this way...) /*if(isSplit) @@ -5191,8 +5177,10 @@ m_bLastNoteEntryBlocked = false; } else { - m_bLastNoteEntryBlocked = true; // if the cursor is block by the end of the pattern here, - } // we must remember to not step back should the next note form a chord. + // if the cursor is block by the end of the pattern here, + // we must remember to not step back should the next note form a chord. + m_bLastNoteEntryBlocked = true; + } } @@ -5222,6 +5210,45 @@ } +// Construct a chord from the chord presets. Returns number of notes in chord. +int CViewPattern::ConstructChord(int note, ModCommand::NOTE (&outNotes)[4]) +//------------------------------------------------------------------------- +{ + CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + MPTChords &chords = pMainFrm->GetChords(); + UINT baseOctave = pMainFrm->GetBaseOctave(); + UINT chordNum = note - baseOctave * 12 - 1; + + if(chordNum >= CountOf(chords)) + { + return 0; + } + MPTChord &chord = chords[chordNum]; + + ModCommand::NOTE baseNote = static_cast<ModCommand::NOTE>(chord.key + baseOctave * 12 + 1); + if(!ModCommand::IsNote(baseNote)) + { + return 0; + } + + int numNotes = 1; + outNotes[0] = baseNote; + + for(size_t i = 0; i < CountOf(chord.notes); i++) + { + if(chord.notes[i]) + { + ModCommand::NOTE note = static_cast<ModCommand::NOTE>(((baseNote - 1) / 12) * 12 + chord.notes[i]); + if(ModCommand::IsNote(note)) + { + outNotes[numNotes++] = note; + } + } + } + return numNotes; +} + + // Enter a chord in the pattern void CViewPattern::TempEnterChord(int note) //----------------------------------------- @@ -5234,91 +5261,57 @@ } CSoundFile &sndFile = pModDoc->GetrSoundFile(); - UINT nPlayChord = 0; - BYTE chordplaylist[3]; - - const CHANNELINDEX nChn = GetCurrentChannel(); - UINT nPlayIns = 0; - // Simply backup the whole row. - pModDoc->GetPatternUndo().PrepareUndo(m_nPattern, nChn, GetCurrentRow(), sndFile.GetNumChannels(), 1); - - const PatternRow rowBase = sndFile.Patterns[m_nPattern].GetRow(GetCurrentRow()); - ModCommand* pTarget = &rowBase[nChn]; - // Save old row contents - vector<ModCommand> newrow(sndFile.GetNumChannels()); - for(CHANNELINDEX n = 0; n < sndFile.GetNumChannels(); n++) + ModCommand::NOTE chordNotes[4]; + int numNotes = ConstructChord(note, chordNotes); + if(!numNotes) { - newrow[n] = rowBase[n]; + return; } - // This is being written to - ModCommand* p = &newrow[nChn]; + const CHANNELINDEX chn = GetCurrentChannel(); + const PatternRow rowBase = sndFile.Patterns[m_nPattern].GetRow(GetCurrentRow()); + // Save old row contents + std::vector<ModCommand> newRow(rowBase, rowBase + sndFile.GetNumChannels()); const bool liveRecord = IsLiveRecord(); const bool recordEnabled = IsEditingEnabled(); + bool modified = false; // -- establish note data - HandleSplit(p, note); + HandleSplit(newRow[chn], note); + const BYTE recordGroup = pModDoc->IsChannelRecord(chn); - MPTChords &chords = pMainFrm->GetChords(); - UINT baseoctave = pMainFrm->GetBaseOctave(); - UINT nchord = note - baseoctave * 12 - 1; - UINT nNote; - bool modified = false; - if (nchord < 3 * 12) + CHANNELINDEX curChn = chn; + for(int i = 0; i < numNotes; i++) { - UINT nchordnote = chords[nchord].key + baseoctave * 12 + 1; + // Find appropriate channel + while(curChn < sndFile.GetNumChannels() && pModDoc->IsChannelRecord(curChn) != recordGroup) + { + curChn++; + } + if(curChn >= sndFile.GetNumChannels()) + { + numNotes = i; + break; + } - if (nchordnote <= NOTE_MAX) + chordPlayChannels[i] = curChn; + + ModCommand &m = newRow[curChn]; + m.note = chordNotes[i]; + if(newRow[chn].instr) { - UINT nchordch = nChn, nchno = 0; - nNote = nchordnote; - p->note = nNote; - if(rowBase[nChn] != *p) - { - modified = true; - } + m.instr = newRow[chn].instr; + } - BYTE recordGroup, currentRecordGroup = 0; - - recordGroup = pModDoc->IsChannelRecord(nChn); - - for (UINT kchrd=1; kchrd < sndFile.m_nChannels; kchrd++) - { - if ((nchno > 2) || (!chords[nchord].notes[nchno])) break; - if (++nchordch >= sndFile.m_nChannels) nchordch = 0; - - currentRecordGroup = pModDoc->IsChannelRecord(nchordch); - if (!recordGroup) - recordGroup = currentRecordGroup; //record group found - - UINT n = ((nchordnote-1)/12) * 12 + chords[nchord].notes[nchno]; - if(recordEnabled) - { - if ((nchordch != nChn) && recordGroup && (currentRecordGroup == recordGroup) && (n <= NOTE_MAX)) - { - newrow[nchordch].note = n; - if (p->instr) newrow[nchordch].instr = p->instr; - if(rowBase[nchordch] != newrow[nchordch]) - { - modified = true; - } - - nchno++; - if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYNEWNOTE) - { - if ((n) && (n <= NOTE_MAX)) chordplaylist[nPlayChord++] = n; - } - } - } else - { - nchno++; - if ((n) && (n <= NOTE_MAX)) chordplaylist[nPlayChord++] = n; - } - } + if(rowBase[chn] != m) + { + modified = true; } + curChn++; } + m_Status.set(psChordPlaying); // -- write notedata if(recordEnabled) @@ -5327,9 +5320,12 @@ if(modified) { + // Simply backup the whole row. + pModDoc->GetPatternUndo().PrepareUndo(m_nPattern, chn, GetCurrentRow(), sndFile.GetNumChannels(), 1); + for(CHANNELINDEX n = 0; n < sndFile.GetNumChannels(); n++) { - rowBase[n] = newrow[n]; + rowBase[n] = newRow[n]; } pModDoc->SetModified(); InvalidateRow(); @@ -5339,34 +5335,41 @@ // -- play note - if ((TrackerSettings::Instance().m_dwPatternSetup & (PATTERN_PLAYNEWNOTE|PATTERN_PLAYEDITROW)) || (!recordEnabled)) + if((TrackerSettings::Instance().m_dwPatternSetup & (PATTERN_PLAYNEWNOTE | PATTERN_PLAYEDITROW)) || !recordEnabled) { + if(prevChordNote) + { + TempStopChord(prevChordNote); + prevChordNote = note; + } const bool playWholeRow = ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord); - if (playWholeRow) + if(playWholeRow) { // play the whole row in "step mode" PatternStep(false); } - if (!playWholeRow || !recordEnabled) + if(!playWholeRow || !recordEnabled) { // NOTE: This code is *also* used for the PATTERN_PLAYEDITROW edit mode because of some unforseeable race conditions when modifying pattern data. // We have to use this code when editing is disabled or else we will get some stupid hazards, because we would first have to write the new note // data to the pattern and then remove it again - but often, it is actually removed before the row is parsed by the soundlib. // just play the newly inserted notes... - if (p->instr) + ModCommand &firstNote = rowBase[chn]; + UINT nPlayIns = 0; + if(firstNote.instr) { // ...using the already specified instrument - nPlayIns = p->instr; - } else if ((!p->instr) && (p->note <= NOTE_MAX)) + nPlayIns = firstNote.instr; + } else if(!firstNote.instr) { // ...or one that can be found on a previous row of this pattern. - ModCommand *search = pTarget; + ModCommand *search = &firstNote; ROWINDEX srow = GetCurrentRow(); - while (srow-- > 0) + while(srow-- > 0) { search -= sndFile.GetNumChannels(); - if (search->instr) + if(search->instr) { nPlayIns = search->instr; m_nFoundInstrument = nPlayIns; //used to figure out which instrument to stop on key release. @@ -5374,24 +5377,19 @@ } } } - bool isPlaying = ((pMainFrm->GetModPlaying() == pModDoc) && (pMainFrm->IsPlaying())); - pModDoc->PlayNote(p->note, nPlayIns, 0, !isPlaying, -1, 0, 0, nChn); //rewbs.vstiLive - added extra args - for (UINT kplchrd=0; kplchrd<nPlayChord; kplchrd++) + const bool isPlaying = pMainFrm->GetModPlaying() == pModDoc && pMainFrm->IsPlaying(); + for(int i = 0; i < numNotes; i++) { - if (chordplaylist[kplchrd]) - { - pModDoc->PlayNote(chordplaylist[kplchrd], nPlayIns, 0, false, -1, 0, 0, nChn); //rewbs.vstiLive - - added extra args - m_Status.set(psChordPlaying); - } + chordPlayChannels[i] = pModDoc->PlayNote(chordNotes[i], nPlayIns, 0, !isPlaying && i == 0, -1, 0, 0, chn); } } } // end play note // Set new cursor position (row spacing) - only when not recording live - if (recordEnabled && !liveRecord) + if(recordEnabled && !liveRecord) { - if ((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) + if(m_nSpacing > 0 && m_nSpacing <= MAX_SPACING) SetCurrentRow(GetCurrentRow() + m_nSpacing); SetSelToCursor(); @@ -5533,7 +5531,7 @@ const CSoundFile *sndFile = GetSoundFile(); if(sndFile != nullptr) { - const ORDERINDEX curOrder = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); + const ORDERINDEX curOrder = GetCurrentOrder(); if(curOrder + 1 < sndFile->Order.size() && m_nPattern == sndFile->Order[curOrder]) { const ORDERINDEX nextOrder = sndFile->Order.GetNextOrderIgnoringSkips(curOrder); @@ -5733,7 +5731,7 @@ return; } - UINT paramNdx = nID - ID_CHANGE_PCNOTE_PARAM; + uint16 paramNdx = static_cast<uint16>(nID - ID_CHANGE_PCNOTE_PARAM); bool bModified = false; for(ROWINDEX nRow = m_Selection.GetStartRow(); nRow <= m_Selection.GetEndRow(); nRow++) { @@ -5747,7 +5745,7 @@ } } } - if (bModified) + if(bModified) { SetModified(); InvalidatePattern(); @@ -5767,7 +5765,7 @@ const CHANNELINDEX plugChannel = m_MenuCursor.GetChannel(); if(plugChannel < pSndFile->GetNumChannels()) { - UINT newPlug = nID - ID_PLUGSELECT; + PLUGINDEX newPlug = static_cast<PLUGINDEX>(nID - ID_PLUGSELECT); if(newPlug <= MAX_MIXPLUGINS && newPlug != pSndFile->ChnSettings[plugChannel].nMixPlugin) { pSndFile->ChnSettings[plugChannel].nMixPlugin = newPlug; @@ -5781,7 +5779,7 @@ } //rewbs.merge -bool CViewPattern::HandleSplit(ModCommand* p, int note) +bool CViewPattern::HandleSplit(ModCommand &m, int note) //----------------------------------------------------- { ModCommand::INSTR ins = GetCurrentInstrument(); @@ -5804,10 +5802,10 @@ } } - p->note = note; + m.note = static_cast<ModCommand::NOTE>(note); if(ins) { - p->instr = ins; + m.instr = ins; } return isSplit; @@ -5903,8 +5901,8 @@ return true; } -bool CViewPattern::BuildRecordCtxMenu(HMENU hMenu, CInputHandler *ih, UINT nChn, CModDoc* pModDoc) const -//------------------------------------------------------------------------------------------------------ +bool CViewPattern::BuildRecordCtxMenu(HMENU hMenu, CInputHandler *ih, CHANNELINDEX nChn, CModDoc* pModDoc) const +//-------------------------------------------------------------------------------------------------------------- { AppendMenu(hMenu, pModDoc->IsChannelRecord1(nChn) ? (MF_STRING | MF_CHECKED) : MF_STRING, ID_EDIT_RECSELECT, "Record select\t" + ih->GetKeyTextFromCommand(kcChannelRecordSelect)); AppendMenu(hMenu, pModDoc->IsChannelRecord2(nChn) ? (MF_STRING | MF_CHECKED) : MF_STRING, ID_EDIT_SPLITRECSELECT, "Split Record select\t" + ih->GetKeyTextFromCommand(kcChannelSplitRecordSelect)); @@ -6137,7 +6135,7 @@ } else { CHAR s[64]; - for (UINT i = 1; i <= sndFile->GetNumSamples(); i++) if (sndFile->GetSample(i).pSample != nullptr) + for(SAMPLEINDEX i = 1; i <= sndFile->GetNumSamples(); i++) if (sndFile->GetSample(i).pSample != nullptr) { wsprintf(s, "%02d: %s", i, sndFile->GetSampleName(i)); AppendMenu(instrumentChangeMenu, MF_STRING, ID_CHANGE_INSTRUMENT + i, s); @@ -6234,7 +6232,7 @@ } } - return chans.size(); + return static_cast<CHANNELINDEX>(chans.size()); } @@ -6413,7 +6411,7 @@ } CString msg; - ORDERINDEX currentOrder = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); + ORDERINDEX currentOrder = GetCurrentOrder(); if(pSndFile->Order[currentOrder] == m_nPattern) { const double t = pSndFile->GetPlaybackTimeAt(currentOrder, GetCurrentRow(), false); @@ -6422,14 +6420,15 @@ else { const uint32 minutes = static_cast<uint32>(t / 60.0); - const float seconds = t - minutes*60; + const double seconds = t - (minutes * 60); msg.Format("Estimate for playback time at order %d (pattern %d), row %d: %d minute%s %.2f seconds.", currentOrder, m_nPattern, GetCurrentRow(), minutes, (minutes == 1) ? "" : "s", seconds); } + } else + { + msg.Format("Unable to determine the time: pattern at current order (%d) does not correspond to pattern at pattern view (pattern %d).", currentOrder, m_nPattern); } - else - msg.Format("Unable to determine the time: pattern at current order (%d) does not correspond to pattern at pattern view (pattern %d).", currentOrder, m_nPattern); - Reporting::Notification(msg); + Reporting::Notification(msg); } @@ -6558,7 +6557,7 @@ // but set instr if note is a PC note and instr is blank. if((p->IsNote() || p->IsPcNote() || p->instr) && (p->instr != nIns)) { - p->instr = nIns; + p->instr = static_cast<ModCommand::INSTR>(nIns); modified = true; } } @@ -6626,7 +6625,7 @@ { return; } - ORDERINDEX ord = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); + ORDERINDEX ord = GetCurrentOrder(); PATTERNINDEX pat = m_nPattern; ROWINDEX row = m_Cursor.GetRow(); @@ -6680,14 +6679,14 @@ pos.pattern = nPattern; pos.row = pastePos.GetRow(); pos.channel = pastePos.GetChannel(); - bool result = PatternClipboard::Paste(*GetSoundFile(), pos, mode, SendCtrlMessage(CTRLMSG_GETCURRENTORDER)); + ORDERINDEX curOrder = GetCurrentOrder(); + bool result = PatternClipboard::Paste(*GetSoundFile(), pos, mode, curOrder); EndWaitCursor(); if(pos.pattern != nPattern) { // Multipaste: Switch to pasted pattern. SetCurrentPattern(pos.pattern); - ORDERINDEX curOrder = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); curOrder = GetSoundFile()->Order.FindOrder(pos.pattern, curOrder); SendCtrlMessage(CTRLMSG_SETCURRENTORDER, curOrder); } Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2013-03-16 21:03:51 UTC (rev 1582) +++ trunk/OpenMPT/mptrack/View_pat.h 2013-03-16 23:32:19 UTC (rev 1583) @@ -197,6 +197,8 @@ BYTE activeNoteChannel[NOTE_MAX + 1]; BYTE splitActiveNoteChannel[NOTE_MAX + 1]; + CHANNELINDEX chordPlayChannels[4]; + ModCommand::NOTE prevChordNote; public: CEffectVis *m_pEffectVis; //rewbs.fxVis @@ -226,6 +228,7 @@ PATTERNINDEX GetCurrentPattern() const { return m_nPattern; } ROWINDEX GetCurrentRow() const { return m_Cursor.GetRow(); } CHANNELINDEX GetCurrentChannel() const { return m_Cursor.GetChannel(); } + ORDERINDEX GetCurrentOrder() const { return static_cast<ORDERINDEX>(SendCtrlMessage(CTRLMSG_GETCURRENTORDER)); } // Get ModCommand at the pattern cursor position. ModCommand &GetCursorCommand() { return GetModCommand(m_Cursor); }; @@ -306,6 +309,9 @@ void TempEnterFXparam(int v); void EnterAftertouch(int note, int atValue); + // Construct a chord from the chord presets. Returns number of notes in chord. + int ConstructChord(int note, ModCommand::NOTE (&outNotes)[4]); + void QuantizeRow(PATTERNINDEX &pat, ROWINDEX &row) const; PATTERNINDEX GetNextPattern() const; @@ -433,14 +439,14 @@ bool PastePattern(PATTERNINDEX nPattern, const PatternCursor &pastePos, PatternClipboard::PasteModes mode); void SetSplitKeyboardSettings(); - bool HandleSplit(ModCommand *p, int note); + bool HandleSplit(ModCommand &m, int note); bool IsNoteSplit(int note) const; CHANNELINDEX FindGroupRecordChannel(BYTE recordGroup, bool forceFreeChannel, CHANNELINDEX startChannel = 0) const; bool BuildChannelControlCtxMenu(HMENU hMenu) const; bool BuildPluginCtxMenu(HMENU hMenu, UINT nChn, CSoundFile *pSndFile) const; - bool BuildRecordCtxMenu(HMENU hMenu, CInputHandler *ih, UINT nChn, CModDoc *pModDoc) const; + bool BuildRecordCtxMenu(HMENU hMenu, CInputHandler *ih, CHANNELINDEX nChn, CModDoc *pModDoc) const; bool BuildSoloMuteCtxMenu(HMENU hMenu, CInputHandler *ih, UINT nChn, CSoundFile *pSndFile) const; bool BuildRowInsDelCtxMenu(HMENU hMenu, CInputHandler *ih) const; bool BuildMiscCtxMenu(HMENU hMenu, CInputHandler *ih) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-17 21:59:40
|
Revision: 1596 http://sourceforge.net/p/modplug/code/1596 Author: saga-games Date: 2013-03-17 21:59:29 +0000 (Sun, 17 Mar 2013) Log Message: ----------- [Fix] Chord Editor: Couldn't choose D# key from the on-screen keyboard (broke when implementing relative chords) [Mod] Chord Editor: In relative mode, the base note is now displayed again (as C) [New] Pattern Editor: Added shortcuts: Select Row, Select Event. Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/View_pat.cpp Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2013-03-17 17:05:51 UTC (rev 1595) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2013-03-17 21:59:29 UTC (rev 1596) @@ -655,6 +655,8 @@ DefineKeyCommand(kcToggleClipboardManager, 1900, _T("Toggle Clipboard Manager")); DefineKeyCommand(kcClipboardPrev, 1901, _T("Cycle to Previous Clipboard")); DefineKeyCommand(kcClipboardNext, 1902, _T("Cycle to Next Clipboard")); + DefineKeyCommand(kcSelectRow, 1903, _T("Select Row")); + DefineKeyCommand(kcSelectEvent, 1904, _T("Select Event")); // Add new key commands here. Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2013-03-17 17:05:51 UTC (rev 1595) +++ trunk/OpenMPT/mptrack/CommandSet.h 2013-03-17 21:59:29 UTC (rev 1596) @@ -215,6 +215,8 @@ kcCopySelectWithSelect, kcCopySelectOffWithSelect, kcSelectColumn, + kcSelectRow, + kcSelectEvent, kcSelectBeat, kcSelectMeasure, kcEndSelect=kcSelectMeasure, Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-03-17 17:05:51 UTC (rev 1595) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2013-03-17 21:59:29 UTC (rev 1596) @@ -1441,19 +1441,11 @@ RECT rect1, rect2, rect, rcInt, rcUni; POINT pt; - PatternRect oldSel = m_Selection; - m_Selection = PatternRect(beginSel, endSel); - const CSoundFile *pSndFile = GetSoundFile(); - if(pSndFile != nullptr) - { - m_Selection.Sanitize(pSndFile->Patterns[m_nPattern].GetNumRows(), pSndFile->GetNumChannels()); - } - // Get current selection area - PatternCursor endSel2(oldSel.GetLowerRight()); + PatternCursor endSel2(m_Selection.GetLowerRight()); endSel2.Move(1, 0, 1); - pt = GetPointFromPosition(oldSel.GetUpperLeft()); + pt = GetPointFromPosition(m_Selection.GetUpperLeft()); rect1.left = pt.x; rect1.top = pt.y; pt = GetPointFromPosition(endSel2); @@ -1463,6 +1455,13 @@ if(rect1.top < m_szHeader.cy) rect1.top = m_szHeader.cy; // Get new selection area + m_Selection = PatternRect(beginSel, endSel); + const CSoundFile *pSndFile = GetSoundFile(); + if(pSndFile != nullptr) + { + m_Selection.Sanitize(pSndFile->Patterns[m_nPattern].GetNumRows(), pSndFile->GetNumChannels()); + } + pt = GetPointFromPosition(m_Selection.GetUpperLeft()); rect2.left = pt.x; rect2.top = pt.y; Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-17 17:05:51 UTC (rev 1595) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-17 21:59:29 UTC (rev 1596) @@ -1342,7 +1342,7 @@ chords[chord].notes[0] = NOTE_NONE; chords[chord].notes[1] = NOTE_NONE; chords[chord].notes[2] = NOTE_NONE; - for (UINT i=0; i<2*12; i++) if (i != (UINT)(chords[chord].key % 12)) + for (UINT i=0; i<2*12; i++) if (i != (chords[chord].key % 12) || chords[chord].key == MPTChord::relativeMode) { UINT n = m_Keyboard.GetFlags(i); if (i == (UINT)nKey) n = (n) ? 0 : 1; @@ -1399,8 +1399,7 @@ octave = chords[chord].key / 12; if(chords[chord].key == MPTChord::relativeMode) { - note = -1; - octave = 0; + note = octave = 0; } for(UINT i=0; i<2*12; i++) { Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-17 17:05:51 UTC (rev 1595) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-17 21:59:29 UTC (rev 1596) @@ -4274,6 +4274,13 @@ case kcSelectMeasure: SelectBeatOrMeasure(wParam == kcSelectBeat); return wParam; + case kcSelectEvent: SetCurSel(PatternCursor(m_Selection.GetStartRow(), m_Selection.GetStartChannel(), PatternCursor::firstColumn), + PatternCursor(m_Selection.GetEndRow(), m_Selection.GetEndChannel(), PatternCursor::lastColumn)); + return wParam; + case kcSelectRow: SetCurSel(PatternCursor(m_Selection.GetStartRow(), 0, PatternCursor::firstColumn), + PatternCursor(m_Selection.GetEndRow(), pSndFile->GetNumChannels(), PatternCursor::lastColumn)); + return wParam; + case kcClearRow: OnClearField(RowMask(), false); return wParam; case kcClearField: OnClearField(RowMask(m_Cursor), false); return wParam; case kcClearFieldITStyle: OnClearField(RowMask(m_Cursor), false, true); return wParam; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-17 22:36:39
|
Revision: 1597 http://sourceforge.net/p/modplug/code/1597 Author: saga-games Date: 2013-03-17 22:36:32 +0000 (Sun, 17 Mar 2013) Log Message: ----------- [Fix] The previous commit made chord editing a bit more tedious in relative mode... [Ref] Chord related refactoring. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/View_pat.cpp Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-17 21:59:29 UTC (rev 1596) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-17 22:36:32 UTC (rev 1597) @@ -424,8 +424,6 @@ CModDoc *GetActiveDoc(); CView *GetActiveView(); //rewbs.customKeys CImageList *GetImageList() { return &m_ImageList; } - MPTChords &GetChords() { return TrackerSettings::Instance().Chords; } - const MPTChords &GetChords() const { return TrackerSettings::Instance().Chords; } void OnDocumentCreated(CModDoc *pModDoc); void OnDocumentClosed(CModDoc *pModDoc); void UpdateTree(CModDoc *pModDoc, DWORD lHint=0, CObject *pHint=NULL); Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-17 21:59:29 UTC (rev 1596) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-17 22:36:32 UTC (rev 1597) @@ -1326,24 +1326,36 @@ } +MPTChord &CChordEditor::GetChord() +//-------------------------------- +{ + MPTChords &chords = TrackerSettings::GetChords(); + int chord = m_CbnShortcut.GetCurSel(); + if(chord >= 0) chord = m_CbnShortcut.GetItemData(chord); + if(chord < 0 || chord >= CountOf(chords)) chord = 0; + return chords[chord]; +} + + LRESULT CChordEditor::OnKeyboardNotify(WPARAM wParam, LPARAM nKey) //---------------------------------------------------------------- { - CMainFrame *pMainFrm; - int chord; - if (wParam != KBDNOTIFY_LBUTTONDOWN) return 0; - if ((pMainFrm = CMainFrame::GetMainFrame()) == NULL) return 0; - MPTChords &chords = pMainFrm->GetChords(); - chord = m_CbnShortcut.GetCurSel(); - if (chord >= 0) chord = m_CbnShortcut.GetItemData(chord); - if ((chord < 0) || (chord >= CountOf(chords))) chord = 0; + MPTChord &chord = GetChord(); UINT cnote = NOTE_NONE; - chords[chord].notes[0] = NOTE_NONE; - chords[chord].notes[1] = NOTE_NONE; - chords[chord].notes[2] = NOTE_NONE; - for (UINT i=0; i<2*12; i++) if (i != (chords[chord].key % 12) || chords[chord].key == MPTChord::relativeMode) + chord.notes[0] = NOTE_NONE; + chord.notes[1] = NOTE_NONE; + chord.notes[2] = NOTE_NONE; + for(UINT i = 0; i < 2 * 12; i++) { + if(chord.key == MPTChord::relativeMode) + { + if(!i) continue; + } else + { + if(i == chord.key % 12) continue; + } + UINT n = m_Keyboard.GetFlags(i); if (i == (UINT)nKey) n = (n) ? 0 : 1; if (n) @@ -1351,7 +1363,7 @@ if ((cnote < 3) || (i == (UINT)nKey)) { UINT k = (cnote < 3) ? cnote : 2; - chords[chord].notes[k] = static_cast<BYTE>(i+1); + chord.notes[k] = static_cast<BYTE>(i+1); if (cnote < 3) cnote++; } } @@ -1364,21 +1376,14 @@ void CChordEditor::OnChordChanged() //--------------------------------- { - CMainFrame *pMainFrm; - int chord; - - if ((pMainFrm = CMainFrame::GetMainFrame()) == NULL) return; - MPTChords &chords = pMainFrm->GetChords(); - chord = m_CbnShortcut.GetCurSel(); - if (chord >= 0) chord = m_CbnShortcut.GetItemData(chord); - if ((chord < 0) || (chord >= CountOf(chords))) chord = 0; - if(chords[chord].key != MPTChord::relativeMode) - m_CbnBaseNote.SetCurSel(chords[chord].key + 1); + MPTChord &chord = GetChord(); + if(chord.key != MPTChord::relativeMode) + m_CbnBaseNote.SetCurSel(chord.key + 1); else m_CbnBaseNote.SetCurSel(0); - m_CbnNote1.SetCurSel(chords[chord].notes[0]); - m_CbnNote2.SetCurSel(chords[chord].notes[1]); - m_CbnNote3.SetCurSel(chords[chord].notes[2]); + m_CbnNote1.SetCurSel(chord.notes[0]); + m_CbnNote2.SetCurSel(chord.notes[1]); + m_CbnNote3.SetCurSel(chord.notes[2]); UpdateKeyboard(); } @@ -1386,30 +1391,20 @@ void CChordEditor::UpdateKeyboard() //--------------------------------- { - CMainFrame *pMainFrm; - int chord; - UINT note, octave; - - if ((pMainFrm = CMainFrame::GetMainFrame()) == NULL) return; - MPTChords &chords = pMainFrm->GetChords(); - chord = m_CbnShortcut.GetCurSel(); - if (chord >= 0) chord = m_CbnShortcut.GetItemData(chord); - if ((chord < 0) || (chord >= CountOf(chords))) chord = 0; - note = chords[chord].key % 12; - octave = chords[chord].key / 12; - if(chords[chord].key == MPTChord::relativeMode) + MPTChord &chord = GetChord(); + UINT note = chord.key % 12; + if(chord.key == MPTChord::relativeMode) { - note = octave = 0; + note = 0; } - for(UINT i=0; i<2*12; i++) + for(UINT i = 0; i < 2 * 12; i++) { - BOOL b = FALSE; - - if (i == note) b = TRUE; - if ((chords[chord].notes[0]) && (i+1 == chords[chord].notes[0])) b = TRUE; - if ((chords[chord].notes[1]) && (i+1 == chords[chord].notes[1])) b = TRUE; - if ((chords[chord].notes[2]) && (i+1 == chords[chord].notes[2])) b = TRUE; - m_Keyboard.SetFlags(i, (b) ? 1 : 0); + UINT b = 0; + if(i == note) b = 1; + else if(chord.notes[0] && i + 1 == chord.notes[0]) b = 1; + else if(chord.notes[1] && i + 1 == chord.notes[1]) b = 1; + else if(chord.notes[2] && i + 1 == chord.notes[2]) b = 1; + m_Keyboard.SetFlags(i, b); } m_Keyboard.InvalidateRect(NULL, FALSE); } @@ -1418,15 +1413,9 @@ void CChordEditor::OnBaseNoteChanged() //------------------------------------ { - CMainFrame *pMainFrm; - - if ((pMainFrm = CMainFrame::GetMainFrame()) == NULL) return; - MPTChords &chords = pMainFrm->GetChords(); - int chord = m_CbnShortcut.GetCurSel(); - if (chord >= 0) chord = m_CbnShortcut.GetItemData(chord); - if ((chord < 0) || (chord >= CountOf(chords))) chord = 0; + MPTChord &chord = GetChord(); int basenote = m_CbnBaseNote.GetItemData(m_CbnBaseNote.GetCurSel()); - chords[chord].key = (uint8)basenote; + chord.key = (uint8)basenote; UpdateKeyboard(); } @@ -1434,17 +1423,11 @@ void CChordEditor::OnNote1Changed() //--------------------------------- { - CMainFrame *pMainFrm; - - if ((pMainFrm = CMainFrame::GetMainFrame()) == NULL) return; - MPTChords &chords = pMainFrm->GetChords(); - int chord = m_CbnShortcut.GetCurSel(); - if (chord >= 0) chord = m_CbnShortcut.GetItemData(chord); - if ((chord < 0) || (chord >= CountOf(chords))) chord = 0; + MPTChord &chord = GetChord(); int note = m_CbnNote1.GetCurSel(); - if (note >= 0) + if(note >= 0) { - chords[chord].notes[0] = (uint8)note; + chord.notes[0] = (uint8)note; UpdateKeyboard(); } } @@ -1453,17 +1436,11 @@ void CChordEditor::OnNote2Changed() //--------------------------------- { - CMainFrame *pMainFrm; - - if ((pMainFrm = CMainFrame::GetMainFrame()) == NULL) return; - MPTChords &chords = pMainFrm->GetChords(); - int chord = m_CbnShortcut.GetCurSel(); - if (chord >= 0) chord = m_CbnShortcut.GetItemData(chord); - if ((chord < 0) || (chord >= CountOf(chords))) chord = 0; + MPTChord &chord = GetChord(); int note = m_CbnNote2.GetCurSel(); - if (note >= 0) + if(note >= 0) { - chords[chord].notes[1] = (uint8)note; + chord.notes[1] = (uint8)note; UpdateKeyboard(); } } @@ -1472,17 +1449,11 @@ void CChordEditor::OnNote3Changed() //--------------------------------- { - CMainFrame *pMainFrm; - - if ((pMainFrm = CMainFrame::GetMainFrame()) == NULL) return; - MPTChords &chords = pMainFrm->GetChords(); - int chord = m_CbnShortcut.GetCurSel(); - if (chord >= 0) chord = m_CbnShortcut.GetItemData(chord); - if ((chord < 0) || (chord >= CountOf(chords))) chord = 0; + MPTChord &chord = GetChord(); int note = m_CbnNote3.GetCurSel(); - if (note >= 0) + if(note >= 0) { - chords[chord].notes[2] = (uint8)note; + chord.notes[2] = (uint8)note; UpdateKeyboard(); } } Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2013-03-17 21:59:29 UTC (rev 1596) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2013-03-17 22:36:32 UTC (rev 1597) @@ -281,6 +281,8 @@ CChordEditor(CWnd *parent=NULL):CDialog(IDD_CHORDEDIT, parent) {} protected: + MPTChord &GetChord(); + virtual void DoDataExchange(CDataExchange* pDX); virtual BOOL OnInitDialog(); void UpdateKeyboard(); Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-17 21:59:29 UTC (rev 1596) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-17 22:36:32 UTC (rev 1597) @@ -228,6 +228,8 @@ void SetDefaultDirectory(const LPCTSTR szFilenameFrom, Directory dir, bool bStripFilename = false); LPCTSTR GetDefaultDirectory(Directory dir) const; + static MPTChords &GetChords() { return Instance().Chords; } + // Get settings object singleton static TrackerSettings &Instance() { return settings; } Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-17 21:59:29 UTC (rev 1596) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-17 22:36:32 UTC (rev 1597) @@ -5231,9 +5231,8 @@ int CViewPattern::ConstructChord(int note, ModCommand::NOTE (&outNotes)[4], ModCommand::NOTE baseNote) //---------------------------------------------------------------------------------------------------- { - const CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - const MPTChords &chords = pMainFrm->GetChords(); - UINT baseOctave = pMainFrm->GetBaseOctave(); + const MPTChords &chords = TrackerSettings::GetChords(); + UINT baseOctave = CMainFrame::GetMainFrame()->GetBaseOctave(); UINT chordNum = note - baseOctave * 12 - NOTE_MIN; if(chordNum >= CountOf(chords)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-18 13:27:54
|
Revision: 1599 http://sourceforge.net/p/modplug/code/1599 Author: saga-games Date: 2013-03-18 13:27:40 +0000 (Mon, 18 Mar 2013) Log Message: ----------- [Imp] Pattern Editor: "Record note off" works better with chords now. Modified Paths: -------------- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/TrackerSettings.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-18 01:25:01 UTC (rev 1598) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-18 13:27:40 UTC (rev 1599) @@ -1353,7 +1353,7 @@ if(!i) continue; } else { - if(i == chord.key % 12) continue; + if(i == chord.key % 12u) continue; } UINT n = m_Keyboard.GetFlags(i); Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-18 01:25:01 UTC (rev 1598) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-18 13:27:40 UTC (rev 1599) @@ -128,6 +128,7 @@ { enum { + notesPerChord = 4, relativeMode = 0x3F, }; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-18 01:25:01 UTC (rev 1598) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-18 13:27:40 UTC (rev 1599) @@ -4704,12 +4704,15 @@ const bool liveRecord = IsLiveRecord(); const bool isSplit = IsNoteSplit(note); - const CHANNELINDEX nChnCursor = GetCurrentChannel(); UINT ins = 0; BYTE *activeNoteMap = isSplit ? splitActiveNoteChannel : activeNoteChannel; - const CHANNELINDEX nChn = (activeNoteMap[note] < pSndFile->GetNumChannels()) ? activeNoteMap[note] : nChnCursor; + const CHANNELINDEX nChnCursor = GetCurrentChannel(); + const CHANNELINDEX nChn = bChordMode ? chordPatternChannels[0] : (activeNoteMap[note] < pSndFile->GetNumChannels() ? activeNoteMap[note] : nChnCursor); + CHANNELINDEX noteChannels[MPTChord::notesPerChord] = { nChn }; + int numNotes = 1; + if(pModDoc) { if(isSplit) @@ -4724,20 +4727,21 @@ if(!ins) ins = m_nFoundInstrument; - const bool playWholeRow = ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord); + const bool playWholeRow = ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord && IsLiveRecord()); if(bChordMode == true) { m_Status.reset(psChordPlaying); ModCommand::NOTE notes[4]; - int numNotes = ConstructChord(note, notes, prevChordBaseNote); + numNotes = ConstructChord(note, notes, prevChordBaseNote); if(!numNotes) { return; } for(int i = 0; i < numNotes; i++) { - pModDoc->NoteOff(notes[i], true, ins, GetCurrentChannel(), playWholeRow ? chordPlayChannels[i] : CHANNELINDEX_INVALID); + pModDoc->NoteOff(notes[i], true, ins, GetCurrentChannel(), playWholeRow ? chordPatternChannels[i] : CHANNELINDEX_INVALID); + noteChannels[i] = chordPatternChannels[i]; } prevChordNote = NOTE_NONE; } else @@ -4779,7 +4783,6 @@ } ModCommand *pTarget = pSndFile->Patterns[nPat].GetpModCommand(nRow, nChn); - // Don't overwrite: if(pTarget->note != NOTE_NONE || pTarget->instr || pTarget->volcmd != VOLCMD_NONE) { @@ -4789,7 +4792,7 @@ if(pTarget->note == note && liveRecord && pSndFile->Patterns[nPat].IsValidRow(nRow)) { pTarget = pSndFile->Patterns[nPat].GetpModCommand(nRow, nChn); - if(pTarget->note || (!bChordMode && (pTarget->instr || pTarget->volcmd))) + if(pTarget->note != NOTE_NONE || (!bChordMode && (pTarget->instr || pTarget->volcmd))) return; } else { @@ -4798,49 +4801,53 @@ } // Create undo-point. - pModDoc->GetPatternUndo().PrepareUndo(nPat, nChn, nRow, 1, 1); + pModDoc->GetPatternUndo().PrepareUndo(nPat, nChn, nRow, noteChannels[numNotes - 1] - nChn + 1, 1); - // -- write sdx if playing live - if(usePlaybackPosition && nTick && pTarget->command == CMD_NONE && !doQuantize) + for(int i = 0; i < numNotes; i++) { - pTarget->command = (pSndFile->TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX; - pTarget->param = 0xD0 | min(0xF, nTick); - } + ModCommand *pTarget = pSndFile->Patterns[nPat].GetpModCommand(nRow, noteChannels[i]); - //Enter note off - if(pSndFile->GetModSpecifications().hasNoteOff && (pSndFile->GetNumInstruments() > 0 || !pSndFile->GetModSpecifications().hasNoteCut)) - { - // === - // Not used in sample (if module format supports ^^^ instead) - pTarget->note = NOTE_KEYOFF; - } else if(pSndFile->GetModSpecifications().hasNoteCut) - { - // ^^^ - pTarget->note = NOTE_NOTECUT; - } else - { - // we don't have anything to cut (MOD format) - use volume or ECx - if(usePlaybackPosition && nTick && !doQuantize) // ECx + // -- write sdx if playing live + if(usePlaybackPosition && nTick && pTarget->command == CMD_NONE && !doQuantize) { pTarget->command = (pSndFile->TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX; - pTarget->param = 0xC0 | min(0xF, nTick); - } else // C00 + pTarget->param = 0xD0 | min(0xF, nTick); + } + + //Enter note off + if(pSndFile->GetModSpecifications().hasNoteOff && (pSndFile->GetNumInstruments() > 0 || !pSndFile->GetModSpecifications().hasNoteCut)) { - pTarget->note = NOTE_NONE; - pTarget->command = CMD_VOLUME; - pTarget->param = 0; + // === + // Not used in sample (if module format supports ^^^ instead) + pTarget->note = NOTE_KEYOFF; + } else if(pSndFile->GetModSpecifications().hasNoteCut) + { + // ^^^ + pTarget->note = NOTE_NOTECUT; + } else + { + // we don't have anything to cut (MOD format) - use volume or ECx + if(usePlaybackPosition && nTick && !doQuantize) // ECx + { + pTarget->command = (pSndFile->TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX; + pTarget->param = 0xC0 | min(0xF, nTick); + } else // C00 + { + pTarget->note = NOTE_NONE; + pTarget->command = CMD_VOLUME; + pTarget->param = 0; + } } + pTarget->instr = 0; // Instrument numbers next to note-offs can do all kinds of weird things in XM files, and they are pointless anyway. + pTarget->volcmd = VOLCMD_NONE; + pTarget->vol = 0; } - pTarget->instr = 0; // Instrument numbers next to note-offs can do all kinds of weird things in XM files, and they are pointless anyway. - pTarget->volcmd = VOLCMD_NONE; - pTarget->vol = 0; pModDoc->SetModified(); if(nPat == m_nPattern) { - PatternCursor sel(nRow, nChn); - InvalidateCell(sel); + InvalidateRow(nRow); } else { InvalidatePattern(); @@ -5228,8 +5235,8 @@ // Construct a chord from the chord presets. Returns number of notes in chord. -int CViewPattern::ConstructChord(int note, ModCommand::NOTE (&outNotes)[4], ModCommand::NOTE baseNote) -//---------------------------------------------------------------------------------------------------- +int CViewPattern::ConstructChord(int note, ModCommand::NOTE (&outNotes)[MPTChord::notesPerChord], ModCommand::NOTE baseNote) +//-------------------------------------------------------------------------------------------------------------------------- { const MPTChords &chords = TrackerSettings::GetChords(); UINT baseOctave = CMainFrame::GetMainFrame()->GetBaseOctave(); @@ -5297,7 +5304,7 @@ const CHANNELINDEX chn = GetCurrentChannel(); const PatternRow rowBase = sndFile.Patterns[m_nPattern].GetRow(GetCurrentRow()); - ModCommand::NOTE chordNotes[4], baseNote = rowBase[chn].note; + ModCommand::NOTE chordNotes[MPTChord::notesPerChord], baseNote = rowBase[chn].note; if(!ModCommand::IsNote(baseNote)) { baseNote = prevChordBaseNote; @@ -5333,7 +5340,7 @@ break; } - chordPlayChannels[i] = curChn; + chordPatternChannels[i] = curChn; ModCommand &m = newRow[curChn]; m.note = chordNotes[i]; @@ -5417,7 +5424,7 @@ const bool isPlaying = pMainFrm->GetModPlaying() == pModDoc && pMainFrm->IsPlaying(); for(int i = 0; i < numNotes; i++) { - chordPlayChannels[i] = pModDoc->PlayNote(chordNotes[i], nPlayIns, 0, !isPlaying && i == 0, -1, 0, 0, chn); + pModDoc->PlayNote(chordNotes[i], nPlayIns, 0, !isPlaying && i == 0, -1, 0, 0, chn); } } } // end play note Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2013-03-18 01:25:01 UTC (rev 1598) +++ trunk/OpenMPT/mptrack/View_pat.h 2013-03-18 13:27:40 UTC (rev 1599) @@ -196,7 +196,7 @@ WORD OldVUMeters[MAX_BASECHANNELS]; // Chord preview - CHANNELINDEX chordPlayChannels[4]; + CHANNELINDEX chordPatternChannels[MPTChord::notesPerChord]; ModCommand::NOTE prevChordNote, prevChordBaseNote; BYTE activeNoteChannel[NOTE_MAX + 1]; @@ -312,7 +312,7 @@ void EnterAftertouch(int note, int atValue); // Construct a chord from the chord presets. Returns number of notes in chord. - static int ConstructChord(int note, ModCommand::NOTE (&outNotes)[4], ModCommand::NOTE baseNote); + static int ConstructChord(int note, ModCommand::NOTE (&outNotes)[MPTChord::notesPerChord], ModCommand::NOTE baseNote); void QuantizeRow(PATTERNINDEX &pat, ROWINDEX &row) const; PATTERNINDEX GetNextPattern() const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-18 23:30:20
|
Revision: 1600 http://sourceforge.net/p/modplug/code/1600 Author: saga-games Date: 2013-03-18 23:30:10 +0000 (Mon, 18 Mar 2013) Log Message: ----------- [Fix] Pattern Editor: Live edit pos is now based on playback notifications instead of internal processing position, which may well be in the future already. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainbar.cpp trunk/OpenMPT/mptrack/Mainbar.h trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-18 13:27:40 UTC (rev 1599) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-18 23:30:10 UTC (rev 1600) @@ -1042,6 +1042,7 @@ p->nOrder = m_pSndFile->m_nCurrentOrder; p->nRow = m_pSndFile->m_nRow; p->nPattern = m_pSndFile->m_nPattern; + p->nTick = m_pSndFile->m_nTickCount; if (m_dwNotifyType & MPTNOTIFY_SAMPLE) { SAMPLEINDEX nSmp = m_dwNotifyType & 0xFFFF; @@ -1056,8 +1057,7 @@ p->dwPos[k] = MPTNOTIFY_POSVALID | (DWORD)(pChn->nPos); } } - } else - if (m_dwNotifyType & (MPTNOTIFY_VOLENV|MPTNOTIFY_PANENV|MPTNOTIFY_PITCHENV)) + } else if (m_dwNotifyType & (MPTNOTIFY_VOLENV|MPTNOTIFY_PANENV|MPTNOTIFY_PITCHENV)) { UINT nIns = m_dwNotifyType & 0xFFFF; for (CHANNELINDEX k = 0; k < MAX_CHANNELS; k++) @@ -1079,9 +1079,9 @@ if(chnEnv.flags[ENV_ENABLED]) { uint32 pos = chnEnv.nEnvPosition; - if(m_pSndFile->IsCompatibleMode(TRK_IMPULSETRACKER | TRK_FASTTRACKER2)) + if(m_pSndFile->IsCompatibleMode(TRK_IMPULSETRACKER)) { - // Impulse Tracker / Fasttracker 2 envelope handling (see SndMix.cpp for details) + // Impulse Tracker envelope handling (see e.g. CSoundFile::IncrementEnvelopePosition in SndMix.cpp for details) if(pos > 0) pos--; else @@ -1091,8 +1091,7 @@ } } } - } else - if (m_dwNotifyType & (MPTNOTIFY_VUMETERS)) + } else if (m_dwNotifyType & (MPTNOTIFY_VUMETERS)) { for (UINT k=0; k<MAX_CHANNELS; k++) { @@ -1101,8 +1100,7 @@ UINT vur = pChn->nRightVU; p->dwPos[k] = (vul << 8) | (vur); } - } else - if (m_dwNotifyType & MPTNOTIFY_MASTERVU) + } else if (m_dwNotifyType & MPTNOTIFY_MASTERVU) { DWORD lVu = (gnLVuMeter >> 11); DWORD rVu = (gnRVuMeter >> 11); Modified: trunk/OpenMPT/mptrack/Mainbar.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.cpp 2013-03-18 13:27:40 UTC (rev 1599) +++ trunk/OpenMPT/mptrack/Mainbar.cpp 2013-03-18 23:30:10 UTC (rev 1600) @@ -937,7 +937,7 @@ } -VOID CModTreeBar::UpdatePlayPos(CModDoc *pModDoc, PMPTNOTIFICATION pNotify) +VOID CModTreeBar::UpdatePlayPos(CModDoc *pModDoc, MPTNOTIFICATION *pNotify) //------------------------------------------------------------------------- { if (m_pModTree) m_pModTree->UpdatePlayPos(pModDoc, pNotify); Modified: trunk/OpenMPT/mptrack/Mainbar.h =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.h 2013-03-18 13:27:40 UTC (rev 1599) +++ trunk/OpenMPT/mptrack/Mainbar.h 2013-03-18 23:30:10 UTC (rev 1600) @@ -116,7 +116,7 @@ VOID OnDocumentCreated(CModDoc *pModDoc); VOID OnDocumentClosed(CModDoc *pModDoc); VOID OnUpdate(CModDoc *pModDoc, DWORD lHint=0, CObject *pHint=NULL); - VOID UpdatePlayPos(CModDoc *pModDoc, PMPTNOTIFICATION pNotify); + VOID UpdatePlayPos(CModDoc *pModDoc, MPTNOTIFICATION *pNotify); HWND GetModTreeHWND(); //rewbs.customKeys BOOL PostMessageToModTree(UINT cmdID, WPARAM wParam, LPARAM lParam); //rewbs.customKeys Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-18 13:27:40 UTC (rev 1599) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-18 23:30:10 UTC (rev 1600) @@ -273,15 +273,16 @@ #define MPTNOTIFY_STOP 0x00800000 #define MPTNOTIFY_POSVALID 0x80000000 // dwPos[i] is valid -typedef struct MPTNOTIFICATION +struct MPTNOTIFICATION { DWORD dwType; DWORD dwLatency; - ORDERINDEX nOrder; // Always valid + ROWINDEX nRow; // Always valid + UINT nTick; // dito + ORDERINDEX nOrder; // dito PATTERNINDEX nPattern; // dito - ROWINDEX nRow; // dito DWORD dwPos[MAX_CHANNELS]; // sample/envelope pos for each channel if >= 0 -} MPTNOTIFICATION, *PMPTNOTIFICATION; +}; ///////////////////////////////////////////////////////////////////////// Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-18 13:27:40 UTC (rev 1599) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-18 23:30:10 UTC (rev 1600) @@ -170,6 +170,7 @@ memset(activeNoteChannel, 0xFF, sizeof(activeNoteChannel)); m_nPlayPat = PATTERNINDEX_INVALID; m_nPlayRow = 0; + m_nPlayTick = 0; m_nMidRow = 0; m_nDragItem = 0; m_bInItemRect = false; @@ -1871,6 +1872,7 @@ DeleteRows(0, pSndFile->GetNumChannels() - 1, m_Selection.GetNumRows()); } + void CViewPattern::InsertRows(CHANNELINDEX colmin, CHANNELINDEX colmax) //--------------------------------------------------------------------- { @@ -1908,13 +1910,11 @@ } -//rewbs.customKeys void CViewPattern::OnInsertRows() //------------------------------- { InsertRows(m_Selection.GetStartChannel(), m_Selection.GetEndChannel()); } -//end rewbs.customKeys void CViewPattern::OnEditFind() @@ -3551,7 +3551,6 @@ SetCurrentRow((nRow < pSndFile->Patterns[nPat].GetNumRows()) ? nRow : 0, FALSE, FALSE); } } - SetPlayCursor(PATTERNINDEX_INVALID, 0); } else { if(updateOrderList) @@ -3559,11 +3558,10 @@ SendCtrlMessage(CTRLMSG_FORCEREFRESH); //force orderlist refresh updateOrderList = false; } - SetPlayCursor(nPat, nRow); } + SetPlayCursor(nPat, nRow); + m_nPlayTick = pnotify->nTick; - - } //Ends condition "if(pnotify->dwType & MPTNOTIFY_POSITION)" if((pnotify->dwType & (MPTNOTIFY_VUMETERS|MPTNOTIFY_STOP)) && m_Status[psShowVUMeters]) @@ -3675,7 +3673,10 @@ ModCommandPos editpos; if(bLiveRecord) { - SetEditPos(rSf, editpos.row, editpos.pattern, rSf.m_nRow, rSf.m_nPattern); + if(m_nPlayPat != PATTERNINDEX_INVALID) + SetEditPos(rSf, editpos.row, editpos.pattern, m_nPlayRow, m_nPlayPat); + else + SetEditPos(rSf, editpos.row, editpos.pattern, rSf.m_nRow, rSf.m_nPattern); } else { editpos.pattern = m_nPattern; @@ -4694,21 +4695,20 @@ //----------------------------------------------------------------------------- { CModDoc *pModDoc = GetDocument(); - CSoundFile *pSndFile = pModDoc->GetSoundFile(); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + if(pModDoc == nullptr || pMainFrm == nullptr) + { + return; + } + CSoundFile &sndFile = pModDoc->GetrSoundFile(); - // Get playback edit positions from play engine here in case they are needed below. - const ROWINDEX nRowPlayback = pSndFile->m_nRow; - const UINT nTick = pSndFile->m_nTickCount; - const PATTERNINDEX nPatPlayback = pSndFile->m_nPattern; - const bool liveRecord = IsLiveRecord(); const bool isSplit = IsNoteSplit(note); UINT ins = 0; BYTE *activeNoteMap = isSplit ? splitActiveNoteChannel : activeNoteChannel; const CHANNELINDEX nChnCursor = GetCurrentChannel(); - const CHANNELINDEX nChn = bChordMode ? chordPatternChannels[0] : (activeNoteMap[note] < pSndFile->GetNumChannels() ? activeNoteMap[note] : nChnCursor); + const CHANNELINDEX nChn = bChordMode ? chordPatternChannels[0] : (activeNoteMap[note] < sndFile.GetNumChannels() ? activeNoteMap[note] : nChnCursor); CHANNELINDEX noteChannels[MPTChord::notesPerChord] = { nChn }; int numNotes = 1; @@ -4727,7 +4727,7 @@ if(!ins) ins = m_nFoundInstrument; - const bool playWholeRow = ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord && IsLiveRecord()); + const bool playWholeRow = ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord); if(bChordMode == true) { m_Status.reset(psChordPlaying); @@ -4746,7 +4746,7 @@ prevChordNote = NOTE_NONE; } else { - pModDoc->NoteOff(note, ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOTEFADE) || pSndFile->GetNumInstruments() == 0), ins, nChnCursor, playWholeRow ? nChn : CHANNELINDEX_INVALID); + pModDoc->NoteOff(note, ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOTEFADE) || sndFile.GetNumInstruments() == 0), ins, nChnCursor, playWholeRow ? nChn : CHANNELINDEX_INVALID); } } @@ -4770,28 +4770,24 @@ const bool usePlaybackPosition = (!bChordMode) && (liveRecord && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_AUTODELAY)); //Work out where to put the note off - ROWINDEX nRow = GetCurrentRow(); - PATTERNINDEX nPat = m_nPattern; + ModCommandPos editPos = GetEditPos(sndFile, usePlaybackPosition); - if(usePlaybackPosition) - SetEditPos(*pSndFile, nRow, nPat, nRowPlayback, nPatPlayback); - const bool doQuantize = (liveRecord || (fromMidi && (TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_PLAYPATTERNONMIDIIN))) && TrackerSettings::Instance().recordQuantizeRows != 0; if(doQuantize) { - QuantizeRow(nPat, nRow); + QuantizeRow(editPos.pattern, editPos.row); } - ModCommand *pTarget = pSndFile->Patterns[nPat].GetpModCommand(nRow, nChn); + ModCommand *pTarget = sndFile.Patterns[editPos.pattern].GetpModCommand(editPos.row, nChn); // Don't overwrite: if(pTarget->note != NOTE_NONE || pTarget->instr || pTarget->volcmd != VOLCMD_NONE) { // If there's a note in the current location and the song is playing and following, // the user probably just tapped the key - let's try the next row down. - nRow++; - if(pTarget->note == note && liveRecord && pSndFile->Patterns[nPat].IsValidRow(nRow)) + editPos.row++; + if(pTarget->note == note && liveRecord && sndFile.Patterns[editPos.pattern].IsValidRow(editPos.row)) { - pTarget = pSndFile->Patterns[nPat].GetpModCommand(nRow, nChn); + pTarget = sndFile.Patterns[editPos.pattern].GetpModCommand(editPos.row, nChn); if(pTarget->note != NOTE_NONE || (!bChordMode && (pTarget->instr || pTarget->volcmd))) return; } else @@ -4801,36 +4797,36 @@ } // Create undo-point. - pModDoc->GetPatternUndo().PrepareUndo(nPat, nChn, nRow, noteChannels[numNotes - 1] - nChn + 1, 1); + pModDoc->GetPatternUndo().PrepareUndo(editPos.pattern, nChn, editPos.row, noteChannels[numNotes - 1] - nChn + 1, 1); for(int i = 0; i < numNotes; i++) { - ModCommand *pTarget = pSndFile->Patterns[nPat].GetpModCommand(nRow, noteChannels[i]); + ModCommand *pTarget = sndFile.Patterns[editPos.pattern].GetpModCommand(editPos.row, noteChannels[i]); // -- write sdx if playing live - if(usePlaybackPosition && nTick && pTarget->command == CMD_NONE && !doQuantize) + if(usePlaybackPosition && m_nPlayTick && pTarget->command == CMD_NONE && !doQuantize) { - pTarget->command = (pSndFile->TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX; - pTarget->param = 0xD0 | min(0xF, nTick); + pTarget->command = (sndFile.TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX; + pTarget->param = 0xD0 | min(0xF, m_nPlayTick); } //Enter note off - if(pSndFile->GetModSpecifications().hasNoteOff && (pSndFile->GetNumInstruments() > 0 || !pSndFile->GetModSpecifications().hasNoteCut)) + if(sndFile.GetModSpecifications().hasNoteOff && (sndFile.GetNumInstruments() > 0 || !sndFile.GetModSpecifications().hasNoteCut)) { // === // Not used in sample (if module format supports ^^^ instead) pTarget->note = NOTE_KEYOFF; - } else if(pSndFile->GetModSpecifications().hasNoteCut) + } else if(sndFile.GetModSpecifications().hasNoteCut) { // ^^^ pTarget->note = NOTE_NOTECUT; } else { // we don't have anything to cut (MOD format) - use volume or ECx - if(usePlaybackPosition && nTick && !doQuantize) // ECx + if(usePlaybackPosition && m_nPlayTick && !doQuantize) // ECx { - pTarget->command = (pSndFile->TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX; - pTarget->param = 0xC0 | min(0xF, nTick); + pTarget->command = (sndFile.TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX; + pTarget->param = 0xC0 | min(0xF, m_nPlayTick); } else // C00 { pTarget->note = NOTE_NONE; @@ -4845,9 +4841,9 @@ pModDoc->SetModified(); - if(nPat == m_nPattern) + if(editPos.pattern == m_nPattern) { - InvalidateRow(nRow); + InvalidateRow(editPos.row); } else { InvalidatePattern(); @@ -4964,14 +4960,6 @@ } CSoundFile &sndFile = pModDoc->GetrSoundFile(); - ROWINDEX nRow = GetCurrentRow(); - const ROWINDEX nRowPlayback = sndFile.m_nRow; - const UINT nTick = sndFile.m_nTickCount; - const PATTERNINDEX nPatPlayback = sndFile.m_nPattern; - - const bool recordEnabled = IsEditingEnabled(); - CHANNELINDEX nChn = GetCurrentChannel(); - if(note < NOTE_MIN_SPECIAL) { Limit(note, sndFile.GetModSpecifications().noteMin, sndFile.GetModSpecifications().noteMax); @@ -4990,11 +4978,17 @@ return; } - BYTE recordGroup = pModDoc->IsChannelRecord(nChn); const bool liveRecord = IsLiveRecord(); const bool usePlaybackPosition = (liveRecord && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_AUTODELAY) && !sndFile.m_SongFlags[SONG_STEP]); const bool isSplit = IsNoteSplit(note); + ModCommandPos editPos = GetEditPos(sndFile, usePlaybackPosition); + + const bool recordEnabled = IsEditingEnabled(); + CHANNELINDEX nChn = GetCurrentChannel(); + + BYTE recordGroup = pModDoc->IsChannelRecord(nChn); + if(pModDoc->GetSplitKeyboardSettings().IsSplitActive() && ((recordGroup == 1 && isSplit) || (recordGroup == 2 && !isSplit))) { @@ -5015,32 +5009,28 @@ if (m_nSpacing > 0 && m_nSpacing <= MAX_SPACING) { if ((timeGetTime() - m_dwLastNoteEntryTime < TrackerSettings::Instance().gnAutoChordWaitTime) - && (nRow >= m_nSpacing) && (!m_bLastNoteEntryBlocked)) + && (editPos.row >= m_nSpacing) && (!m_bLastNoteEntryBlocked)) { - nRow -= m_nSpacing; + editPos.row -= m_nSpacing; } } } m_dwLastNoteEntryTime = timeGetTime(); - PATTERNINDEX nPat = m_nPattern; - if(usePlaybackPosition) - SetEditPos(sndFile, nRow, nPat, nRowPlayback, nPatPlayback); - // Quantize const bool doQuantize = (liveRecord || (fromMidi && (TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_PLAYPATTERNONMIDIIN))) && TrackerSettings::Instance().recordQuantizeRows != 0; if(doQuantize) { - QuantizeRow(nPat, nRow); + QuantizeRow(editPos.pattern, editPos.row); // "Grace notes" are stuffed into the next row, if possible - if(sndFile.Patterns[nPat].GetpModCommand(nRow, nChn)->IsNote() && nRow < sndFile.Patterns[nPat].GetNumRows() - 1) + if(sndFile.Patterns[editPos.pattern].GetpModCommand(editPos.row, nChn)->IsNote() && editPos.row < sndFile.Patterns[editPos.pattern].GetNumRows() - 1) { - nRow++; + editPos.row++; } } // -- Work out where to put the new note - ModCommand *pTarget = sndFile.Patterns[nPat].GetpModCommand(nRow, nChn); + ModCommand *pTarget = sndFile.Patterns[editPos.pattern].GetpModCommand(editPos.row, nChn); ModCommand newcmd = *pTarget; // Param control 'note' @@ -5103,14 +5093,14 @@ } // -- write sdx if playing live - if(usePlaybackPosition && nTick && !doQuantize) // avoid SD0 which will be mis-interpreted + if(usePlaybackPosition && m_nPlayTick && !doQuantize) // avoid SD0 which will be mis-interpreted { if(newcmd.command == CMD_NONE) //make sure we don't overwrite any existing commands. { newcmd.command = (sndFile.TypeIsS3M_IT_MPT()) ? CMD_S3MCMDEX : CMD_MODCMDEX; UINT maxSpeed = 0x0F; if(sndFile.m_nMusicSpeed > 0) maxSpeed = min(0x0F, sndFile.m_nMusicSpeed - 1); - newcmd.param = 0xD0 + min(maxSpeed, nTick); + newcmd.param = 0xD0 + min(maxSpeed, m_nPlayTick); } } @@ -5124,7 +5114,7 @@ const bool modified = (recordEnabled && *pTarget != newcmd); if (modified) { - pModDoc->GetPatternUndo().PrepareUndo(nPat, nChn, nRow, 1, 1); + pModDoc->GetPatternUndo().PrepareUndo(editPos.pattern, nChn, editPos.row, 1, 1); *pTarget = newcmd; } @@ -5135,7 +5125,7 @@ if (playWholeRow) { // play the whole row in "step mode" - PatternStep(nRow); + PatternStep(editPos.row); } if (!playWholeRow || !recordEnabled) { @@ -5149,7 +5139,7 @@ { // ...or one that can be found on a previous row of this pattern. ModCommand *search = pTarget; - ROWINDEX srow = nRow; + ROWINDEX srow = editPos.row; while(srow-- > 0) { search -= sndFile.GetNumChannels(); @@ -5169,7 +5159,7 @@ // -- if recording, handle post note entry behaviour (move cursor etc..) if(recordEnabled) { - PatternCursor sel(nRow, nChn, m_Cursor.GetColumnType()); + PatternCursor sel(editPos.row, nChn, m_Cursor.GetColumnType()); if(!liveRecord) { // Update only when not recording live. @@ -5179,7 +5169,7 @@ if(modified) // Has it really changed? { pModDoc->SetModified(); - if(nPat == m_nPattern) + if(editPos.pattern == m_nPattern) InvalidateCell(sel); else InvalidatePattern(); @@ -5195,9 +5185,9 @@ { if((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) { - if(nRow + m_nSpacing < sndFile.Patterns[nPat].GetNumRows() || (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL)) + if(editPos.row + m_nSpacing < sndFile.Patterns[editPos.pattern].GetNumRows() || (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL)) { - SetCurrentRow(nRow + m_nSpacing, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) ? true: false); + SetCurrentRow(editPos.row + m_nSpacing, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) ? true: false); m_bLastNoteEntryBlocked = false; } else { @@ -5538,7 +5528,7 @@ return; } - const ROWINDEX currentTick = sndFile->m_nMusicSpeed * row + sndFile->m_nTickCount; + const ROWINDEX currentTick = sndFile->m_nMusicSpeed * row + m_nPlayTick; const ROWINDEX ticksPerNote = TrackerSettings::Instance().recordQuantizeRows * sndFile->m_nMusicSpeed; // Previous quantization step Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2013-03-18 13:27:40 UTC (rev 1599) +++ trunk/OpenMPT/mptrack/View_pat.h 2013-03-18 23:30:10 UTC (rev 1600) @@ -162,6 +162,7 @@ UINT m_nMidRow, m_nSpacing, m_nAccelChar, m_nLastPlayedRow, m_nLastPlayedOrder; FlagSet<PatternStatus> m_Status; ROWINDEX m_nPlayRow; + UINT m_nPlayTick; PATTERNINDEX m_nPattern, m_nPlayPat; int m_nXScroll, m_nYScroll; @@ -192,16 +193,16 @@ vector<ModCommand::NOTE> octaveKeyMemory; - WORD ChnVUMeters[MAX_BASECHANNELS]; - WORD OldVUMeters[MAX_BASECHANNELS]; - // Chord preview CHANNELINDEX chordPatternChannels[MPTChord::notesPerChord]; ModCommand::NOTE prevChordNote, prevChordBaseNote; - BYTE activeNoteChannel[NOTE_MAX + 1]; - BYTE splitActiveNoteChannel[NOTE_MAX + 1]; + WORD ChnVUMeters[MAX_BASECHANNELS]; + WORD OldVUMeters[MAX_BASECHANNELS]; + BYTE activeNoteChannel[NOTE_MAX + NOTE_MIN]; + BYTE splitActiveNoteChannel[NOTE_MAX + NOTE_MIN]; + public: CEffectVis *m_pEffectVis; //rewbs.fxVis Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-18 13:27:40 UTC (rev 1599) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-18 23:30:10 UTC (rev 1600) @@ -2200,7 +2200,7 @@ } -void CModTree::UpdatePlayPos(CModDoc *pModDoc, PMPTNOTIFICATION pNotify) +void CModTree::UpdatePlayPos(CModDoc *pModDoc, MPTNOTIFICATION *pNotify) //---------------------------------------------------------------------- { ModTreeDocInfo *pInfo = GetDocumentInfoFromModDoc(pModDoc); Modified: trunk/OpenMPT/mptrack/View_tre.h =================================================================== --- trunk/OpenMPT/mptrack/View_tre.h 2013-03-18 13:27:40 UTC (rev 1599) +++ trunk/OpenMPT/mptrack/View_tre.h 2013-03-18 23:30:10 UTC (rev 1600) @@ -162,7 +162,7 @@ void UpdateView(ModTreeDocInfo *pInfo, DWORD dwHint); void OnUpdate(CModDoc *pModDoc, DWORD dwHint, CObject *pHint); bool CanDrop(HTREEITEM hItem, bool bDoDrop); - void UpdatePlayPos(CModDoc *pModDoc, PMPTNOTIFICATION pNotify); + void UpdatePlayPos(CModDoc *pModDoc, MPTNOTIFICATION *pNotify); bool IsItemExpanded(HTREEITEM hItem); // Overrides This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-03-19 17:32:50
|
Revision: 1601 http://sourceforge.net/p/modplug/code/1601 Author: manxorist Date: 2013-03-19 17:32:39 +0000 (Tue, 19 Mar 2013) Log Message: ----------- [New] Add hidden setting "ShowSplashScreen" in [Display]. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-03-18 23:30:10 UTC (rev 1600) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-03-19 17:32:39 UTC (rev 1601) @@ -908,7 +908,7 @@ if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) return FALSE; m_pMainWnd = pMainFrame; - if (cmdInfo.m_bShowSplash) + if (cmdInfo.m_bShowSplash && TrackerSettings::Instance().m_ShowSplashScreen) { StartSplashScreen(); } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-18 23:30:10 UTC (rev 1600) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-03-19 17:32:39 UTC (rev 1601) @@ -32,6 +32,7 @@ TrackerSettings::TrackerSettings() //-------------------------------- { + m_ShowSplashScreen = true; gnPatternSpacing = 0; gbPatternRecord = TRUE; gbPatternVUMeters = FALSE; @@ -250,6 +251,7 @@ } // GUI Stuff + m_ShowSplashScreen = CMainFrame::GetPrivateProfileLong("Display", "ShowSplashScreen", m_ShowSplashScreen, iniFile); gbMdiMaximize = CMainFrame::GetPrivateProfileLong("Display", "MDIMaximize", gbMdiMaximize, iniFile); glTreeWindowWidth = CMainFrame::GetPrivateProfileLong("Display", "MDITreeWidth", glTreeWindowWidth, iniFile); glTreeSplitRatio = CMainFrame::GetPrivateProfileLong("Display", "MDITreeRatio", glTreeSplitRatio, iniFile); Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-18 23:30:10 UTC (rev 1600) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-19 17:32:39 UTC (rev 1601) @@ -154,6 +154,7 @@ atRecordAsMacro, }; + bool m_ShowSplashScreen; BOOL gbMdiMaximize; bool gbShowHackControls; LONG glTreeWindowWidth, glTreeSplitRatio; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-23 01:20:14
|
Revision: 1634 http://sourceforge.net/p/modplug/code/1634 Author: saga-games Date: 2013-03-23 01:20:05 +0000 (Sat, 23 Mar 2013) Log Message: ----------- [Imp] Tree view: Navigating with keyboard (e.g. using alphanumeric keys in the instrument browser) should work much better now. [Ref] Only create one CSoundFile object for both treeviews, since we only need one anyway. Still might want to de-duplicate all the other stuff as well, and probably get rid of m_SongFile completely... Modified Paths: -------------- trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainbar.cpp trunk/OpenMPT/mptrack/Mainbar.h trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/PatternClipboard.cpp trunk/OpenMPT/mptrack/PatternClipboard.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2013-03-23 00:23:07 UTC (rev 1633) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2013-03-23 01:20:05 UTC (rev 1634) @@ -131,7 +131,11 @@ if(m_pMainFrm && executeCommand != kcNull) { - m_pMainFrm->PostMessage(WM_MOD_KEYCOMMAND, executeCommand, wParam); + if(!m_pMainFrm->SendMessage(WM_MOD_KEYCOMMAND, executeCommand, wParam)) + { + // Command was not handled, so let Windows process it. + return kcNull; + } } return executeCommand; @@ -151,7 +155,11 @@ if(pSourceWnd && (executeCommand != kcNull)) { - pSourceWnd->PostMessage(WM_MOD_KEYCOMMAND, executeCommand, nChar); + if(!pSourceWnd->SendMessage(WM_MOD_KEYCOMMAND, executeCommand, nChar)) + { + // Command was not handled, so let Windows process it. + return kcNull; + } } return executeCommand; @@ -525,7 +533,7 @@ case ID_EDIT_SPLITKEYBOARDSETTINGS: s="Split &Keyboard Settings\t"; c = kcShowSplitKeyboardSettings; break; // "Paste Special" sub menu case ID_EDIT_PASTE_SPECIAL: s="&Mix Paste\t"; c = kcEditMixPaste; break; - case ID_EDIT_MIXPASTE_ITSTYLE: s="&Mix Paste (IT Style)\t"; c = kcEditMixPasteITStyle; break; + case ID_EDIT_MIXPASTE_ITSTYLE: s="M&ix Paste (IT Style)\t"; c = kcEditMixPasteITStyle; break; case ID_EDIT_PASTEFLOOD: s="Paste Fl&ood\t"; c = kcEditPasteFlood; break; case ID_EDIT_PUSHFORWARDPASTE: s="&Push Forward Paste (Insert)\t"; c = kcEditPushForwardPaste; break; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-23 00:23:07 UTC (rev 1633) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-23 01:20:05 UTC (rev 1634) @@ -203,8 +203,8 @@ ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction //#include <direct.h> -CMainFrame::CMainFrame() -//---------------------- +CMainFrame::CMainFrame() : m_wndTree(m_TreeBrowseFile) +//---------------------------------------------------- { m_bModTreeHasFocus = false; //rewbs.customKeys m_pNoteMapHasFocus = nullptr; //rewbs.customKeys Modified: trunk/OpenMPT/mptrack/Mainbar.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.cpp 2013-03-23 00:23:07 UTC (rev 1633) +++ trunk/OpenMPT/mptrack/Mainbar.cpp 2013-03-23 01:20:05 UTC (rev 1634) @@ -606,8 +606,8 @@ END_MESSAGE_MAP() -CModTreeBar::CModTreeBar() -//------------------------ +CModTreeBar::CModTreeBar(CSoundFile &sf) : m_TreeBrowseFile(sf) +//------------------------------------------------------------- { m_pModTree = m_pModTreeData = NULL; m_nTreeSplitRatio = TrackerSettings::Instance().glTreeSplitRatio; @@ -618,9 +618,9 @@ //------------------------------------------------------------- { LRESULT l = CDialogBar::HandleInitDialog(wParam, lParam); - m_pModTreeData = new CModTree(); + m_pModTreeData = new CModTree(nullptr, m_TreeBrowseFile); if (m_pModTreeData) m_pModTreeData->SubclassDlgItem(IDC_TREEDATA, this); - m_pModTree = new CModTree(m_pModTreeData); + m_pModTree = new CModTree(m_pModTreeData, m_TreeBrowseFile); if (m_pModTree) m_pModTree->SubclassDlgItem(IDC_TREEVIEW, this); m_dwStatus = 0; m_sizeDefault.cx = TrackerSettings::Instance().glTreeWindowWidth + 3; @@ -635,12 +635,12 @@ if (m_pModTree) { delete m_pModTree; - m_pModTree = NULL; + m_pModTree = nullptr; } if (m_pModTreeData) { delete m_pModTreeData; - m_pModTreeData = NULL; + m_pModTreeData = nullptr; } } @@ -1068,9 +1068,9 @@ BOOL CModTreeBar::PostMessageToModTree(UINT cmdID, WPARAM wParam, LPARAM lParam) { if (::GetFocus() == m_pModTree->m_hWnd) - return m_pModTree->PostMessage(cmdID, wParam, lParam); + return m_pModTree->SendMessage(cmdID, wParam, lParam); if (::GetFocus() == m_pModTreeData->m_hWnd) - return m_pModTreeData->PostMessage(cmdID, wParam, lParam); + return m_pModTreeData->SendMessage(cmdID, wParam, lParam); return 0; } Modified: trunk/OpenMPT/mptrack/Mainbar.h =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.h 2013-03-23 00:23:07 UTC (rev 1633) +++ trunk/OpenMPT/mptrack/Mainbar.h 2013-03-23 01:20:05 UTC (rev 1634) @@ -90,6 +90,7 @@ //================================== { protected: + CSoundFile &m_TreeBrowseFile; DWORD m_dwStatus; // MTB_XXXX UINT m_nCursorDrag; CPoint ptDragging; @@ -99,7 +100,7 @@ public: CModTree *m_pModTree, *m_pModTreeData; - CModTreeBar(); + CModTreeBar(CSoundFile &sf); virtual ~CModTreeBar(); public: Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-23 00:23:07 UTC (rev 1633) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-23 01:20:05 UTC (rev 1634) @@ -341,7 +341,7 @@ protected: - CSoundFile m_WaveFile; + CSoundFile m_WaveFile, m_TreeBrowseFile; CModTreeBar m_wndTree; CStatusBar m_wndStatusBar; CMainToolBar m_wndToolBar; Modified: trunk/OpenMPT/mptrack/PatternClipboard.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.cpp 2013-03-23 00:23:07 UTC (rev 1633) +++ trunk/OpenMPT/mptrack/PatternClipboard.cpp 2013-03-23 01:20:05 UTC (rev 1634) @@ -832,6 +832,15 @@ } +// Check whether patterns can be pasted from clipboard +bool PatternClipboard::CanPaste() +//------------------------------- +{ + return !!IsClipboardFormatAvailable(CF_TEXT); +} + + + // System-specific clipboard functions bool PatternClipboard::ToSystemClipboard(const CString &data) //----------------------------------------------------------- Modified: trunk/OpenMPT/mptrack/PatternClipboard.h =================================================================== --- trunk/OpenMPT/mptrack/PatternClipboard.h 2013-03-23 00:23:07 UTC (rev 1633) +++ trunk/OpenMPT/mptrack/PatternClipboard.h 2013-03-23 01:20:05 UTC (rev 1634) @@ -83,6 +83,8 @@ static void SetClipboardSize(clipindex_t maxEntries); // Return the current number of clipboards. static clipindex_t GetClipboardSize() { return instance.clipboards.size(); }; + // Check whether patterns can be pasted from clipboard + static bool CanPaste(); protected: Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-23 00:23:07 UTC (rev 1633) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-23 01:20:05 UTC (rev 1634) @@ -1473,7 +1473,7 @@ if(BuildRowInsDelCtxMenu(hMenu, ih)) AppendMenu(hMenu, MF_SEPARATOR, 0, ""); - CString s = "Quantize "; + CString s = "&Quantize "; if(TrackerSettings::Instance().recordQuantizeRows != 0) { s.AppendFormat("(Currently: %d Rows)", TrackerSettings::Instance().recordQuantizeRows); @@ -5907,7 +5907,7 @@ { AppendMenu(hMenu, pSndFile->ChnSettings[nChn].dwFlags[CHN_MUTE] ? (MF_STRING|MF_CHECKED) : MF_STRING, ID_PATTERN_MUTE, - "Mute Channel\t" + ih->GetKeyTextFromCommand(kcChannelMute)); + "&Mute Channel\t" + ih->GetKeyTextFromCommand(kcChannelMute)); bool bSolo = false, bUnmuteAll = false; bool bSoloPending = false, bUnmuteAllPending = false; // doesn't work perfectly yet @@ -5925,8 +5925,8 @@ if(pSndFile->ChnSettings[i].dwFlags[CHN_MUTE]) bUnmuteAll = bUnmuteAllPending = true; if(!pSndFile->ChnSettings[i].dwFlags[CHN_MUTE] && pSndFile->m_bChannelMuteTogglePending[i]) bUnmuteAllPending = true; } - if (bSolo) AppendMenu(hMenu, MF_STRING, ID_PATTERN_SOLO, "Solo Channel\t" + ih->GetKeyTextFromCommand(kcChannelSolo)); - if (bUnmuteAll) AppendMenu(hMenu, MF_STRING, ID_PATTERN_UNMUTEALL, "Unmute All\t" + ih->GetKeyTextFromCommand(kcChannelUnmuteAll)); + if (bSolo) AppendMenu(hMenu, MF_STRING, ID_PATTERN_SOLO, "&Solo Channel\t" + ih->GetKeyTextFromCommand(kcChannelSolo)); + if (bUnmuteAll) AppendMenu(hMenu, MF_STRING, ID_PATTERN_UNMUTEALL, "&Unmute All\t" + ih->GetKeyTextFromCommand(kcChannelUnmuteAll)); AppendMenu(hMenu, pSndFile->m_bChannelMuteTogglePending[nChn] ? (MF_STRING|MF_CHECKED) : MF_STRING, @@ -5938,7 +5938,7 @@ if (bUnmuteAllPending) AppendMenu(hMenu, MF_STRING, ID_PATTERN_TRANSITION_UNMUTEALL, "On transition: Unmute all\t" + ih->GetKeyTextFromCommand(kcUnmuteAllChnOnPatTransition)); if (bSoloPending) AppendMenu(hMenu, MF_STRING, ID_PATTERN_TRANSITIONSOLO, "On transition: Solo\t" + ih->GetKeyTextFromCommand(kcSoloChnOnPatTransition)); - AppendMenu(hMenu, MF_STRING, ID_PATTERN_CHNRESET, "Reset Channel\t" + ih->GetKeyTextFromCommand(kcChannelReset)); + AppendMenu(hMenu, MF_STRING, ID_PATTERN_CHNRESET, "&Reset Channel\t" + ih->GetKeyTextFromCommand(kcChannelReset)); return true; } @@ -5946,8 +5946,8 @@ bool CViewPattern::BuildRecordCtxMenu(HMENU hMenu, CInputHandler *ih, CHANNELINDEX nChn, CModDoc* pModDoc) const //-------------------------------------------------------------------------------------------------------------- { - AppendMenu(hMenu, pModDoc->IsChannelRecord1(nChn) ? (MF_STRING | MF_CHECKED) : MF_STRING, ID_EDIT_RECSELECT, "Record select\t" + ih->GetKeyTextFromCommand(kcChannelRecordSelect)); - AppendMenu(hMenu, pModDoc->IsChannelRecord2(nChn) ? (MF_STRING | MF_CHECKED) : MF_STRING, ID_EDIT_SPLITRECSELECT, "Split Record select\t" + ih->GetKeyTextFromCommand(kcChannelSplitRecordSelect)); + AppendMenu(hMenu, pModDoc->IsChannelRecord1(nChn) ? (MF_STRING | MF_CHECKED) : MF_STRING, ID_EDIT_RECSELECT, "R&ecord select\t" + ih->GetKeyTextFromCommand(kcChannelRecordSelect)); + AppendMenu(hMenu, pModDoc->IsChannelRecord2(nChn) ? (MF_STRING | MF_CHECKED) : MF_STRING, ID_EDIT_SPLITRECSELECT, "S&plit Record select\t" + ih->GetKeyTextFromCommand(kcChannelSplitRecordSelect)); return true; } @@ -5958,8 +5958,8 @@ { const CString label = (m_Selection.GetStartRow() != m_Selection.GetEndRow() ? "Rows" : "Row"); - AppendMenu(hMenu, MF_STRING, ID_PATTERN_INSERTROW, "Insert " + label + "\t" + ih->GetKeyTextFromCommand(kcInsertRow)); - AppendMenu(hMenu, MF_STRING, ID_PATTERN_DELETEROW, "Delete " + label + "\t" + ih->GetKeyTextFromCommand(kcDeleteRows) ); + AppendMenu(hMenu, MF_STRING, ID_PATTERN_INSERTROW, "&Insert " + label + "\t" + ih->GetKeyTextFromCommand(kcInsertRow)); + AppendMenu(hMenu, MF_STRING, ID_PATTERN_DELETEROW, "&Delete " + label + "\t" + ih->GetKeyTextFromCommand(kcDeleteRows) ); return true; } @@ -6029,19 +6029,19 @@ //----------------------------------------------------------------------------------------- { HMENU pasteSpecialMenu = ::CreatePopupMenu(); - AppendMenu(hMenu, MF_STRING, ID_EDIT_CUT, "Cut\t" + ih->GetKeyTextFromCommand(kcEditCut)); - AppendMenu(hMenu, MF_STRING, ID_EDIT_COPY, "Copy\t" + ih->GetKeyTextFromCommand(kcEditCopy)); - AppendMenu(hMenu, MF_STRING, ID_EDIT_PASTE, "Paste\t" + ih->GetKeyTextFromCommand(kcEditPaste)); + AppendMenu(hMenu, MF_STRING, ID_EDIT_CUT, "Cu&t\t" + ih->GetKeyTextFromCommand(kcEditCut)); + AppendMenu(hMenu, MF_STRING, ID_EDIT_COPY, "&Copy\t" + ih->GetKeyTextFromCommand(kcEditCopy)); + AppendMenu(hMenu, MF_STRING | (PatternClipboard::CanPaste() ? 0 : MF_GRAYED), ID_EDIT_PASTE, "&Paste\t" + ih->GetKeyTextFromCommand(kcEditPaste)); AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(pasteSpecialMenu), "Paste Special"); - AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_MIXPASTE, "Mix Paste\t" + ih->GetKeyTextFromCommand(kcEditMixPaste)); - AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_MIXPASTE_ITSTYLE, "Mix Paste (IT Style)\t" + ih->GetKeyTextFromCommand(kcEditMixPasteITStyle)); - AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_PASTEFLOOD, "Paste Flood\t" + ih->GetKeyTextFromCommand(kcEditPasteFlood)); - AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_PUSHFORWARDPASTE, "Push Forward Paste (Insert)\t" + ih->GetKeyTextFromCommand(kcEditPushForwardPaste)); + AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_MIXPASTE, "&Mix Paste\t" + ih->GetKeyTextFromCommand(kcEditMixPaste)); + AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_MIXPASTE_ITSTYLE, "M&ix Paste (IT Style)\t" + ih->GetKeyTextFromCommand(kcEditMixPasteITStyle)); + AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_PASTEFLOOD, "Paste Fl&ood\t" + ih->GetKeyTextFromCommand(kcEditPasteFlood)); + AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_PUSHFORWARDPASTE, "&Push Forward Paste (Insert)\t" + ih->GetKeyTextFromCommand(kcEditPushForwardPaste)); DWORD greyed = pModDoc->GetPatternUndo().CanUndo() ? MF_ENABLED : MF_GRAYED; if (!greyed || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) { - AppendMenu(hMenu, MF_STRING | greyed, ID_EDIT_UNDO, "Undo\t" + ih->GetKeyTextFromCommand(kcEditUndo)); + AppendMenu(hMenu, MF_STRING | greyed, ID_EDIT_UNDO, "&Undo\t" + ih->GetKeyTextFromCommand(kcEditUndo)); } AppendMenu(hMenu, MF_STRING, ID_CLEAR_SELECTION, "Clear selection\t" + ih->GetKeyTextFromCommand(kcSampleDelete)); @@ -6056,7 +6056,7 @@ if (!greyed || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) { - AppendMenu(hMenu, MF_STRING|greyed, ID_PATTERN_VISUALIZE_EFFECT, "Visualize Effect\t" + ih->GetKeyTextFromCommand(kcPatternVisualizeEffect)); + AppendMenu(hMenu, MF_STRING|greyed, ID_PATTERN_VISUALIZE_EFFECT, "&Visualize Effect\t" + ih->GetKeyTextFromCommand(kcPatternVisualizeEffect)); return true; } return false; @@ -6098,7 +6098,7 @@ if(!greyed || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) { - AppendMenu(hMenu, MF_STRING | greyed, ID_PATTERN_AMPLIFY, "Amplify\t" + ih->GetKeyTextFromCommand(kcPatternAmplify)); + AppendMenu(hMenu, MF_STRING | greyed, ID_PATTERN_AMPLIFY, "&Amplify\t" + ih->GetKeyTextFromCommand(kcPatternAmplify)); return true; } return false; @@ -6110,17 +6110,17 @@ { AppendMenu(hMenu, MF_SEPARATOR, 0, ""); - AppendMenu(hMenu, MF_STRING, ID_PATTERN_DUPLICATECHANNEL, "Duplicate this channel"); + AppendMenu(hMenu, MF_STRING, ID_PATTERN_DUPLICATECHANNEL, "&Duplicate this channel"); HMENU addChannelMenu = ::CreatePopupMenu(); - AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(addChannelMenu), "Add channel\t"); - AppendMenu(addChannelMenu, MF_STRING, ID_PATTERN_ADDCHANNEL_FRONT, "Before this channel"); - AppendMenu(addChannelMenu, MF_STRING, ID_PATTERN_ADDCHANNEL_AFTER, "After this channel"); + AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(addChannelMenu), "&Add channel\t"); + AppendMenu(addChannelMenu, MF_STRING, ID_PATTERN_ADDCHANNEL_FRONT, "&Before this channel"); + AppendMenu(addChannelMenu, MF_STRING, ID_PATTERN_ADDCHANNEL_AFTER, "&After this channel"); HMENU removeChannelMenu = ::CreatePopupMenu(); - AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(removeChannelMenu), "Remove channel\t"); - AppendMenu(removeChannelMenu, MF_STRING, ID_PATTERN_REMOVECHANNEL, "Remove this channel\t"); - AppendMenu(removeChannelMenu, MF_STRING, ID_PATTERN_REMOVECHANNELDIALOG, "Choose channels to remove...\t"); + AppendMenu(hMenu, MF_POPUP, reinterpret_cast<UINT_PTR>(removeChannelMenu), "Remo&ve channel\t"); + AppendMenu(removeChannelMenu, MF_STRING, ID_PATTERN_REMOVECHANNEL, "&Remove this channel\t"); + AppendMenu(removeChannelMenu, MF_STRING, ID_PATTERN_REMOVECHANNELDIALOG, "&Choose channels to remove...\t"); return false; Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-23 00:23:07 UTC (rev 1633) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-23 01:20:05 UTC (rev 1634) @@ -108,8 +108,8 @@ ///////////////////////////////////////////////////////////////////////////// // CViewModTree construction/destruction -CModTree::CModTree(CModTree *pDataTree) -//------------------------------------- +CModTree::CModTree(CModTree *pDataTree, CSoundFile &sf) : m_SongFile(sf) +//---------------------------------------------------------------------- { m_pDataTree = pDataTree; m_dwStatus = 0; @@ -261,7 +261,6 @@ LPBYTE lpStream = f.Lock(); if (lpStream) { - //m_SongFile.Create(lpStream, CMainFrame::GetMainFrame()->GetActiveDoc(), dwLen); m_SongFile.Destroy(); m_SongFile.Create(lpStream, NULL, dwLen); f.Unlock(); @@ -302,7 +301,11 @@ } } - ModTreeDocInfo *pInfo = new ModTreeDocInfo(*pModDoc->GetSoundFile()); + ModTreeDocInfo *pInfo = new (std::nothrow) ModTreeDocInfo(pModDoc->GetrSoundFile()); + if(!pInfo) + { + return; + } pInfo->nSeqSel = SEQUENCEINDEX_INVALID; pInfo->nOrdSel = ORDERINDEX_INVALID; DocInfo.push_back(pInfo); @@ -628,14 +631,13 @@ //---------------------------------------------------------- { CModDoc *pDoc; - CSoundFile *pSndFile; CHAR s[256], stmp[256]; TV_ITEM tvi; const DWORD hintFlagPart = HintFlagPart(lHint); if ((pInfo == nullptr) || (pInfo->pModDoc == nullptr) || (!m_pDataTree)) return; if (!hintFlagPart) return; pDoc = pInfo->pModDoc; - pSndFile = pDoc->GetSoundFile(); + CSoundFile &sndFile = pDoc->GetrSoundFile(); // Create headers s[0] = 0; if ((hintFlagPart & (HINT_MODGENERAL|HINT_MODTYPE)) || (!pInfo->hSong)) @@ -668,7 +670,7 @@ SetItem(&tvi); } } - if (pSndFile->GetType() & (MOD_TYPE_IT|MOD_TYPE_XM|MOD_TYPE_MPT)) + if (sndFile.GetType() & (MOD_TYPE_IT|MOD_TYPE_XM|MOD_TYPE_MPT)) { if (!pInfo->hInstruments) pInfo->hInstruments = InsertItem("Instruments", IMAGE_FOLDER, IMAGE_FOLDER, pInfo->hSong, TVI_LAST); } else @@ -700,7 +702,7 @@ } for (UINT iFx=0; iFx<MAX_MIXPLUGINS; iFx++) { - const SNDMIXPLUGIN &plugin = pSndFile->m_MixPlugins[iFx]; + const SNDMIXPLUGIN &plugin = sndFile.m_MixPlugins[iFx]; if (plugin.IsValidPlugin()) { if (!pInfo->hEffects) @@ -730,7 +732,7 @@ bool adjustParentNode = false; // adjust sequence name of "Sequence" node? // (only one seq remaining || previously only one sequence): update parent item - if((pInfo->tiSequences.size() > 1 && pSndFile->Order.GetNumSequences() == 1) || (pInfo->tiSequences.size() == 1 && pSndFile->Order.GetNumSequences() > 1)) + if((pInfo->tiSequences.size() > 1 && sndFile.Order.GetNumSequences() == 1) || (pInfo->tiSequences.size() == 1 && sndFile.Order.GetNumSequences() > 1)) { for(size_t nSeq = 0; nSeq < pInfo->tiOrders.size(); nSeq++) { @@ -740,13 +742,13 @@ } if(pInfo->tiSequences[nSeq]) DeleteItem(pInfo->tiSequences[nSeq]); pInfo->tiSequences[nSeq] = NULL; } - pInfo->tiOrders.resize(pSndFile->Order.GetNumSequences()); - pInfo->tiSequences.resize(pSndFile->Order.GetNumSequences(), NULL); + pInfo->tiOrders.resize(sndFile.Order.GetNumSequences()); + pInfo->tiSequences.resize(sndFile.Order.GetNumSequences(), NULL); adjustParentNode = true; } // If there are too many sequences, delete them. - for(size_t nSeq = pSndFile->Order.GetNumSequences(); nSeq < pInfo->tiSequences.size(); nSeq++) if (pInfo->tiSequences[nSeq]) + for(size_t nSeq = sndFile.Order.GetNumSequences(); nSeq < pInfo->tiSequences.size(); nSeq++) if (pInfo->tiSequences[nSeq]) { for(size_t nOrd = 0; nOrd < pInfo->tiOrders[nSeq].size(); nOrd++) if (pInfo->tiOrders[nSeq][nOrd]) { @@ -754,23 +756,23 @@ } DeleteItem(pInfo->tiSequences[nSeq]); pInfo->tiSequences[nSeq] = NULL; } - if (pInfo->tiSequences.size() < pSndFile->Order.GetNumSequences()) // Resize tiSequences if needed. + if (pInfo->tiSequences.size() < sndFile.Order.GetNumSequences()) // Resize tiSequences if needed. { - pInfo->tiSequences.resize(pSndFile->Order.GetNumSequences(), NULL); - pInfo->tiOrders.resize(pSndFile->Order.GetNumSequences()); + pInfo->tiSequences.resize(sndFile.Order.GetNumSequences(), NULL); + pInfo->tiOrders.resize(sndFile.Order.GetNumSequences()); } HTREEITEM hAncestorNode = pInfo->hOrders; - SEQUENCEINDEX nSeqMin = 0, nSeqMax = pSndFile->Order.GetNumSequences() - 1; + SEQUENCEINDEX nSeqMin = 0, nSeqMax = sndFile.Order.GetNumSequences() - 1; SEQUENCEINDEX nHintParam = lHint >> HINT_SHIFT_SEQUENCE; if ((hintFlagPart == HINT_SEQNAMES) && (nHintParam <= nSeqMax)) nSeqMin = nSeqMax = nHintParam; // Adjust caption of the "Sequence" node (if only one sequence exists, it should be labeled with the sequence name) - if(((hintFlagPart == HINT_SEQNAMES) && pSndFile->Order.GetNumSequences() == 1) || adjustParentNode) + if(((hintFlagPart == HINT_SEQNAMES) && sndFile.Order.GetNumSequences() == 1) || adjustParentNode) { - CString sSeqName = pSndFile->Order.GetSequence(0).m_sName; - if(sSeqName.IsEmpty() || pSndFile->Order.GetNumSequences() > 1) + CString sSeqName = sndFile.Order.GetSequence(0).m_sName; + if(sSeqName.IsEmpty() || sndFile.Order.GetNumSequences() > 1) sSeqName = "Sequence"; else sSeqName = "Sequence: " + sSeqName; @@ -780,16 +782,16 @@ // go through all sequences for(SEQUENCEINDEX nSeq = nSeqMin; nSeq <= nSeqMax; nSeq++) { - if(pSndFile->Order.GetNumSequences() > 1) + if(sndFile.Order.GetNumSequences() > 1) { // more than one sequence -> add folder CString sSeqName; - if(pSndFile->Order.GetSequence(nSeq).m_sName.IsEmpty()) + if(sndFile.Order.GetSequence(nSeq).m_sName.IsEmpty()) sSeqName.Format("Sequence %d", nSeq); else - sSeqName.Format("%d: %s", nSeq, (LPCTSTR)pSndFile->Order.GetSequence(nSeq).m_sName); + sSeqName.Format("%d: %s", nSeq, (LPCTSTR)sndFile.Order.GetSequence(nSeq).m_sName); - UINT state = (nSeq == pSndFile->Order.GetCurrentSequenceIndex()) ? TVIS_BOLD : 0; + UINT state = (nSeq == sndFile.Order.GetCurrentSequenceIndex()) ? TVIS_BOLD : 0; if(pInfo->tiSequences[nSeq] == NULL) { @@ -811,36 +813,36 @@ } // If there are items past the new sequence length, delete them. - for(size_t nOrd = pSndFile->Order.GetSequence(nSeq).GetLengthTailTrimmed(); nOrd < pInfo->tiOrders[nSeq].size(); nOrd++) if (pInfo->tiOrders[nSeq][nOrd]) + for(size_t nOrd = sndFile.Order.GetSequence(nSeq).GetLengthTailTrimmed(); nOrd < pInfo->tiOrders[nSeq].size(); nOrd++) if (pInfo->tiOrders[nSeq][nOrd]) { DeleteItem(pInfo->tiOrders[nSeq][nOrd]); pInfo->tiOrders[nSeq][nOrd] = NULL; } - if (pInfo->tiOrders[nSeq].size() < pSndFile->Order.GetSequence(nSeq).GetLengthTailTrimmed()) // Resize tiOrders if needed. - pInfo->tiOrders[nSeq].resize(pSndFile->Order.GetSequence(nSeq).GetLengthTailTrimmed(), NULL); + if (pInfo->tiOrders[nSeq].size() < sndFile.Order.GetSequence(nSeq).GetLengthTailTrimmed()) // Resize tiOrders if needed. + pInfo->tiOrders[nSeq].resize(sndFile.Order.GetSequence(nSeq).GetLengthTailTrimmed(), NULL); const bool patNamesOnly = (hintFlagPart == HINT_PATNAMES); - //if (hintFlagPart == HINT_PATNAMES) && (dwHintParam < pSndFile->Order.size())) imin = imax = dwHintParam; - for (ORDERINDEX iOrd = 0; iOrd < pSndFile->Order.GetSequence(nSeq).GetLengthTailTrimmed(); iOrd++) + //if (hintFlagPart == HINT_PATNAMES) && (dwHintParam < sndFile.Order.size())) imin = imax = dwHintParam; + for (ORDERINDEX iOrd = 0; iOrd < sndFile.Order.GetSequence(nSeq).GetLengthTailTrimmed(); iOrd++) { - if(patNamesOnly && pSndFile->Order.GetSequence(nSeq)[iOrd] != nPat) + if(patNamesOnly && sndFile.Order.GetSequence(nSeq)[iOrd] != nPat) continue; UINT state = (iOrd == pInfo->nOrdSel && nSeq == pInfo->nSeqSel) ? TVIS_BOLD : 0; - if (pSndFile->Order.GetSequence(nSeq)[iOrd] < pSndFile->Patterns.Size()) + if (sndFile.Order.GetSequence(nSeq)[iOrd] < sndFile.Patterns.Size()) { stmp[0] = 0; - pSndFile->Patterns[pSndFile->Order.GetSequence(nSeq)[iOrd]].GetName(stmp); + sndFile.Patterns[sndFile.Order.GetSequence(nSeq)[iOrd]].GetName(stmp); if (stmp[0]) { wsprintf(s, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_HEXDISPLAY) ? "[%02Xh] %d: %s" : "[%02d] %d: %s", - iOrd, pSndFile->Order.GetSequence(nSeq)[iOrd], stmp); + iOrd, sndFile.Order.GetSequence(nSeq)[iOrd], stmp); } else { wsprintf(s, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_HEXDISPLAY) ? "[%02Xh] Pattern %d" : "[%02d] Pattern %d", - iOrd, pSndFile->Order.GetSequence(nSeq)[iOrd]); + iOrd, sndFile.Order.GetSequence(nSeq)[iOrd]); } } else { - if(pSndFile->Order.GetSequence(nSeq)[iOrd] == pSndFile->Order.GetIgnoreIndex()) + if(sndFile.Order.GetSequence(nSeq)[iOrd] == sndFile.Order.GetIgnoreIndex()) { // +++ Item wsprintf(s, "[%02d] Skip", iOrd); @@ -873,12 +875,12 @@ if ((pInfo->hPatterns) && (hintFlagPart != HINT_INSNAMES) && (hintFlagPart != HINT_SMPNAMES)) { const PATTERNINDEX nPat = (PATTERNINDEX)(lHint >> HINT_SHIFT_PAT); - pInfo->tiPatterns.resize(pSndFile->Patterns.Size(), NULL); - PATTERNINDEX imin = 0, imax = pSndFile->Patterns.Size()-1; - if ((hintFlagPart == HINT_PATNAMES) && (nPat < pSndFile->Patterns.Size())) imin = imax = nPat; + pInfo->tiPatterns.resize(sndFile.Patterns.Size(), NULL); + PATTERNINDEX imin = 0, imax = sndFile.Patterns.Size()-1; + if ((hintFlagPart == HINT_PATNAMES) && (nPat < sndFile.Patterns.Size())) imin = imax = nPat; BOOL bDelPat = FALSE; - ASSERT(pInfo->tiPatterns.size() == pSndFile->Patterns.Size()); + ASSERT(pInfo->tiPatterns.size() == sndFile.Patterns.Size()); for(PATTERNINDEX iPat = imin; iPat <= imax; iPat++) { if ((bDelPat) && (pInfo->tiPatterns[iPat])) @@ -886,10 +888,10 @@ DeleteItem(pInfo->tiPatterns[iPat]); pInfo->tiPatterns[iPat] = NULL; } - if (pSndFile->Patterns[iPat]) + if (sndFile.Patterns[iPat]) { stmp[0] = 0; - pSndFile->Patterns[iPat].GetName(stmp); + sndFile.Patterns[iPat].GetName(stmp); if (stmp[0]) { wsprintf(s, "%d: %s", iPat, stmp); @@ -928,14 +930,14 @@ if ((hintFlagPart == HINT_SMPNAMES) && (nSmp) && (nSmp < MAX_SAMPLES)) { smin = smax = nSmp; } for(SAMPLEINDEX nSmp = smin; nSmp <= smax; nSmp++) { - if (nSmp <= pSndFile->m_nSamples) + if (nSmp <= sndFile.m_nSamples) { - const bool sampleExists = (pSndFile->GetSample(nSmp).pSample != nullptr); + const bool sampleExists = (sndFile.GetSample(nSmp).pSample != nullptr); int nImage = (sampleExists) ? IMAGE_SAMPLES : IMAGE_NOSAMPLE; if(sampleExists && pInfo->samplesPlaying[nSmp]) nImage = IMAGE_SAMPLEACTIVE; if(pInfo->pModDoc->IsSampleMuted(nSmp)) nImage = IMAGE_SAMPLEMUTE; - wsprintf(s, "%3d: %s", nSmp, pSndFile->m_szNames[nSmp]); + wsprintf(s, "%3d: %s", nSmp, sndFile.m_szNames[nSmp]); if (!pInfo->tiSamples[nSmp]) { pInfo->tiSamples[nSmp] = InsertItem(s, nImage, nImage, pInfo->hSamples, TVI_LAST); @@ -970,8 +972,8 @@ if ((hintFlagPart == HINT_INSNAMES) && (nIns) && (nIns < MAX_INSTRUMENTS)) { smin = smax = nIns; - if (((pSndFile->Instruments[smin]) && (pInfo->tiInstruments[smin] == NULL)) - || ((!pSndFile->Instruments[smin]) && (pInfo->tiInstruments[smin] != NULL))) + if (((sndFile.Instruments[smin]) && (pInfo->tiInstruments[smin] == NULL)) + || ((!sndFile.Instruments[smin]) && (pInfo->tiInstruments[smin] != NULL))) { smax = MAX_INSTRUMENTS-1; for (INSTRUMENTINDEX iRem=smin; iRem<smax; iRem++) @@ -986,17 +988,17 @@ } for (INSTRUMENTINDEX nIns = smin; nIns <= smax; nIns++) { - if ((nIns <= pSndFile->GetNumInstruments()) && (pSndFile->Instruments[nIns])) + if ((nIns <= sndFile.GetNumInstruments()) && (sndFile.Instruments[nIns])) { - if(pSndFile->m_SongFlags[SONG_ITPROJECT]) + if(sndFile.m_SongFlags[SONG_ITPROJECT]) { // path info for ITP instruments - const bool pathOk = pSndFile->m_szInstrumentPath[nIns - 1][0] != '\0'; + const bool pathOk = sndFile.m_szInstrumentPath[nIns - 1][0] != '\0'; const bool instMod = pDoc->m_bsInstrumentModified.test(nIns - 1); - wsprintf(s, pathOk ? (instMod ? "%3d: * %s" : "%3d: %s") : "%3d: ? %s", nIns, (LPCTSTR)pSndFile->GetInstrumentName(nIns)); + wsprintf(s, pathOk ? (instMod ? "%3d: * %s" : "%3d: %s") : "%3d: ? %s", nIns, (LPCTSTR)sndFile.GetInstrumentName(nIns)); } else { - wsprintf(s, "%3d: %s", nIns, (LPCTSTR)pSndFile->GetInstrumentName(nIns)); + wsprintf(s, "%3d: %s", nIns, (LPCTSTR)sndFile.GetInstrumentName(nIns)); } int nImage = IMAGE_INSTRUMENTS; @@ -1326,7 +1328,7 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if (pMainFrm) pMainFrm->PlaySoundFile(szFullPath, nParam); } - break; + return TRUE; case MODITEM_MIDIPERCUSSION: modItemID |= 0x80; @@ -1339,7 +1341,7 @@ if (pMainFrm) pMainFrm->PlaySoundFile(lpMidiLib->MidiMap[modItemID], static_cast<ModCommand::NOTE>(nParam)); } } - break; + return TRUE; default: if (modItemType & 0x8000) @@ -1361,6 +1363,7 @@ rgn = pDLSBank->GetRegionFromKey(instr, nParam - NOTE_MIN); } pMainFrm->PlayDLSInstrument(bank, instr, rgn, static_cast<ModCommand::NOTE>(nParam)); + return TRUE; } } } @@ -2207,7 +2210,7 @@ if(pInfo == nullptr) return; ORDERINDEX nNewOrd = (pNotify) ? pNotify->nOrder : ORDERINDEX_INVALID; - SEQUENCEINDEX nNewSeq = (pModDoc->GetSoundFile() != nullptr) ? pModDoc->GetSoundFile()->Order.GetCurrentSequenceIndex() : SEQUENCEINDEX_INVALID; + SEQUENCEINDEX nNewSeq = pModDoc->GetrSoundFile().Order.GetCurrentSequenceIndex(); if (nNewOrd != pInfo->nOrdSel || nNewSeq != pInfo->nSeqSel) { pInfo->nOrdSel = nNewOrd; @@ -2232,18 +2235,17 @@ if(!updateSamples && !updateInstruments) return; - CSoundFile *pSndFile = pModDoc->GetSoundFile(); - if(pSndFile == nullptr) return; + const CSoundFile &sndFile = pModDoc->GetrSoundFile(); for(CHANNELINDEX nChn = 0; nChn < MAX_CHANNELS; nChn++) { - if(pSndFile->Chn[nChn].pCurrentSample != nullptr) + if(sndFile.Chn[nChn].pCurrentSample != nullptr) { if(updateSamples) { - for(SAMPLEINDEX nSmp = pSndFile->GetNumSamples(); nSmp >= 1; nSmp--) + for(SAMPLEINDEX nSmp = sndFile.GetNumSamples(); nSmp >= 1; nSmp--) { - if(pSndFile->Chn[nChn].pModSample == &pSndFile->GetSample(nSmp)) + if(sndFile.Chn[nChn].pModSample == &sndFile.GetSample(nSmp)) { pInfo->samplesPlaying.set(nSmp); break; @@ -2252,9 +2254,9 @@ } if(updateInstruments) { - for(INSTRUMENTINDEX nIns = pSndFile->GetNumInstruments(); nIns >= 1; nIns--) + for(INSTRUMENTINDEX nIns = sndFile.GetNumInstruments(); nIns >= 1; nIns--) { - if(pSndFile->Chn[nChn].pModInstrument == pSndFile->Instruments[nIns]) + if(sndFile.Chn[nChn].pModInstrument == sndFile.Instruments[nIns]) { pInfo->instrumentsPlaying.set(nIns); break; @@ -3393,17 +3395,19 @@ LRESULT CModTree::OnCustomKeyMsg(WPARAM wParam, LPARAM /*lParam*/) //---------------------------------------------------------------- { - if (wParam == kcNull) + if(wParam == kcNull) return NULL; CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (wParam>=kcTreeViewStartNotes && wParam<=kcTreeViewEndNotes) + if(wParam >= kcTreeViewStartNotes && wParam <= kcTreeViewEndNotes) { - PlayItem(GetSelectedItem(), static_cast<ModCommand::NOTE>(wParam - kcTreeViewStartNotes + 1 + pMainFrm->GetBaseOctave() * 12)); - return wParam; + if(PlayItem(GetSelectedItem(), static_cast<ModCommand::NOTE>(wParam - kcTreeViewStartNotes + 1 + pMainFrm->GetBaseOctave() * 12))) + return wParam; + else + return NULL; } - if (wParam>=kcTreeViewStartNoteStops && wParam<=kcTreeViewEndNoteStops) + if(wParam >= kcTreeViewStartNoteStops && wParam <= kcTreeViewEndNoteStops) { return wParam; } @@ -3549,8 +3553,8 @@ if(info->item.pszText != nullptr && modDoc != nullptr) { - CSoundFile *sndFile = modDoc->GetSoundFile(); - const CModSpecifications &modSpecs = sndFile->GetModSpecifications(); + CSoundFile &sndFile = modDoc->GetrSoundFile(); + const CModSpecifications &modSpecs = sndFile.GetModSpecifications(); switch(modItemType) { @@ -3561,18 +3565,18 @@ bool valid = true; if(info->item.pszText[0] == '-') { - pat = sndFile->Order.GetInvalidPatIndex(); + pat = sndFile.Order.GetInvalidPatIndex(); } else if(info->item.pszText[0] == '+') { if(modSpecs.hasIgnoreIndex) - pat = sndFile->Order.GetIgnoreIndex(); + pat = sndFile.Order.GetIgnoreIndex(); else valid = false; } else { - valid = (pat < sndFile->Patterns.GetNumPatterns()); + valid = (pat < sndFile.Patterns.GetNumPatterns()); } - PATTERNINDEX &target = sndFile->Order.GetSequence(static_cast<SEQUENCEINDEX>(modItemID >> 16)).At(static_cast<ORDERINDEX>(modItemID & 0xFFFF)); + PATTERNINDEX &target = sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItemID >> 16)).At(static_cast<ORDERINDEX>(modItemID & 0xFFFF)); if(valid && pat != target) { target = pat; @@ -3583,36 +3587,36 @@ break; case MODITEM_SEQUENCE: - if(modItemID < sndFile->Order.GetNumSequences() && sndFile->Order.GetSequence(static_cast<SEQUENCEINDEX>(modItemID)).m_sName != info->item.pszText) + if(modItemID < sndFile.Order.GetNumSequences() && sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItemID)).m_sName != info->item.pszText) { - sndFile->Order.GetSequence(static_cast<SEQUENCEINDEX>(modItemID)).m_sName = info->item.pszText; + sndFile.Order.GetSequence(static_cast<SEQUENCEINDEX>(modItemID)).m_sName = info->item.pszText; modDoc->SetModified(); modDoc->UpdateAllViews(NULL, HINT_MODSEQUENCE, NULL); } break; case MODITEM_PATTERN: - if(modItemID < sndFile->Patterns.GetNumPatterns() && modSpecs.hasPatternNames && sndFile->Patterns[modItemID].GetName() != info->item.pszText) + if(modItemID < sndFile.Patterns.GetNumPatterns() && modSpecs.hasPatternNames && sndFile.Patterns[modItemID].GetName() != info->item.pszText) { - sndFile->Patterns[modItemID].SetName(info->item.pszText); + sndFile.Patterns[modItemID].SetName(info->item.pszText); modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_PAT) | HINT_PATTERNDATA | HINT_PATNAMES); } break; case MODITEM_SAMPLE: - if(modItemID <= sndFile->GetNumSamples() && strcmp(sndFile->m_szNames[modItemID], info->item.pszText)) + if(modItemID <= sndFile.GetNumSamples() && strcmp(sndFile.m_szNames[modItemID], info->item.pszText)) { - strncpy(sndFile->m_szNames[modItemID], info->item.pszText, modSpecs.sampleNameLengthMax); + strncpy(sndFile.m_szNames[modItemID], info->item.pszText, modSpecs.sampleNameLengthMax); modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_SMP) | HINT_SMPNAMES | HINT_SAMPLEDATA | HINT_SAMPLEINFO); } break; case MODITEM_INSTRUMENT: - if(modItemID <= sndFile->GetNumInstruments() && sndFile->Instruments[modItemID] != nullptr && strcmp(sndFile->Instruments[modItemID]->name, info->item.pszText)) + if(modItemID <= sndFile.GetNumInstruments() && sndFile.Instruments[modItemID] != nullptr && strcmp(sndFile.Instruments[modItemID]->name, info->item.pszText)) { - strncpy(sndFile->Instruments[modItemID]->name, info->item.pszText, modSpecs.instrNameLengthMax); + strncpy(sndFile.Instruments[modItemID]->name, info->item.pszText, modSpecs.instrNameLengthMax); modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (UINT(modItemID) << HINT_SHIFT_INS) | HINT_ENVELOPE | HINT_INSTRUMENT); } Modified: trunk/OpenMPT/mptrack/View_tre.h =================================================================== --- trunk/OpenMPT/mptrack/View_tre.h 2013-03-23 00:23:07 UTC (rev 1633) +++ trunk/OpenMPT/mptrack/View_tre.h 2013-03-23 01:20:05 UTC (rev 1634) @@ -28,17 +28,18 @@ struct ModTreeDocInfo { CModDoc *pModDoc; - // Module information - SEQUENCEINDEX nSeqSel; - ORDERINDEX nOrdSel; // Tree state variables + vector<vector<HTREEITEM> > tiOrders; + vector<HTREEITEM> tiSequences, tiPatterns; HTREEITEM hSong, hPatterns, hSamples, hInstruments, hComments, hOrders, hEffects; - vector<HTREEITEM> tiPatterns; HTREEITEM tiSamples[MAX_SAMPLES]; HTREEITEM tiInstruments[MAX_INSTRUMENTS]; - vector<vector<HTREEITEM> > tiOrders; - vector<HTREEITEM> tiSequences; HTREEITEM tiEffects[MAX_MIXPLUGINS]; + + // Module information + ORDERINDEX nOrdSel; + SEQUENCEINDEX nSeqSel; + bitset<MAX_SAMPLES> samplesPlaying; bitset<MAX_INSTRUMENTS> instrumentsPlaying; @@ -112,13 +113,12 @@ MODITEM_SEQUENCE, }; - CSoundFile m_SongFile; + CSoundFile &m_SongFile; // For browsing samples and instruments inside modules on disk CModTreeDropTarget m_DropTarget; - CModTree *m_pDataTree; + CModTree *m_pDataTree; // Pointer to instrument browser (lower part of tree view) - if it's a nullptr, this object is the instrument browser itself. DWORD m_dwStatus; HWND m_hDropWnd; uint64 m_qwItemDrag; - bool m_bShowAllFiles; UINT m_nDocNdx, m_nDragDocNdx; HTREEITEM m_hItemDrag, m_hItemDrop; HTREEITEM m_hInsLib, m_hMidiLib; @@ -128,10 +128,11 @@ vector<HTREEITEM> m_tiDLS; vector<ModTreeDocInfo *> DocInfo; // Instrument library + bool m_bShowAllFiles; CHAR m_szInstrLibPath[_MAX_PATH], m_szOldPath[_MAX_PATH], m_szSongName[_MAX_PATH]; public: - CModTree(CModTree *pDataTree=NULL); + CModTree(CModTree *pDataTree, CSoundFile &sf); virtual ~CModTree(); // Attributes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-23 19:22:10
|
Revision: 1649 http://sourceforge.net/p/modplug/code/1649 Author: saga-games Date: 2013-03-23 19:22:04 +0000 (Sat, 23 Mar 2013) Log Message: ----------- [Mod] Since there is just one exception handler per process (not per thread), simply logic fo the ExceptionHandler class. Modified Paths: -------------- trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/ExceptionHandler.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mptrack.cpp Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-03-23 18:50:36 UTC (rev 1648) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-03-23 19:22:04 UTC (rev 1649) @@ -17,27 +17,6 @@ #include "dbghelp.h" -LONG ExceptionHandler::UnhandledExceptionFilterMain(_EXCEPTION_POINTERS *pExceptionInfo) -//-------------------------------------------------------------------------------------- -{ - return UnhandledExceptionFilter(pExceptionInfo, "main"); -} - - -LONG ExceptionHandler::UnhandledExceptionFilterAudio(_EXCEPTION_POINTERS *pExceptionInfo) -//--------------------------------------------------------------------------------------- -{ - return UnhandledExceptionFilter(pExceptionInfo, "audio"); -} - - -LONG ExceptionHandler::UnhandledExceptionFilterNotify(_EXCEPTION_POINTERS *pExceptionInfo) -//---------------------------------------------------------------------------------------- -{ - return UnhandledExceptionFilter(pExceptionInfo, "notify"); -} - - typedef BOOL (WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, @@ -45,8 +24,8 @@ ); // Try to close the audio device and rescue unsaved work if an unhandled exception occours... -LONG ExceptionHandler::UnhandledExceptionFilter(_EXCEPTION_POINTERS *pExceptionInfo, const CString threadName) -//------------------------------------------------------------------------------------------------------------ +LONG ExceptionHandler::UnhandledExceptionFilter(_EXCEPTION_POINTERS *pExceptionInfo) +//---------------------------------------------------------------------------------- { CMainFrame* pMainFrame = CMainFrame::GetMainFrame(); @@ -63,7 +42,7 @@ } CString errorMessage; - errorMessage.Format("Unhandled exception 0x%X at address %p occoured in the %s thread.", pExceptionInfo->ExceptionRecord->ExceptionCode, pExceptionInfo->ExceptionRecord->ExceptionAddress, threadName); + errorMessage.Format("Unhandled exception 0x%X at address %p occoured.", pExceptionInfo->ExceptionRecord->ExceptionCode, pExceptionInfo->ExceptionRecord->ExceptionAddress); const CString timestampDir = (CTime::GetCurrentTime()).Format("%Y-%m-%d %H.%M.%S\\"); CString baseRescuePath; @@ -90,7 +69,7 @@ MINIDUMPWRITEDUMP pDump = (MINIDUMPWRITEDUMP)::GetProcAddress(hDll, "MiniDumpWriteDump"); if (pDump) { - const CString filename = baseRescuePath + "crash-" + threadName + ".dmp"; + const CString filename = baseRescuePath + "crash.dmp"; HANDLE hFile = ::CreateFile(filename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile != INVALID_HANDLE_VALUE) Modified: trunk/OpenMPT/mptrack/ExceptionHandler.h =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.h 2013-03-23 18:50:36 UTC (rev 1648) +++ trunk/OpenMPT/mptrack/ExceptionHandler.h 2013-03-23 19:22:04 UTC (rev 1649) @@ -16,18 +16,11 @@ { public: - // Call this in the main thread to activate unhandled exception filtering for this thread. - static void RegisterMainThread() { ::SetUnhandledExceptionFilter(UnhandledExceptionFilterMain); }; - // Call this in the audio thread to activate unhandled exception filtering for this thread. - static void RegisterAudioThread() { ::SetUnhandledExceptionFilter(UnhandledExceptionFilterAudio); }; - // Call this in the notification thread to activate unhandled exception filtering for this thread. - static void RegisterNotifyThread() { ::SetUnhandledExceptionFilter(UnhandledExceptionFilterNotify); }; + // Call this to activate unhandled exception filtering. + static void Register() { ::SetUnhandledExceptionFilter(UnhandledExceptionFilter); }; protected: - static LONG WINAPI UnhandledExceptionFilterMain(_EXCEPTION_POINTERS *pExceptionInfo); - static LONG WINAPI UnhandledExceptionFilterAudio(_EXCEPTION_POINTERS *pExceptionInfo); - static LONG WINAPI UnhandledExceptionFilterNotify(_EXCEPTION_POINTERS *pExceptionInfo); - static LONG UnhandledExceptionFilter(_EXCEPTION_POINTERS *pExceptionInfo, const CString threadName); + static LONG WINAPI UnhandledExceptionFilter(_EXCEPTION_POINTERS *pExceptionInfo); }; Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-23 18:50:36 UTC (rev 1648) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-23 19:22:04 UTC (rev 1649) @@ -698,8 +698,6 @@ BOOL bWait; UINT nSleep; - ExceptionHandler::RegisterAudioThread(); - // -> CODE#0021 // -> DESC="use multimedia timer instead of Sleep() in audio thread" HANDLE sleepEvent = CreateEvent(NULL,TRUE,FALSE,NULL); @@ -778,8 +776,6 @@ { CMainFrame *pMainFrm; - ExceptionHandler::RegisterNotifyThread(); - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_BELOW_NORMAL); for (;;) { Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-03-23 18:50:36 UTC (rev 1648) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-03-23 19:22:04 UTC (rev 1649) @@ -644,7 +644,7 @@ _CrtSetDebugFillThreshold(0); // Disable buffer filling in secure enhanced CRT functions. #endif - ExceptionHandler::RegisterMainThread(); + ExceptionHandler::Register(); m_bPortableMode = false; m_pModTemplate = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-03-24 00:20:00
|
Revision: 1660 http://sourceforge.net/p/modplug/code/1660 Author: saga-games Date: 2013-03-24 00:19:53 +0000 (Sun, 24 Mar 2013) Log Message: ----------- [Mod] Create instrument-inside-module previewing object only on demand. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainbar.cpp trunk/OpenMPT/mptrack/Mainbar.h trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-23 22:46:24 UTC (rev 1659) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-24 00:19:53 UTC (rev 1660) @@ -203,8 +203,8 @@ ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction //#include <direct.h> -CMainFrame::CMainFrame() : m_wndTree(m_TreeBrowseFile) -//---------------------------------------------------- +CMainFrame::CMainFrame() +//---------------------- { m_bModTreeHasFocus = false; //rewbs.customKeys m_pNoteMapHasFocus = nullptr; //rewbs.customKeys Modified: trunk/OpenMPT/mptrack/Mainbar.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.cpp 2013-03-23 22:46:24 UTC (rev 1659) +++ trunk/OpenMPT/mptrack/Mainbar.cpp 2013-03-24 00:19:53 UTC (rev 1660) @@ -606,8 +606,8 @@ END_MESSAGE_MAP() -CModTreeBar::CModTreeBar(CSoundFile &sf) : m_TreeBrowseFile(sf) -//------------------------------------------------------------- +CModTreeBar::CModTreeBar() +//------------------------ { m_pModTree = m_pModTreeData = NULL; m_nTreeSplitRatio = TrackerSettings::Instance().glTreeSplitRatio; @@ -618,9 +618,9 @@ //------------------------------------------------------------- { LRESULT l = CDialogBar::HandleInitDialog(wParam, lParam); - m_pModTreeData = new CModTree(nullptr, m_TreeBrowseFile); + m_pModTreeData = new CModTree(nullptr); if (m_pModTreeData) m_pModTreeData->SubclassDlgItem(IDC_TREEDATA, this); - m_pModTree = new CModTree(m_pModTreeData, m_TreeBrowseFile); + m_pModTree = new CModTree(m_pModTreeData); if (m_pModTree) m_pModTree->SubclassDlgItem(IDC_TREEVIEW, this); m_dwStatus = 0; m_sizeDefault.cx = TrackerSettings::Instance().glTreeWindowWidth + 3; Modified: trunk/OpenMPT/mptrack/Mainbar.h =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.h 2013-03-23 22:46:24 UTC (rev 1659) +++ trunk/OpenMPT/mptrack/Mainbar.h 2013-03-24 00:19:53 UTC (rev 1660) @@ -90,7 +90,6 @@ //================================== { protected: - CSoundFile &m_TreeBrowseFile; DWORD m_dwStatus; // MTB_XXXX UINT m_nCursorDrag; CPoint ptDragging; @@ -100,7 +99,7 @@ public: CModTree *m_pModTree, *m_pModTreeData; - CModTreeBar(CSoundFile &sf); + CModTreeBar(); virtual ~CModTreeBar(); public: Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-23 22:46:24 UTC (rev 1659) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-24 00:19:53 UTC (rev 1660) @@ -341,7 +341,7 @@ protected: - CSoundFile m_WaveFile, m_TreeBrowseFile; + CSoundFile m_WaveFile; CModTreeBar m_wndTree; CStatusBar m_wndStatusBar; CMainToolBar m_wndToolBar; Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-23 22:46:24 UTC (rev 1659) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-03-24 00:19:53 UTC (rev 1660) @@ -19,6 +19,8 @@ #include "vstplug.h" +CSoundFile *CModTree::m_SongFile = nullptr; + ///////////////////////////////////////////////////////////////////////////// // CModTreeDropTarget @@ -108,8 +110,8 @@ ///////////////////////////////////////////////////////////////////////////// // CViewModTree construction/destruction -CModTree::CModTree(CModTree *pDataTree, CSoundFile &sf) : m_SongFile(sf) -//---------------------------------------------------------------------- +CModTree::CModTree(CModTree *pDataTree) +//------------------------------------- { m_pDataTree = pDataTree; m_dwStatus = 0; @@ -250,6 +252,7 @@ strcpy(m_szInstrLibPath, pszLibPath); if ((pszSongName[0]) && (_stricmp(m_szSongName, pszSongName))) { + // Load module for previewing its instruments CMappedFile f; SetCurrentDirectory(m_szInstrLibPath); @@ -261,8 +264,20 @@ LPBYTE lpStream = f.Lock(); if (lpStream) { - m_SongFile.Destroy(); - m_SongFile.Create(lpStream, NULL, dwLen); + if(m_SongFile != nullptr) + { + m_SongFile->Destroy(); + } else + { + m_SongFile = new (std::nothrow) CSoundFile; + } + if(m_SongFile != nullptr) + { + m_SongFile->Create(lpStream, NULL, dwLen); + // Destroy some stuff that we're not going to use anyway. + m_SongFile->Patterns.DestroyPatterns(); + m_SongFile->FreeMessage(); + } f.Unlock(); } } @@ -1310,14 +1325,14 @@ lstrcpyn(szName, GetItemText(hItem), sizeof(szName)); const size_t n = ConvertStrTo<size_t>(szName); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (pMainFrm) + if (pMainFrm && m_SongFile) { if (modItemType == MODITEM_INSLIB_INSTRUMENT) { - pMainFrm->PlaySoundFile(&m_SongFile, static_cast<INSTRUMENTINDEX>(n), SAMPLEINDEX_INVALID, nParam); + pMainFrm->PlaySoundFile(m_SongFile, static_cast<INSTRUMENTINDEX>(n), SAMPLEINDEX_INVALID, nParam); } else { - pMainFrm->PlaySoundFile(&m_SongFile, INSTRUMENTINDEX_INVALID, static_cast<SAMPLEINDEX>(n), nParam); + pMainFrm->PlaySoundFile(m_SongFile, INSTRUMENTINDEX_INVALID, static_cast<SAMPLEINDEX>(n), nParam); } } } else @@ -1594,15 +1609,15 @@ if (!m_hInsLib) return; SetRedraw(FALSE); - if ((m_szSongName[0]) && (!m_pDataTree)) + if(m_szSongName[0] && !m_pDataTree && m_SongFile) { wsprintf(s, "%s", m_szSongName); SetItemText(m_hInsLib, s); SetItemImage(m_hInsLib, IMAGE_FOLDERSONG, IMAGE_FOLDERSONG); - for (UINT iIns=1; iIns<=m_SongFile.m_nInstruments; iIns++) + for(INSTRUMENTINDEX iIns = 1; iIns <= m_SongFile->GetNumInstruments(); iIns++) { - ModInstrument *pIns = m_SongFile.Instruments[iIns]; - if (pIns) + ModInstrument *pIns = m_SongFile->Instruments[iIns]; + if(pIns) { lstrcpyn(szPath, pIns->name, 32); wsprintf(s, "%3d: %s", iIns, szPath); @@ -1610,10 +1625,10 @@ InsertItem(&tvis); } } - for(SAMPLEINDEX iSmp = 1; iSmp <= m_SongFile.GetNumSamples(); iSmp++) + for(SAMPLEINDEX iSmp = 1; iSmp <= m_SongFile->GetNumSamples(); iSmp++) { - const ModSample &sample = m_SongFile.GetSample(iSmp); - lstrcpyn(szPath, m_SongFile.m_szNames[iSmp], 32); + const ModSample &sample = m_SongFile->GetSample(iSmp); + lstrcpyn(szPath, m_SongFile->m_szNames[iSmp], 32); if (sample.pSample) { wsprintf(s, "%3d: %s", iSmp, szPath); @@ -1924,10 +1939,11 @@ bOk = TRUE; } else { - if (SetCurrentDirectory(lpszDir)) + if(SetCurrentDirectory(lpszDir)) { m_szSongName[0] = 0; - if (m_SongFile.GetType() != MOD_TYPE_NONE) m_SongFile.Destroy(); + delete m_SongFile; + m_SongFile = nullptr; GetCurrentDirectory(sizeof(m_szInstrLibPath), m_szInstrLibPath); PostMessage(WM_COMMAND, ID_MODTREE_REFRESHINSTRLIB); bOk = TRUE; @@ -1988,7 +2004,7 @@ pdropinfo->dwDropType = ((m_qwItemDrag & 0xFFFF) == MODITEM_INSLIB_SAMPLE) ? DRAGONDROP_SAMPLE : DRAGONDROP_INSTRUMENT; pdropinfo->dwDropItem = n; pdropinfo->pModDoc = nullptr; - pdropinfo->lDropParam = (LPARAM)&m_SongFile; + pdropinfo->lDropParam = (LPARAM)m_SongFile; } else { InsLibGetFullPath(m_hItemDrag, pszFullPath); Modified: trunk/OpenMPT/mptrack/View_tre.h =================================================================== --- trunk/OpenMPT/mptrack/View_tre.h 2013-03-23 22:46:24 UTC (rev 1659) +++ trunk/OpenMPT/mptrack/View_tre.h 2013-03-24 00:19:53 UTC (rev 1660) @@ -113,7 +113,7 @@ MODITEM_SEQUENCE, }; - CSoundFile &m_SongFile; // For browsing samples and instruments inside modules on disk + static CSoundFile *m_SongFile; // For browsing samples and instruments inside modules on disk CModTreeDropTarget m_DropTarget; CModTree *m_pDataTree; // Pointer to instrument browser (lower part of tree view) - if it's a nullptr, this object is the instrument browser itself. DWORD m_dwStatus; @@ -132,7 +132,7 @@ CHAR m_szInstrLibPath[_MAX_PATH], m_szOldPath[_MAX_PATH], m_szSongName[_MAX_PATH]; public: - CModTree(CModTree *pDataTree, CSoundFile &sf); + CModTree(CModTree *pDataTree); virtual ~CModTree(); // Attributes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-03-25 13:47:33
|
Revision: 1665 http://sourceforge.net/p/modplug/code/1665 Author: manxorist Date: 2013-03-25 13:47:27 +0000 (Mon, 25 Mar 2013) Log Message: ----------- [Var] Add soundlib/snd_rvb.h to VS2010 project. Modified Paths: -------------- trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-24 19:47:18 UTC (rev 1664) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2013-03-25 13:47:27 UTC (rev 1665) @@ -420,6 +420,7 @@ <ClInclude Include="..\soundlib\RowVisitor.h" /> <ClInclude Include="..\soundlib\SampleFormatConverters.h" /> <ClInclude Include="..\soundlib\SampleIO.h" /> + <ClInclude Include="..\soundlib\snd_rvb.h" /> <ClInclude Include="..\soundlib\WAVTools.h" /> <ClInclude Include="..\soundlib\XMTools.h" /> <ClInclude Include="ACMConvert.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-24 19:47:18 UTC (rev 1664) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2013-03-25 13:47:27 UTC (rev 1665) @@ -759,6 +759,9 @@ <ClInclude Include="..\soundlib\ITCompression.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="..\soundlib\snd_rvb.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="res\bitmap1.bmp"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-03 22:12:46
|
Revision: 1722 http://sourceforge.net/p/modplug/code/1722 Author: saga-games Date: 2013-04-03 22:12:35 +0000 (Wed, 03 Apr 2013) Log Message: ----------- [Fix] Pre-Amp slider in soundcard options was upside down. [Mod] Updated credits Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-03 22:12:01 UTC (rev 1721) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-03 22:12:35 UTC (rev 1722) @@ -121,7 +121,7 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); BOOL bAsio = FALSE; CHAR s[128]; - + CPropertyPage::OnInitDialog(); if (m_dwSoundSetup & SOUNDSETUP_SOFTPANNING) CheckDlgButton(IDC_CHECK2, MF_CHECKED); if (m_dwSoundSetup & SOUNDSETUP_ENABLEMMX) CheckDlgButton(IDC_CHECK3, MF_CHECKED); @@ -282,7 +282,7 @@ { if(m_PreAmpNoteShowed == true) { - int n = 40 - m_SliderPreAmp.GetPos(); + int n = m_SliderPreAmp.GetPos(); if ((n >= 0) && (n <= 40)) // approximately +/- 10dB { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); @@ -306,7 +306,7 @@ CSoundFile::m_nStereoSeparation = 32 << m_SliderStereoSep.GetPos(); wsprintf(s, "%d%%", (CSoundFile::m_nStereoSeparation * 100) / 128); SetDlgItemText(IDC_TEXT1, s); - + } @@ -315,7 +315,7 @@ { int n = (TrackerSettings::Instance().m_nPreAmp - 64) / 8; if ((n < 0) || (n > 40)) n = 16; - m_SliderPreAmp.SetPos(40 - n); + m_SliderPreAmp.SetPos(n); } @@ -538,7 +538,7 @@ //--------------------------------- { DWORD dwQuality; - + CPropertyPage::OnInitDialog(); dwQuality = TrackerSettings::Instance().m_dwQuality; // Resampling type @@ -712,12 +712,12 @@ m_CEditWFIRCutoff.EnableWindow(TRUE); wsprintf(s, "%d", static_cast<int>((TrackerSettings::Instance().m_MixerSettings.gdWFIRCutoff*100))); break; - default: + default: m_CbnWFIRType.AddString("None"); m_CEditWFIRCutoff.EnableWindow(FALSE); m_CbnWFIRType.EnableWindow(FALSE); } - + m_CEditWFIRCutoff.SetWindowText(s); OnSettingsChanged(); } @@ -732,7 +732,7 @@ m_CEditWFIRCutoff.SetWindowText("97"); m_CEditRampUp.SetWindowText("16"); m_CEditRampDown.SetWindowText("42"); - + } extern void SndMixInitializeTables(const MixerSettings & mixersettings); @@ -1102,7 +1102,7 @@ //----------------------------- { CMainFrame::m_nLastOptionsPage = OPTIONS_PAGE_EQ; - SetDlgItemText(IDC_EQ_WARNING, + SetDlgItemText(IDC_EQ_WARNING, "Note: This EQ, when enabled from Player tab, is applied to " "any and all of the modules " "that you load in OpenMPT; its settings are stored globally, " @@ -1142,8 +1142,8 @@ DDX_Control(pDX, IDC_COMBO2, m_ATBehaviour); //}}AFX_DATA_MAP } - + BOOL CMidiSetupDlg::OnInitDialog() //-------------------------------- { @@ -1225,7 +1225,7 @@ if (IsDlgButtonChecked(IDC_MIDIVOL_TO_NOTEVOL)) m_dwMidiSetup |= MIDISETUP_MIDIVOL_TO_NOTEVOL; if (IsDlgButtonChecked(IDC_MIDIPLAYCONTROL)) m_dwMidiSetup |= MIDISETUP_RESPONDTOPLAYCONTROLMSGS; if (IsDlgButtonChecked(IDC_MIDIPLAYPATTERNONMIDIIN)) m_dwMidiSetup |= MIDISETUP_PLAYPATTERNONMIDIIN; - + if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) { int n = combo->GetCurSel(); @@ -1248,4 +1248,3 @@ CMainFrame::m_nLastOptionsPage = OPTIONS_PAGE_MIDI; return CPropertyPage::OnSetActive(); } - Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-04-03 22:12:01 UTC (rev 1721) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-04-03 22:12:35 UTC (rev 1722) @@ -57,7 +57,7 @@ public: CModDocTemplate(UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass): CMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass) {} - + #if (_MSC_VER < MSVC_VER_2010) virtual CDocument* OpenDocumentFile(LPCTSTR path, BOOL makeVisible = TRUE); #else @@ -88,7 +88,7 @@ } #if (_MSC_VER < MSVC_VER_2010) - CDocument *pDoc = CMultiDocTemplate::OpenDocumentFile(path, makeVisible); + CDocument *pDoc = CMultiDocTemplate::OpenDocumentFile(path, makeVisible); #else CDocument *pDoc = CMultiDocTemplate::OpenDocumentFile(path, addToMru, makeVisible); #endif @@ -108,7 +108,7 @@ Reporting::Error(str); } else //Case: Valid path but opening fails. - { + { const int nOdc = theApp.GetOpenDocumentCount(); CString str; str.Format(GetStrI18N(_TEXT("Opening \"%s\" failed. This can happen if " @@ -298,9 +298,9 @@ public: CMPTCommandLineInfo() - { - m_bNoAcm = m_bNoDls = m_bNoMp3 = m_bSafeMode = m_bWavEx = - m_bNoPlugins = m_bDebug = m_bNoSettingsOnNewVersion = m_bPortable = false; + { + m_bNoAcm = m_bNoDls = m_bNoMp3 = m_bSafeMode = m_bWavEx = + m_bNoPlugins = m_bDebug = m_bNoSettingsOnNewVersion = m_bPortable = false; } virtual void ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast); }; @@ -334,7 +334,7 @@ //------------------------------------------------------------------- { TCHAR szFileName[_MAX_PATH], s[_MAX_PATH], szUltraSndPath[_MAX_PATH]; - + if ((!lpszConfigFile) || (!lpszConfigFile[0])) return FALSE; if (!glpMidiLibrary) { @@ -427,7 +427,7 @@ //----------------------------------------------------- { TCHAR szFileName[_MAX_PATH], s[128]; - + if ((!glpMidiLibrary) || (!lpszConfigFile) || (!lpszConfigFile[0])) return FALSE; for(size_t iMidi = 0; iMidi < 256; iMidi++) if (glpMidiLibrary->MidiMap[iMidi]) { @@ -548,10 +548,10 @@ DWORD nBanks = 0; for(size_t i = 0; i < gpDLSBanks.size(); i++) { - + if(!gpDLSBanks[i] || !gpDLSBanks[i]->GetFileName() || !gpDLSBanks[i]->GetFileName()[0]) continue; - + _tcsncpy(szPath, gpDLSBanks[i]->GetFileName(), CountOf(szPath) - 1); if(theApp.IsPortableMode()) { @@ -621,7 +621,7 @@ ON_COMMAND(ID_FILE_NEWIT, OnFileNewIT) // -> CODE#0023 // -> DESC="IT project files (.itp)" - ON_COMMAND(ID_NEW_ITPROJECT,OnFileNewITProject) + ON_COMMAND(ID_NEW_ITPROJECT,OnFileNewITProject) // -! NEW_FEATURE#0023 ON_COMMAND(ID_NEW_MPT, OnFileNewMPT) ON_COMMAND(ID_FILE_OPEN, OnFileOpen) @@ -772,7 +772,7 @@ { strcpy(m_szConfigDirectory, m_szExePath); } - + // Create tunings dir CString sTuningPath; sTuningPath.Format(TEXT("%stunings\\"), m_szConfigDirectory); @@ -798,9 +798,9 @@ WIN32_FIND_DATA FindFileData; HANDLE hFind; hFind = FindFirstFile(sSearchPattern, &FindFileData); - if(hFind != INVALID_HANDLE_VALUE) + if(hFind != INVALID_HANDLE_VALUE) { - do + do { MoveConfigFile(FindFileData.cFileName, "tunings\\"); } while(FindNextFile(hFind, &FindFileData) != 0); @@ -875,7 +875,7 @@ { free((void *)m_pszProfileName); } - m_pszProfileName = _tcsdup(m_szConfigFileName); + m_pszProfileName = _tcsdup(m_szConfigFileName); int mruListLength = GetPrivateProfileInt("Misc", "MRUListLength", 10, m_pszProfileName); Limit(mruListLength, 0, 15); @@ -1252,7 +1252,7 @@ protected: afx_msg void OnPaint(); afx_msg BOOL OnEraseBkgnd(CDC *) { return TRUE; } - afx_msg void OnLButtonDblClk(UINT, CPoint) { m_dwStartTime = timeGetTime(); } + afx_msg void OnLButtonDblClk(UINT, CPoint) { m_dwStartTime = timeGetTime(); } DECLARE_MESSAGE_MAP() }; @@ -1431,7 +1431,7 @@ #define PI 3.14159265358979323f BOOL CPaletteBitmap::Animate() //---------------------------- -{ +{ //included random hacking by rewbs to get funny animation. LPBYTE dest, src; DWORD t = (timeGetTime() - m_dwStartTime) / 10; @@ -1447,7 +1447,7 @@ dir = ((t/256) % 2 != 0); //change dir every 256 t t = t%256; if (!dir) t = (256-t); - + sizex = m_nRotoWidth; sizey = m_nRotoHeight; m_dwFrameTime = t; @@ -1459,8 +1459,8 @@ spdy = 0; spdx =(Cosinus(Phi)+Sinus(Phi<<2))*(Dist<<9)/sizex; spdy =(Sinus(Phi)+Cosinus(Phi>>2))*(Dist<<9)/sizey; - srcx = 0x800000 - ((spdx * sizex) >> 1) + (spdy * sizey); - srcy = 0x800000 - ((spdy * sizex) >> 1) + (spdx * sizey); + srcx = 0x800000 - ((spdx * sizex) >> 1) + (spdy * sizey); + srcy = 0x800000 - ((spdy * sizex) >> 1) + (spdx * sizey); for (UINT y=sizey; y; y--) { UINT oldx = srcx, oldy = srcy; @@ -1538,11 +1538,10 @@ BOOL CAboutDlg::OnInitDialog() //---------------------------- { - CHAR s[256]; + const char * const s = "Build Date: " __DATE__ " " __TIME__; CDialog::OnInitDialog(); m_bmp.SubclassDlgItem(IDC_BITMAP1, this); m_bmp.LoadBitmap(MAKEINTRESOURCE(IDB_MPTRACK)); - wsprintf(s, "Build Date: %s", gszBuildDate); SetDlgItemText(IDC_EDIT2, s); SetDlgItemText(IDC_EDIT3, CString("OpenMPT ") + MptVersion::str #if (MPT_VERSION_NUMERIC & 0xFF) != 0 @@ -1557,14 +1556,15 @@ "http://openmpt.org/download"); static const char* const pArrCredit = - { + { "OpenMPT / ModPlug Tracker|" "Copyright \xA9 2004-2013 Contributors|" "Copyright \xA9 1997-2003 Olivier Lapicque|" "|" "Contributors:|" "Johannes Schultz (2008-2013)|" - "Ahti Lepp\xE4nen (2005-2011)|" + "Ahti Lepp\xE4nen (2005-2011, 2013)|" + "Joern Heusipp (2012-2013)|" "Robin Fernandes (2004-2007)|" "Sergiy Pylypenko (2007)|" "Eric Chavanon (2004-2005)|" @@ -1591,6 +1591,8 @@ "https://github.com/iamgreaser/it2everything/|" "Jean-loup Gailly and Mark Adler for zlib|" "http://zlib.net/|" + "PortAudio|" + "http://www.portaudio.com/|" "Josh Coalson for libFLAC|" "http://flac.sourceforge.net/|" "The mpg123 project for libmpg123|" @@ -1677,7 +1679,7 @@ { CRect rect; int cx, cy, newcx, newcy; - + CDialog::OnInitDialog(); m_Bmp.SubclassDlgItem(IDC_SPLASH, this); m_Bmp.LoadBitmap(MAKEINTRESOURCE(IDB_SPLASHNOFOLDFIN)); @@ -1893,7 +1895,7 @@ //////////////////////////////////////////////////////////////////////////////// // CFastBitmap 8-bit output / 4-bit input -// useful for lots of small blits with color mapping +// useful for lots of small blits with color mapping // combined in one big blit void CFastBitmap::Init(LPMODPLUGDIB lpTextDib) @@ -1989,7 +1991,7 @@ BYTE *pdest; UINT x1, x2; int srcwidth, srcinc; - + m_n4BitPalette[0] = (BYTE)m_nTextColor; m_n4BitPalette[15] = (BYTE)m_nBkColor; if (x < 0) @@ -2117,6 +2119,7 @@ } CloseHandle(hmf); } + // Fallback if (dwLen > CTrackApp::gMemStatus.dwTotalPhys) return NULL; if ((lpStream = (LPBYTE)GlobalAllocPtr(GHND, dwLen)) == NULL) return NULL; m_File.Read(lpStream, dwLen); @@ -2379,12 +2382,12 @@ // Do it! CMainFrame::GetInputHandler()->Bypass(true); - if(dlg.DoModal() != IDOK) + bool doCancel = dlg.DoModal() != IDOK; + CMainFrame::GetInputHandler()->Bypass(false); + if(doCancel) { - CMainFrame::GetInputHandler()->Bypass(false); return result; } - CMainFrame::GetInputHandler()->Bypass(false); // Retrieve variables if(filterIndex != nullptr) @@ -2497,4 +2500,4 @@ { if (m_pRecentFileList && nItem >= 0 && nItem < m_pRecentFileList->GetSize()) m_pRecentFileList->Remove(nItem); -} +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-05 22:45:42
|
Revision: 1742 http://sourceforge.net/p/modplug/code/1742 Author: saga-games Date: 2013-04-05 22:45:30 +0000 (Fri, 05 Apr 2013) Log Message: ----------- [Fix] Tree view: Lowercase letters can now be entered properly into name fields as well. Modified Paths: -------------- trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/View_tre.h Modified: trunk/OpenMPT/mptrack/View_tre.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_tre.cpp 2013-04-05 17:41:18 UTC (rev 1741) +++ trunk/OpenMPT/mptrack/View_tre.cpp 2013-04-05 22:45:30 UTC (rev 1742) @@ -123,6 +123,7 @@ m_hDropWnd = NULL; m_hInsLib = m_hMidiLib = NULL; m_nDocNdx = m_nDragDocNdx = 0; + doLabelEdit = false; MemsetZero(m_tiMidiGrp); MemsetZero(m_tiMidi); MemsetZero(m_tiPerc); @@ -229,7 +230,7 @@ KeyEventType kT = ih->GetKeyEventType(nFlags); InputTargetContext ctx = (InputTargetContext)(kCtxViewTree); - if (ih->KeyEvent(ctx, nChar, nRepCnt, nFlags, kT) != kcNull) + if (!doLabelEdit && ih->KeyEvent(ctx, nChar, nRepCnt, nFlags, kT) != kcNull) return true; // Mapped to a command, no need to pass message on. } //end rewbs.customKeys @@ -1048,7 +1049,7 @@ uint64 CModTree::GetModItem(HTREEITEM hItem) -//----------------------------------------- +//------------------------------------------ { LPARAM lParam; HTREEITEM hItemParent, hItemParentParent, hRootParent; @@ -3205,7 +3206,7 @@ pSndFile->m_szInstrumentPath[modItemID - 1] = files.first_file; } - pModDoc->SaveInstrument(modItemID); + pModDoc->SaveInstrument(static_cast<INSTRUMENTINDEX>(modItemID)); if(pModDoc) pModDoc->UpdateAllViews(NULL, HINT_MODTYPE); OnRefreshTree(); @@ -3534,6 +3535,7 @@ if(text) { + doLabelEdit = true; CMainFrame::GetMainFrame()->GetInputHandler()->Bypass(true); editCtrl->SetWindowText(text); *result = FALSE; @@ -3549,6 +3551,7 @@ //---------------------------------------------------------- { CMainFrame::GetMainFrame()->GetInputHandler()->Bypass(false); + doLabelEdit = false; NMTVDISPINFO *info = reinterpret_cast<NMTVDISPINFO *>(nmhdr); const uint64 modItem = GetModItem(info->item.hItem); Modified: trunk/OpenMPT/mptrack/View_tre.h =================================================================== --- trunk/OpenMPT/mptrack/View_tre.h 2013-04-05 17:41:18 UTC (rev 1741) +++ trunk/OpenMPT/mptrack/View_tre.h 2013-04-05 22:45:30 UTC (rev 1742) @@ -128,7 +128,7 @@ vector<HTREEITEM> m_tiDLS; vector<ModTreeDocInfo *> DocInfo; // Instrument library - bool m_bShowAllFiles; + bool m_bShowAllFiles, doLabelEdit; CHAR m_szInstrLibPath[_MAX_PATH], m_szOldPath[_MAX_PATH], m_szSongName[_MAX_PATH]; public: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-06 18:34:26
|
Revision: 1755 http://sourceforge.net/p/modplug/code/1755 Author: manxorist Date: 2013-04-06 18:34:18 +0000 (Sat, 06 Apr 2013) Log Message: ----------- [Ref] Add CModDoc::SetNotifications and remove the current notification flags from CMainFrame. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-06 18:22:02 UTC (rev 1754) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-06 18:34:18 UTC (rev 1755) @@ -145,8 +145,9 @@ //--------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - if (m_pModDoc) m_pModDoc->SetFollowWnd(m_hWnd, Notification::Default); - if (pMainFrm) pMainFrm->SetFollowSong(m_pModDoc, m_hWnd, TRUE, Notification::Default); + if (m_pModDoc) m_pModDoc->SetNotifications(Notification::Default); + if (m_pModDoc) m_pModDoc->SetFollowWnd(m_hWnd); + if (pMainFrm) pMainFrm->SetFollowSong(m_pModDoc, m_hWnd, TRUE); PostViewMessage(VIEWMSG_SETACTIVE, NULL); SetFocus(); @@ -158,7 +159,8 @@ void CCtrlGeneral::OnDeactivatePage() //----------------------------------- { - if (m_pModDoc) m_pModDoc->SetFollowWnd(NULL, Notification::None); + if (m_pModDoc) m_pModDoc->SetNotifications(Notification::None); + if (m_pModDoc) m_pModDoc->SetFollowWnd(NULL); m_VuMeterLeft.SetVuMeter(0); m_VuMeterRight.SetVuMeter(0); } Modified: trunk/OpenMPT/mptrack/Globals.cpp =================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp 2013-04-06 18:22:02 UTC (rev 1754) +++ trunk/OpenMPT/mptrack/Globals.cpp 2013-04-06 18:34:18 UTC (rev 1755) @@ -641,8 +641,9 @@ { if (pMainFrm->GetFollowSong(pModDoc) == m_hWnd) { + pModDoc->SetNotifications(Notification::None); pMainFrm->SetFollowSong(pModDoc, NULL, FALSE); - pModDoc->SetFollowWnd(NULL, Notification::None); + pModDoc->SetFollowWnd(NULL); } if (pMainFrm->GetMidiRecordWnd() == m_hWnd) { Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-06 18:22:02 UTC (rev 1754) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-06 18:34:18 UTC (rev 1755) @@ -196,7 +196,6 @@ m_hWndMidi = NULL; m_pSndFile = nullptr; m_dwTimeSec = 0; - m_notifyItem = 0; m_nTimer = 0; m_nAvgMixChn = m_nMixChn = 0; m_szUserText[0] = 0; @@ -959,9 +958,18 @@ } } if(!m_pSndFile) return FALSE; + FlagSet<Notification::Type,uint16> notifyType; + notifyType = Notification::None; + Notification::Item notifyItem = 0; + + if(m_pSndFile->m_pModDoc) + { + notifyType = m_pSndFile->m_pModDoc->GetNotificationType(); + notifyItem = m_pSndFile->m_pModDoc->GetNotificationItem(); + } if(m_nMixChn < m_pSndFile->m_nMixStat) m_nMixChn++; if(m_nMixChn > m_pSndFile->m_nMixStat) m_nMixChn--; - if(m_notifyType == Notification::None) return FALSE; + if(notifyType == Notification::None) return FALSE; // Notify Client //if(m_NotifyBuffer.read_size() > 0) { @@ -972,8 +980,8 @@ Notification notification; Notification *p = ¬ification; - p->type = m_notifyType; - p->item = m_notifyItem; + p->type = notifyType; + p->item = notifyItem; if(endOfStream) p->type.set(Notification::EOS); p->timestampSamples = notificationtimestamp; @@ -982,10 +990,10 @@ p->order = m_pSndFile->m_nCurrentOrder; p->pattern = m_pSndFile->m_nPattern; - if(m_notifyType[Notification::Sample]) + if(notifyType[Notification::Sample]) { // Sample positions - SAMPLEINDEX smp = m_notifyItem; + SAMPLEINDEX smp = notifyItem; for(CHANNELINDEX k = 0; k < MAX_CHANNELS; k++) { const ModChannel &chn = m_pSndFile->Chn[k]; @@ -999,10 +1007,10 @@ p->pos[k] = Notification::PosInvalid; } } - } else if(m_notifyType[Notification::VolEnv | Notification::PanEnv | Notification::PitchEnv]) + } else if(notifyType[Notification::VolEnv | Notification::PanEnv | Notification::PitchEnv]) { // Instrument envelopes - INSTRUMENTINDEX ins = m_notifyItem; + INSTRUMENTINDEX ins = notifyItem; for(CHANNELINDEX k = 0; k < MAX_CHANNELS; k++) { const ModChannel &chn = m_pSndFile->Chn[k]; @@ -1012,9 +1020,9 @@ && (!chn.dwFlags[CHN_NOTEFADE] || chn.nFadeOutVol)) // And it hasn't completely faded out yet, so it's still playing { enmEnvelopeTypes notifyEnv = ENV_VOLUME; - if(m_notifyType[Notification::PitchEnv]) + if(notifyType[Notification::PitchEnv]) notifyEnv = ENV_PITCH; - else if(m_notifyType[Notification::PanEnv]) + else if(notifyType[Notification::PanEnv]) notifyEnv = ENV_PANNING; const ModChannel::EnvInfo &chnEnv = chn.GetEnvelope(notifyEnv); @@ -1036,7 +1044,7 @@ p->pos[k] = Notification::PosInvalid; } } - } else if(m_notifyType[Notification::VUMeters]) + } else if(notifyType[Notification::VUMeters]) { // Pattern channel VU meters for(CHANNELINDEX k = 0; k < m_pSndFile->GetNumChannels(); k++) @@ -1368,18 +1376,16 @@ } -void CMainFrame::SetPlaybackSoundFile(CSoundFile *pSndFile, HWND hPat, Notification::Type notifyType, Notification::Item notifyItem) -//---------------------------------------------------------------------------------------------------------------------------------- +void CMainFrame::SetPlaybackSoundFile(CSoundFile *pSndFile, HWND hPat) +//-------------------------------------------------------------------- { m_pSndFile = pSndFile; m_hFollowSong = hPat; - m_notifyType = notifyType; - m_notifyItem = notifyItem; } -bool CMainFrame::PlayMod(CModDoc *pModDoc, HWND hPat, Notification::Type notifyType, Notification::Item notifyItem) -//----------------------------------------------------------------------------------------------------------------- +bool CMainFrame::PlayMod(CModDoc *pModDoc, HWND hPat) +//--------------------------------------------------- { CriticalSection::AssertUnlocked(); if(!pModDoc) return false; @@ -1398,7 +1404,7 @@ // set mixing parameters in CSoundFile ApplyTrackerSettings(pSndFile); - SetPlaybackSoundFile(pSndFile, hPat, notifyType, notifyItem); + SetPlaybackSoundFile(pSndFile, hPat); const bool bPaused = m_pSndFile->IsPaused(); const bool bPatLoop = m_pSndFile->m_SongFlags[SONG_PATTERNLOOP]; @@ -1699,8 +1705,8 @@ } -BOOL CMainFrame::SetFollowSong(CModDoc *pDoc, HWND hwnd, BOOL bFollowSong, Notification::Type type, Notification::Item item) -//-------------------------------------------------------------------------------------------------------------------------- +BOOL CMainFrame::SetFollowSong(CModDoc *pDoc, HWND hwnd, BOOL bFollowSong) +//------------------------------------------------------------------------ { if((!pDoc) || (pDoc != GetModPlaying())) return FALSE; if(bFollowSong) @@ -1710,11 +1716,6 @@ { if(hwnd == m_hFollowSong) m_hFollowSong = NULL; } - if(type != Notification::None) - { - m_notifyType = type; - m_notifyItem = item; - } return TRUE; } @@ -1745,7 +1746,7 @@ CriticalSection cs; UpdateAudioParameters(FALSE); } - if (pActiveMod) PlayMod(pActiveMod, hFollow, m_notifyType); + if (pActiveMod) PlayMod(pActiveMod, hFollow); UpdateWindow(); } else { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-06 18:22:02 UTC (rev 1754) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-06 18:34:18 UTC (rev 1755) @@ -315,9 +315,6 @@ CImageList m_ImageList; CSoundFile *m_pSndFile; // != NULL only when currently playing or rendering HWND m_hFollowSong, m_hWndMidi; - // Kind of notification that should be generated - FlagSet<Notification::Type, uint16> m_notifyType; - Notification::Item m_notifyItem; CSoundFile::samplecount_t m_dwTimeSec; UINT_PTR m_nTimer; UINT m_nAvgMixChn, m_nMixChn; @@ -444,11 +441,11 @@ bool PausePlayback(); bool IsPlaybackRunning() const { return m_IsPlaybackRunning; } static bool IsValidSoundFile(CSoundFile *pSndFile) { return pSndFile && pSndFile->GetType(); } - void SetPlaybackSoundFile(CSoundFile *pSndFile, HWND hPat = NULL, Notification::Type notifyType = Notification::None, Notification::Item notifyItem = 0); + void SetPlaybackSoundFile(CSoundFile *pSndFile, HWND hPat=NULL); void UnsetPlaybackSoundFile(); void GenerateStopNotification(); - bool PlayMod(CModDoc *, HWND hPat=NULL, Notification::Type notifyType = Notification::None, Notification::Item notifyItem = 0); + bool PlayMod(CModDoc *, HWND hPat=NULL); bool StopMod(CModDoc *pDoc=NULL); bool PauseMod(CModDoc *pDoc=NULL); @@ -476,7 +473,7 @@ BOOL SetupMidi(DWORD d, LONG n); void SetPreAmp(UINT n); HWND GetFollowSong(const CModDoc *pDoc) const { return (pDoc == GetModPlaying()) ? m_hFollowSong : NULL; } - BOOL SetFollowSong(CModDoc *, HWND hwnd, BOOL bFollowSong=TRUE, Notification::Type type = Notification::Default, Notification::Item item = 0); + BOOL SetFollowSong(CModDoc *, HWND hwnd, BOOL bFollowSong=TRUE); void ResetNotificationBuffer(); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-06 18:22:02 UTC (rev 1754) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-06 18:34:18 UTC (rev 1755) @@ -125,6 +125,9 @@ m_lpszLog = NULL; m_hWndFollow = NULL; + m_notifyType = Notification::None; + m_notifyItem = 0; + m_PatternUndo.SetParent(this); m_SampleUndo.SetParent(this); @@ -937,7 +940,7 @@ if (pMainFrm->GetModPlaying() != this) { m_SndFile.m_SongFlags.set(SONG_PAUSED); - pMainFrm->PlayMod(this, m_hWndFollow, m_notifyType, m_notifyItem); + pMainFrm->PlayMod(this, m_hWndFollow); } CriticalSection cs; @@ -1420,14 +1423,12 @@ } -void CModDoc::SetFollowWnd(HWND hwnd, Notification::Type type, Notification::Item item) -//------------------------------------------------------------------------------------- +void CModDoc::SetFollowWnd(HWND hwnd) +//------------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); m_hWndFollow = hwnd; - m_notifyType = type; - m_notifyItem = item; - if(pMainFrm) pMainFrm->SetFollowSong(this, m_hWndFollow, TRUE, m_notifyType, m_notifyItem); + if(pMainFrm) pMainFrm->SetFollowSong(this, m_hWndFollow, TRUE); } @@ -1927,7 +1928,7 @@ cs.Leave(); m_SndFile.m_SongFlags.reset(SONG_STEP | SONG_PAUSED | SONG_PATTERNLOOP); - pMainFrm->PlayMod(this, m_hWndFollow, m_notifyType, m_notifyItem); + pMainFrm->PlayMod(this, m_hWndFollow); } } @@ -2012,7 +2013,7 @@ cs.Leave(); - pMainFrm->PlayMod(this, m_hWndFollow, m_notifyType, m_notifyItem); + pMainFrm->PlayMod(this, m_hWndFollow); } } @@ -2326,7 +2327,8 @@ if(pModPlaying != this) { - pMainFrm->PlayMod(this, followSonghWnd, m_notifyType|Notification::Position|Notification::VUMeters, m_notifyItem); //rewbs.fix2977 + SetNotifications(m_notifyType|Notification::Position|Notification::VUMeters, m_notifyItem); + pMainFrm->PlayMod(this, followSonghWnd); //rewbs.fix2977 } } //SwitchToView(); @@ -2382,7 +2384,8 @@ if(pModPlaying != this) { - pMainFrm->PlayMod(this, followSonghWnd, m_notifyType | Notification::Position | Notification::VUMeters, m_notifyItem); //rewbs.fix2977 + SetNotifications(m_notifyType|Notification::Position|Notification::VUMeters, m_notifyItem); + pMainFrm->PlayMod(this, followSonghWnd); //rewbs.fix2977 } } //SwitchToView(); @@ -2441,7 +2444,8 @@ if(pModPlaying != this) { - pMainFrm->PlayMod(this, followSonghWnd, m_notifyType | Notification::Position | Notification::VUMeters, m_notifyItem); //rewbs.fix2977 + SetNotifications(m_notifyType|Notification::Position|Notification::VUMeters, m_notifyItem); + pMainFrm->PlayMod(this, followSonghWnd); //rewbs.fix2977 } } //SwitchToView(); Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-04-06 18:22:02 UTC (rev 1754) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-04-06 18:34:18 UTC (rev 1755) @@ -208,8 +208,12 @@ void ViewSample(UINT nSmp); void ViewInstrument(UINT nIns); HWND GetFollowWnd() const { return m_hWndFollow; } - void SetFollowWnd(HWND hwnd, Notification::Type type, Notification::Item item = 0); + void SetFollowWnd(HWND hwnd); + void SetNotifications(Notification::Type type, Notification::Item item = 0) { m_notifyType = type; m_notifyItem = item; } + FlagSet<Notification::Type, uint16> GetNotificationType() const { return m_notifyType; } + Notification::Item GetNotificationItem() const { return m_notifyItem; } + void ActivateWindow(); void SongProperties(); Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2013-04-06 18:22:02 UTC (rev 1754) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2013-04-06 18:34:18 UTC (rev 1755) @@ -203,7 +203,8 @@ case ENV_PITCH: type = Notification::PitchEnv; break; default: m_nEnv = ENV_VOLUME; type = Notification::VolEnv; break; } - pModDoc->SetFollowWnd(m_hWnd, type, m_nInstrument); + pModDoc->SetNotifications(type, m_nInstrument); + pModDoc->SetFollowWnd(m_hWnd); UpdateScrollSize(); UpdateNcButtonState(); InvalidateRect(NULL, FALSE); Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-06 18:22:02 UTC (rev 1754) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-06 18:34:18 UTC (rev 1755) @@ -767,7 +767,8 @@ CModDoc *pModDoc = GetDocument(); if (pModDoc) { - pModDoc->SetFollowWnd(m_hWnd, Notification::Position | Notification::VUMeters); + pModDoc->SetNotifications(Notification::Position | Notification::VUMeters); + pModDoc->SetFollowWnd(m_hWnd); UpdateIndicator(); } } @@ -2467,7 +2468,8 @@ if (pMainFrm->GetModPlaying() != pModDoc) { - pMainFrm->PlayMod(pModDoc, m_hWnd, Notification::Position|Notification::VUMeters); + pModDoc->SetNotifications(Notification::Position | Notification::VUMeters); + pMainFrm->PlayMod(pModDoc, m_hWnd); } if(row == ROWINDEX_INVALID) { @@ -3928,8 +3930,9 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); CModDoc *pModDoc = GetDocument(); m_Status.set(psFollowSong); - if (pModDoc) pModDoc->SetFollowWnd(m_hWnd, Notification::Position|Notification::VUMeters); - if (pMainFrm) pMainFrm->SetFollowSong(pModDoc, m_hWnd, TRUE, Notification::Position|Notification::VUMeters); + if(pModDoc) pModDoc->SetNotifications(Notification::Position | Notification::VUMeters); + if(pModDoc) pModDoc->SetFollowWnd(m_hWnd); + if(pMainFrm) pMainFrm->SetFollowSong(pModDoc, m_hWnd, TRUE); SetFocus(); } else { Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-04-06 18:22:02 UTC (rev 1754) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-04-06 18:34:18 UTC (rev 1755) @@ -225,7 +225,8 @@ if (!pModDoc) return FALSE; pSndFile = pModDoc->GetSoundFile(); if ((nSmp < 1) || (nSmp > pSndFile->m_nSamples)) return FALSE; - pModDoc->SetFollowWnd(m_hWnd, Notification::Sample, nSmp); + pModDoc->SetNotifications(Notification::Sample, nSmp); + pModDoc->SetFollowWnd(m_hWnd); if (nSmp == m_nSample) return FALSE; m_dwBeginSel = m_dwEndSel = 0; m_bDrawingEnabled = false; // sample drawing This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-06 20:19:02
|
Revision: 1763 http://sourceforge.net/p/modplug/code/1763 Author: manxorist Date: 2013-04-06 20:18:50 +0000 (Sat, 06 Apr 2013) Log Message: ----------- [Ref] Remove pointless HINT_MPTSETUP. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.h Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-06 20:00:48 UTC (rev 1762) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2013-04-06 20:18:50 UTC (rev 1763) @@ -120,7 +120,7 @@ m_SliderSamplePreAmp.SetRange(0, MAX_SLIDER_SAMPLE_VOL); m_bEditsLocked=false; - UpdateView(HINT_MODGENERAL|HINT_MODTYPE|HINT_MODSEQUENCE|HINT_MPTSETUP, NULL); + UpdateView(HINT_MODGENERAL|HINT_MODTYPE|HINT_MODSEQUENCE, NULL); OnActivatePage(0); m_bInitialized = TRUE; @@ -249,10 +249,7 @@ wsprintf(s, "%s, %d channel%s", pszModType, m_pSndFile->GetNumChannels(), (m_pSndFile->GetNumChannels() != 1) ? "s" : ""); m_EditModType.SetWindowText(s); } - if (dwHint & HINT_MPTSETUP) - { - CheckDlgButton(IDC_CHECK_LOOPSONG, (TrackerSettings::Instance().gbLoopSong) ? TRUE : FALSE); - } + CheckDlgButton(IDC_CHECK_LOOPSONG, (TrackerSettings::Instance().gbLoopSong) ? TRUE : FALSE); if (dwHint & HINT_MPTOPTIONS) { m_VuMeterLeft.InvalidateRect(NULL, FALSE); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-06 20:00:48 UTC (rev 1762) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-06 20:18:50 UTC (rev 1763) @@ -1774,7 +1774,6 @@ CSoundFile::SetAGC(TrackerSettings::Instance().m_dwQuality & QUALITY_AGC); #endif } - PostMessage(WM_MOD_INVALIDATEPATTERNS, HINT_MPTSETUP); } return TRUE; } Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-04-06 20:00:48 UTC (rev 1762) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-04-06 20:18:50 UTC (rev 1763) @@ -29,7 +29,6 @@ #define HINT_PATTERNROW 0x00040 #define HINT_PATNAMES 0x00080 #define HINT_MPTOPTIONS 0x00100 -#define HINT_MPTSETUP 0x00200 #define HINT_SAMPLEINFO 0x00400 #define HINT_SAMPLEDATA 0x00800 #define HINT_INSTRUMENT 0x01000 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-07 13:12:41
|
Revision: 1765 http://sourceforge.net/p/modplug/code/1765 Author: saga-games Date: 2013-04-07 13:12:30 +0000 (Sun, 07 Apr 2013) Log Message: ----------- [Ref] Turned plugin pointer in plugin editor window class into a reference. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.h trunk/OpenMPT/mptrack/DefaultVstEditor.cpp trunk/OpenMPT/mptrack/DefaultVstEditor.h trunk/OpenMPT/mptrack/VSTEditor.cpp trunk/OpenMPT/mptrack/VSTEditor.h trunk/OpenMPT/mptrack/Vstplug.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-04-06 20:19:59 UTC (rev 1764) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-04-07 13:12:30 UTC (rev 1765) @@ -49,10 +49,9 @@ ON_COMMAND_RANGE(ID_LEARN_MACRO_FROM_PLUGGUI, ID_LEARN_MACRO_FROM_PLUGGUI + NUM_MACROS, PrepareToLearnMacro) END_MESSAGE_MAP() -CAbstractVstEditor::CAbstractVstEditor(CVstPlugin *pPlugin) +CAbstractVstEditor::CAbstractVstEditor(CVstPlugin &plugin) : m_VstPlugin(plugin) { m_nCurProg = -1; - m_pVstPlugin = pPlugin; m_pMenu = new CMenu(); m_pInputMenu = new CMenu(); m_pOutputMenu = new CMenu(); @@ -71,43 +70,39 @@ #ifdef VST_LOG Log("~CVstEditor()\n"); #endif - if (m_pVstPlugin) - { - m_pMenu->DestroyMenu(); - m_pPresetMenu->DestroyMenu(); - m_pInputMenu->DestroyMenu(); - m_pOutputMenu->DestroyMenu(); - m_pMacroMenu->DestroyMenu(); + m_pMenu->DestroyMenu(); + m_pPresetMenu->DestroyMenu(); + m_pInputMenu->DestroyMenu(); + m_pOutputMenu->DestroyMenu(); + m_pMacroMenu->DestroyMenu(); - m_pOptionsMenu->DestroyMenu(); + m_pOptionsMenu->DestroyMenu(); - delete m_pMenu; - delete m_pPresetMenu; - delete m_pInputMenu; - delete m_pOutputMenu; - delete m_pMacroMenu; - delete m_pOptionsMenu; + delete m_pMenu; + delete m_pPresetMenu; + delete m_pInputMenu; + delete m_pOutputMenu; + delete m_pMacroMenu; + delete m_pOptionsMenu; - for(size_t i = 0; i < m_pPresetMenuGroup.size(); i++) + for(size_t i = 0; i < m_pPresetMenuGroup.size(); i++) + { + if(m_pPresetMenuGroup[i]->m_hMenu) { - if(m_pPresetMenuGroup[i]->m_hMenu) - { - m_pPresetMenuGroup[i]->DestroyMenu(); - delete m_pPresetMenuGroup[i]; - } + m_pPresetMenuGroup[i]->DestroyMenu(); + delete m_pPresetMenuGroup[i]; } - m_pPresetMenuGroup.clear(); + } + m_pPresetMenuGroup.clear(); - m_pVstPlugin->m_pEditor = nullptr; - m_pVstPlugin = nullptr; - } + m_VstPlugin.m_pEditor = nullptr; } void CAbstractVstEditor::OnLoadPreset() //------------------------------------- { - if(m_pVstPlugin && m_pVstPlugin->LoadProgram()) + if(m_VstPlugin.LoadProgram()) { UpdatePresetMenu(true); UpdatePresetField(); @@ -118,21 +113,18 @@ void CAbstractVstEditor::OnSavePreset() //------------------------------------- { - if(m_pVstPlugin) - { - m_pVstPlugin->SaveProgram(); - } + m_VstPlugin.SaveProgram(); } void CAbstractVstEditor::OnCopyParameters() //----------------------------------------- { - if(m_pVstPlugin == nullptr || CMainFrame::GetMainFrame() == nullptr) return; + if(CMainFrame::GetMainFrame() == nullptr) return; BeginWaitCursor(); std::ostringstream f(std::ios::out | std::ios::binary); - if(VSTPresets::SaveFile(f, *m_pVstPlugin, false)) + if(VSTPresets::SaveFile(f, m_VstPlugin, false)) { const std::string data = f.str(); @@ -157,7 +149,7 @@ void CAbstractVstEditor::OnPasteParameters() //------------------------------------------ { - if(m_pVstPlugin == nullptr || CMainFrame::GetMainFrame() == nullptr) return; + if(CMainFrame::GetMainFrame() == nullptr) return; BeginWaitCursor(); if(CMainFrame::GetMainFrame()->OpenClipboard()) @@ -168,12 +160,12 @@ if(hCpy != nullptr && (p = static_cast<const char *>(GlobalLock(hCpy))) != nullptr) { FileReader file(p, GlobalSize(hCpy)); - VSTPresets::ErrorCode error = VSTPresets::LoadFile(file, *m_pVstPlugin); + VSTPresets::ErrorCode error = VSTPresets::LoadFile(file, m_VstPlugin); GlobalUnlock(hCpy); if(error == VSTPresets::noError) { - const CSoundFile &sndFile = m_pVstPlugin->GetSoundFile(); + const CSoundFile &sndFile = m_VstPlugin.GetSoundFile(); CModDoc *pModDoc; if(sndFile.GetModSpecifications().supportsPlugins && (pModDoc = sndFile.GetpModDoc()) != nullptr) { @@ -194,9 +186,9 @@ VOID CAbstractVstEditor::OnRandomizePreset() //----------------------------------------- { - if(m_pVstPlugin && Reporting::Confirm("Are you sure you want to randomize parameters?\nYou will lose current parameter values.", false, false, this) == cnfYes) + if(Reporting::Confirm("Are you sure you want to randomize parameters?\nYou will lose current parameter values.", false, false, this) == cnfYes) { - m_pVstPlugin->RandomizeParams(); + m_VstPlugin.RandomizeParams(); UpdateParamDisplays(); } } @@ -206,16 +198,13 @@ //-------------------------------------------- { //TODO: create menus on click so they are only updated when required - if (m_pVstPlugin) - { - UpdatePresetMenu(force); - UpdateInputMenu(); - UpdateOutputMenu(); - UpdateMacroMenu(); - UpdateOptionsMenu(); - UpdatePresetField(); - ::SetMenu(m_hWnd, m_pMenu->m_hMenu); - } + UpdatePresetMenu(force); + UpdateInputMenu(); + UpdateOutputMenu(); + UpdateMacroMenu(); + UpdateOptionsMenu(); + UpdatePresetField(); + ::SetMenu(m_hWnd, m_pMenu->m_hMenu); return; } @@ -223,7 +212,7 @@ void CAbstractVstEditor::UpdatePresetField() //------------------------------------------ { - if(m_pVstPlugin->GetNumPrograms() > 0) + if(m_VstPlugin.GetNumPrograms() > 0) { if(m_pMenu->GetMenuItemCount() < 5) { @@ -234,7 +223,7 @@ m_pMenu->AppendMenu(MF_BYPOSITION|MF_DISABLED, 0, TEXT("")); } - m_pMenu->ModifyMenu(8, MF_BYPOSITION, 0, m_pVstPlugin->GetFormattedProgramName(m_pVstPlugin->GetCurrentProgram())); + m_pMenu->ModifyMenu(8, MF_BYPOSITION, 0, m_VstPlugin.GetFormattedProgramName(m_VstPlugin.GetCurrentProgram())); } DrawMenuBar(); @@ -248,12 +237,12 @@ int nIndex = nID - ID_PRESET_SET; if(nIndex >= 0) { - m_pVstPlugin->SetCurrentProgram(nIndex); + m_VstPlugin.SetCurrentProgram(nIndex); UpdatePresetField(); - if(m_pVstPlugin->GetSoundFile().GetModSpecifications().supportsPlugins) + if(m_VstPlugin.GetSoundFile().GetModSpecifications().supportsPlugins) { - m_pVstPlugin->GetModDoc()->SetModified(); + m_VstPlugin.GetModDoc()->SetModified(); } } } @@ -262,13 +251,10 @@ void CAbstractVstEditor::OnBypassPlug() //------------------------------------- { - if(m_pVstPlugin) + m_VstPlugin.ToggleBypass(); + if(m_VstPlugin.GetSoundFile().GetModSpecifications().supportsPlugins) { - m_pVstPlugin->ToggleBypass(); - if(m_pVstPlugin->GetSoundFile().GetModSpecifications().supportsPlugins) - { - m_pVstPlugin->GetModDoc()->SetModified(); - } + m_VstPlugin.GetModDoc()->SetModified(); } } @@ -276,30 +262,21 @@ void CAbstractVstEditor::OnRecordAutomation() //------------------------------------------- { - if(m_pVstPlugin) - { - m_pVstPlugin->m_bRecordAutomation = !m_pVstPlugin->m_bRecordAutomation; - } + m_VstPlugin.m_bRecordAutomation = !m_VstPlugin.m_bRecordAutomation; } void CAbstractVstEditor::OnRecordMIDIOut() //---------------------------------------- { - if(m_pVstPlugin) - { - m_pVstPlugin->m_bRecordMIDIOut = !m_pVstPlugin->m_bRecordMIDIOut; - } + m_VstPlugin.m_bRecordMIDIOut = !m_VstPlugin.m_bRecordMIDIOut; } void CAbstractVstEditor::OnPassKeypressesToPlug() //----------------------------------------------- { - if(m_pVstPlugin) - { - m_pVstPlugin->m_bPassKeypressesToPlug = !m_pVstPlugin->m_bPassKeypressesToPlug; - } + m_VstPlugin.m_bPassKeypressesToPlug = !m_VstPlugin.m_bPassKeypressesToPlug; } @@ -309,7 +286,7 @@ if (pMsg) { //We handle keypresses before Windows has a chance to handle them (for alt etc..) - if(!m_pVstPlugin->m_bPassKeypressesToPlug && + if(!m_VstPlugin.m_bPassKeypressesToPlug && (pMsg->message == WM_SYSKEYUP || pMsg->message == WM_KEYUP || pMsg->message == WM_SYSKEYDOWN || pMsg->message == WM_KEYDOWN) ) { @@ -345,15 +322,15 @@ void CAbstractVstEditor::SetTitle() //--------------------------------- { - if(m_pVstPlugin && m_pVstPlugin->m_pMixStruct) + if(m_VstPlugin.m_pMixStruct) { CString Title; - Title.Format("FX %02d: ", m_pVstPlugin->m_nSlot + 1); + Title.Format("FX %02d: ", m_VstPlugin.m_nSlot + 1); - if(strcmp(m_pVstPlugin->m_pMixStruct->GetName(), "")) - Title.Append(m_pVstPlugin->m_pMixStruct->GetName()); + if(strcmp(m_VstPlugin.m_pMixStruct->GetName(), "")) + Title.Append(m_VstPlugin.m_pMixStruct->GetName()); else - Title.Append(m_pVstPlugin->m_pMixStruct->GetLibraryName()); + Title.Append(m_VstPlugin.m_pMixStruct->GetLibraryName()); SetWindowText(Title); } @@ -383,7 +360,7 @@ { if(ValidateCurrentInstrument()) { - CModDoc* pModDoc = m_pVstPlugin->GetModDoc(); + CModDoc* pModDoc = m_VstPlugin.GetModDoc(); CMainFrame* pMainFrm = CMainFrame::GetMainFrame(); pModDoc->PlayNote(wParam - kcVSTGUIStartNotes + 1 + pMainFrm->GetBaseOctave() * 12, m_nInstrument, 0, false); } @@ -393,7 +370,7 @@ { if(ValidateCurrentInstrument()) { - CModDoc* pModDoc = m_pVstPlugin->GetModDoc(); + CModDoc* pModDoc = m_VstPlugin.GetModDoc(); CMainFrame* pMainFrm = CMainFrame::GetMainFrame(); pModDoc->NoteOff(wParam - kcVSTGUIStartNoteStops + 1 + pMainFrm->GetBaseOctave() * 12, false, m_nInstrument); } @@ -415,13 +392,13 @@ //only show messagebox if plug is able to process notes. if(m_nInstrument == INSTRUMENTINDEX_INVALID) { - if(m_pVstPlugin->CanRecieveMidiEvents()) + if(m_VstPlugin.CanRecieveMidiEvents()) { - CModDoc *pModDoc = m_pVstPlugin->GetModDoc(); + CModDoc *pModDoc = m_VstPlugin.GetModDoc(); if(pModDoc == nullptr) return false; - if(!m_pVstPlugin->isInstrument() || pModDoc->GetSoundFile()->GetModSpecifications().instrumentsMax == 0 || + if(!m_VstPlugin.isInstrument() || pModDoc->GetSoundFile()->GetModSpecifications().instrumentsMax == 0 || Reporting::Confirm(_T("You need to assign an instrument to this plugin before you can play notes from here.\nCreate a new instrument and assign this plugin to the instrument?"), false, false) == cnfNo) { return false; @@ -476,8 +453,8 @@ return; } - const VstInt32 numProgs = m_pVstPlugin->GetNumPrograms(); - const VstInt32 curProg = m_pVstPlugin->GetCurrentProgram(); + const VstInt32 numProgs = m_VstPlugin.GetNumPrograms(); + const VstInt32 curProg = m_VstPlugin.GetCurrentProgram(); const int numSubMenus = ((numProgs - 1) / PRESETS_PER_GROUP) + 1; if(numSubMenus > 1) @@ -504,7 +481,7 @@ for(VstInt32 p = 0; p < numProgs; p++) { - CString programName = m_pVstPlugin->GetFormattedProgramName(p); + CString programName = m_VstPlugin.GetFormattedProgramName(p); UINT splitMenuFlag = 0; if(entryInThisMenu++ == PRESETS_PER_GROUP) @@ -531,8 +508,8 @@ void CAbstractVstEditor::UpdatePresetMenu(bool force) //--------------------------------------------------- { - const VstInt32 numProgs = m_pVstPlugin->GetNumPrograms(); - const VstInt32 curProg = m_pVstPlugin->GetCurrentProgram(); + const VstInt32 numProgs = m_VstPlugin.GetNumPrograms(); + const VstInt32 curProg = m_VstPlugin.GetCurrentProgram(); if(m_pPresetMenu->m_hMenu) // We rebuild menu from scratch { // So remove any exiting menus... @@ -574,7 +551,7 @@ CMenu *pInfoMenu = m_pMenu->GetSubMenu(2); pInfoMenu->DeleteMenu(0, MF_BYPOSITION); - CModDoc* pModDoc = m_pVstPlugin->GetModDoc(); + CModDoc* pModDoc = m_VstPlugin.GetModDoc(); CSoundFile* pSndFile = pModDoc->GetSoundFile(); if(m_pInputMenu->m_hMenu) @@ -589,7 +566,7 @@ CString name; vector<CVstPlugin *> inputPlugs; - m_pVstPlugin->GetInputPlugList(inputPlugs); + m_VstPlugin.GetInputPlugList(inputPlugs); for(size_t nPlug=0; nPlug < inputPlugs.size(); nPlug++) { name.Format("FX%02d: %s", inputPlugs[nPlug]->m_nSlot + 1, inputPlugs[nPlug]->m_pMixStruct->GetName()); @@ -597,7 +574,7 @@ } vector<CHANNELINDEX> inputChannels; - m_pVstPlugin->GetInputChannelList(inputChannels); + m_VstPlugin.GetInputChannelList(inputChannels); for(size_t nChn=0; nChn<inputChannels.size(); nChn++) { if(nChn == 0 && inputPlugs.size()) @@ -609,7 +586,7 @@ } vector<INSTRUMENTINDEX> inputInstruments; - m_pVstPlugin->GetInputInstrumentList(inputInstruments); + m_VstPlugin.GetInputInstrumentList(inputInstruments); for(size_t nIns = 0; nIns<inputInstruments.size(); nIns++) { bool checked = false; @@ -649,7 +626,7 @@ } vector<CVstPlugin *> outputPlugs; - m_pVstPlugin->GetOutputPlugList(outputPlugs); + m_VstPlugin.GetOutputPlugList(outputPlugs); CString name; for(size_t nPlug = 0; nPlug < outputPlugs.size(); nPlug++) @@ -677,7 +654,7 @@ bool greyed; int action; - CModDoc *pModDoc = m_pVstPlugin->GetModDoc(); + CModDoc *pModDoc = m_VstPlugin.GetModDoc(); if(!pModDoc) { return; @@ -711,7 +688,7 @@ greyed = false; } else { - macroName = midiCfg.GetParameteredMacroName(nMacro, m_pVstPlugin->GetSlot(), *pModDoc->GetSoundFile()); + macroName = midiCfg.GetParameteredMacroName(nMacro, m_VstPlugin.GetSlot(), *pModDoc->GetSoundFile()); if(macroType != sfx_plug || macroName.Left(3) != "N/A") { greyed = false; @@ -737,16 +714,16 @@ m_pOptionsMenu->CreatePopupMenu(); //Bypass - m_pOptionsMenu->AppendMenu(MF_STRING | m_pVstPlugin->IsBypassed() ? MF_CHECKED : 0, + m_pOptionsMenu->AppendMenu(MF_STRING | m_VstPlugin.IsBypassed() ? MF_CHECKED : 0, ID_PLUG_BYPASS, "&Bypass Plugin\t" + ih->GetKeyTextFromCommand(kcVSTGUIBypassPlug)); //Record Params - m_pOptionsMenu->AppendMenu(MF_STRING | m_pVstPlugin->m_bRecordAutomation ? MF_CHECKED : 0, + m_pOptionsMenu->AppendMenu(MF_STRING | m_VstPlugin.m_bRecordAutomation ? MF_CHECKED : 0, ID_PLUG_RECORDAUTOMATION, "Record &Parameter Changes\t" + ih->GetKeyTextFromCommand(kcVSTGUIToggleRecordParams)); //Record MIDI Out - m_pOptionsMenu->AppendMenu(MF_STRING | m_pVstPlugin->m_bRecordMIDIOut ? MF_CHECKED : 0, + m_pOptionsMenu->AppendMenu(MF_STRING | m_VstPlugin.m_bRecordMIDIOut ? MF_CHECKED : 0, ID_PLUG_RECORD_MIDIOUT, "Record &MIDI Out to Pattern Editor\t" + ih->GetKeyTextFromCommand(kcVSTGUIToggleRecordMIDIOut)); //Pass on keypresses - m_pOptionsMenu->AppendMenu(MF_STRING | m_pVstPlugin->m_bPassKeypressesToPlug ? MF_CHECKED : 0, + m_pOptionsMenu->AppendMenu(MF_STRING | m_VstPlugin.m_bPassKeypressesToPlug ? MF_CHECKED : 0, ID_PLUG_PASSKEYS, "Pass &Keys to Plugin\t" + ih->GetKeyTextFromCommand(kcVSTGUIToggleSendKeysToPlug)); @@ -759,7 +736,7 @@ void CAbstractVstEditor::OnToggleEditor(UINT nID) //----------------------------------------------- { - CModDoc *pModDoc = m_pVstPlugin->GetModDoc(); + CModDoc *pModDoc = m_VstPlugin.GetModDoc(); if(pModDoc) { @@ -778,11 +755,11 @@ bool CAbstractVstEditor::CheckInstrument(INSTRUMENTINDEX ins) //----------------------------------------------------------- { - const CSoundFile &sndFile = m_pVstPlugin->GetSoundFile(); + const CSoundFile &sndFile = m_VstPlugin.GetSoundFile(); if(ins != INSTRUMENTINDEX_INVALID && ins < MAX_INSTRUMENTS && sndFile.Instruments[ins] != nullptr) { - return (sndFile.Instruments[ins]->nMixPlug) == (m_pVstPlugin->m_nSlot + 1); + return (sndFile.Instruments[ins]->nMixPlug) == (m_VstPlugin.m_nSlot + 1); } return false; } @@ -800,7 +777,7 @@ */ //Then just take the first instrument that points to this plug.. vector<INSTRUMENTINDEX> plugInstrumentList; - m_pVstPlugin->GetInputInstrumentList(plugInstrumentList); + m_VstPlugin.GetInputInstrumentList(plugInstrumentList); if(plugInstrumentList.size()) { return static_cast<INSTRUMENTINDEX>(plugInstrumentList[0]); @@ -821,28 +798,28 @@ void CAbstractVstEditor::OnSetPreviousVSTPreset() //----------------------------------------------- { - OnSetPreset(ID_PRESET_SET + m_pVstPlugin->GetCurrentProgram() - 1); + OnSetPreset(ID_PRESET_SET + m_VstPlugin.GetCurrentProgram() - 1); } void CAbstractVstEditor::OnSetNextVSTPreset() //------------------------------------------- { - OnSetPreset(ID_PRESET_SET + m_pVstPlugin->GetCurrentProgram() + 1); + OnSetPreset(ID_PRESET_SET + m_VstPlugin.GetCurrentProgram() + 1); } void CAbstractVstEditor::OnVSTPresetBackwardJump() //------------------------------------------------ { - OnSetPreset(max(ID_PRESET_SET + m_pVstPlugin->GetCurrentProgram() - 10, ID_PRESET_SET)); + OnSetPreset(max(ID_PRESET_SET + m_VstPlugin.GetCurrentProgram() - 10, ID_PRESET_SET)); } void CAbstractVstEditor::OnVSTPresetForwardJump() //----------------------------------------------- { - OnSetPreset(min(ID_PRESET_SET + m_pVstPlugin->GetCurrentProgram() + 10, ID_PRESET_SET + m_pVstPlugin->GetNumPrograms() - 1)); + OnSetPreset(min(ID_PRESET_SET + m_VstPlugin.GetCurrentProgram() + 10, ID_PRESET_SET + m_VstPlugin.GetNumPrograms() - 1)); } @@ -857,8 +834,8 @@ bool CAbstractVstEditor::CreateInstrument() //----------------------------------------- { - CModDoc *pModDoc = m_pVstPlugin->GetModDoc(); - CSoundFile &sndFile = m_pVstPlugin->GetSoundFile(); + CModDoc *pModDoc = m_VstPlugin.GetModDoc(); + CSoundFile &sndFile = m_VstPlugin.GetSoundFile(); if(pModDoc == nullptr) { return false; @@ -874,9 +851,9 @@ ModInstrument *pIns = sndFile.Instruments[nIns]; m_nInstrument = nIns; - _snprintf(pIns->name, CountOf(pIns->name) - 1, _T("%d: %s"), m_pVstPlugin->GetSlot() + 1, sndFile.m_MixPlugins[m_pVstPlugin->GetSlot()].GetName()); - StringFixer::CopyN(pIns->filename, sndFile.m_MixPlugins[m_pVstPlugin->GetSlot()].GetLibraryName()); - pIns->nMixPlug = (PLUGINDEX)m_pVstPlugin->GetSlot() + 1; + _snprintf(pIns->name, CountOf(pIns->name) - 1, _T("%d: %s"), m_VstPlugin.GetSlot() + 1, sndFile.m_MixPlugins[m_VstPlugin.GetSlot()].GetName()); + StringFixer::CopyN(pIns->filename, sndFile.m_MixPlugins[m_VstPlugin.GetSlot()].GetLibraryName()); + pIns->nMixPlug = (PLUGINDEX)m_VstPlugin.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. //pIns->wMidiBank = (WORD)((m_pVstPlugin->GetCurrentProgram() >> 7) + 1); Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2013-04-06 20:19:59 UTC (rev 1764) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2013-04-07 13:12:30 UTC (rev 1765) @@ -22,9 +22,9 @@ public: - CVstPlugin *m_pVstPlugin; + CVstPlugin &m_VstPlugin; int m_nCurProg; - CAbstractVstEditor(CVstPlugin *pPlugin); + CAbstractVstEditor(CVstPlugin &plugin); virtual ~CAbstractVstEditor(); void SetupMenu(bool force = false); void SetTitle(); Modified: trunk/OpenMPT/mptrack/DefaultVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2013-04-06 20:19:59 UTC (rev 1764) +++ trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2013-04-07 13:12:30 UTC (rev 1765) @@ -154,8 +154,8 @@ } -CDefaultVstEditor::CDefaultVstEditor(CVstPlugin *pPlugin) : CAbstractVstEditor(pPlugin) -//------------------------------------------------------------------------------------- +CDefaultVstEditor::CDefaultVstEditor(CVstPlugin &plugin) : CAbstractVstEditor(plugin) +//----------------------------------------------------------------------------------- { m_nControlLock = 0; paramOffset = 0; @@ -239,12 +239,7 @@ void CDefaultVstEditor::UpdateControls(bool updateParamNames) //----------------------------------------------------------- { - if(m_pVstPlugin == nullptr) - { - return; - } - - const PlugParamIndex numParams = m_pVstPlugin->GetNumParameters(); + const PlugParamIndex numParams = m_VstPlugin.GetNumParameters(); const PlugParamIndex scrollMax = numParams - min(numParams, NUM_PLUGINEDITOR_PARAMETERS); LimitMax(paramOffset, scrollMax); @@ -276,7 +271,7 @@ if(updateParamNames) { // Update param name - controls[i]->SetParamName(m_pVstPlugin->GetFormattedParamName(param)); + controls[i]->SetParamName(m_VstPlugin.GetFormattedParamName(param)); } UpdateParamDisplay(param); @@ -410,7 +405,7 @@ // Restore previous editor position int editorX, editorY; - m_pVstPlugin->GetEditorPos(editorX, editorY); + m_VstPlugin.GetEditorPos(editorX, editorY); if((editorX >= 0) && (editorY >= 0)) { @@ -453,17 +448,14 @@ void CDefaultVstEditor::DoClose() //------------------------------- { - if((m_pVstPlugin) && (m_hWnd)) + if(m_hWnd) { CRect rect; GetWindowRect(&rect); - m_pVstPlugin->SetEditorPos(rect.left, rect.top); + m_VstPlugin.SetEditorPos(rect.left, rect.top); } - if(m_pVstPlugin) - { - m_pVstPlugin->Dispatch(effEditClose, 0, 0, NULL, 0); - } + m_VstPlugin.Dispatch(effEditClose, 0, 0, NULL, 0); DestroyWindow(); } @@ -514,18 +506,18 @@ void CDefaultVstEditor::SetParam(PlugParamIndex param, int value) //--------------------------------------------------------------- { - if(m_pVstPlugin == nullptr || param >= m_pVstPlugin->GetNumParameters()) + if(param >= m_VstPlugin.GetNumParameters()) { return; } - m_pVstPlugin->SetParameter(param, static_cast<PlugParamValue>(value) / static_cast<PlugParamValue>(PARAM_RESOLUTION)); + m_VstPlugin.SetParameter(param, static_cast<PlugParamValue>(value) / static_cast<PlugParamValue>(PARAM_RESOLUTION)); // Update other GUI controls UpdateParamDisplay(param); // Act as if an automation message has been sent by the plugin (record param changes, set document modified, etc...) - m_pVstPlugin->AutomateParameter(param); + m_VstPlugin.AutomateParameter(param); } @@ -534,21 +526,21 @@ void CDefaultVstEditor::UpdateParamDisplay(PlugParamIndex param) //-------------------------------------------------------------- { - if (m_nControlLock || param < paramOffset || param >= paramOffset + NUM_PLUGINEDITOR_PARAMETERS || m_pVstPlugin == nullptr) + if(m_nControlLock || param < paramOffset || param >= paramOffset + NUM_PLUGINEDITOR_PARAMETERS) { //Just to make sure we're not here as a consequence of an internal GUI change, and avoid modifying a parameter that doesn't exist on the GUI. return; } // Get the actual parameter value from the plugin - const int val = static_cast<int>(m_pVstPlugin->GetParameter(param) * static_cast<float>(PARAM_RESOLUTION) + 0.5f); + const int val = static_cast<int>(m_VstPlugin.GetParameter(param) * static_cast<float>(PARAM_RESOLUTION) + 0.5f); // Update the GUI controls // Set lock to indicate that the changes to the GUI are internal - no need to notify the plug and re-update GUI. m_nControlLock++; - controls[param - paramOffset]->SetParamValue(val, m_pVstPlugin->GetFormattedParamValue(param)); + controls[param - paramOffset]->SetParamValue(val, m_VstPlugin.GetFormattedParamValue(param)); // Unset lock - done with internal GUI updates. m_nControlLock--; Modified: trunk/OpenMPT/mptrack/DefaultVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/DefaultVstEditor.h 2013-04-06 20:19:59 UTC (rev 1764) +++ trunk/OpenMPT/mptrack/DefaultVstEditor.h 2013-04-07 13:12:30 UTC (rev 1765) @@ -23,9 +23,9 @@ #ifndef NO_VST -//==================== +//=================== class ParamControlSet -//==================== +//=================== { protected: CSliderCtrl valueSlider; @@ -66,7 +66,7 @@ public: - CDefaultVstEditor(CVstPlugin *pPlugin); + CDefaultVstEditor(CVstPlugin &plugin); virtual ~CDefaultVstEditor(); void UpdateParamDisplays() { UpdateControls(false); }; Modified: trunk/OpenMPT/mptrack/VSTEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/VSTEditor.cpp 2013-04-06 20:19:59 UTC (rev 1764) +++ trunk/OpenMPT/mptrack/VSTEditor.cpp 2013-04-07 13:12:30 UTC (rev 1765) @@ -13,8 +13,8 @@ #ifndef NO_VST -COwnerVstEditor::COwnerVstEditor(CVstPlugin *pPlugin) : CAbstractVstEditor(pPlugin) -//--------------------------------------------------------------------------------- +COwnerVstEditor::COwnerVstEditor(CVstPlugin &plugin) : CAbstractVstEditor(plugin) +//------------------------------------------------------------------------------- { } @@ -34,41 +34,38 @@ SetupMenu(); - if(m_pVstPlugin) + // Set editor window size + ERect *pRect = nullptr; + m_VstPlugin.Dispatch(effEditGetRect, 0, 0, &pRect, 0); + m_VstPlugin.Dispatch(effEditOpen, 0, 0, m_hWnd, 0); + m_VstPlugin.Dispatch(effEditGetRect, 0, 0, &pRect, 0); + if((pRect) && (pRect->right > pRect->left) && (pRect->bottom > pRect->top)) { - // Set editor window size - ERect *pRect = nullptr; - m_pVstPlugin->Dispatch(effEditGetRect, 0, 0, &pRect, 0); - m_pVstPlugin->Dispatch(effEditOpen, 0, 0, m_hWnd, 0); - m_pVstPlugin->Dispatch(effEditGetRect, 0, 0, &pRect, 0); - if((pRect) && (pRect->right > pRect->left) && (pRect->bottom > pRect->top)) - { - // Plugin provided valid window size. - SetSize(pRect->right - pRect->left, pRect->bottom - pRect->top); - } + // Plugin provided valid window size. + SetSize(pRect->right - pRect->left, pRect->bottom - pRect->top); + } - // Restore previous editor position - int editorX, editorY; - m_pVstPlugin->GetEditorPos(editorX, editorY); + // Restore previous editor position + int editorX, editorY; + m_VstPlugin.GetEditorPos(editorX, editorY); - if((editorX >= 0) && (editorY >= 0)) + if((editorX >= 0) && (editorY >= 0)) + { + int cxScreen = GetSystemMetrics(SM_CXSCREEN); + int cyScreen = GetSystemMetrics(SM_CYSCREEN); + if((editorX + 8 < cxScreen) && (editorY + 8 < cyScreen)) { - int cxScreen = GetSystemMetrics(SM_CXSCREEN); - int cyScreen = GetSystemMetrics(SM_CYSCREEN); - if((editorX + 8 < cxScreen) && (editorY + 8 < cyScreen)) - { - SetWindowPos(NULL, editorX, editorY, 0, 0, - SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); - } + SetWindowPos(NULL, editorX, editorY, 0, 0, + SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); } - SetTitle(); + } + SetTitle(); - m_pVstPlugin->Dispatch(effEditTop, 0,0, NULL, 0); - m_pVstPlugin->Dispatch(effEditIdle, 0,0, NULL, 0); + m_VstPlugin.Dispatch(effEditTop, 0,0, NULL, 0); + m_VstPlugin.Dispatch(effEditIdle, 0,0, NULL, 0); - // Set knob mode to linear (2) instead of circular (0) for those plugins that support it (e.g. Steinberg VB-1) - m_pVstPlugin->Dispatch(effSetEditKnobMode, 0, 2, nullptr, 0.0f); - } + // Set knob mode to linear (2) instead of circular (0) for those plugins that support it (e.g. Steinberg VB-1) + m_VstPlugin.Dispatch(effSetEditKnobMode, 0, 2, nullptr, 0.0f); ShowWindow(SW_SHOW); return TRUE; @@ -99,27 +96,15 @@ void COwnerVstEditor::DoClose() //----------------------------- { -#ifdef VST_LOG - Log("CVstEditor::DoClose()\n"); -#endif // VST_LOG - if ((m_pVstPlugin) && (m_hWnd)) + if(m_hWnd) { CRect rect; GetWindowRect(&rect); - m_pVstPlugin->SetEditorPos(rect.left, rect.top); + m_VstPlugin.SetEditorPos(rect.left, rect.top); } - if (m_pVstPlugin) + m_VstPlugin.Dispatch(effEditClose, 0, 0, NULL, 0); + if(m_hWnd) { -#ifdef VST_LOG - Log("Dispatching effEditClose...\n"); -#endif // VST_LOG - m_pVstPlugin->Dispatch(effEditClose, 0, 0, NULL, 0); - } - if (m_hWnd) - { -#ifdef VST_LOG - Log("Destroying window...\n"); -#endif // VST_LOG DestroyWindow(); } } Modified: trunk/OpenMPT/mptrack/VSTEditor.h =================================================================== --- trunk/OpenMPT/mptrack/VSTEditor.h 2013-04-06 20:19:59 UTC (rev 1764) +++ trunk/OpenMPT/mptrack/VSTEditor.h 2013-04-07 13:12:30 UTC (rev 1765) @@ -17,18 +17,12 @@ #ifndef NO_VST -//============================== +//============================================== class COwnerVstEditor: public CAbstractVstEditor -//============================== +//============================================== { -protected: -/* CVstPlugin *m_pVstPlugin; - CMenu *m_pMenu; - CMenu *m_pPresetMenu; -*/ - public: - COwnerVstEditor(CVstPlugin *pPlugin); + COwnerVstEditor(CVstPlugin &plugin); virtual ~COwnerVstEditor(); virtual void OnOK(); virtual void OnCancel(); @@ -38,7 +32,7 @@ virtual bool SetSize(int contentWidth, int contentHeight); //Overridden: - void UpdateParamDisplays() { m_pVstPlugin->Dispatch(effEditIdle, 0,0, NULL, 0); }; //we trust that the plugin GUI can update its display with a bit of idle time. + void UpdateParamDisplays() { m_VstPlugin.Dispatch(effEditIdle, 0, 0, nullptr, 0.0f); }; //we trust that the plugin GUI can update its display with a bit of idle time. afx_msg void OnClose(); bool OpenEditor(CWnd *parent); void DoClose(); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-04-06 20:19:59 UTC (rev 1764) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-04-07 13:12:30 UTC (rev 1765) @@ -2751,9 +2751,9 @@ } else { if (HasEditor()) - m_pEditor = new COwnerVstEditor(this); + m_pEditor = new COwnerVstEditor(*this); else - m_pEditor = new CDefaultVstEditor(this); + m_pEditor = new CDefaultVstEditor(*this); if (m_pEditor) m_pEditor->OpenEditor(CMainFrame::GetMainFrame()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-07 18:35:45
|
Revision: 1769 http://sourceforge.net/p/modplug/code/1769 Author: saga-games Date: 2013-04-07 18:35:32 +0000 (Sun, 07 Apr 2013) Log Message: ----------- [Ref] Less pointers in the VST editor Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-04-07 17:38:33 UTC (rev 1768) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-04-07 18:35:32 UTC (rev 1769) @@ -52,15 +52,8 @@ CAbstractVstEditor::CAbstractVstEditor(CVstPlugin &plugin) : m_VstPlugin(plugin) { m_nCurProg = -1; - m_pMenu = new CMenu(); - m_pInputMenu = new CMenu(); - m_pOutputMenu = new CMenu(); - m_pMacroMenu = new CMenu(); - m_pPresetMenu = new CMenu(); - m_pOptionsMenu = new CMenu(); - - m_pMenu->LoadMenu(IDR_VSTMENU); + m_Menu.LoadMenu(IDR_VSTMENU); m_nInstrument = GetBestInstrumentCandidate(); m_nLearnMacro = -1; } @@ -70,21 +63,14 @@ #ifdef VST_LOG Log("~CVstEditor()\n"); #endif - m_pMenu->DestroyMenu(); - m_pPresetMenu->DestroyMenu(); - m_pInputMenu->DestroyMenu(); - m_pOutputMenu->DestroyMenu(); - m_pMacroMenu->DestroyMenu(); + m_Menu.DestroyMenu(); + m_PresetMenu.DestroyMenu(); + m_InputMenu.DestroyMenu(); + m_OutputMenu.DestroyMenu(); + m_MacroMenu.DestroyMenu(); - m_pOptionsMenu->DestroyMenu(); + m_OptionsMenu.DestroyMenu(); - delete m_pMenu; - delete m_pPresetMenu; - delete m_pInputMenu; - delete m_pOutputMenu; - delete m_pMacroMenu; - delete m_pOptionsMenu; - for(size_t i = 0; i < m_pPresetMenuGroup.size(); i++) { if(m_pPresetMenuGroup[i]->m_hMenu) @@ -204,7 +190,7 @@ UpdateMacroMenu(); UpdateOptionsMenu(); UpdatePresetField(); - ::SetMenu(m_hWnd, m_pMenu->m_hMenu); + ::SetMenu(m_hWnd, m_Menu.m_hMenu); return; } @@ -214,16 +200,16 @@ { if(m_VstPlugin.GetNumPrograms() > 0) { - if(m_pMenu->GetMenuItemCount() < 5) + if(m_Menu.GetMenuItemCount() < 5) { - m_pMenu->AppendMenu(MF_BYPOSITION, ID_VSTPRESETBACKWARDJUMP, TEXT("<<")); - m_pMenu->AppendMenu(MF_BYPOSITION, ID_PREVIOUSVSTPRESET, TEXT("<")); - m_pMenu->AppendMenu(MF_BYPOSITION, ID_NEXTVSTPRESET, TEXT(">")); - m_pMenu->AppendMenu(MF_BYPOSITION, ID_VSTPRESETFORWARDJUMP, TEXT(">>")); - m_pMenu->AppendMenu(MF_BYPOSITION|MF_DISABLED, 0, TEXT("")); + m_Menu.AppendMenu(MF_BYPOSITION, ID_VSTPRESETBACKWARDJUMP, TEXT("<<")); + m_Menu.AppendMenu(MF_BYPOSITION, ID_PREVIOUSVSTPRESET, TEXT("<")); + m_Menu.AppendMenu(MF_BYPOSITION, ID_NEXTVSTPRESET, TEXT(">")); + m_Menu.AppendMenu(MF_BYPOSITION, ID_VSTPRESETFORWARDJUMP, TEXT(">>")); + m_Menu.AppendMenu(MF_BYPOSITION|MF_DISABLED, 0, TEXT("")); } - m_pMenu->ModifyMenu(8, MF_BYPOSITION, 0, m_VstPlugin.GetFormattedProgramName(m_VstPlugin.GetCurrentProgram())); + m_Menu.ModifyMenu(8, MF_BYPOSITION, 0, m_VstPlugin.GetFormattedProgramName(m_VstPlugin.GetCurrentProgram())); } DrawMenuBar(); @@ -430,7 +416,7 @@ { case 0: // Grey out paste menu item. - m_pMenu->EnableMenuItem(ID_EDIT_PASTE, MF_BYCOMMAND | (IsClipboardFormatAvailable(clipboardFormat) ? 0 : MF_GRAYED)); + m_Menu.EnableMenuItem(ID_EDIT_PASTE, MF_BYCOMMAND | (IsClipboardFormatAvailable(clipboardFormat) ? 0 : MF_GRAYED)); break; case 1: // Generate preset menu on click. @@ -447,7 +433,7 @@ void CAbstractVstEditor::FillPresetMenu() //--------------------------------------- { - if(m_pPresetMenu->GetMenuItemCount() != 0) + if(m_PresetMenu.GetMenuItemCount() != 0) { // Already filled... return; @@ -468,7 +454,7 @@ CString label; label.Format("Bank %d (%d-%d)", bank + 1, prog, Util::Min(prog + PRESETS_PER_GROUP - 1, numProgs)); - m_pPresetMenu->AppendMenu(MF_POPUP | (bank % 32 == 0 ? MF_MENUBREAK : 0), reinterpret_cast<UINT_PTR>(m_pPresetMenuGroup[bank]->m_hMenu), label); + m_PresetMenu.AppendMenu(MF_POPUP | (bank % 32 == 0 ? MF_MENUBREAK : 0), reinterpret_cast<UINT_PTR>(m_pPresetMenuGroup[bank]->m_hMenu), label); } } @@ -477,7 +463,7 @@ int entryInThisColumn = 0; // If there would be only one sub menu, we add directly to factory menu - CMenu *targetMenu = (numProgs > PRESETS_PER_GROUP) ? m_pPresetMenuGroup[subMenuIndex] : m_pPresetMenu; + CMenu *targetMenu = (numProgs > PRESETS_PER_GROUP) ? m_pPresetMenuGroup[subMenuIndex] : &m_PresetMenu; for(VstInt32 p = 0; p < numProgs; p++) { @@ -511,7 +497,7 @@ const VstInt32 numProgs = m_VstPlugin.GetNumPrograms(); const VstInt32 curProg = m_VstPlugin.GetCurrentProgram(); - if(m_pPresetMenu->m_hMenu) // We rebuild menu from scratch + if(m_PresetMenu.m_hMenu) // We rebuild menu from scratch { // So remove any exiting menus... if(curProg == m_nCurProg && !force) // ... unless menu exists and is accurate, return; // in which case we are done. @@ -527,18 +513,18 @@ } m_pPresetMenuGroup.clear(); - m_pPresetMenu->DestroyMenu(); // Destroy Factory preset menu - m_pMenu->DeleteMenu(1, MF_BYPOSITION); + m_PresetMenu.DestroyMenu(); // Destroy Factory preset menu + m_Menu.DeleteMenu(1, MF_BYPOSITION); } - if(!m_pPresetMenu->m_hMenu) + if(!m_PresetMenu.m_hMenu) { // Create Factory preset menu - m_pPresetMenu->CreatePopupMenu(); + m_PresetMenu.CreatePopupMenu(); } // Add Factory menu to main menu - m_pMenu->InsertMenu(1, MF_BYPOSITION | MF_POPUP | (numProgs ? 0 : MF_GRAYED), reinterpret_cast<UINT_PTR>(m_pPresetMenu->m_hMenu), "&Presets"); + m_Menu.InsertMenu(1, MF_BYPOSITION | MF_POPUP | (numProgs ? 0 : MF_GRAYED), reinterpret_cast<UINT_PTR>(m_PresetMenu.m_hMenu), "&Presets"); // Depending on the plugin and its number of presets, creating the menu entries can take quite a while (e.g. Synth1), // so we fill the menu only on demand (when it is clicked), so that the editor GUI creation doesn't take forever. @@ -548,19 +534,19 @@ void CAbstractVstEditor::UpdateInputMenu() //---------------------------------------- { - CMenu *pInfoMenu = m_pMenu->GetSubMenu(2); + CMenu *pInfoMenu = m_Menu.GetSubMenu(2); pInfoMenu->DeleteMenu(0, MF_BYPOSITION); CModDoc* pModDoc = m_VstPlugin.GetModDoc(); CSoundFile* pSndFile = pModDoc->GetSoundFile(); - if(m_pInputMenu->m_hMenu) + if(m_InputMenu.m_hMenu) { - m_pInputMenu->DestroyMenu(); + m_InputMenu.DestroyMenu(); } - if(!m_pInputMenu->m_hMenu) + if(!m_InputMenu.m_hMenu) { - m_pInputMenu->CreatePopupMenu(); + m_InputMenu.CreatePopupMenu(); } CString name; @@ -570,7 +556,7 @@ for(size_t nPlug=0; nPlug < inputPlugs.size(); nPlug++) { 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); + m_InputMenu.AppendMenu(MF_STRING, ID_PLUGSELECT + inputPlugs[nPlug]->m_nSlot, name); } vector<CHANNELINDEX> inputChannels; @@ -579,10 +565,10 @@ { if(nChn == 0 && inputPlugs.size()) { - m_pInputMenu->AppendMenu(MF_SEPARATOR); + m_InputMenu.AppendMenu(MF_SEPARATOR); } name.Format("Chn%02d: %s", inputChannels[nChn] + 1, pSndFile->ChnSettings[inputChannels[nChn]].szName); - m_pInputMenu->AppendMenu(MF_STRING, NULL, name); + m_InputMenu.AppendMenu(MF_STRING, NULL, name); } vector<INSTRUMENTINDEX> inputInstruments; @@ -592,40 +578,40 @@ bool checked = false; if(nIns == 0 && (inputPlugs.size() || inputChannels.size())) { - m_pInputMenu->AppendMenu(MF_SEPARATOR); + m_InputMenu.AppendMenu(MF_SEPARATOR); } name.Format("Ins%02d: %s", inputInstruments[nIns], pSndFile->GetInstrumentName(inputInstruments[nIns])); if(inputInstruments[nIns] == m_nInstrument) checked = true; - m_pInputMenu->AppendMenu(MF_STRING | (checked ? MF_CHECKED : 0), ID_SELECTINST + inputInstruments[nIns], name); + m_InputMenu.AppendMenu(MF_STRING | (checked ? MF_CHECKED : 0), ID_SELECTINST + inputInstruments[nIns], name); } if(inputPlugs.size() == 0 && inputChannels.size() == 0 && inputInstruments.size() == 0) { - m_pInputMenu->AppendMenu(MF_STRING | MF_GRAYED, NULL, "None"); + m_InputMenu.AppendMenu(MF_STRING | MF_GRAYED, NULL, "None"); } - pInfoMenu->InsertMenu(0, MF_BYPOSITION | MF_POPUP, reinterpret_cast<UINT_PTR>(m_pInputMenu->m_hMenu), "I&nputs"); + pInfoMenu->InsertMenu(0, MF_BYPOSITION | MF_POPUP, reinterpret_cast<UINT_PTR>(m_InputMenu.m_hMenu), "I&nputs"); } void CAbstractVstEditor::UpdateOutputMenu() //----------------------------------------- { - CMenu *pInfoMenu = m_pMenu->GetSubMenu(2); + CMenu *pInfoMenu = m_Menu.GetSubMenu(2); pInfoMenu->DeleteMenu(1, MF_BYPOSITION); - if(m_pOutputMenu->m_hMenu) + if(m_OutputMenu.m_hMenu) { - m_pOutputMenu->DestroyMenu(); + m_OutputMenu.DestroyMenu(); } - if(!m_pOutputMenu->m_hMenu) + if(!m_OutputMenu.m_hMenu) { - m_pOutputMenu->CreatePopupMenu(); + m_OutputMenu.CreatePopupMenu(); } - vector<CVstPlugin *> outputPlugs; + std::vector<CVstPlugin *> outputPlugs; m_VstPlugin.GetOutputPlugList(outputPlugs); CString name; @@ -635,15 +621,15 @@ { 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); + m_OutputMenu.AppendMenu(MF_STRING, ID_PLUGSELECT + outputPlugs[nPlug]->m_nSlot, name); } else { name = "Master Output"; - m_pOutputMenu->AppendMenu(MF_STRING | MF_GRAYED, NULL, name); + m_OutputMenu.AppendMenu(MF_STRING | MF_GRAYED, NULL, name); } } - pInfoMenu->InsertMenu(1, MF_BYPOSITION | MF_POPUP, reinterpret_cast<UINT_PTR>(m_pOutputMenu->m_hMenu), "Ou&tputs"); + pInfoMenu->InsertMenu(1, MF_BYPOSITION | MF_POPUP, reinterpret_cast<UINT_PTR>(m_OutputMenu.m_hMenu), "Ou&tputs"); } @@ -660,16 +646,16 @@ return; } - CMenu *pInfoMenu = m_pMenu->GetSubMenu(2); + CMenu *pInfoMenu = m_Menu.GetSubMenu(2); pInfoMenu->DeleteMenu(2, MF_BYPOSITION); - if(m_pMacroMenu->m_hMenu) + if(m_MacroMenu.m_hMenu) { - m_pMacroMenu->DestroyMenu(); + m_MacroMenu.DestroyMenu(); } - if(!m_pMacroMenu->m_hMenu) + if(!m_MacroMenu.m_hMenu) { - m_pMacroMenu->CreatePopupMenu(); + m_MacroMenu.CreatePopupMenu(); } for(int nMacro = 0; nMacro < NUM_MACROS; nMacro++) @@ -696,39 +682,39 @@ } label.Format("SF%X: %s", nMacro, macroName); - m_pMacroMenu->AppendMenu(MF_STRING | (greyed ? MF_GRAYED : 0), action, label); + m_MacroMenu.AppendMenu(MF_STRING | (greyed ? MF_GRAYED : 0), action, label); } - pInfoMenu->InsertMenu(2, MF_BYPOSITION | MF_POPUP, reinterpret_cast<UINT_PTR>(m_pMacroMenu->m_hMenu), "&Macros"); + pInfoMenu->InsertMenu(2, MF_BYPOSITION | MF_POPUP, reinterpret_cast<UINT_PTR>(m_MacroMenu.m_hMenu), "&Macros"); } void CAbstractVstEditor::UpdateOptionsMenu() //------------------------------------------ { - if(m_pOptionsMenu->m_hMenu) - m_pOptionsMenu->DestroyMenu(); + if(m_OptionsMenu.m_hMenu) + m_OptionsMenu.DestroyMenu(); CInputHandler *ih = (CMainFrame::GetMainFrame())->GetInputHandler(); - m_pOptionsMenu->CreatePopupMenu(); + m_OptionsMenu.CreatePopupMenu(); //Bypass - m_pOptionsMenu->AppendMenu(MF_STRING | m_VstPlugin.IsBypassed() ? MF_CHECKED : 0, + m_OptionsMenu.AppendMenu(MF_STRING | m_VstPlugin.IsBypassed() ? MF_CHECKED : 0, ID_PLUG_BYPASS, "&Bypass Plugin\t" + ih->GetKeyTextFromCommand(kcVSTGUIBypassPlug)); //Record Params - m_pOptionsMenu->AppendMenu(MF_STRING | m_VstPlugin.m_bRecordAutomation ? MF_CHECKED : 0, + m_OptionsMenu.AppendMenu(MF_STRING | m_VstPlugin.m_bRecordAutomation ? MF_CHECKED : 0, ID_PLUG_RECORDAUTOMATION, "Record &Parameter Changes\t" + ih->GetKeyTextFromCommand(kcVSTGUIToggleRecordParams)); //Record MIDI Out - m_pOptionsMenu->AppendMenu(MF_STRING | m_VstPlugin.m_bRecordMIDIOut ? MF_CHECKED : 0, + m_OptionsMenu.AppendMenu(MF_STRING | m_VstPlugin.m_bRecordMIDIOut ? MF_CHECKED : 0, ID_PLUG_RECORD_MIDIOUT, "Record &MIDI Out to Pattern Editor\t" + ih->GetKeyTextFromCommand(kcVSTGUIToggleRecordMIDIOut)); //Pass on keypresses - m_pOptionsMenu->AppendMenu(MF_STRING | m_VstPlugin.m_bPassKeypressesToPlug ? MF_CHECKED : 0, + m_OptionsMenu.AppendMenu(MF_STRING | m_VstPlugin.m_bPassKeypressesToPlug ? MF_CHECKED : 0, ID_PLUG_PASSKEYS, "Pass &Keys to Plugin\t" + ih->GetKeyTextFromCommand(kcVSTGUIToggleSendKeysToPlug)); - m_pMenu->DeleteMenu(3, MF_BYPOSITION); - m_pMenu->InsertMenu(3, MF_BYPOSITION|MF_POPUP, reinterpret_cast<UINT_PTR>(m_pOptionsMenu->m_hMenu), "&Options"); + m_Menu.DeleteMenu(3, MF_BYPOSITION); + m_Menu.InsertMenu(3, MF_BYPOSITION|MF_POPUP, reinterpret_cast<UINT_PTR>(m_OptionsMenu.m_hMenu), "&Options"); } @@ -776,7 +762,7 @@ } */ //Then just take the first instrument that points to this plug.. - vector<INSTRUMENTINDEX> plugInstrumentList; + std::vector<INSTRUMENTINDEX> plugInstrumentList; m_VstPlugin.GetInputInstrumentList(plugInstrumentList); if(plugInstrumentList.size()) { @@ -892,4 +878,4 @@ return m_nLearnMacro; } -#endif // NO_VST +#endif // NO_VST \ No newline at end of file Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2013-04-07 17:38:33 UTC (rev 1768) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2013-04-07 18:35:32 UTC (rev 1769) @@ -66,13 +66,13 @@ DECLARE_MESSAGE_MAP() private: - CMenu *m_pMenu; - CMenu *m_pPresetMenu; - vector<CMenu *> m_pPresetMenuGroup; - CMenu *m_pInputMenu; - CMenu *m_pOutputMenu; - CMenu *m_pMacroMenu; - CMenu *m_pOptionsMenu; + CMenu m_Menu; + CMenu m_PresetMenu; + std::vector<CMenu *> m_pPresetMenuGroup; + CMenu m_InputMenu; + CMenu m_OutputMenu; + CMenu m_MacroMenu; + CMenu m_OptionsMenu; static UINT clipboardFormat; void FillPresetMenu(); @@ -86,7 +86,7 @@ bool ValidateCurrentInstrument(); INSTRUMENTINDEX m_nInstrument; int m_nLearnMacro; - + void OnToggleEditor(UINT nID); void OnSetInputInstrument(UINT nID); afx_msg void OnInitMenu(CMenu* pMenu); @@ -97,4 +97,3 @@ #endif // NO_VST - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-04-07 21:29:22
|
Revision: 1771 http://sourceforge.net/p/modplug/code/1771 Author: saga-games Date: 2013-04-07 21:29:10 +0000 (Sun, 07 Apr 2013) Log Message: ----------- [Imp] If a plugin editor is focussed, MIDI is now always routed to that plugin. [Imp] MIDI CC shortcuts should now work in all places. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp trunk/OpenMPT/mptrack/MIDIMappingDialog.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Mpt_midi.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_gen.h trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/view_com.cpp trunk/OpenMPT/mptrack/view_com.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -28,6 +28,7 @@ ON_WM_CLOSE() ON_WM_INITMENU() ON_WM_MENUSELECT() + ON_WM_SETFOCUS() ON_COMMAND(ID_EDIT_COPY, OnCopyParameters) ON_COMMAND(ID_EDIT_PASTE, OnPasteParameters) ON_COMMAND(ID_PRESET_LOAD, OnLoadPreset) @@ -43,6 +44,7 @@ ON_COMMAND(ID_VSTPRESETFORWARDJUMP, OnVSTPresetForwardJump) ON_COMMAND(ID_PLUGINTOINSTRUMENT, OnCreateInstrument) ON_COMMAND_RANGE(ID_PRESET_SET, ID_PRESET_SET + MAX_PLUGPRESETS, OnSetPreset) + ON_MESSAGE(WM_MOD_MIDIMSG, OnMidiMsg) ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys ON_COMMAND_RANGE(ID_PLUGSELECT, ID_PLUGSELECT + MAX_MIXPLUGINS, OnToggleEditor) //rewbs.patPlugName ON_COMMAND_RANGE(ID_SELECTINST, ID_SELECTINST + MAX_INSTRUMENTS, OnSetInputInstrument) //rewbs.patPlugName @@ -85,6 +87,29 @@ } +void CAbstractVstEditor::OnSetFocus(CWnd *oldWnd) +//----------------------------------------------- +{ + CDialog::OnSetFocus(oldWnd); + CMainFrame::GetMainFrame()->SetMidiRecordWnd(GetSafeHwnd()); +} + + +LRESULT CAbstractVstEditor::OnMidiMsg(WPARAM midiData, LPARAM) +//------------------------------------------------------------ +{ + CModDoc *modDoc = m_VstPlugin.GetModDoc(); + if(modDoc != nullptr) + { + if(!CheckInstrument(m_nInstrument)) + m_nInstrument = GetBestInstrumentCandidate(); + modDoc->ProcessMIDI(midiData, m_nInstrument, &m_VstPlugin, kCtxVSTGUI); + return 1; + } + return 0; +} + + void CAbstractVstEditor::OnLoadPreset() //------------------------------------- { @@ -738,8 +763,8 @@ } -bool CAbstractVstEditor::CheckInstrument(INSTRUMENTINDEX ins) -//----------------------------------------------------------- +bool CAbstractVstEditor::CheckInstrument(INSTRUMENTINDEX ins) const +//----------------------------------------------------------------- { const CSoundFile &sndFile = m_VstPlugin.GetSoundFile(); @@ -751,8 +776,8 @@ } -INSTRUMENTINDEX CAbstractVstEditor::GetBestInstrumentCandidate() -//-------------------------------------------------------------- +INSTRUMENTINDEX CAbstractVstEditor::GetBestInstrumentCandidate() const +//-------------------------------------------------------------------- { //First try current instrument: /* CModDoc* pModDoc = m_pVstPlugin->GetModDoc(); Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2013-04-07 21:29:10 UTC (rev 1771) @@ -51,6 +51,7 @@ afx_msg void OnCreateInstrument(); afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hMenu); afx_msg LRESULT OnCustomKeyMsg(WPARAM, LPARAM); //rewbs.customKeys + afx_msg LRESULT OnMidiMsg(WPARAM, LPARAM); //Overridden methods: virtual void OnOK() = 0; @@ -59,6 +60,7 @@ virtual void DoClose() = 0; virtual void UpdateParamDisplays() = 0; virtual afx_msg void OnClose() = 0; + void OnSetFocus(CWnd *oldWnd); virtual bool IsResizable() const = 0; virtual bool SetSize(int contentWidth, int contentHeight) = 0; @@ -81,8 +83,8 @@ void UpdateOutputMenu(); void UpdateMacroMenu(); void UpdateOptionsMenu(); - INSTRUMENTINDEX GetBestInstrumentCandidate(); - bool CheckInstrument(INSTRUMENTINDEX ins); + INSTRUMENTINDEX GetBestInstrumentCandidate() const; + bool CheckInstrument(INSTRUMENTINDEX ins) const; bool ValidateCurrentInstrument(); INSTRUMENTINDEX m_nInstrument; int m_nLearnMacro; Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -31,7 +31,7 @@ SetKey(HOTKEYF_MIDI, MIDIEvents::GetDataByte1FromEvent(dwMidiDataParam)); m_pOptKeyDlg->OnSetKeyChoice(); } - return 0; + return 1; } Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -23,13 +23,17 @@ m_rMIDIMapper(m_rSndFile.GetMIDIMapper()) //--------------------------------------------------------------------- { + oldMIDIRecondWnd = CMainFrame::GetMainFrame()->GetMidiRecordWnd(); } + CMIDIMappingDialog::~CMIDIMappingDialog() //--------------------------------------- { + CMainFrame::GetMainFrame()->SetMidiRecordWnd(oldMIDIRecondWnd); } + void CMIDIMappingDialog::DoDataExchange(CDataExchange* pDX) //--------------------------------------------------------- { @@ -76,7 +80,7 @@ OnCbnSelchangeComboController(); UpdateString(); } - return 0; + return 1; } @@ -102,7 +106,7 @@ //Add plugin parameter names AddPluginParameternamesToCombobox(m_PlugParamCBox, m_rSndFile.m_MixPlugins[(m_Setting.GetPlugIndex() <= MAX_MIXPLUGINS) ? m_Setting.GetPlugIndex() - 1 : 0]); m_PlugParamCBox.SetCurSel(m_Setting.GetParamIndex()); - + //Add directives to list. typedef CMIDIMapper::const_iterator CITER; for(CITER iter = m_rMIDIMapper.Begin(); iter != m_rMIDIMapper.End(); iter++) @@ -238,7 +242,7 @@ { if(m_EventCBox.GetCurSel() == 0) { - m_Setting.SetEvent(0xB); + m_Setting.SetEvent(0xB); m_ControllerCBox.EnableWindow(); } else @@ -315,7 +319,7 @@ CString CMIDIMappingDialog::CreateListString(const CMIDIMappingDirective& s) -//---------------------------------------------------------------------------- +//-------------------------------------------------------------------------- { CString str; str.Preallocate(100); Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.h 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.h 2013-04-07 21:29:10 UTC (rev 1771) @@ -40,6 +40,7 @@ private: CSoundFile& m_rSndFile; CMIDIMapper& m_rMIDIMapper; + HWND oldMIDIRecondWnd; private: void UpdateString(); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -2605,13 +2605,10 @@ //---------------------------------- { CModDoc* pModDoc = GetActiveDoc(); - CSoundFile* pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : nullptr; - if(!pSndFile) return; + if(!pModDoc) return; - const HWND oldMIDIRecondWnd = GetMidiRecordWnd(); - CMIDIMappingDialog dlg(this, *pSndFile); + CMIDIMappingDialog dlg(this, pModDoc->GetrSoundFile()); dlg.DoModal(); - SetMidiRecordWnd(oldMIDIRecondWnd); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -905,6 +905,80 @@ } +void CModDoc::ProcessMIDI(uint32 midiData, INSTRUMENTINDEX ins, IMixPlugin *plugin, InputTargetContext ctx) +//--------------------------------------------------------------------------------------------------------- +{ + static uint8 midiVolume = 127; + + MIDIEvents::EventType event = MIDIEvents::GetTypeFromEvent(midiData); + uint8 midiByte1 = MIDIEvents::GetDataByte1FromEvent(midiData); + uint8 midiByte2 = MIDIEvents::GetDataByte2FromEvent(midiData); + uint8 note = midiByte1 + NOTE_MIN; + int vol = midiByte2; + + if((event == MIDIEvents::evNoteOn) && !vol) event = MIDIEvents::evNoteOff; //Convert event to note-off if req'd + + uint8 mappedIndex = 0, paramValue = 0; + uint32 paramIndex = 0; + bool captured = m_SndFile.GetMIDIMapper().OnMIDImsg(midiData, mappedIndex, paramIndex, paramValue); + + // Handle MIDI messages assigned to shortcuts + CInputHandler *ih = CMainFrame::GetMainFrame()->GetInputHandler(); + if(ih->HandleMIDIMessage(ctx, midiData) != kcNull + || ih->HandleMIDIMessage(kCtxAllContexts, midiData) != kcNull) + { + // Mapped to a command, no need to pass message on. + captured = true; + } + + if(captured) + { + // Event captured by MIDI mapping or shortcut, no need to pass message on. + return; + } + + switch(event) + { + case MIDIEvents::evNoteOff: + midiByte2 = 0; + + case MIDIEvents::evNoteOn: + if(ins > 0 && ins <= GetNumInstruments()) + { + LimitMax(note, NOTE_MAX); + NoteOff(note, false, ins); + if(midiByte2 & 0x7F) + { + vol = CMainFrame::ApplyVolumeRelatedSettings(midiData, midiVolume); + PlayNote(note, ins, 0, false, vol); + } + return; + } + break; + + case MIDIEvents::evControllerChange: + if(midiByte1 == MIDIEvents::MIDICC_Volume_Coarse) + { + midiVolume = midiByte2; + break; + } + } + + if((TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDITOPLUG) && CMainFrame::GetMainFrame()->GetModPlaying() == this && plugin != nullptr) + { + plugin->MidiSend(midiData); + // Sending midi may modify the plug. For now, if MIDI data is not active sensing or aftertouch messages, set modified. + if(midiData != MIDIEvents::System(MIDIEvents::sysActiveSense) + && event != MIDIEvents::evPolyAftertouch && event != MIDIEvents::evChannelAftertouch + && event != MIDIEvents::evPitchBend + && m_SndFile.GetModSpecifications().supportsPlugins) + { + CMainFrame::GetMainFrame()->ThreadSafeSetModified(this); + } + } +} + + CHANNELINDEX CModDoc::PlayNote(UINT note, INSTRUMENTINDEX nins, SAMPLEINDEX nsmp, bool pause, LONG nVol, SmpLength loopStart, SmpLength loopEnd, CHANNELINDEX nCurrentChn, const SmpLength sampleOffset) //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ { @@ -1023,11 +1097,11 @@ { // UINT nPlugin = m_SndFile.GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, EVEN_IF_MUTED); - UINT nPlugin = 0; + PLUGINDEX nPlugin = 0; if (pChn->pModInstrument) - nPlugin = pChn->pModInstrument->nMixPlug; // first try instrument VST + nPlugin = pChn->pModInstrument->nMixPlug; // First try instrument plugin if ((!nPlugin || nPlugin > MAX_MIXPLUGINS) && nCurrentChn != CHANNELINDEX_INVALID) - nPlugin = m_SndFile.ChnSettings[nCurrentChn].nMixPlugin; // Then try Channel VST + nPlugin = m_SndFile.ChnSettings[nCurrentChn].nMixPlugin; // Then try channel plugin if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS)) { @@ -1421,7 +1495,7 @@ void CModDoc::SetFollowWnd(HWND hwnd) -//------------------------------------------------- +//----------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); m_hWndFollow = hwnd; Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-04-07 21:29:10 UTC (rev 1771) @@ -142,6 +142,7 @@ LogEventUnexpectedError }; +enum InputTargetContext; //============================= class CModDoc: public CDocument @@ -252,6 +253,7 @@ bool RemoveSample(SAMPLEINDEX nSmp); bool RemoveInstrument(INSTRUMENTINDEX nIns); + void ProcessMIDI(uint32 midiData, INSTRUMENTINDEX ins, IMixPlugin *plugin, InputTargetContext ctx); CHANNELINDEX PlayNote(UINT note, INSTRUMENTINDEX nins, SAMPLEINDEX nsmp, bool pause, LONG nVol=-1, SmpLength loopStart = 0, SmpLength loopEnd = 0, CHANNELINDEX nCurrentChn = CHANNELINDEX_INVALID, const SmpLength sampleOffset = 0); bool NoteOff(UINT note, bool fade = false, INSTRUMENTINDEX ins = INSTRUMENTINDEX_INVALID, CHANNELINDEX currentChn = CHANNELINDEX_INVALID, CHANNELINDEX stopChn = CHANNELINDEX_INVALID); //rewbs.vstiLive: add params Modified: trunk/OpenMPT/mptrack/Mpt_midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpt_midi.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/Mpt_midi.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -72,8 +72,6 @@ ///////////////////////////////////////////////////////////////////////////// // MMSYSTEM Midi Record -DWORD gdwLastMidiEvtTime = 0; - void CALLBACK MidiInCallBack(HMIDIIN, UINT wMsg, DWORD, DWORD dwParam1, DWORD dwParam2) //------------------------------------------------------------------------------------- { @@ -90,29 +88,25 @@ #endif hWndMidi = pMainFrm->GetMidiRecordWnd(); - if ((hWndMidi) && ((wMsg == MIM_DATA) || (wMsg == MIM_MOREDATA))) + if(wMsg == MIM_DATA || wMsg == MIM_MOREDATA) { - switch(MIDIEvents::GetTypeFromEvent(dwParam1)) + if(::IsWindow(hWndMidi)) { - case MIDIEvents::evSystem: // Midi Clock - if (wMsg == MIM_DATA) - { - DWORD dwTime = timeGetTime(); - const DWORD timediff = dwTime - gdwLastMidiEvtTime; - if (timediff < 20 * 3) break; - - gdwLastMidiEvtTime = dwTime; // continue - } - else break; - + switch(MIDIEvents::GetTypeFromEvent(dwParam1)) + { case MIDIEvents::evNoteOff: // Note Off case MIDIEvents::evNoteOn: // Note On ApplyTransposeKeyboardSetting(*pMainFrm, dwParam1); + // Intentional fall-through default: - ::PostMessage(hWndMidi, WM_MOD_MIDIMSG, dwParam1, dwParam2); - break; + if(::SendMessage(hWndMidi, WM_MOD_MIDIMSG, dwParam1, dwParam2)) + return; // Message has been handled + break; + } } + // Pass MIDI to keyboard handler + pMainFrm->GetInputHandler()->HandleMIDIMessage(kCtxAllContexts, dwParam1); } } Modified: trunk/OpenMPT/mptrack/View_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_gen.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/View_gen.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -109,6 +109,7 @@ ON_NOTIFY(TCN_SELCHANGE, IDC_TABCTRL1, OnTabSelchange) ON_MESSAGE(WM_MOD_UNLOCKCONTROLS, OnUnlockControls) ON_MESSAGE(WM_MOD_VIEWMSG, OnModViewMsg) + ON_MESSAGE(WM_MOD_MIDIMSG, OnMidiMsg) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -269,6 +270,17 @@ // -! NEW_FEATURE#0015 +LRESULT CViewGlobals::OnMidiMsg(WPARAM midiData, LPARAM) +//------------------------------------------------------ +{ + // Handle MIDI messages assigned to shortcuts + CInputHandler *ih = CMainFrame::GetMainFrame()->GetInputHandler(); + ih->HandleMIDIMessage(kCtxViewGeneral, midiData) != kcNull + || ih->HandleMIDIMessage(kCtxAllContexts, midiData) != kcNull; + return 1; +} + + void CViewGlobals::RecalcLayout() //------------------------------- { Modified: trunk/OpenMPT/mptrack/View_gen.h =================================================================== --- trunk/OpenMPT/mptrack/View_gen.h 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/View_gen.h 2013-04-07 21:29:10 UTC (rev 1771) @@ -78,6 +78,7 @@ virtual void UpdateView(DWORD dwHintMask=0, CObject *pObj=NULL); virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); virtual LRESULT OnModViewMsg(WPARAM, LPARAM); + LRESULT OnMidiMsg(WPARAM midiData, LPARAM); virtual HBRUSH OnCtlColor(CDC *pDC, CWnd* pWnd, UINT nCtlColor); // -> CODE#0015 Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -2132,91 +2132,19 @@ } -LRESULT CViewInstrument::OnMidiMsg(WPARAM dwMidiDataParam, LPARAM) -//----------------------------------------------------------- +LRESULT CViewInstrument::OnMidiMsg(WPARAM midiData, LPARAM) +//--------------------------------------------------------- { - const DWORD dwMidiData = dwMidiDataParam; - static BYTE midivolume = 127; - - CModDoc *pModDoc = GetDocument(); - if(pModDoc == nullptr) + CModDoc *modDoc = GetDocument(); + if(modDoc != nullptr) { - return 0; + modDoc->ProcessMIDI(midiData, m_nInstrument, modDoc->GetrSoundFile().GetInstrumentPlugin(m_nInstrument), kCtxViewInstruments); + return 1; } - CSoundFile &sndFile = pModDoc->GetrSoundFile(); - - BYTE midiByte1 = MIDIEvents::GetDataByte1FromEvent(dwMidiData); - BYTE midiByte2 = MIDIEvents::GetDataByte2FromEvent(dwMidiData); - - uint8 nNote = midiByte1 + NOTE_MIN; - int nVol = midiByte2; - MIDIEvents::EventType event = MIDIEvents::GetTypeFromEvent(dwMidiData); - if((event == MIDIEvents::evNoteOn) && !nVol) event = MIDIEvents::evNoteOff; //Convert event to note-off if req'd - - BYTE mappedIndex = 0, paramValue = 0; - uint32 paramIndex = 0; - bool captured = sndFile.GetMIDIMapper().OnMIDImsg(dwMidiData, mappedIndex, paramIndex, paramValue); - - // Handle MIDI messages assigned to shortcuts - CInputHandler *ih = CMainFrame::GetMainFrame()->GetInputHandler(); - if(ih->HandleMIDIMessage(kCtxViewInstruments, dwMidiData) != kcNull - || ih->HandleMIDIMessage(kCtxAllContexts, dwMidiData) != kcNull) - { - // Mapped to a command, no need to pass message on. - captured = true; - } - - if(captured) - { - // Event captured by MIDI mapping or shortcut, no need to pass message on. - return 0; - } - - switch(event) - { - case MIDIEvents::evNoteOff: // Note Off - midiByte2 = 0; - - case MIDIEvents::evNoteOn: // Note On - LimitMax(nNote, NOTE_MAX); - pModDoc->NoteOff(nNote, false, m_nInstrument); - if(midiByte2 & 0x7F) - { - nVol = CMainFrame::ApplyVolumeRelatedSettings(dwMidiData, midivolume); - pModDoc->PlayNote(nNote, m_nInstrument, 0, false, nVol); - } - break; - - case MIDIEvents::evControllerChange: //Controller change - switch(midiByte1) - { - case MIDIEvents::MIDICC_Volume_Coarse: //Volume - midivolume = midiByte2; - break; - } - - default: - if((TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDITOPLUG) && CMainFrame::GetMainFrame()->GetModPlaying() == pModDoc) - { - const INSTRUMENTINDEX instr = m_nInstrument; - IMixPlugin* plug = sndFile.GetInstrumentPlugin(instr); - if(plug) - { - plug->MidiSend(dwMidiData); - // Sending midi may modify the plug. For now, if MIDI data - // is not active sensing or aftertouch messages, set modified. - if(dwMidiData != MIDIEvents::System(MIDIEvents::sysActiveSense) && event != MIDIEvents::evPolyAftertouch && event != MIDIEvents::evChannelAftertouch && sndFile.GetModSpecifications().supportsPlugins) - { - CMainFrame::GetMainFrame()->ThreadSafeSetModified(pModDoc); - } - } - } - break; - } - return 0; } + BOOL CViewInstrument::PreTranslateMessage(MSG *pMsg) //-------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -3794,7 +3794,7 @@ if(captured) { // Event captured by MIDI mapping or shortcut, no need to pass message on. - return 0; + return 1; } switch(event) @@ -3898,7 +3898,7 @@ break; } - return 0; + return 1; } Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -2641,7 +2641,7 @@ || ih->HandleMIDIMessage(kCtxAllContexts, dwMidiData) != kcNull) { // Mapped to a command, no need to pass message on. - return 0; + return 1; } switch(event) @@ -2670,7 +2670,7 @@ break; } - return 0; + return 1; } BOOL CViewSample::PreTranslateMessage(MSG *pMsg) Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -2594,12 +2594,10 @@ // Shift pressed -> Open MIDI mapping dialog CMainFrame::GetInputHandler()->SetModifierMask(0); // Make sure that the dialog will open only once. - const HWND oldMIDIRecondWnd = CMainFrame::GetMainFrame()->GetMidiRecordWnd(); CMIDIMappingDialog dlg(pVstEditor, pModDoc->GetrSoundFile()); dlg.m_Setting.SetParamIndex(param); dlg.m_Setting.SetPlugIndex(GetSlot() + 1); dlg.DoModal(); - CMainFrame::GetMainFrame()->SetMidiRecordWnd(oldMIDIRecondWnd); } // Learn macro Modified: trunk/OpenMPT/mptrack/view_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/view_com.cpp 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/view_com.cpp 2013-04-07 21:29:10 UTC (rev 1771) @@ -96,6 +96,7 @@ //{{AFX_MSG_MAP(CViewComments) ON_WM_SIZE() ON_WM_DESTROY() + ON_MESSAGE(WM_MOD_MIDIMSG, OnMidiMsg) ON_COMMAND(IDC_LIST_SAMPLES, OnShowSamples) ON_COMMAND(IDC_LIST_INSTRUMENTS, OnShowInstruments) ON_COMMAND(IDC_LIST_PATTERNS, OnShowPatterns) @@ -177,6 +178,17 @@ } +LRESULT CViewComments::OnMidiMsg(WPARAM midiData, LPARAM) +//------------------------------------------------------- +{ + // Handle MIDI messages assigned to shortcuts + CInputHandler *ih = CMainFrame::GetMainFrame()->GetInputHandler(); + ih->HandleMIDIMessage(kCtxViewComments, midiData) != kcNull + || ih->HandleMIDIMessage(kCtxAllContexts, midiData) != kcNull; + return 1; +} + + /////////////////////////////////////////////////////////////// // CViewComments drawing Modified: trunk/OpenMPT/mptrack/view_com.h =================================================================== --- trunk/OpenMPT/mptrack/view_com.h 2013-04-07 20:55:21 UTC (rev 1770) +++ trunk/OpenMPT/mptrack/view_com.h 2013-04-07 21:29:10 UTC (rev 1771) @@ -44,6 +44,7 @@ virtual void OnInitialUpdate(); virtual void OnUpdate(CView *pSender, LPARAM lHint, CObject *pHint); virtual LRESULT OnModViewMsg(WPARAM, LPARAM); + LRESULT OnMidiMsg(WPARAM midiData, LPARAM); //}}AFX_VIRTUAL protected: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-04-08 16:34:18
|
Revision: 1777 http://sourceforge.net/p/modplug/code/1777 Author: manxorist Date: 2013-04-08 16:34:04 +0000 (Mon, 08 Apr 2013) Log Message: ----------- [Ref] Do less work in NotifyThread. Move searching for the newest notification to the main thread and let the notify thread only forward a rate-limited trigger. This also fixes an obscure race condition when clicking stop and clearing the notification buffer while a notification was pending. Modified Paths: -------------- trunk/OpenMPT/mptrack/InputHandler.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h Modified: trunk/OpenMPT/mptrack/InputHandler.h =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.h 2013-04-08 10:38:15 UTC (rev 1776) +++ trunk/OpenMPT/mptrack/InputHandler.h 2013-04-08 16:34:04 UTC (rev 1777) @@ -14,7 +14,7 @@ enum { WM_MOD_UPDATEPOSITION = (WM_USER+1973), - WM_MOD_UPDATEPOSITIONTHREADED, + WM_MOD_NOTIFICATION, WM_MOD_INVALIDATEPATTERNS, WM_MOD_ACTIVATEVIEW, WM_MOD_CHANGEVIEWCLASS, Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-08 10:38:15 UTC (rev 1776) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-04-08 16:34:04 UTC (rev 1777) @@ -85,8 +85,8 @@ ON_UPDATE_COMMAND_UI(ID_INDICATOR_XINFO,OnUpdateXInfo) //rewbs.xinfo ON_UPDATE_COMMAND_UI(ID_INDICATOR_CPU, OnUpdateCPU) ON_UPDATE_COMMAND_UI(IDD_TREEVIEW, OnUpdateControlBarMenu) + ON_MESSAGE(WM_MOD_NOTIFICATION, OnNotification) ON_MESSAGE(WM_MOD_UPDATEPOSITION, OnUpdatePosition) - ON_MESSAGE(WM_MOD_UPDATEPOSITIONTHREADED, OnUpdatePositionThreaded) ON_MESSAGE(WM_MOD_INVALIDATEPATTERNS, OnInvalidatePatterns) ON_MESSAGE(WM_MOD_SPECIALKEY, OnSpecialKey) ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys @@ -670,83 +670,35 @@ DWORD CMainFrame::NotifyThread() //------------------------------ { - // initialize thread message queue MSG msg; - PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); -#ifdef NDEBUG - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL ); // we shall not stall the audio thread while holding m_NotificationBufferMutex -#endif + PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); // initialize thread message queue bool terminate = false; bool cansend = true; while(!terminate) { - switch(MsgWaitForMultipleObjects(1, &m_hNotifyWakeUp, FALSE, 1000, QS_ALLEVENTS)) + HANDLE waitHandles[2]; + waitHandles[0] = m_PendingNotificationSempahore; + waitHandles[1] = m_hNotifyWakeUp; + switch(MsgWaitForMultipleObjects(2, waitHandles, FALSE, 1000, QS_ALLEVENTS)) { + case WAIT_OBJECT_0 + 0: + // last notification has been handled by gui thread + cansend = true; + break; case WAIT_OBJECT_0 + 1: - { - while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + if(cansend) { - if(msg.message == WM_QUIT) terminate = true; + if(PostMessage(WM_MOD_NOTIFICATION, 0, 0)) + { + // message sent, do not send any more until it has been handled + cansend = false; + } } - } break; - case WAIT_OBJECT_0: + case WAIT_OBJECT_0 + 2: + while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - const Notification * pnotify = nullptr; - { - int64 currenttotalsamples = 0; - bool currenttotalsamplesValid = false; - { - CriticalSection cs; - if(gpSoundDevice && gpSoundDevice->HasGetStreamPosition()) - { - currenttotalsamples = gpSoundDevice->GetStreamPositionSamples(); - currenttotalsamplesValid = true; - } - } - // advance to the newest notification, drop the obsolete ones - Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); - if(!currenttotalsamplesValid) - { - currenttotalsamples = m_TotalSamplesRendered; - currenttotalsamplesValid = true; - } - const Notification * p = m_NotifyBuffer.peek_p(); - if(p && currenttotalsamples >= p->timestampSamples) - { - pnotify = p; - while(m_NotifyBuffer.peek_next_p() && currenttotalsamples >= m_NotifyBuffer.peek_next_p()->timestampSamples) - { - m_NotifyBuffer.pop(); - p = m_NotifyBuffer.peek_p(); - pnotify = p; - } - } - } - if(pnotify) - { - if(!cansend) - { - // poll the semaphore instead of waiting directly after sending the message to avoid deadlocks on termination of openmpt or when stopping audio rendering - if(WaitForSingleObject(m_PendingNotificationSempahore, 0) == WAIT_OBJECT_0) - { - // last notification has been handled by gui thread, so we can pop the notify buffer - cansend = true; - } - } - if(cansend) - { - m_PendingNotification = *pnotify; // copy notification so that we can free the buffer - { - Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); - m_NotifyBuffer.pop(); - } - if(PostMessage(WM_MOD_UPDATEPOSITIONTHREADED, 0, 0)) - { - cansend = false; - } - } - } + if(msg.message == WM_QUIT) terminate = true; } break; } @@ -755,6 +707,60 @@ } +LRESULT CMainFrame::OnNotification(WPARAM, LPARAM) +//------------------------------------------------ +{ + Notification PendingNotification; + bool found = false; + int64 currenttotalsamples = 0; + bool currenttotalsamplesValid = false; + { + CriticalSection cs; + if(gpSoundDevice && gpSoundDevice->HasGetStreamPosition()) + { + currenttotalsamples = gpSoundDevice->GetStreamPositionSamples(); + currenttotalsamplesValid = true; + } + } + { + // advance to the newest notification, drop the obsolete ones + Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); + if(!currenttotalsamplesValid) + { + currenttotalsamples = m_TotalSamplesRendered; + currenttotalsamplesValid = true; + } + const Notification * pnotify = nullptr; + const Notification * p = m_NotifyBuffer.peek_p(); + if(p && currenttotalsamples >= p->timestampSamples) + { + pnotify = p; + while(m_NotifyBuffer.peek_next_p() && currenttotalsamples >= m_NotifyBuffer.peek_next_p()->timestampSamples) + { + m_NotifyBuffer.pop(); + p = m_NotifyBuffer.peek_p(); + pnotify = p; + } + } + if(pnotify) + { + PendingNotification = *pnotify; // copy notification so that we can free the buffer + found = true; + { + Util::lock_guard<Util::mutex> lock(m_NotificationBufferMutex); + m_NotifyBuffer.pop(); + } + } + } + if(found) + { + OnUpdatePosition(0, (LPARAM)&PendingNotification); + } + ReleaseSemaphore(m_PendingNotificationSempahore, 1, NULL); + return 0; +} + + void CMainFrame::SetAudioThreadActive(bool active) //------------------------------------------------ { @@ -2283,17 +2289,6 @@ } -LRESULT CMainFrame::OnUpdatePositionThreaded(WPARAM, LPARAM) -//---------------------------------------------------------- -{ - Notification * pnotify = &m_PendingNotification; - LRESULT retval = OnUpdatePosition(0, (LPARAM)pnotify); - // for all notifications which were delivered via the notification thread, release the semaphore - ReleaseSemaphore(m_PendingNotificationSempahore, 1, NULL); - return retval; -} - - LRESULT CMainFrame::OnUpdatePosition(WPARAM, LPARAM lParam) //--------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-08 10:38:15 UTC (rev 1776) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-04-08 16:34:04 UTC (rev 1777) @@ -323,7 +323,6 @@ int64 m_TotalSamplesRendered; Util::fixed_size_queue<Notification,MAX_UPDATE_HISTORY> m_NotifyBuffer; HANDLE m_PendingNotificationSempahore; // protects the one notification that is in flight from the notification thread to the gui thread from being freed while the gui thread still uses it - Notification m_PendingNotification; // Instrument preview in tree view CSoundFile m_WaveFile; @@ -530,8 +529,8 @@ afx_msg void OnPanic(); afx_msg void OnReportBug(); //rewbs.customKeys afx_msg BOOL OnInternetLink(UINT nID); + afx_msg LRESULT OnNotification(WPARAM, LPARAM lParam); afx_msg LRESULT OnUpdatePosition(WPARAM, LPARAM lParam); - afx_msg LRESULT OnUpdatePositionThreaded(WPARAM, LPARAM lParam); afx_msg void OnExampleSong(UINT nId); afx_msg void OnOpenTemplateModule(UINT nId); afx_msg LRESULT OnInvalidatePatterns(WPARAM, LPARAM); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |