From: <sag...@us...> - 2010-02-20 21:02:11
|
Revision: 503 http://modplug.svn.sourceforge.net/modplug/?rev=503&view=rev Author: saga-games Date: 2010-02-20 21:02:02 +0000 (Sat, 20 Feb 2010) Log Message: ----------- [New] Instrument Editor: Transpose Up/Down for sample map. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_ins.h trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/soundlib/modcommand.h Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-02-20 20:34:40 UTC (rev 502) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2010-02-20 21:02:02 UTC (rev 503) @@ -25,6 +25,8 @@ ON_WM_LBUTTONDOWN() ON_WM_RBUTTONDOWN() ON_WM_LBUTTONDBLCLK() + ON_COMMAND(ID_NOTEMAP_TRANS_UP, OnMapTransposeUp) + ON_COMMAND(ID_NOTEMAP_TRANS_DOWN, OnMapTransposeDown) ON_COMMAND(ID_NOTEMAP_COPY_NOTE, OnMapCopyNote) ON_COMMAND(ID_NOTEMAP_COPY_SMP, OnMapCopySample) ON_COMMAND(ID_NOTEMAP_RESET, OnMapReset) @@ -288,7 +290,7 @@ if (hMenu) { - AppendMenu(hMenu, MF_STRING, ID_INSTRUMENT_SAMPLEMAP, "Edit Sample Map"); + AppendMenu(hMenu, MF_STRING, ID_INSTRUMENT_SAMPLEMAP, "Edit Sample &Map"); if (hSubMenu) { BYTE smpused[(MAX_SAMPLES+7)/8]; @@ -309,18 +311,24 @@ AppendMenu(hSubMenu, MF_STRING, ID_NOTEMAP_EDITSAMPLE+j, s); } } - AppendMenu(hMenu, MF_POPUP, (UINT)hSubMenu, "Edit Sample"); + AppendMenu(hMenu, MF_POPUP, (UINT)hSubMenu, "&Edit Sample"); AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); } - wsprintf(s, "Map all notes to sample %d", pIns->Keyboard[m_nNote]); + wsprintf(s, "Map all notes to &sample %d", pIns->Keyboard[m_nNote]); AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_COPY_SMP, s); - if(pIns->NoteMap[m_nNote] < NOTE_MIN_SPECIAL) - wsprintf(s, "Map all notes to %s", pSndFile->GetNoteName(pIns->NoteMap[m_nNote], m_nInstrument).c_str()); - else - wsprintf(s, "Map all notes to %s", szSpecialNoteNames[pIns->NoteMap[m_nNote] - NOTE_MIN_SPECIAL]); - AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_COPY_NOTE, s); - AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_RESET, "Reset note mapping"); - AppendMenu(hMenu, MF_STRING, ID_INSTRUMENT_DUPLICATE, "Duplicate Instrument\tShift+New"); + + if(pSndFile->GetType() != MOD_TYPE_XM) + { + if(pIns->NoteMap[m_nNote] < NOTE_MIN_SPECIAL) + wsprintf(s, "Map all ¬es to %s", pSndFile->GetNoteName(pIns->NoteMap[m_nNote], m_nInstrument).c_str()); + else + wsprintf(s, "Map all ¬es to %s", szSpecialNoteNames[pIns->NoteMap[m_nNote] - NOTE_MIN_SPECIAL]); + AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_COPY_NOTE, s); + AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_TRANS_UP, "Transpose map &up"); + AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_TRANS_DOWN, "Transpose map &down"); + } + AppendMenu(hMenu, MF_STRING, ID_NOTEMAP_RESET, "&Reset note mapping"); + AppendMenu(hMenu, MF_STRING, ID_INSTRUMENT_DUPLICATE, "Duplicate &Instrument\tShift+New"); SetMenuDefaultItem(hMenu, ID_INSTRUMENT_SAMPLEMAP, FALSE); ClientToScreen(&pt); ::TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, m_hWnd, NULL); @@ -335,56 +343,52 @@ void CNoteMapWnd::OnMapCopyNote() //------------------------------- { - if (m_pModDoc) + if(m_pModDoc == nullptr) return; + CSoundFile *pSndFile; + MODINSTRUMENT *pIns; + + pSndFile = m_pModDoc->GetSoundFile(); + pIns = pSndFile->Instruments[m_nInstrument]; + if (pIns) { - CSoundFile *pSndFile; - MODINSTRUMENT *pIns; - - pSndFile = m_pModDoc->GetSoundFile(); - pIns = pSndFile->Instruments[m_nInstrument]; - if (pIns) + bool bModified = false; + UINT n = pIns->NoteMap[m_nNote]; + for (NOTEINDEXTYPE i = 0; i < NOTE_MAX; i++) if (pIns->NoteMap[i] != n) { - BOOL bModified = FALSE; - UINT n = pIns->NoteMap[m_nNote]; - for (UINT i=0; i<NOTE_MAX; i++) if (pIns->NoteMap[i] != n) - { - pIns->NoteMap[i] = n; - bModified = TRUE; - } - if (bModified) - { - m_pModDoc->SetModified(); - InvalidateRect(NULL, FALSE); - } + pIns->NoteMap[i] = n; + bModified = true; } + if (bModified) + { + m_pModDoc->SetModified(); + InvalidateRect(NULL, FALSE); + } } } void CNoteMapWnd::OnMapCopySample() -//------------------------------------- +//--------------------------------- { - if (m_pModDoc) + if(m_pModDoc == nullptr) return; + CSoundFile *pSndFile; + MODINSTRUMENT *pIns; + + pSndFile = m_pModDoc->GetSoundFile(); + pIns = pSndFile->Instruments[m_nInstrument]; + if (pIns) { - CSoundFile *pSndFile; - MODINSTRUMENT *pIns; - - pSndFile = m_pModDoc->GetSoundFile(); - pIns = pSndFile->Instruments[m_nInstrument]; - if (pIns) + bool bModified = false; + UINT n = pIns->Keyboard[m_nNote]; + for (NOTEINDEXTYPE i = 0; i < NOTE_MAX; i++) if (pIns->Keyboard[i] != n) { - BOOL bModified = FALSE; - UINT n = pIns->Keyboard[m_nNote]; - for (UINT i=0; i<NOTE_MAX; i++) if (pIns->Keyboard[i] != n) - { - pIns->Keyboard[i] = n; - bModified = TRUE; - } - if (bModified) - { - m_pModDoc->SetModified(); - InvalidateRect(NULL, FALSE); - } + pIns->Keyboard[i] = n; + bModified = true; } + if (bModified) + { + m_pModDoc->SetModified(); + InvalidateRect(NULL, FALSE); + } } } @@ -392,27 +396,70 @@ void CNoteMapWnd::OnMapReset() //---------------------------- { - if (m_pModDoc) + if(m_pModDoc == nullptr) return; + CSoundFile *pSndFile; + MODINSTRUMENT *pIns; + + pSndFile = m_pModDoc->GetSoundFile(); + pIns = pSndFile->Instruments[m_nInstrument]; + if (pIns) { - CSoundFile *pSndFile; - MODINSTRUMENT *pIns; - - pSndFile = m_pModDoc->GetSoundFile(); - pIns = pSndFile->Instruments[m_nInstrument]; - if (pIns) + bool bModified = false; + for (NOTEINDEXTYPE i = 0; i < NOTE_MAX; i++) if (pIns->NoteMap[i] != i + 1) { - BOOL bModified = FALSE; - for (UINT i=0; i<NOTE_MAX; i++) if (pIns->NoteMap[i] != i+1) + pIns->NoteMap[i] = i + 1; + bModified = true; + } + if (bModified) + { + m_pModDoc->SetModified(); + InvalidateRect(NULL, FALSE); + } + } +} + + +void CNoteMapWnd::OnMapTransposeUp() +//---------------------------------- +{ + MapTranspose(1); +} + + +void CNoteMapWnd::OnMapTransposeDown() +//------------------------------------ +{ + MapTranspose(-1); +} + + +void CNoteMapWnd::MapTranspose(int nAmount) +//----------------------------------------- +{ + if(m_pModDoc == nullptr || nAmount == 0) return; + CSoundFile *pSndFile; + MODINSTRUMENT *pIns; + + pSndFile = m_pModDoc->GetSoundFile(); + pIns = pSndFile->Instruments[m_nInstrument]; + if (pIns) + { + bool bModified = false; + for(NOTEINDEXTYPE i = 0; i < NOTE_MAX; i++) + { + int n = pIns->NoteMap[i]; + if ((n > NOTE_MIN && nAmount < 0) || (n < NOTE_MAX && nAmount > 0)) { - pIns->NoteMap[i] = i+1; - bModified = TRUE; + n = CLAMP(n + nAmount, NOTE_MIN, NOTE_MAX); + pIns->NoteMap[i] = (BYTE)n; + bModified = true; } - if (bModified) - { - m_pModDoc->SetModified(); - InvalidateRect(NULL, FALSE); - } } + if (bModified) + { + m_pModDoc->SetModified(); + InvalidateRect(NULL, FALSE); + } } } Modified: trunk/OpenMPT/mptrack/Ctrl_ins.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.h 2010-02-20 20:34:40 UTC (rev 502) +++ trunk/OpenMPT/mptrack/Ctrl_ins.h 2010-02-20 21:02:02 UTC (rev 503) @@ -19,6 +19,9 @@ int m_cxFont, m_cyFont; COLORREF colorText, colorTextSel; +private: + void MapTranspose(int nAmount); + public: CNoteMapWnd() { m_nPlayingNote=-1; m_nNote = 5*12; m_pModDoc = NULL; m_nInstrument = 0; m_bIns = FALSE; m_cxFont = m_cyFont = 0; m_hFont = NULL; m_nOldNote = m_nOldIns = 0; m_pParent = NULL; } BOOL SetCurrentInstrument(CModDoc *pModDoc, UINT nIns); @@ -47,6 +50,8 @@ afx_msg void OnPaint(); afx_msg void OnMapCopySample(); afx_msg void OnMapCopyNote(); + afx_msg void OnMapTransposeUp(); + afx_msg void OnMapTransposeDown(); afx_msg void OnMapReset(); afx_msg void OnEditSample(UINT nID); afx_msg void OnEditSampleMap(); Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2010-02-20 20:34:40 UTC (rev 502) +++ trunk/OpenMPT/mptrack/resource.h 2010-02-20 21:02:02 UTC (rev 503) @@ -1200,6 +1200,8 @@ #define ID_SAMPLE_GENERATOR_MENU 60244 #define ID_SAMPLE_GENERATOR_PRESET_MENU 60344 #define ID_SAMPLE_GENERATE 60445 +#define ID_NOTEMAP_TRANS_UP 60446 +#define ID_NOTEMAP_TRANS_DOWN 60447 // Next default values for new objects // @@ -1207,7 +1209,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 526 -#define _APS_NEXT_COMMAND_VALUE 60446 +#define _APS_NEXT_COMMAND_VALUE 60448 #define _APS_NEXT_CONTROL_VALUE 2427 #define _APS_NEXT_SYMED_VALUE 901 #endif Modified: trunk/OpenMPT/soundlib/modcommand.h =================================================================== --- trunk/OpenMPT/soundlib/modcommand.h 2010-02-20 20:34:40 UTC (rev 502) +++ trunk/OpenMPT/soundlib/modcommand.h 2010-02-20 21:02:02 UTC (rev 503) @@ -10,6 +10,7 @@ #define NOTE_FADE 0xFD //253, IT's action for illegal notes - DO NOT SAVE AS 253 as this is IT's internal representation of "no note"! #define NOTE_PC 0xFC //252, Param Control 'note'. Changes param value on first tick. #define NOTE_PCS 0xFB //251, Param Control(Smooth) 'note'. Changes param value during the whole row. +#define NOTE_MIN 1 #define NOTE_MAX 120 //Defines maximum notevalue(with index starting from 1) as well as maximum number of notes. #define NOTE_MAX_SPECIAL NOTE_KEYOFF #define NOTE_MIN_SPECIAL NOTE_PCS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |