From: <sag...@us...> - 2011-11-18 22:52:27
|
Revision: 1138 http://modplug.svn.sourceforge.net/modplug/?rev=1138&view=rev Author: saga-games Date: 2011-11-18 22:52:19 +0000 (Fri, 18 Nov 2011) Log Message: ----------- [Ref] Moved some of the MIDI Macro code around yet again. Should also work in VS2008 again. [Mod] OpenMPT: Version is now 1.20.00.54 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/mptrack.vcproj trunk/OpenMPT/mptrack/mptrack_08.vcproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters trunk/OpenMPT/mptrack/test/test.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Sndfile.cpp Added Paths: ----------- trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp trunk/OpenMPT/mptrack/MIDIMacroDialog.h trunk/OpenMPT/soundlib/MIDIMacros.cpp trunk/OpenMPT/soundlib/MIDIMacros.h Removed Paths: ------------- trunk/OpenMPT/mptrack/MIDIMacros.cpp trunk/OpenMPT/mptrack/MIDIMacros.h Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-11-18 22:30:48 UTC (rev 1137) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2011-11-18 22:52:19 UTC (rev 1138) @@ -9,7 +9,7 @@ #include "view_pat.h" #include "ChannelManagerDlg.h" #include "../common/StringFixer.h" -#include "MIDIMacros.h" +#include "MIDIMacroDialog.h" ////////////////////////////////////////////////////////////// Added: trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp (rev 0) +++ trunk/OpenMPT/mptrack/MIDIMacroDialog.cpp 2011-11-18 22:52:19 UTC (rev 1138) @@ -0,0 +1,531 @@ +/* + * MIDIMacroDialog.cpp + * ------------------- + * Purpose: MIDI Macro Configuration Dialog implementation + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + +#include "stdafx.h" +#include "../common/Reporting.h" +#include "../common/StringFixer.h" +#include "Mainfrm.h" +#include "mptrack.h" +#include "Vstplug.h" +#include "resource.h" +#include "MIDIMacros.h" +#include "MIDIMacroDialog.h" + + +BEGIN_MESSAGE_MAP(CMidiMacroSetup, CDialog) + ON_COMMAND(IDC_CHECK1, OnEmbedMidiCfg) + ON_COMMAND(IDC_BUTTON1, OnSetAsDefault) + ON_COMMAND(IDC_BUTTON2, OnResetCfg) + ON_COMMAND(IDC_BUTTON3, OnMacroHelp) + ON_CBN_SELCHANGE(IDC_COMBO1, OnSFxChanged) + ON_CBN_SELCHANGE(IDC_COMBO2, OnSFxPresetChanged) + ON_CBN_SELCHANGE(IDC_COMBO3, OnZxxPresetChanged) + ON_CBN_SELCHANGE(IDC_COMBO4, UpdateDialog) + ON_CBN_SELCHANGE(IDC_MACROPLUG, OnPlugChanged) + ON_CBN_SELCHANGE(IDC_MACROPARAM,OnPlugParamChanged) + ON_CBN_SELCHANGE(IDC_MACROCC, OnCCChanged) + ON_EN_CHANGE(IDC_EDIT1, OnSFxEditChanged) + ON_EN_CHANGE(IDC_EDIT2, OnZxxEditChanged) + ON_COMMAND_RANGE(ID_PLUGSELECT, ID_PLUGSELECT + NUM_MACROS - 1, OnViewAllParams) //rewbs.patPlugName + ON_COMMAND_RANGE(ID_PLUGSELECT + NUM_MACROS, ID_PLUGSELECT + NUM_MACROS + NUM_MACROS - 1, OnSetSFx) //rewbs.patPlugName +END_MESSAGE_MAP() + + +void CMidiMacroSetup::DoDataExchange(CDataExchange* pDX) +//------------------------------------------------------ +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CModTypeDlg) + DDX_Control(pDX, IDC_COMBO1, m_CbnSFx); + DDX_Control(pDX, IDC_COMBO2, m_CbnSFxPreset); + DDX_Control(pDX, IDC_COMBO3, m_CbnZxxPreset); + DDX_Control(pDX, IDC_COMBO4, m_CbnZxx); + DDX_Control(pDX, IDC_EDIT1, m_EditSFx); + DDX_Control(pDX, IDC_EDIT2, m_EditZxx); + DDX_Control(pDX, IDC_MACROPLUG, m_CbnMacroPlug); + DDX_Control(pDX, IDC_MACROPARAM, m_CbnMacroParam); + DDX_Control(pDX, IDC_MACROCC, m_CbnMacroCC); + //}}AFX_DATA_MAP +} + + +BOOL CMidiMacroSetup::OnInitDialog() +//---------------------------------- +{ + CHAR s[128]; + CDialog::OnInitDialog(); + CheckDlgButton(IDC_CHECK1, m_bEmbed ? BST_CHECKED : BST_UNCHECKED); + m_EditSFx.SetLimitText(MACRO_LENGTH - 1); + m_EditZxx.SetLimitText(MACRO_LENGTH - 1); + + for (UINT isfx=0; isfx<16; isfx++) + { + wsprintf(s, "%d (SF%X)", isfx, isfx); + m_CbnSFx.AddString(s); + } + m_CbnSFx.SetCurSel(0); + for(int i = 0; i < sfx_max; i++) + { + m_CbnSFxPreset.SetItemData(m_CbnSFxPreset.AddString(macroTools.GetMacroName(static_cast<enmParameteredMacroType>(i))), i); + } + OnSFxChanged(); + + for (int cc = MIDICC_start; cc <= MIDICC_end; cc++) + { + wsprintf(s, "CC %02d %s", cc, MidiCCNames[cc]); + m_CbnMacroCC.SetItemData(m_CbnMacroCC.AddString(s), cc); + } + + for (int zxx = 0; zxx < 128; zxx++) + { + wsprintf(s, "Z%02X", zxx | 0x80); + m_CbnZxx.AddString(s); + } + m_CbnZxx.SetCurSel(0); + m_CbnZxxPreset.AddString("Custom"); + m_CbnZxxPreset.AddString("Z80-Z8F controls resonance"); + m_CbnZxxPreset.AddString("Z80-ZFF controls resonance"); + m_CbnZxxPreset.AddString("Z80-ZFF controls cutoff"); + m_CbnZxxPreset.AddString("Z80-ZFF controls filter mode"); + m_CbnZxxPreset.AddString("Z80-Z9F controls resonance+mode"); + m_CbnZxxPreset.SetCurSel(macroTools.GetZxxType(m_MidiCfg.szMidiZXXExt)); + UpdateDialog(); + + int offsetx=108, offsety=30, separatorx=4, separatory=2, + height=18, widthMacro=30, widthVal=90, widthType=135, widthBtn=70; + + for (UINT m = 0; m < NUM_MACROS; m++) + { + m_EditMacro[m].Create("", /*BS_FLAT |*/ WS_CHILD | WS_VISIBLE | WS_TABSTOP /*| WS_BORDER*/, + CRect(offsetx, offsety + m * (separatory + height), offsetx + widthMacro, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + NUM_MACROS + m); + m_EditMacro[m].SetFont(GetFont()); + + m_EditMacroType[m].Create(ES_READONLY | WS_CHILD| WS_VISIBLE | WS_TABSTOP | WS_BORDER, + CRect(offsetx + separatorx + widthMacro, offsety + m* (separatory + height), offsetx + widthMacro + widthType, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + NUM_MACROS + m); + m_EditMacroType[m].SetFont(GetFont()); + + m_EditMacroValue[m].Create(ES_CENTER | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, + CRect(offsetx + separatorx + widthType + widthMacro, offsety + m * (separatory + height), offsetx + widthMacro + widthType + widthVal, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + NUM_MACROS + m); + m_EditMacroValue[m].SetFont(GetFont()); + + m_BtnMacroShowAll[m].Create("Show All...", WS_CHILD | WS_TABSTOP | WS_VISIBLE, + CRect(offsetx + separatorx + widthType + widthMacro + widthVal, offsety + m *(separatory + height), offsetx + widthMacro + widthType + widthVal + widthBtn, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + m); + m_BtnMacroShowAll[m].SetFont(GetFont()); + } + UpdateMacroList(); + + for (UINT plug=0; plug<MAX_MIXPLUGINS; plug++) + { + PSNDMIXPLUGIN p = &(m_SndFile.m_MixPlugins[plug]); + StringFixer::SetNullTerminator(p->Info.szLibraryName); + if (p->Info.szLibraryName[0]) + { + wsprintf(s, "FX%d: %s", plug+1, p->Info.szName); + m_CbnMacroPlug.SetItemData(m_CbnMacroPlug.AddString(s), plug); + } + } + m_CbnMacroPlug.SetCurSel(0); + OnPlugChanged(); + return FALSE; +} + + +// macro == -1 for updating all macros at once +void CMidiMacroSetup::UpdateMacroList(int macro) +//---------------------------------------------- +{ + if (!m_EditMacro[0]) + { + // GUI not yet initialized + return; + } + + int start, end; + + if (macro >= 0 && macro < 16) + { + start = end = macro; + } else + { + start = 0; + end = NUM_MACROS - 1; + } + + CString s; + const int selectedMacro = m_CbnSFx.GetCurSel(); + + for (int m = start; m <= end; m++) + { + // SFx + s.Format("SF%X", m); + m_EditMacro[m].SetWindowText(s); + + // Macro value: + CString macroText = m_MidiCfg.szMidiSFXExt[m]; + m_EditMacroValue[m].SetWindowText(macroText); + m_EditMacroValue[m].SetBackColor(m == selectedMacro ? RGB(200, 200, 225) : RGB(245, 245, 245)); + + // Macro Type: + const enmParameteredMacroType macroType = macroTools.GetMacroType(macroText); + switch (macroType) + { + case sfx_cc: + s.Format("MIDI CC %d", macroTools.MacroToMidiCC(macroText)); + break; + + case sfx_plug: + s.Format("Control Plugin Param %d", macroTools.MacroToPlugParam(macroText)); + break; + + default: + s = macroTools.GetMacroName(macroType); + break; + } + m_EditMacroType[m].SetWindowText(s); + m_EditMacroType[m].SetBackColor(m == selectedMacro ? RGB(200,200,225) : RGB(245,245,245) ); + + // Param details button: + m_BtnMacroShowAll[m].ShowWindow((macroType == sfx_plug) ? SW_SHOW : SW_HIDE); + } +} + + +void CMidiMacroSetup::UpdateDialog() +//---------------------------------- +{ + CHAR s[MACRO_LENGTH]; + UINT sfx, sfx_preset, zxx; + + sfx = m_CbnSFx.GetCurSel(); + sfx_preset = m_CbnSFxPreset.GetItemData(m_CbnSFxPreset.GetCurSel()); + if (sfx < 16) + { + ToggleBoxes(sfx_preset, sfx); + memcpy(s, m_MidiCfg.szMidiSFXExt[sfx], MACRO_LENGTH); + StringFixer::SetNullTerminator(s); + m_EditSFx.SetWindowText(s); + } + + zxx = m_CbnZxx.GetCurSel(); + if (zxx < 0x80) + { + memcpy(s, m_MidiCfg.szMidiZXXExt[zxx], MACRO_LENGTH); + StringFixer::SetNullTerminator(s); + m_EditZxx.SetWindowText(s); + } + UpdateMacroList(); +} + + +void CMidiMacroSetup::OnSetAsDefault() +//------------------------------------ +{ + theApp.SetDefaultMidiMacro(&m_MidiCfg); +} + + +void CMidiMacroSetup::OnResetCfg() +//-------------------------------- +{ + theApp.GetDefaultMidiMacro(&m_MidiCfg); + m_CbnZxxPreset.SetCurSel(0); + OnSFxChanged(); +} + + +void CMidiMacroSetup::OnMacroHelp() +//--------------------------------- +{ + Reporting::Information(_T("Valid characters in macros:\n\n" + "0-9, A-F - Raw hex data (4-Bit value)\n" + "c - MIDI channel (4-Bit value)\n" + "n - Note value\n\n" + "v - Note velocity\n" + "u - Computed note volume (including envelopes)\n\n" + "x - Note panning\n" + "y - Computed panning (including envelopes)\n\n" + "a - High byte of bank select\n" + "b - Low byte of bank select\n" + "p - Program select\n\n" + "z - Zxx parameter (00-7F)\n\n" + "Macros can be up to 31 characters long and contain multiple MIDI messages. SysEx messages are automatically terminated if not specified by the user."), + _T("OpenMPT MIDI Macro quick reference")); +} + + +void CMidiMacroSetup::OnEmbedMidiCfg() +//------------------------------------ +{ + m_bEmbed = IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED; +} + + +void CMidiMacroSetup::OnSFxChanged() +//---------------------------------- +{ + UINT sfx = m_CbnSFx.GetCurSel(); + if (sfx < 16) + { + CString macroText; + memcpy(macroText.GetBuffer(MACRO_LENGTH), m_MidiCfg.szMidiSFXExt[sfx], MACRO_LENGTH); + int preset = macroTools.GetMacroType(macroText); + m_CbnSFxPreset.SetCurSel(preset); + } + UpdateDialog(); +} + + +void CMidiMacroSetup::OnSFxPresetChanged() +//---------------------------------------- +{ + UINT sfx = m_CbnSFx.GetCurSel(); + enmParameteredMacroType sfx_preset = static_cast<enmParameteredMacroType>(m_CbnSFxPreset.GetItemData(m_CbnSFxPreset.GetCurSel())); + + if (sfx < 16) + { + if(sfx_preset != sfx_custom) + { + strcpy(m_MidiCfg.szMidiSFXExt[sfx], macroTools.CreateParameteredMacroFromType(sfx_preset)); + } + UpdateDialog(); + } +} + + +void CMidiMacroSetup::OnZxxPresetChanged() +//---------------------------------------- +{ + enmFixedMacroType zxx_preset = static_cast<enmFixedMacroType>(m_CbnZxxPreset.GetCurSel()); + + if (zxx_preset != zxx_custom) + { + macroTools.CreateZxxFromType(m_MidiCfg.szMidiZXXExt, zxx_preset); + UpdateDialog(); + } +} + + +void CMidiMacroSetup::OnSFxEditChanged() +//-------------------------------------- +{ + UINT sfx = m_CbnSFx.GetCurSel(); + if (sfx < 16) + { + if(ValidateMacroString(m_EditSFx, m_MidiCfg.szMidiSFXExt[sfx], true)) + { + CHAR s[MACRO_LENGTH]; + MemsetZero(s); + m_EditSFx.GetWindowText(s, MACRO_LENGTH); + StringFixer::SetNullTerminator(s); + memcpy(m_MidiCfg.szMidiSFXExt[sfx], s, MACRO_LENGTH); + + int sfx_preset = macroTools.GetMacroType(m_MidiCfg.szMidiSFXExt[sfx]); + m_CbnSFxPreset.SetCurSel(sfx_preset); + ToggleBoxes(sfx_preset, sfx); + UpdateMacroList(sfx); + } + } +} + + +void CMidiMacroSetup::OnZxxEditChanged() +//-------------------------------------- +{ + UINT zxx = m_CbnZxx.GetCurSel(); + if (zxx < 128) + { + if(ValidateMacroString(m_EditZxx, m_MidiCfg.szMidiZXXExt[zxx], false)) + { + CHAR s[MACRO_LENGTH]; + MemsetZero(s); + m_EditZxx.GetWindowText(s, MACRO_LENGTH); + StringFixer::SetNullTerminator(s); + memcpy(m_MidiCfg.szMidiZXXExt[zxx], s, MACRO_LENGTH); + } + } +} + +void CMidiMacroSetup::OnSetSFx(UINT id) +//------------------------------------- +{ + m_CbnSFx.SetCurSel(id - (ID_PLUGSELECT + NUM_MACROS)); + OnSFxChanged(); +} + +void CMidiMacroSetup::OnViewAllParams(UINT id) +//-------------------------------------------- +{ + CString message, plugName, line; + int sfx = id - ID_PLUGSELECT; + int param = macroTools.MacroToPlugParam(m_MidiCfg.szMidiSFXExt[sfx]); + CVstPlugin *pVstPlugin; + message.Format("These are the parameters that can be controlled by macro SF%X:\n\n", sfx); + + for(PLUGINDEX plug = 0; plug < MAX_MIXPLUGINS; plug++) + { + plugName = m_SndFile.m_MixPlugins[plug].Info.szName; + if(m_SndFile.m_MixPlugins[plug].Info.dwPluginId1 != 0) + { + pVstPlugin = (CVstPlugin*) m_SndFile.m_MixPlugins[plug].pMixPlugin; + if(pVstPlugin && param <= pVstPlugin->GetNumParameters()) + { + line.Format("FX%d: %s\t %s\n", plug + 1, plugName, pVstPlugin->GetFormattedParamName(param)); + message += line; + } + } + } + + Reporting::Notification(message, "Macro -> Params"); +} + +void CMidiMacroSetup::OnPlugChanged() +//----------------------------------- +{ + int plug = m_CbnMacroPlug.GetItemData(m_CbnMacroPlug.GetCurSel()); + + if (plug < 0 || plug > MAX_MIXPLUGINS) + return; + + PSNDMIXPLUGIN pPlugin = &m_SndFile.m_MixPlugins[plug]; + CVstPlugin *pVstPlugin = (pPlugin->pMixPlugin) ? (CVstPlugin *)pPlugin->pMixPlugin : NULL; + + if (pVstPlugin) + { + m_CbnMacroParam.SetRedraw(FALSE); + m_CbnMacroParam.Clear(); + m_CbnMacroParam.ResetContent(); + AddPluginParameternamesToCombobox(m_CbnMacroParam, *pVstPlugin); + m_CbnMacroParam.SetRedraw(TRUE); + + int param = macroTools.MacroToPlugParam(m_MidiCfg.szMidiSFXExt[m_CbnSFx.GetCurSel()]); + m_CbnMacroParam.SetCurSel(param); + } + //OnPlugParamChanged(); +} + +void CMidiMacroSetup::OnPlugParamChanged() +//---------------------------------------- +{ + CString macroText; + UINT param = m_CbnMacroParam.GetItemData(m_CbnMacroParam.GetCurSel()); + + if(param < 128) + { + macroText.Format("F0F0%02Xz",param + 128); + m_EditSFx.SetWindowText(macroText); + } else if(param < 384) + { + macroText.Format("F0F1%02Xz",param - 128); + m_EditSFx.SetWindowText(macroText); + } else + { + Reporting::Notification("Only parameters 0 to 383 can be controlled using MIDI Macros. Use Parameter Control Events to automate higher parameters."); + } +} + +void CMidiMacroSetup::OnCCChanged() +//--------------------------------- +{ + CString macroText; + UINT cc = m_CbnMacroCC.GetItemData(m_CbnMacroCC.GetCurSel()); + macroText.Format("Bc%02Xz", cc & 0xFF); + m_EditSFx.SetWindowText(macroText); +} + +void CMidiMacroSetup::ToggleBoxes(UINT sfx_preset, UINT sfx) +//---------------------------------------------------------- +{ + + if (sfx_preset == sfx_plug) + { + m_CbnMacroCC.ShowWindow(FALSE); + m_CbnMacroPlug.ShowWindow(TRUE); + m_CbnMacroParam.ShowWindow(TRUE); + m_CbnMacroPlug.EnableWindow(TRUE); + m_CbnMacroParam.EnableWindow(TRUE); + SetDlgItemText(IDC_GENMACROLABEL, "Plug/Param"); + m_CbnMacroParam.SetCurSel(macroTools.MacroToPlugParam(m_MidiCfg.szMidiSFXExt[sfx])); + } else + { + m_CbnMacroPlug.EnableWindow(FALSE); + m_CbnMacroParam.EnableWindow(FALSE); + } + + if (sfx_preset == sfx_cc) + { + m_CbnMacroCC.EnableWindow(TRUE); + m_CbnMacroCC.ShowWindow(TRUE); + m_CbnMacroPlug.ShowWindow(FALSE); + m_CbnMacroParam.ShowWindow(FALSE); + SetDlgItemText(IDC_GENMACROLABEL, "MIDI CC"); + m_CbnMacroCC.SetCurSel(macroTools.MacroToMidiCC(m_MidiCfg.szMidiSFXExt[sfx])); + } else + { + m_CbnMacroCC.EnableWindow(FALSE); + } + + //m_EditSFx.EnableWindow((sfx_preset == sfx_unused) ? FALSE : TRUE); + +} + + +bool CMidiMacroSetup::ValidateMacroString(CEdit &wnd, char *lastMacro, bool isParametric) +//--------------------------------------------------------------------------------------- +{ + CString macroStr; + wnd.GetWindowText(macroStr); + + bool allowed = true, caseChange = false; + for(int i = 0; i < macroStr.GetLength(); i++) + { + char c = macroStr.GetAt(i); + if(c == 'k' || c == 'K') // Previously, 'K' was used for MIDI channel + { + caseChange = true; + macroStr.SetAt(i, 'c'); + } else if(c >= 'd' && c <= 'f') // abc have special meanings, but def can be fixed + { + caseChange = true; + macroStr.SetAt(i, c - 'a' + 'A'); + } else if(c == 'N' || c == 'V' || c == 'U' || c == 'X' || c == 'Y' || c == 'Z' || c == 'P') + { + caseChange = true; + macroStr.SetAt(i, c - 'A' + 'a'); + } else if(!( + (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'c') || + (c == 'v' || c == 'u' || c == 'x' || c == 'y' || c == 'p' || c == 'n' || c == ' ') || + (c == 'z' && isParametric))) + { + allowed = false; + break; + } + } + + if(!allowed) + { + // Replace text and keep cursor position if we just typed in an invalid character + int start, end; + wnd.GetSel(start, end); + wnd.SetWindowText(lastMacro); + wnd.SetSel(start - 1, end - 1, true); + MessageBeep(MB_OK); + return false; + } + else + { + if(caseChange) + { + // Replace text and keep cursor position if there was a case conversion + int start, end; + wnd.GetSel(start, end); + wnd.SetWindowText(macroStr); + wnd.SetSel(start, end, true); + } + return true; + } +} Added: trunk/OpenMPT/mptrack/MIDIMacroDialog.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMacroDialog.h (rev 0) +++ trunk/OpenMPT/mptrack/MIDIMacroDialog.h 2011-11-18 22:52:19 UTC (rev 1138) @@ -0,0 +1,65 @@ +/* + * MIDIMacroDialog.h + * ----------------- + * Purpose: Header file for MIDI macro configuration dialog implementation + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + +#pragma once +#ifndef MIDIMACRODIALOG_H +#define MIDIMACRODIALOG_H +//class CColourEdit; +#include "ColourEdit.h" +#include "../soundlib/MIDIMacros.h" + + +//=================================== +class CMidiMacroSetup: public CDialog +//=================================== +{ +public: + CMidiMacroSetup(CSoundFile &sndFile, CWnd *parent = NULL) : CDialog(IDD_MIDIMACRO, parent), m_SndFile(sndFile), macroTools(sndFile), m_MidiCfg(sndFile.m_MidiCfg) + { + m_bEmbed = (m_SndFile.m_dwSongFlags & SONG_EMBEDMIDICFG) != 0; + } + + bool m_bEmbed; + MODMIDICFG m_MidiCfg; + + +protected: + CComboBox m_CbnSFx, m_CbnSFxPreset, m_CbnZxx, m_CbnZxxPreset, m_CbnMacroPlug, m_CbnMacroParam, m_CbnMacroCC; + CEdit m_EditSFx, m_EditZxx; + CColourEdit m_EditMacroValue[NUM_MACROS], m_EditMacroType[NUM_MACROS]; //rewbs.macroGUI + CButton m_EditMacro[NUM_MACROS], m_BtnMacroShowAll[NUM_MACROS]; + + CSoundFile &m_SndFile; + MIDIMacroTools macroTools; + + bool ValidateMacroString(CEdit &wnd, char *lastMacro, bool isParametric); + + void UpdateMacroList(int macro=-1); + void ToggleBoxes(UINT preset, UINT sfx); + virtual BOOL OnInitDialog(); + virtual void DoDataExchange(CDataExchange* pDX); + afx_msg void UpdateDialog(); + afx_msg void OnSetAsDefault(); + afx_msg void OnResetCfg(); + afx_msg void OnMacroHelp(); + afx_msg void OnEmbedMidiCfg(); + afx_msg void OnSFxChanged(); + afx_msg void OnSFxPresetChanged(); + afx_msg void OnZxxPresetChanged(); + afx_msg void OnSFxEditChanged(); + afx_msg void OnZxxEditChanged(); + afx_msg void OnPlugChanged(); + afx_msg void OnPlugParamChanged(); + afx_msg void OnCCChanged(); + + afx_msg void OnViewAllParams(UINT id); + afx_msg void OnSetSFx(UINT id); + DECLARE_MESSAGE_MAP() +}; + +#endif // MIDIMACRODIALOG_H Deleted: trunk/OpenMPT/mptrack/MIDIMacros.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMacros.cpp 2011-11-18 22:30:48 UTC (rev 1137) +++ trunk/OpenMPT/mptrack/MIDIMacros.cpp 2011-11-18 22:52:19 UTC (rev 1138) @@ -1,785 +0,0 @@ -/* - * MIDIMacros.cpp - * -------------- - * Purpose: Helper functions / classes for MIDI Macro functionality, including the MIDI Macro editor. - * Notes : (currently none) - * Authors: OpenMPT Devs - */ - -#include "stdafx.h" -#include "../common/Reporting.h" -#include "../common/StringFixer.h" -#include "Mainfrm.h" -#include "mptrack.h" -#include "Vstplug.h" -#include "resource.h" -#include "MIDIMacros.h" - - - -enmParameteredMacroType MIDIMacroTools::GetMacroType(CString value) -//----------------------------------------------------------------- -{ - value.Remove(' '); - if (value.Compare("") == 0) return sfx_unused; - if (value.Compare("F0F000z") == 0) return sfx_cutoff; - if (value.Compare("F0F001z") == 0) return sfx_reso; - if (value.Compare("F0F002z") == 0) return sfx_mode; - if (value.Compare("F0F003z") == 0) return sfx_drywet; - if (value.Compare("Bc00z") >= 0 && value.Compare("BcFFz") <= 0 && value.GetLength() == 5) - return sfx_cc; - if (value.Compare("F0F080z") >= 0 && value.Compare("F0F1FFz") <= 0 && value.GetLength() == 7) - return sfx_plug; - return sfx_custom; // custom / unknown -} - - -// Returns macro description including plugin parameter / MIDI CC information -CString MIDIMacroTools::GetMacroName(CString value, PLUGINDEX plugin) const -//------------------------------------------------------------------------- -{ - const enmParameteredMacroType macroType = GetMacroType(value); - - switch(macroType) - { - case sfx_plug: - { - const int param = MacroToPlugParam(value); - CString paramName; - - if(plugin < MAX_MIXPLUGINS) - { - CVstPlugin *pPlug = reinterpret_cast<CVstPlugin *>(m_SndFile.m_MixPlugins[plugin].pMixPlugin); - if(pPlug) - { - paramName = pPlug->GetParamName(param); - } - if (paramName.IsEmpty()) - { - return _T("N/A"); - } - - CString formattedName; - formattedName.Format(_T("Param %d (%s)"), param, paramName); - return CString(formattedName); - } else - { - return _T("N/A - No Plugin"); - } - } - - case sfx_cc: - { - CString formattedCC; - formattedCC.Format(_T("MIDI CC %d"), MacroToMidiCC(value)); - return formattedCC; - } - - default: - return GetMacroName(macroType); - } -} - - -// Returns generic macro description. -CString MIDIMacroTools::GetMacroName(enmParameteredMacroType macro) -//----------------------------------------------------------------- -{ - switch(macro) - { - case sfx_unused: - return _T("Unused"); - case sfx_cutoff: - return _T("Set Filter Cutoff"); - case sfx_reso: - return _T("Set Filter Resonance"); - case sfx_mode: - return _T("Set Filter Mode"); - case sfx_drywet: - return _T("Set Plugin Dry/Wet Ratio"); - case sfx_plug: - return _T("Control Plugin Parameter..."); - case sfx_cc: - return _T("MIDI CC..."); - case sfx_custom: - default: - return _T("Custom"); - } -} - - -int MIDIMacroTools::MacroToPlugParam(CString macro) -//------------------------------------------------- -{ - macro.Remove(' '); - int code=0; - char* param = (char *) (LPCTSTR) macro; - param += 4; - if ((param[0] >= '0') && (param[0] <= '9')) code = (param[0] - '0') << 4; else - if ((param[0] >= 'A') && (param[0] <= 'F')) code = (param[0] - 'A' + 0x0A) << 4; - if ((param[1] >= '0') && (param[1] <= '9')) code += (param[1] - '0'); else - if ((param[1] >= 'A') && (param[1] <= 'F')) code += (param[1] - 'A' + 0x0A); - - if (macro.GetLength() >= 4 && macro.GetAt(3) == '0') - return (code - 128); - else - return (code + 128); -} - - -int MIDIMacroTools::MacroToMidiCC(CString macro) -//---------------------------------------------- -{ - macro.Remove(' '); - int code=0; - char* param = (char *) (LPCTSTR) macro; - param += 2; - if ((param[0] >= '0') && (param[0] <= '9')) code = (param[0] - '0') << 4; else - if ((param[0] >= 'A') && (param[0] <= 'F')) code = (param[0] - 'A' + 0x0A) << 4; - if ((param[1] >= '0') && (param[1] <= '9')) code += (param[1] - '0'); else - if ((param[1] >= 'A') && (param[1] <= 'F')) code += (param[1] - 'A' + 0x0A); - - return code; -} - - -int MIDIMacroTools::FindMacroForParam(long param) const -//----------------------------------------------------- -{ - for (size_t macro = 0; macro < NUM_MACROS; macro++) - { - CString macroString = m_SndFile.m_MidiCfg.szMidiSFXExt[macro]; - if (GetMacroType(macroString) == sfx_plug && MacroToPlugParam(macroString) == param) - { - return macro; - } - } - - return -1; -} - - -// Retrieve Zxx (Z80-ZFF) type from current macro configuration -enmFixedMacroType MIDIMacroTools::GetZxxType(const char (&szMidiZXXExt)[128][MACRO_LENGTH]) -//----------------------------------------------------------------------------------------- -{ - // Compare with all possible preset patterns - for(size_t i = 1; i < zxx_max; i++) - { - // Prepare pattern to compare - char szPatterns[128][MACRO_LENGTH]; - CreateZxxFromType(szPatterns, static_cast<enmFixedMacroType>(i)); - - bool bFound = true; - for(size_t j = 0; j < 128; j++) - { - if(strncmp(szPatterns[j], szMidiZXXExt[j], MACRO_LENGTH)) - { - bFound = false; - break; - } - } - if(bFound) return static_cast<enmFixedMacroType>(i); - } - return zxx_custom; // Custom setup -} - - -// Create Zxx (Z80 - ZFF) from one out of five presets -void MIDIMacroTools::CreateZxxFromType(char (&szMidiZXXExt)[128][MACRO_LENGTH], enmFixedMacroType iZxxType) -//--------------------------------------------------------------------------------------------------------- -{ - for(size_t i = 0; i < 128; i++) - { - switch(iZxxType) - { - case zxx_reso4Bit: - // Type 1 - Z80 - Z8F controls resonance - if (i < 16) wsprintf(szMidiZXXExt[i], "F0F001%02X", i * 8); - else strcpy(szMidiZXXExt[i], ""); - break; - - case zxx_reso7Bit: - // Type 2 - Z80 - ZFF controls resonance - wsprintf(szMidiZXXExt[i], "F0F001%02X", i); - break; - - case zxx_cutoff: - // Type 3 - Z80 - ZFF controls cutoff - wsprintf(szMidiZXXExt[i], "F0F000%02X", i); - break; - - case zxx_mode: - // Type 4 - Z80 - ZFF controls filter mode - wsprintf(szMidiZXXExt[i], "F0F002%02X", i); - break; - - case zxx_resomode: - // Type 5 - Z80 - Z9F controls resonance + filter mode - if (i < 16) wsprintf(szMidiZXXExt[i], "F0F001%02X", i * 8); - else if (i < 32) wsprintf(szMidiZXXExt[i], "F0F002%02X", (i - 16) * 8); - else strcpy(szMidiZXXExt[i], ""); - break; - } - } -} - - -// Check if the MIDI Macro configuration used is the default one, -// i.e. the configuration that is assumed when loading a file that has no macros embedded. -bool MIDIMacroTools::IsMacroDefaultSetupUsed() const -//-------------------------------------------------- -{ - // TODO - Global macros - - // SF0: Z00-Z7F controls cutoff - if(GetMacroType(m_SndFile.m_MidiCfg.szMidiSFXExt[0]) != sfx_cutoff) - { - return false; - } - // Z80-Z8F controls resonance - if(GetZxxType(m_SndFile.m_MidiCfg.szMidiZXXExt) != zxx_reso4Bit) - { - return false; - } - // All other parametered macros are unused - for(size_t i = 1; i < NUM_MACROS; i++) - { - if(GetMacroType(m_SndFile.m_MidiCfg.szMidiSFXExt[i]) != sfx_unused) - { - return false; - } - } - return true; -} - - -#ifdef MODPLUG_TRACKER - -//////////////////////////////////////////////////////////////////////// -// MIDI Macro Configuration Dialog - -BEGIN_MESSAGE_MAP(CMidiMacroSetup, CDialog) - ON_COMMAND(IDC_CHECK1, OnEmbedMidiCfg) - ON_COMMAND(IDC_BUTTON1, OnSetAsDefault) - ON_COMMAND(IDC_BUTTON2, OnResetCfg) - ON_COMMAND(IDC_BUTTON3, OnMacroHelp) - ON_CBN_SELCHANGE(IDC_COMBO1, OnSFxChanged) - ON_CBN_SELCHANGE(IDC_COMBO2, OnSFxPresetChanged) - ON_CBN_SELCHANGE(IDC_COMBO3, OnZxxPresetChanged) - ON_CBN_SELCHANGE(IDC_COMBO4, UpdateDialog) - ON_CBN_SELCHANGE(IDC_MACROPLUG, OnPlugChanged) - ON_CBN_SELCHANGE(IDC_MACROPARAM,OnPlugParamChanged) - ON_CBN_SELCHANGE(IDC_MACROCC, OnCCChanged) - ON_EN_CHANGE(IDC_EDIT1, OnSFxEditChanged) - ON_EN_CHANGE(IDC_EDIT2, OnZxxEditChanged) - ON_COMMAND_RANGE(ID_PLUGSELECT, ID_PLUGSELECT + NUM_MACROS - 1, OnViewAllParams) //rewbs.patPlugName - ON_COMMAND_RANGE(ID_PLUGSELECT + NUM_MACROS, ID_PLUGSELECT + NUM_MACROS + NUM_MACROS - 1, OnSetSFx) //rewbs.patPlugName -END_MESSAGE_MAP() - - -void CMidiMacroSetup::DoDataExchange(CDataExchange* pDX) -//------------------------------------------------------ -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CModTypeDlg) - DDX_Control(pDX, IDC_COMBO1, m_CbnSFx); - DDX_Control(pDX, IDC_COMBO2, m_CbnSFxPreset); - DDX_Control(pDX, IDC_COMBO3, m_CbnZxxPreset); - DDX_Control(pDX, IDC_COMBO4, m_CbnZxx); - DDX_Control(pDX, IDC_EDIT1, m_EditSFx); - DDX_Control(pDX, IDC_EDIT2, m_EditZxx); - DDX_Control(pDX, IDC_MACROPLUG, m_CbnMacroPlug); - DDX_Control(pDX, IDC_MACROPARAM, m_CbnMacroParam); - DDX_Control(pDX, IDC_MACROCC, m_CbnMacroCC); - //}}AFX_DATA_MAP -} - - -BOOL CMidiMacroSetup::OnInitDialog() -//---------------------------------- -{ - CHAR s[128]; - CDialog::OnInitDialog(); - CheckDlgButton(IDC_CHECK1, m_bEmbed ? BST_CHECKED : BST_UNCHECKED); - m_EditSFx.SetLimitText(MACRO_LENGTH - 1); - m_EditZxx.SetLimitText(MACRO_LENGTH - 1); - - for (UINT isfx=0; isfx<16; isfx++) - { - wsprintf(s, "%d (SF%X)", isfx, isfx); - m_CbnSFx.AddString(s); - } - m_CbnSFx.SetCurSel(0); - for(int i = 0; i < sfx_max; i++) - { - m_CbnSFxPreset.SetItemData(m_CbnSFxPreset.AddString(macroTools.GetMacroName(static_cast<enmParameteredMacroType>(i))), i); - } - OnSFxChanged(); - - for (int cc = MIDICC_start; cc <= MIDICC_end; cc++) - { - wsprintf(s, "CC %02d %s", cc, MidiCCNames[cc]); - m_CbnMacroCC.SetItemData(m_CbnMacroCC.AddString(s), cc); - } - - for (int zxx = 0; zxx < 128; zxx++) - { - wsprintf(s, "Z%02X", zxx | 0x80); - m_CbnZxx.AddString(s); - } - m_CbnZxx.SetCurSel(0); - m_CbnZxxPreset.AddString("Custom"); - m_CbnZxxPreset.AddString("Z80-Z8F controls resonance"); - m_CbnZxxPreset.AddString("Z80-ZFF controls resonance"); - m_CbnZxxPreset.AddString("Z80-ZFF controls cutoff"); - m_CbnZxxPreset.AddString("Z80-ZFF controls filter mode"); - m_CbnZxxPreset.AddString("Z80-Z9F controls resonance+mode"); - m_CbnZxxPreset.SetCurSel(macroTools.GetZxxType(m_MidiCfg.szMidiZXXExt)); - UpdateDialog(); - - int offsetx=108, offsety=30, separatorx=4, separatory=2, - height=18, widthMacro=30, widthVal=90, widthType=135, widthBtn=70; - - for (UINT m = 0; m < NUM_MACROS; m++) - { - m_EditMacro[m].Create("", /*BS_FLAT |*/ WS_CHILD | WS_VISIBLE | WS_TABSTOP /*| WS_BORDER*/, - CRect(offsetx, offsety + m * (separatory + height), offsetx + widthMacro, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + NUM_MACROS + m); - m_EditMacro[m].SetFont(GetFont()); - - m_EditMacroType[m].Create(ES_READONLY | WS_CHILD| WS_VISIBLE | WS_TABSTOP | WS_BORDER, - CRect(offsetx + separatorx + widthMacro, offsety + m* (separatory + height), offsetx + widthMacro + widthType, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + NUM_MACROS + m); - m_EditMacroType[m].SetFont(GetFont()); - - m_EditMacroValue[m].Create(ES_CENTER | ES_READONLY | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, - CRect(offsetx + separatorx + widthType + widthMacro, offsety + m * (separatory + height), offsetx + widthMacro + widthType + widthVal, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + NUM_MACROS + m); - m_EditMacroValue[m].SetFont(GetFont()); - - m_BtnMacroShowAll[m].Create("Show All...", WS_CHILD | WS_TABSTOP | WS_VISIBLE, - CRect(offsetx + separatorx + widthType + widthMacro + widthVal, offsety + m *(separatory + height), offsetx + widthMacro + widthType + widthVal + widthBtn, offsety + m * (separatory + height) + height), this, ID_PLUGSELECT + m); - m_BtnMacroShowAll[m].SetFont(GetFont()); - } - UpdateMacroList(); - - for (UINT plug=0; plug<MAX_MIXPLUGINS; plug++) - { - PSNDMIXPLUGIN p = &(m_SndFile.m_MixPlugins[plug]); - StringFixer::SetNullTerminator(p->Info.szLibraryName); - if (p->Info.szLibraryName[0]) - { - wsprintf(s, "FX%d: %s", plug+1, p->Info.szName); - m_CbnMacroPlug.SetItemData(m_CbnMacroPlug.AddString(s), plug); - } - } - m_CbnMacroPlug.SetCurSel(0); - OnPlugChanged(); - return FALSE; -} - - -// macro == -1 for updating all macros at once -void CMidiMacroSetup::UpdateMacroList(int macro) -//---------------------------------------------- -{ - if (!m_EditMacro[0]) - { - // GUI not yet initialized - return; - } - - int start, end; - - if (macro >= 0 && macro < 16) - { - start = end = macro; - } else - { - start = 0; - end = NUM_MACROS - 1; - } - - CString s; - const int selectedMacro = m_CbnSFx.GetCurSel(); - - for (int m = start; m <= end; m++) - { - // SFx - s.Format("SF%X", m); - m_EditMacro[m].SetWindowText(s); - - // Macro value: - CString macroText = m_MidiCfg.szMidiSFXExt[m]; - m_EditMacroValue[m].SetWindowText(macroText); - m_EditMacroValue[m].SetBackColor(m == selectedMacro ? RGB(200, 200, 225) : RGB(245, 245, 245)); - - // Macro Type: - const enmParameteredMacroType macroType = macroTools.GetMacroType(macroText); - switch (macroType) - { - case sfx_cc: - s.Format("MIDI CC %d", macroTools.MacroToMidiCC(macroText)); - break; - - case sfx_plug: - s.Format("Control Plugin Param %d", macroTools.MacroToPlugParam(macroText)); - break; - - default: - s = macroTools.GetMacroName(macroType); - break; - } - m_EditMacroType[m].SetWindowText(s); - m_EditMacroType[m].SetBackColor(m == selectedMacro ? RGB(200,200,225) : RGB(245,245,245) ); - - // Param details button: - m_BtnMacroShowAll[m].ShowWindow((macroType == sfx_plug) ? SW_SHOW : SW_HIDE); - } -} - - -void CMidiMacroSetup::UpdateDialog() -//---------------------------------- -{ - CHAR s[MACRO_LENGTH]; - UINT sfx, sfx_preset, zxx; - - sfx = m_CbnSFx.GetCurSel(); - sfx_preset = m_CbnSFxPreset.GetItemData(m_CbnSFxPreset.GetCurSel()); - if (sfx < 16) - { - ToggleBoxes(sfx_preset, sfx); - memcpy(s, m_MidiCfg.szMidiSFXExt[sfx], MACRO_LENGTH); - StringFixer::SetNullTerminator(s); - m_EditSFx.SetWindowText(s); - } - - zxx = m_CbnZxx.GetCurSel(); - if (zxx < 0x80) - { - memcpy(s, m_MidiCfg.szMidiZXXExt[zxx], MACRO_LENGTH); - StringFixer::SetNullTerminator(s); - m_EditZxx.SetWindowText(s); - } - UpdateMacroList(); -} - - -void CMidiMacroSetup::OnSetAsDefault() -//------------------------------------ -{ - theApp.SetDefaultMidiMacro(&m_MidiCfg); -} - - -void CMidiMacroSetup::OnResetCfg() -//-------------------------------- -{ - theApp.GetDefaultMidiMacro(&m_MidiCfg); - m_CbnZxxPreset.SetCurSel(0); - OnSFxChanged(); -} - - -void CMidiMacroSetup::OnMacroHelp() -//--------------------------------- -{ - Reporting::Information(_T("Valid characters in macros:\n\n" - "0-9, A-F - Raw hex data (4-Bit value)\n" - "c - MIDI channel (4-Bit value)\n" - "n - Note value\n\n" - "v - Note velocity\n" - "u - Computed note volume (including envelopes)\n\n" - "x - Note panning\n" - "y - Computed panning (including envelopes)\n\n" - "a - High byte of bank select\n" - "b - Low byte of bank select\n" - "p - Program select\n\n" - "z - Zxx parameter (00-7F)\n\n" - "Macros can be up to 31 characters long and contain multiple MIDI messages. SysEx messages are automatically terminated if not specified by the user."), - _T("OpenMPT MIDI Macro quick reference")); -} - - -void CMidiMacroSetup::OnEmbedMidiCfg() -//------------------------------------ -{ - m_bEmbed = IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED; -} - - -void CMidiMacroSetup::OnSFxChanged() -//---------------------------------- -{ - UINT sfx = m_CbnSFx.GetCurSel(); - if (sfx < 16) - { - CString macroText; - memcpy(macroText.GetBuffer(MACRO_LENGTH), m_MidiCfg.szMidiSFXExt[sfx], MACRO_LENGTH); - int preset = macroTools.GetMacroType(macroText); - m_CbnSFxPreset.SetCurSel(preset); - } - UpdateDialog(); -} - - -void CMidiMacroSetup::OnSFxPresetChanged() -//---------------------------------------- -{ - UINT sfx = m_CbnSFx.GetCurSel(); - UINT sfx_preset = m_CbnSFxPreset.GetItemData(m_CbnSFxPreset.GetCurSel()); - - if (sfx < 16) - { - char *pmacro = m_MidiCfg.szMidiSFXExt[sfx]; - switch(sfx_preset) - { - case sfx_unused: strcpy(pmacro, ""); break; // unused - case sfx_cutoff: strcpy(pmacro, "F0F000z"); break; // cutoff - case sfx_reso: strcpy(pmacro, "F0F001z"); break; // reso - case sfx_mode: strcpy(pmacro, "F0F002z"); break; // mode - case sfx_drywet: strcpy(pmacro, "F0F003z"); break; - case sfx_cc: strcpy(pmacro, "Bc00z"); break; // MIDI cc - TODO: get value from other menus - case sfx_plug: strcpy(pmacro, "F0F080z"); break; // plug param - TODO: get value from other menus - case sfx_custom: /*strcpy(pmacro, "z");*/ break; // custom - leave as is. - } - UpdateDialog(); - } -} - - -void CMidiMacroSetup::OnZxxPresetChanged() -//---------------------------------------- -{ - enmFixedMacroType zxx_preset = static_cast<enmFixedMacroType>(m_CbnZxxPreset.GetCurSel()); - - if (zxx_preset != zxx_custom) - { - macroTools.CreateZxxFromType(m_MidiCfg.szMidiZXXExt, zxx_preset); - UpdateDialog(); - } -} - - -void CMidiMacroSetup::OnSFxEditChanged() -//-------------------------------------- -{ - CHAR s[MACRO_LENGTH]; - UINT sfx = m_CbnSFx.GetCurSel(); - if (sfx < 16) - { - if(ValidateMacroString(m_EditSFx, m_MidiCfg.szMidiSFXExt[sfx], true)) - { - MemsetZero(s); - m_EditSFx.GetWindowText(s, MACRO_LENGTH); - StringFixer::SetNullTerminator(s); - memcpy(m_MidiCfg.szMidiSFXExt[sfx], s, MACRO_LENGTH); - - int sfx_preset = macroTools.GetMacroType(m_MidiCfg.szMidiSFXExt[sfx]); - //int param = macroTools.MacroToPlugParam(m_MidiCfg.szMidiSFXExt[sfx]); - - m_CbnSFxPreset.SetCurSel(sfx_preset); - ToggleBoxes(sfx_preset, sfx); - UpdateMacroList(sfx); - } - } -} - - -void CMidiMacroSetup::OnZxxEditChanged() -//-------------------------------------- -{ - CHAR s[MACRO_LENGTH]; - UINT zxx = m_CbnZxx.GetCurSel(); - if (zxx < 128) - { - if(ValidateMacroString(m_EditZxx, m_MidiCfg.szMidiZXXExt[zxx], false)) - { - MemsetZero(s); - m_EditZxx.GetWindowText(s, MACRO_LENGTH); - StringFixer::SetNullTerminator(s); - memcpy(m_MidiCfg.szMidiZXXExt[zxx], s, MACRO_LENGTH); - } - } -} - -void CMidiMacroSetup::OnSetSFx(UINT id) -//------------------------------------- -{ - m_CbnSFx.SetCurSel(id-(ID_PLUGSELECT + NUM_MACROS)); - OnSFxChanged(); -} - -void CMidiMacroSetup::OnViewAllParams(UINT id) -//-------------------------------------------- -{ - CString message, plugName, line; - int sfx = id-ID_PLUGSELECT; - int param = macroTools.MacroToPlugParam(m_MidiCfg.szMidiSFXExt[sfx]); - CVstPlugin *pVstPlugin; - message.Format("These are the parameters that can be controlled by macro SF%X:\n\n",sfx); - - for (UINT plug=0; plug<MAX_MIXPLUGINS; plug++) - { - plugName = m_SndFile.m_MixPlugins[plug].Info.szName; - if (plugName != "") - { - pVstPlugin=(CVstPlugin*) m_SndFile.m_MixPlugins[plug].pMixPlugin; - if (pVstPlugin && param <= pVstPlugin->GetNumParameters()) - { - line.Format("FX%d: %s\t %s\n", plug + 1, plugName, pVstPlugin->GetFormattedParamName(param)); - message += line; - } - } - } - - Reporting::Notification(message, "Macro -> Params"); -} - -void CMidiMacroSetup::OnPlugChanged() -//----------------------------------- -{ - int plug = m_CbnMacroPlug.GetItemData(m_CbnMacroPlug.GetCurSel()); - - if (plug < 0 || plug > MAX_MIXPLUGINS) - return; - - PSNDMIXPLUGIN pPlugin = &m_SndFile.m_MixPlugins[plug]; - CVstPlugin *pVstPlugin = (pPlugin->pMixPlugin) ? (CVstPlugin *)pPlugin->pMixPlugin : NULL; - - if (pVstPlugin) - { - m_CbnMacroParam.SetRedraw(FALSE); - m_CbnMacroParam.Clear(); - m_CbnMacroParam.ResetContent(); - AddPluginParameternamesToCombobox(m_CbnMacroParam, *pVstPlugin); - m_CbnMacroParam.SetRedraw(TRUE); - - int param = macroTools.MacroToPlugParam(m_MidiCfg.szMidiSFXExt[m_CbnSFx.GetCurSel()]); - m_CbnMacroParam.SetCurSel(param); - } - //OnPlugParamChanged(); -} - -void CMidiMacroSetup::OnPlugParamChanged() -//---------------------------------------- -{ - CString macroText; - UINT param = m_CbnMacroParam.GetItemData(m_CbnMacroParam.GetCurSel()); - - if (param < 128) - { - macroText.Format("F0F0%02Xz",param + 128); - m_EditSFx.SetWindowText(macroText); - } else if (param < 384) - { - macroText.Format("F0F1%02Xz",param - 128); - m_EditSFx.SetWindowText(macroText); - } else - { - Reporting::Notification("MPT can only assign macros to parameters 0 to 383. Use Parameter Control Notes to automate higher parameters."); - } -} - -void CMidiMacroSetup::OnCCChanged() -//--------------------------------- -{ - CString macroText; - UINT cc = m_CbnMacroCC.GetItemData(m_CbnMacroCC.GetCurSel()); - macroText.Format("Bc%02Xz", cc & 0xFF); - m_EditSFx.SetWindowText(macroText); -} - -void CMidiMacroSetup::ToggleBoxes(UINT sfx_preset, UINT sfx) -//---------------------------------------------------------- -{ - - if (sfx_preset == sfx_plug) - { - m_CbnMacroCC.ShowWindow(FALSE); - m_CbnMacroPlug.ShowWindow(TRUE); - m_CbnMacroParam.ShowWindow(TRUE); - m_CbnMacroPlug.EnableWindow(TRUE); - m_CbnMacroParam.EnableWindow(TRUE); - SetDlgItemText(IDC_GENMACROLABEL, "Plug/Param"); - m_CbnMacroParam.SetCurSel(macroTools.MacroToPlugParam(m_MidiCfg.szMidiSFXExt[sfx])); - } else - { - m_CbnMacroPlug.EnableWindow(FALSE); - m_CbnMacroParam.EnableWindow(FALSE); - } - - if (sfx_preset == sfx_cc) - { - m_CbnMacroCC.EnableWindow(TRUE); - m_CbnMacroCC.ShowWindow(TRUE); - m_CbnMacroPlug.ShowWindow(FALSE); - m_CbnMacroParam.ShowWindow(FALSE); - SetDlgItemText(IDC_GENMACROLABEL, "MIDI CC"); - m_CbnMacroCC.SetCurSel(macroTools.MacroToMidiCC(m_MidiCfg.szMidiSFXExt[sfx])); - } else - { - m_CbnMacroCC.EnableWindow(FALSE); - } - - //m_EditSFx.EnableWindow((sfx_preset == sfx_unused) ? FALSE : TRUE); - -} - - -bool CMidiMacroSetup::ValidateMacroString(CEdit &wnd, char *lastMacro, bool isParametric) -//--------------------------------------------------------------------------------------- -{ - CString macroStr; - wnd.GetWindowText(macroStr); - - bool allowed = true, caseChange = false; - for(int i = 0; i < macroStr.GetLength(); i++) - { - char c = macroStr.GetAt(i); - if(c == 'k' || c == 'K') // Previously, 'K' was used for MIDI channel - { - caseChange = true; - macroStr.SetAt(i, 'c'); - } else if (c >= 'd' && c <= 'f') // abc have special meanings, but def can be fixed - { - caseChange = true; - macroStr.SetAt(i, c - 'a' + 'A'); - } else if(c == 'N' || c == 'V' || c == 'U' || c == 'X' || c == 'Y' || c == 'Z' || c == 'P') - { - caseChange = true; - macroStr.SetAt(i, c - 'A' + 'a'); - } else if(!( - (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'c') || - (c == 'v' || c == 'u' || c == 'x' || c == 'y' || c == 'p' || c == 'n' || c == ' ') || - (c == 'z' && isParametric))) - { - allowed = false; - break; - } - } - - if(!allowed) - { - // Replace text and keep cursor position if we just typed in an invalid character - int start, end; - wnd.GetSel(start, end); - wnd.SetWindowText(lastMacro); - wnd.SetSel(start - 1, end - 1, true); - MessageBeep(MB_OK); - return false; - } - else - { - if(caseChange) - { - // Replace text and keep cursor position if there was a case conversion - int start, end; - wnd.GetSel(start, end); - wnd.SetWindowText(macroStr); - wnd.SetSel(start, end, true); - } - return true; - } -} - -#endif // MODPLUG_TRACKER Deleted: trunk/OpenMPT/mptrack/MIDIMacros.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMacros.h 2011-11-18 22:30:48 UTC (rev 1137) +++ trunk/OpenMPT/mptrack/MIDIMacros.h 2011-11-18 22:52:19 UTC (rev 1138) @@ -1,133 +0,0 @@ -/* - * MIDIMacros.h - * ------------ - * Purpose: Header file for MIDI macro helper functions / classes - * Notes : (currently none) - * Authors: OpenMPT Devs - */ - -#pragma once -#ifndef MIDIMACROS_H -#define MIDIMACROS_H - -// parametered macro presets: -enum enmParameteredMacroType -{ - sfx_unused = 0, - sfx_cutoff, // Type 1 - Z00 - Z7F controls resonant filter cutoff - sfx_reso, // Type 2 - Z00 - Z7F controls resonant filter resonance - sfx_mode, // Type 3 - Z00 - Z7F controls resonant filter mode (lowpass / highpass) - sfx_drywet, // Type 4 - Z00 - Z7F controls plugin Dry / Wet ratio - sfx_plug, // Type 5 - Z00 - Z7F controls a plugin parameter - sfx_cc, // Type 6 - Z00 - Z7F controls MIDI CC - sfx_custom, - - sfx_max -}; - - -// fixed macro presets: -enum enmFixedMacroType -{ - zxx_custom = 0, - zxx_reso4Bit, // Type 1 - Z80 - Z8F controls resonant filter resonance - zxx_reso7Bit, // Type 2 - Z80 - ZFF controls resonant filter resonance - zxx_cutoff, // Type 3 - Z80 - ZFF controls resonant filter cutoff - zxx_mode, // Type 4 - Z80 - ZFF controls resonant filter mode (lowpass / highpass) - zxx_resomode, // Type 5 - Z80 - Z9F controls resonance + filter mode - - zxx_max -}; - - -class MIDIMacroTools -{ -protected: - CSoundFile &m_SndFile; - -public: - // Get macro type from a macro string - static enmParameteredMacroType GetMacroType(CString value); - static enmFixedMacroType GetZxxType(const char (&szMidiZXXExt)[128][MACRO_LENGTH]); - - // Translate macro type or macro string to macro name - static CString GetMacroName(enmParameteredMacroType macro); - CString GetMacroName(CString value, PLUGINDEX plugin) const; - - // Extract information from a macro string. - static int MacroToPlugParam(CString value); - static int MacroToMidiCC(CString value); - - // Check if any macro can automate a given plugin parameter - int FindMacroForParam(long param) const; - - // Create a new Zxx macro - static void CreateZxxFromType(char (&szMidiZXXExt)[128][MACRO_LENGTH], enmFixedMacroType iZxxType); - - // Check if a given set of macros is the default IT macro set. - bool IsMacroDefaultSetupUsed() const; - - MIDIMacroTools(CSoundFile &sndFile) : m_SndFile(sndFile) { }; -}; - - -#ifdef MODPLUG_TRACKER - -//////////////////////////////////////////////////////////////////////// -// MIDI Macro Configuration Dialog - -//class CColourEdit; -#include "ColourEdit.h" - - -//=================================== -class CMidiMacroSetup: public CDialog -//=================================== -{ -public: - CMidiMacroSetup(CSoundFile &sndFile, CWnd *parent = NULL) : CDialog(IDD_MIDIMACRO, parent), m_SndFile(sndFile), macroTools(sndFile), m_MidiCfg(sndFile.m_MidiCfg) - { - m_bEmbed = (m_SndFile.m_dwSongFlags & SONG_EMBEDMIDICFG) != 0; - } - - bool m_bEmbed; - MODMIDICFG m_MidiCfg; - - -protected: - CComboBox m_CbnSFx, m_CbnSFxPreset, m_CbnZxx, m_CbnZxxPreset, m_CbnMacroPlug, m_CbnMacroParam, m_CbnMacroCC; - CEdit m_EditSFx, m_EditZxx; - CColourEdit m_EditMacroValue[NUM_MACROS], m_EditMacroType[NUM_MACROS]; //rewbs.macroGUI - CButton m_EditMacro[NUM_MACROS], m_BtnMacroShowAll[NUM_MACROS]; - - CSoundFile &m_SndFile; - MIDIMacroTools macroTools; - - bool ValidateMacroString(CEdit &wnd, char *lastMacro, bool isParametric); - - void UpdateMacroList(int macro=-1); - void ToggleBoxes(UINT preset, UINT sfx); - virtual BOOL OnInitDialog(); - virtual void DoDataExchange(CDataExchange* pDX); - afx_msg void UpdateDialog(); - afx_msg void OnSetAsDefault(); - afx_msg void OnResetCfg(); - afx_msg void OnMacroHelp(); - afx_msg void OnEmbedMidiCfg(); - afx_msg void OnSFxChanged(); - afx_msg void OnSFxPresetChanged(); - afx_msg void OnZxxPresetChanged(); - afx_msg void OnSFxEditChanged(); - afx_msg void OnZxxEditChanged(); - afx_msg void OnPlugChanged(); - afx_msg void OnPlugParamChanged(); - afx_msg void OnCCChanged(); - - afx_msg void OnViewAllParams(UINT id); - afx_msg void OnSetSFx(UINT id); - DECLARE_MESSAGE_MAP() -}; - -#endif // MODPLUG_TRACKER - -#endif // MIDIMACROS_H Modified: trunk/OpenMPT/mptrack/mptrack.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack.vcproj 2011-11-18 22:30:48 UTC (rev 1137) +++ trunk/OpenMPT/mptrack/mptrack.vcproj 2011-11-18 22:52:19 UTC (rev 1138) @@ -280,9 +280,12 @@ RelativePath="..\soundlib\Message.cpp"> </File> <File - RelativePath=".\MIDIMacros.cpp"> + RelativePath=".\MIDIMacroDialog.cpp"> </File> <File + RelativePath=".\soundlib\MIDIMacros.cpp"> + </File> + <File RelativePath=".\MIDIMappingDialog.cpp"> </File> <File @@ -768,9 +771,12 @@ RelativePath="..\soundlib\midi.h"> </File> <File - RelativePath=".\MIDIMacros.h"> + RelativePath=".\MIDIMacroDialog.h"> </File> <File + RelativePath=".\soundlib\MIDIMacros.h"> + </File> + <File RelativePath=".\MIDIMappingDialog.h"> </File> <File Modified: trunk/OpenMPT/mptrack/mptrack_08.vcproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-11-18 22:30:48 UTC (rev 1137) +++ trunk/OpenMPT/mptrack/mptrack_08.vcproj 2011-11-18 22:52:19 UTC (rev 1138) @@ -377,6 +377,10 @@ > </File> <File + RelativePath=".\MIDIMacroDialog.cpp" + > + </File> + <File RelativePath="..\soundlib\MIDIMacros.cpp" > </File> @@ -1019,10 +1023,14 @@ > </File> <File - RelativePath=".\MIDIMacros.h" + RelativePath=".\MIDIMacroDialog.h" > </File> <File + RelativePath=".\soundlib\MIDIMacros.h" + > + </File> + <File RelativePath=".\MIDIMappingDialog.h" > </File> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-11-18 22:30:48 UTC (rev 1137) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj 2011-11-18 22:52:19 UTC (rev 1138) @@ -169,6 +169,7 @@ <ItemGroup> <ClCompile Include="..\common\misc_util.cpp" /> <ClCompile Include="..\common\Reporting.cpp" /> + <ClCompile Include="..\soundlib\MIDIMacros.cpp" /> <ClCompile Include="AbstractVstEditor.cpp" /> <ClCompile Include="ACMConvert.cpp" /> <ClCompile Include="ArrayUtils.cpp" /> @@ -204,7 +205,7 @@ <ClCompile Include="mainbar.cpp" /> <ClCompile Include="MainFrm.cpp" /> <ClCompile Include="..\soundlib\Message.cpp" /> - <ClCompile Include="MIDIMacros.cpp" /> + <ClCompile Include="MIDIMacroDialog.cpp" /> <ClCompile Include="MIDIMappingDialog.cpp" /> <ClCompile Include="..\soundlib\mmcmp.cpp" /> <ClCompile Include="..\soundlib\Mmx_mix.cpp" /> @@ -326,10 +327,11 @@ <ClInclude Include="..\common\Reporting.h" /> <ClInclude Include="..\common\StringFixer.h" /> <ClInclude Include="..\common\typedefs.h" /> + <ClInclude Include="..\soundlib\MIDIMacros.h" /> <ClInclude Include="ACMConvert.h" /> <ClInclude Include="Autotune.h" /> <ClInclude Include="ExceptionHandler.h" /> - <ClInclude Include="MIDIMacros.h" /> + <ClInclude Include="MIDIMacroDialog.h" /> <ClInclude Include="PatternRandomizer.h" /> <ClInclude Include="PatternRandomizerGUI.h" /> <ClInclude Include="PatternRandomizerGUIEffect.h" /> Modified: trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters =================================================================== --- trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-11-18 22:30:48 UTC (rev 1137) +++ trunk/OpenMPT/mptrack/mptrack_10.vcxproj.filters 2011-11-18 22:52:19 UTC (rev 1138) @@ -433,7 +433,10 @@ <ClCompile Include="Autotune.cpp"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="MIDIMacros.cpp"> + <ClCompile Include="MIDIMacroDialog.cpp"> + <Filter>Source Files\Dialogs</Filter> + </ClCompile> + <ClCompile Include="..\soundlib\MIDIMacros.cpp"> <Filter>Source Files</Filter> </ClCompile> </ItemGroup> @@ -762,7 +765,10 @@ <ClInclude Include="Autotune.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="MIDIMacros.h"> + <ClInclude Include="MIDIMacroDialog.h"> + <Filter>Header Files\Dialogs</Filter> + </ClInclude> + <ClInclude Include="..\soundlib\MIDIMacros.h"> <Filter>Header Files</Filter> </ClInclude> </ItemGroup> Modified: trunk/OpenMPT/mptrack/test/test.cpp =================================================================== --- trunk/OpenMPT/mptrack/test/test.cpp 2011-11-18 22:30:48 UTC (rev 1137) +++ trunk/OpenMPT/mptrack/test/test.cpp 2011-11-18 22:52:19 UTC (rev 1138) @@ -9,7 +9,7 @@ #include "../moddoc.h" #include "../MainFrm.h" #include "../version.h" -#include "../MIDIMacros.h" +#include "../../soundlib/MIDIMacros.h" #include "../../common/misc_util.h" #include "../serialization_utils.h" #include <limits> Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-11-18 22:30:48 UTC (rev 1137) +++ trunk/OpenMPT/mptrack/version.h 2011-11-18 22:52:19 UTC (rev 1138) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 20 #define VER_MINOR 00 -#define VER_MINORMINOR 53 +#define VER_MINORMINOR 54 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Added: trunk/OpenMPT/soundlib/MIDIMacros.cpp =================================================================== --- trunk/OpenMPT/soundlib/MIDIMacros.cpp (rev 0) +++ trunk/OpenMPT/soundlib/MIDIMacros.cpp 2011-11-18 22:52:19 UTC (rev 1138) @@ -0,0 +1,291 @@ +/* + * MIDIMacros.cpp + * -------------- + * Purpose: Helper functions / classes for MIDI Macro functionality. + * Notes : (currently none) + * Authors: OpenMPT Devs + */ + +#include "stdafx.h" +#include "midi.h" +#include "Sndfile.h" +#include "MIDIMacros.h" +#ifndef NO_VST +#include "../mptrack/Vstplug.h" +#endif // NO_VST + + +enmParameteredMacroType MIDIMacroTools::GetMacroType(CString value) +//----------------------------------------------------------------- +{ + value.Remove(' '); + for(size_t i = 0; i < sfx_max; i++) + { + enmParameteredMacroType sfx = static_cast<enmParameteredMacroType>(i); + if(sfx != sfx_custom) + { + if(value.Compare(CreateParameteredMacroFromType(sfx)) == 0) return sfx; + } + } + // Special macros with additional "parameter": + if (value.Compare(CreateParameteredMacroFromType(sfx_cc, MIDICC_start)) >= 0 && value.Compare(CreateParameteredMacroFromType(sfx_cc, MIDICC_end)) <= 0 && value.GetLength() == 5) + return sfx_cc; + if (value.Compare(CreateParameteredMacroFromType(sfx_plug, 0)) >= 0 && value.Compare(CreateParameteredMacroFromType(sfx_plug, 0x17F)) <= 0 && value.GetLength() == 7) + return sfx_plug; + return sfx_custom; // custom / unknown +} + + +// Returns macro description including plugin parameter / MIDI CC information +CString MIDIMacroTools::GetMacroName(CString value, PLUGINDEX plugin) const +//------------------------------------------------------------------------- +{ + const enmParameteredMacroType macroType = GetMacroType(value); + + switch(macroType) + { + case sfx_plug: + { + const int param = MacroToPlugParam(value); + CString paramName; + +#ifndef NO_VST + if(plugin < MAX_MIXPLUGINS) + { + CVstPlugin *pPlug = reinterpret_cast<CVstPlugin *>(m_SndFile.m_MixPlugins[plugin].pMixPlugin); + if(pPlug) + { + paramName = pPlug->GetParamName(param); + } + if (paramName.IsEmpty()) + { + return _T("N/A"); + } + + CString formattedName; + formattedName.Format(_T("Param %d (%s)"), param, paramName); + return CString(formattedName); + } else +#endif // NO_VST + { + return _T("N/A - No Plugin"); + } + } + + case sfx_cc: + { + CString formattedCC; + formattedCC.Format(_T("MIDI CC %d"), MacroToMidiCC(value)); + return formattedCC; + } + + default: + return GetMacroName(macroType); + } +} + + +// Returns generic macro description. +CString MIDIMacroTools::GetMacroName(enmParameteredMacroType macro) +//----------------------------------------------------------------- +{ + switch(macro) + { + case sfx_unused: + return _T("Unused"); + case sfx_cutoff: + return _T("Set Filter Cutoff"); + case sfx_reso: + return _T("Set Filter Resonance"); + case sfx_mode: + return _T("Set Filter Mode"); + case sfx_drywet: + return _T("Set Plugin Dry/Wet Ratio"); + case sfx_plug: + return _T("Control Plugin Parameter..."); + case sfx_cc: + return _T("MIDI CC..."); + case sfx_custom: + default: + return _T("Custom"); + } +} + + +int MIDIMacroTools::MacroToPlugParam(CString macro) +//------------------------------------------------- +{ + macro.Remove(' '); + int code=0; + char* param = (char *) (LPCTSTR) macro; + param += 4; + if ((param[0] >= '0') && (param[0] <= '9')) code = (param[0] - '0') << 4; else + if ((param[0] >= 'A') && (param[0] <= 'F')) code = (param[0] - 'A' + 0x0A) << 4; + if ((param[1] >= '0') && (param[1] <= '9')) code += (param[1] - '0'); else + if ((param[1] >= 'A') && (param[1] <= 'F')) code += (param[1] - 'A' + 0x0A); + + if (macro.GetLength() >= 4 && macro.GetAt(3) == '0') + return (code - 128); + else + return (code + 128); +} + + +int MIDIMacroTools::MacroToMidiCC(CString macro) +//---------------------------------------------- +{ + macro.Remove(' '); + int code=0; + char* param = (char *) (LPCTSTR) macro; + param += 2; + if ((param[0] >= '0') && (param[0] <= '9')) code = (param[0] - '0') << 4; else + if ((param[0] >= 'A') && (param[0] <= 'F')) code = (param[0] - 'A' + 0x0A) << 4; + if ((param[1] >= '0') && (param[1] <= '9')) code += (param[1] - '0'); else + if ((param[1] >= 'A') && (param[1] <= 'F')) code += (param[1] - 'A' + 0x0A); + + return code; +} + + +int MIDIMacroTools::FindMacroForParam(long param) const +//----------------------------------------------------- +{ + for (size_t macro = 0; macro < NUM_MACROS; macro++) + { + CString macroString = m_SndFile.m_MidiCfg.szMidiSFXExt[macro]; + if (GetMacroType(macroString) == sfx_plug && MacroToPlugParam(macroString) == param) + { + return macro; + } + } + + return -1; +} + + +// Retrieve Zxx (Z80-ZFF) type from current macro configuration +enmFixedMacroType MIDIMacroTools::GetZxxType(const char (&szMidiZXXExt)[128][MACRO_LENGTH]) +//----------------------------------------------------------------------------------------- +{ + // Compare with all possible preset patterns + for(size_t i = 1; i < zxx_max; i++) + { + // Prepare pattern to compare + char szPatterns[128][MACRO_LENGTH]; + CreateZxxFromType(szPatterns, static_cast<enmFixedMacroType>(i)); + + bool bFound = true; + for(size_t j = 0; j < 128; j++) + { + if(strncmp(szPatterns[j], szMidiZXXExt[j], MACRO_LENGTH)) + { + bFound = false; + break; + } + } + if(bFound) return static_cast<enmFixedMacroType>(i); + } + return zxx_custom; // Custom setup +} + + +// Create Zxx (Z80 - ZFF) from one out of five presets +void MIDIMacroTools::CreateZxxFromType(char (&szMidiZXXExt)[128][MACRO_LENGTH], enmFixedMacroType iZxxType) +//--------------------------------------------------------------------------------------------------------- +{ + for(size_t i = 0; i < 128; i++) + { + switch(iZxxType) + { + case zxx_reso4Bit: + // Type 1 - Z80 - Z8F controls resonance + if (i < 16) wsprintf(szMidiZXXExt[i], "F0F001%02X", i * 8); + else strcpy(szMidiZXXExt[i], ""); + break; + + case zxx_reso7Bit: + // Type 2 - Z80 - ZFF controls resonance + wsprintf(szMidiZXXExt[i], "F0F001%02X", i); + break; + + case zxx_cutoff: + // Type 3 - Z80 - ZFF controls cutoff + wsprintf(szMidiZXXExt[i], "F0F000%02X", i); + break; + + case zxx_mode: + // Type 4 - Z80 - ZFF controls filter mode + wsprintf(szMidiZXXExt[i], "F0F002%02X", i); + break; + + case zxx_resomode: + // Type 5 - Z80 - Z9F controls resonance + filter mode + if (i < 16) wsprintf(szMidiZXXExt[i], "F0F001%02X", i * 8); + else if (i < 32) wsprintf(szMidiZXXExt[i], "F0F002%02X", (i - 16) * 8); + else strcpy(szMidiZXXExt[i], ""); + break; + } + } +} + + +CString MIDIMacroTools::CreateParameteredMacroFromType(enmParameteredMacroType type, int subType) +//----------------------------------------------------------------------------------------------- +{ + CString result; + + switch(type) + { + case sfx_unused: + result = ""; + break; + case sfx_cutoff: + result = "F0F000z"; + break; + case sfx_reso: + result = "F0F001z"; + break; + case sfx_mode: + result = "F0F002z"; + break; + case sfx_drywet: + result = "F0F003z"; + break; + case sfx_cc: + result.Format("Bc%02Xz", subType); + break; + case sfx_plug: + result.Format("F0F%03Xz", subType + 0x80); + break; + } + return result; +} + + +// Check if the MIDI Macro confi... [truncated message content] |