From: <sag...@us...> - 2013-03-17 14:35:13
|
Revision: 1592 http://sourceforge.net/p/modplug/code/1592 Author: saga-games Date: 2013-03-17 14:35:03 +0000 (Sun, 17 Mar 2013) Log Message: ----------- [New] Chord Editor: Added a possibility to make chords relative to a note entered in the pattern (http://bugs.openmpt.org/view.php?id=360) [Mod] OpenMPT: Version is now 1.21.01.22 Modified Paths: -------------- trunk/OpenMPT/common/version.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainbar.cpp trunk/OpenMPT/mptrack/Mainbar.h trunk/OpenMPT/mptrack/Mainfrm.h 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/common/version.h =================================================================== --- trunk/OpenMPT/common/version.h 2013-03-17 14:06:32 UTC (rev 1591) +++ trunk/OpenMPT/common/version.h 2013-03-17 14:35:03 UTC (rev 1592) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 21 #define VER_MINOR 01 -#define VER_MINORMINOR 21 +#define VER_MINORMINOR 22 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-17 14:06:32 UTC (rev 1591) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-03-17 14:35:03 UTC (rev 1592) @@ -1274,8 +1274,8 @@ ///////////////////////////////////////////////////////////////////////////// // CMainFrame operations -UINT CMainFrame::GetBaseOctave() -//------------------------------ +UINT CMainFrame::GetBaseOctave() const +//------------------------------------ { return m_wndToolBar.GetBaseOctave(); } Modified: trunk/OpenMPT/mptrack/Mainbar.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.cpp 2013-03-17 14:06:32 UTC (rev 1591) +++ trunk/OpenMPT/mptrack/Mainbar.cpp 2013-03-17 14:35:03 UTC (rev 1592) @@ -393,8 +393,8 @@ } -UINT CMainToolBar::GetBaseOctave() -//-------------------------------- +UINT CMainToolBar::GetBaseOctave() const +//-------------------------------------- { if (nCurrentOctave >= MIN_BASEOCTAVE) return (UINT)nCurrentOctave; return 4; Modified: trunk/OpenMPT/mptrack/Mainbar.h =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.h 2013-03-17 14:06:32 UTC (rev 1591) +++ trunk/OpenMPT/mptrack/Mainbar.h 2013-03-17 14:35:03 UTC (rev 1592) @@ -68,7 +68,7 @@ public: BOOL Create(CWnd *parent); void Init(CMainFrame *); - UINT GetBaseOctave(); + UINT GetBaseOctave() const; BOOL SetBaseOctave(UINT nOctave); BOOL SetCurrentSong(CSoundFile *pModDoc); Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-17 14:06:32 UTC (rev 1591) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-03-17 14:35:03 UTC (rev 1592) @@ -420,11 +420,12 @@ void SetInfoText(LPCSTR lpszText); void SetXInfoText(LPCSTR lpszText); //rewbs.xinfo void SetHelpText(LPCSTR lpszText); - UINT GetBaseOctave(); + UINT GetBaseOctave() const; 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 14:06:32 UTC (rev 1591) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2013-03-17 14:35:03 UTC (rev 1592) @@ -1303,11 +1303,12 @@ pMainFrm = CMainFrame::GetMainFrame(); if (!pMainFrm) return TRUE; // Fills the shortcut key combo box - AppendNotesToControl(m_CbnShortcut, 0, 3*12-1); + AppendNotesToControl(m_CbnShortcut, 0, 3 * 12 - 1); m_CbnShortcut.SetCurSel(0); // Base Note combo box - AppendNotesToControl(m_CbnBaseNote, 0, 3*12-1); + m_CbnBaseNote.SetItemData(m_CbnBaseNote.AddString("Relative"), MPTChord::relativeMode); + AppendNotesToControl(m_CbnBaseNote, 0, 3 * 12 - 1); // Minor notes for (int inotes=-1; inotes<24; inotes++) @@ -1371,7 +1372,10 @@ chord = m_CbnShortcut.GetCurSel(); if (chord >= 0) chord = m_CbnShortcut.GetItemData(chord); if ((chord < 0) || (chord >= CountOf(chords))) chord = 0; - m_CbnBaseNote.SetCurSel(chords[chord].key); + if(chords[chord].key != MPTChord::relativeMode) + m_CbnBaseNote.SetCurSel(chords[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]); @@ -1393,8 +1397,13 @@ if ((chord < 0) || (chord >= CountOf(chords))) chord = 0; note = chords[chord].key % 12; octave = chords[chord].key / 12; - for (UINT i=0; i<2*12; i++) + if(chords[chord].key == MPTChord::relativeMode) { + note = -1; + octave = 0; + } + for(UINT i=0; i<2*12; i++) + { BOOL b = FALSE; if (i == note) b = TRUE; @@ -1417,12 +1426,9 @@ int chord = m_CbnShortcut.GetCurSel(); if (chord >= 0) chord = m_CbnShortcut.GetItemData(chord); if ((chord < 0) || (chord >= CountOf(chords))) chord = 0; - int basenote = m_CbnBaseNote.GetCurSel(); - if (basenote >= 0) - { - chords[chord].key = (uint8)basenote; - UpdateKeyboard(); - } + int basenote = m_CbnBaseNote.GetItemData(m_CbnBaseNote.GetCurSel()); + chords[chord].key = (uint8)basenote; + UpdateKeyboard(); } Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-17 14:06:32 UTC (rev 1591) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2013-03-17 14:35:03 UTC (rev 1592) @@ -126,8 +126,13 @@ // Chords struct MPTChord { - uint8 key; - uint8 notes[3]; + enum + { + relativeMode = 0x3F, + }; + + uint8 key; // Base note + uint8 notes[3]; // Additional chord notes }; typedef MPTChord MPTChords[3 * 12]; // 3 octaves Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-17 14:06:32 UTC (rev 1591) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2013-03-17 14:35:03 UTC (rev 1592) @@ -186,7 +186,7 @@ m_nFoundInstrument = 0; m_nLastPlayedRow = 0; m_nLastPlayedOrder = 0; - prevChordNote = 0; + prevChordNote = NOTE_NONE; } @@ -4723,11 +4723,16 @@ m_Status.reset(psChordPlaying); ModCommand::NOTE notes[4]; - int numNotes = ConstructChord(note, notes); + int 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); } + prevChordNote = NOTE_NONE; } else { pModDoc->NoteOff(note, ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOTEFADE) || pSndFile->GetNumInstruments() == 0), ins, nChnCursor, playWholeRow ? nChn : CHANNELINDEX_INVALID); @@ -5216,34 +5221,51 @@ // Construct a chord from the chord presets. Returns number of notes in chord. -int CViewPattern::ConstructChord(int note, ModCommand::NOTE (&outNotes)[4]) -//------------------------------------------------------------------------- +int CViewPattern::ConstructChord(int note, ModCommand::NOTE (&outNotes)[4], ModCommand::NOTE baseNote) +//---------------------------------------------------------------------------------------------------- { - CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - MPTChords &chords = pMainFrm->GetChords(); + const CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); + const MPTChords &chords = pMainFrm->GetChords(); UINT baseOctave = pMainFrm->GetBaseOctave(); - UINT chordNum = note - baseOctave * 12 - 1; + UINT chordNum = note - baseOctave * 12 - NOTE_MIN; if(chordNum >= CountOf(chords)) { return 0; } - MPTChord &chord = chords[chordNum]; + const MPTChord &chord = chords[chordNum]; - ModCommand::NOTE baseNote = static_cast<ModCommand::NOTE>(chord.key + baseOctave * 12 + 1); - if(!ModCommand::IsNote(baseNote)) + const bool relativeMode = (chord.key == MPTChord::relativeMode); // Notes are relative to a previously entered note in the pattern + ModCommand::NOTE key; + if(relativeMode) { + // Relative mode: Use pattern note as base note. + // If there is no valid note in the pattern: Use shortcut note as relative base note + key = ModCommand::IsNote(baseNote) ? baseNote : static_cast<ModCommand::NOTE>(note); + } else + { + // Default mode: Use base key + key = static_cast<ModCommand::NOTE>(chord.key + baseOctave * 12 + NOTE_MIN); + } + if(!ModCommand::IsNote(key)) + { return 0; } int numNotes = 1; - outNotes[0] = baseNote; + outNotes[0] = key; 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]); + ModCommand::NOTE note = key - NOTE_MIN; + if(!relativeMode) + { + // Only use octave information from the base key + note = (note / 12) * 12; + } + note += chord.notes[i]; if(ModCommand::IsNote(note)) { outNotes[numNotes++] = note; @@ -5266,15 +5288,16 @@ } CSoundFile &sndFile = pModDoc->GetrSoundFile(); - ModCommand::NOTE chordNotes[4]; - int numNotes = ConstructChord(note, chordNotes); + const CHANNELINDEX chn = GetCurrentChannel(); + const PatternRow rowBase = sndFile.Patterns[m_nPattern].GetRow(GetCurrentRow()); + + ModCommand::NOTE chordNotes[4], baseNote = rowBase[chn].note; + int numNotes = ConstructChord(note, chordNotes, baseNote); if(!numNotes) { return; } - 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()); @@ -5342,11 +5365,13 @@ // -- play note if((TrackerSettings::Instance().m_dwPatternSetup & (PATTERN_PLAYNEWNOTE | PATTERN_PLAYEDITROW)) || !recordEnabled) { - if(prevChordNote) + if(prevChordNote != NOTE_NONE) { TempStopChord(prevChordNote); - prevChordNote = note; } + prevChordNote = note; + prevChordBaseNote = baseNote; + const bool playWholeRow = ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord); if(playWholeRow) { Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2013-03-17 14:06:32 UTC (rev 1591) +++ trunk/OpenMPT/mptrack/View_pat.h 2013-03-17 14:35:03 UTC (rev 1592) @@ -195,10 +195,12 @@ WORD ChnVUMeters[MAX_BASECHANNELS]; WORD OldVUMeters[MAX_BASECHANNELS]; + // Chord preview + CHANNELINDEX chordPlayChannels[4]; + ModCommand::NOTE prevChordNote, prevChordBaseNote; + BYTE activeNoteChannel[NOTE_MAX + 1]; BYTE splitActiveNoteChannel[NOTE_MAX + 1]; - CHANNELINDEX chordPlayChannels[4]; - ModCommand::NOTE prevChordNote; public: CEffectVis *m_pEffectVis; //rewbs.fxVis @@ -310,7 +312,7 @@ 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]); + static int ConstructChord(int note, ModCommand::NOTE (&outNotes)[4], 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. |