From: <sag...@us...> - 2010-10-15 14:23:05
|
Revision: 738 http://modplug.svn.sourceforge.net/modplug/?rev=738&view=rev Author: saga-games Date: 2010-10-15 14:22:57 +0000 (Fri, 15 Oct 2010) Log Message: ----------- [Fix] The new "play whole row" thing should also work properly with auto stepping enabled. This also involves a change in CSoundFile::IsPaused() to also check for SONG_STEP, which fixes some problems with this new edit mode but I hope it doesn't break anything else (looks like it doesn't, but who knows...) Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2010-10-12 20:17:40 UTC (rev 737) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2010-10-15 14:22:57 UTC (rev 738) @@ -1878,17 +1878,14 @@ BOOL CMainFrame::PlayMod(CModDoc *pModDoc, HWND hPat, DWORD dwNotifyType) //----------------------------------------------------------------------- { - BOOL bPaused, bPatLoop, bResetAGC; if (!pModDoc) return FALSE; CSoundFile *pSndFile = pModDoc->GetSoundFile(); if ((!pSndFile) || (!pSndFile->GetType())) return FALSE; - bPaused = (pSndFile->m_dwSongFlags & SONG_PAUSED) ? TRUE : FALSE; - bPatLoop = (pSndFile->m_dwSongFlags & SONG_PATTERNLOOP) ? TRUE : FALSE; + const bool bPaused = pSndFile->IsPaused(); + const bool bPatLoop = (pSndFile->m_dwSongFlags & SONG_PATTERNLOOP) ? true : false; pSndFile->ResetChannels(); - bResetAGC = FALSE; - if (((m_pSndFile) && (pSndFile != m_pSndFile)) || (!m_dwElapsedTime)) bResetAGC = TRUE; if ((m_pSndFile) || (m_dwStatus & MODSTATUS_PLAYING)) PauseMod(); - if (bResetAGC) CSoundFile::ResetAGC(); + if (((m_pSndFile) && (pSndFile != m_pSndFile)) || (!m_dwElapsedTime)) CSoundFile::ResetAGC(); m_pSndFile = pSndFile; m_pModPlaying = pModDoc; m_hFollowSong = hPat; Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2010-10-12 20:17:40 UTC (rev 737) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2010-10-15 14:22:57 UTC (rev 738) @@ -162,9 +162,11 @@ #define NUM_VUMETER_PENS 32 // Pattern Setup (contains also non-pattern related settings) +// Feel free to replace the deprecated flags by new flags, but be sure to +// update CMainFrame::LoadIniSettings() as well. #define PATTERN_PLAYNEWNOTE 0x01 // play new notes while recording #define PATTERN_LARGECOMMENTS 0x02 // use large font in comments -#define PATTERN_STDHIGHLIGHT 0x04 // enable primary highlight +#define PATTERN_STDHIGHLIGHT 0x04 // enable primary highlight (measures) #define PATTERN_SMALLFONT 0x08 // use small font in pattern editor #define PATTERN_CENTERROW 0x10 // always center active row #define PATTERN_WRAP 0x20 // wrap around cursor in editor @@ -176,7 +178,7 @@ #define PATTERN_PLAYEDITROW 0x800 // play all notes on the current row while entering notes #define PATTERN_NOEXTRALOUD 0x1000 // no loud samples in sample editor #define PATTERN_DRAGNDROPEDIT 0x2000 // enable drag and drop editing -#define PATTERN_2NDHIGHLIGHT 0x4000 // activate secondary highlight +#define PATTERN_2NDHIGHLIGHT 0x4000 // activate secondary highlight (beats) #define PATTERN_MUTECHNMODE 0x8000 // ignore muted channels #define PATTERN_SHOWPREVIOUS 0x10000 // show prev/next patterns #define PATTERN_CONTSCROLL 0x20000 // continous pattern scrolling Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2010-10-12 20:17:40 UTC (rev 737) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2010-10-15 14:22:57 UTC (rev 738) @@ -2007,7 +2007,7 @@ void CViewPattern::PatternStep(bool autoStep) -//--------------------------------------------- +//------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); CModDoc *pModDoc = GetDocument(); @@ -2015,17 +2015,17 @@ if ((pMainFrm) && (pModDoc)) { CSoundFile *pSndFile = pModDoc->GetSoundFile(); - if ((!pSndFile->Patterns[m_nPattern].GetNumRows()) || (!pSndFile->Patterns[m_nPattern])) return; - // Cut instrument/sample + if ((!pSndFile->Patterns.IsValidPat(m_nPattern)) || (!pSndFile->Patterns[m_nPattern].GetNumRows())) return; BEGIN_CRITICAL(); - for (UINT i=pSndFile->m_nChannels; i<MAX_CHANNELS; i++) + // Cut instrument\xB4s/samples in virtual channels + for (CHANNELINDEX i = pSndFile->m_nChannels; i < MAX_CHANNELS; i++) { pSndFile->Chn[i].dwFlags |= CHN_NOTEFADE | CHN_KEYOFF; - pSndFile->m_dwSongFlags &= ~SONG_PAUSED; - pSndFile->LoopPattern(m_nPattern); - pSndFile->m_nNextRow = GetCurrentRow(); - pSndFile->m_dwSongFlags |= SONG_STEP; } + pSndFile->LoopPattern(m_nPattern); + pSndFile->m_nNextRow = GetCurrentRow(); + pSndFile->m_dwSongFlags &= ~SONG_PAUSED; + pSndFile->m_dwSongFlags |= SONG_STEP; END_CRITICAL(); if (pMainFrm->GetModPlaying() != pModDoc) { @@ -3770,6 +3770,8 @@ } \ } + +// Enter volume effect / number in the pattern. void CViewPattern::TempEnterVol(int v) //------------------------------------ { @@ -3864,6 +3866,7 @@ } +// Enter an effect letter in the pattenr void CViewPattern::TempEnterFX(int c) //----------------------------------- { @@ -3918,6 +3921,7 @@ } +// Enter an effect param in the pattenr void CViewPattern::TempEnterFXparam(int v) //---------------------------------------- { @@ -3964,6 +3968,7 @@ } +// Stop a note that has been entered void CViewPattern::TempStopNote(int note, bool fromMidi, const bool bChordMode) //----------------------------------------------------------------------------- { @@ -4097,6 +4102,7 @@ } +// Enter an octave number in the pattern void CViewPattern::TempEnterOctave(int val) //----------------------------------------- { @@ -4118,6 +4124,8 @@ } + +// Enter an instrument number in the pattern void CViewPattern::TempEnterIns(int val) //-------------------------------------- { @@ -4178,6 +4186,7 @@ } +// Enter a note in the pattern void CViewPattern::TempEnterNote(int note, bool oldStyle, int vol) //---------------------------------------------------------------- { @@ -4230,11 +4239,15 @@ // -- Chord autodetection: step back if we just entered a note - if ((bRecordEnabled) && (recordGroup) && !bIsLiveRecord) { - if ((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) { + if ((bRecordEnabled) && (recordGroup) && !bIsLiveRecord) + { + if ((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) + { if ((timeGetTime() - m_dwLastNoteEntryTime < CMainFrame::gnAutoChordWaitTime) - && (nRow>=m_nSpacing) && (!m_bLastNoteEntryBlocked)) + && (nRow >= m_nSpacing) && (!m_bLastNoteEntryBlocked)) + { nRow -= m_nSpacing; + } } } m_dwLastNoteEntryTime = timeGetTime(); @@ -4257,7 +4270,7 @@ // -- write note and instrument data. const bool isSplit = HandleSplit(p, note); - // Nice idea actually: Use lower section of the keyboard to play chords + // Nice idea actually: Use lower section of the keyboard to play chords (but it won't work 100% correctly this way...) /*if(isSplit) { TempEnterChord(note); @@ -4306,6 +4319,57 @@ if (oldStyle && ((p->note == NOTE_NOTECUT) || (p->note == NOTE_KEYOFF) || (p->note == NOTE_FADE))) p->instr=0; + //-- if not recording, restore old command. + if (bRecordEnabled == false) + { + *p = oldcmd; + } + + // -- play note + if ((CMainFrame::m_dwPatternSetup & (PATTERN_PLAYNEWNOTE|PATTERN_PLAYEDITROW)) || (!bRecordEnabled)) + { + if ((CMainFrame::m_dwPatternSetup & PATTERN_PLAYEDITROW) && !bIsLiveRecord) + { + // play the whole row in "step mode" + PatternStep(false); + } else + { + // just play the newly inserted note... + if (p->instr) + { + // ...using the already specified instrument + nPlayIns = p->instr; + } else if ((!p->instr) && (p->note <= NOTE_MAX)) + { + // ...or one that can be found on a previous row of this pattern. + MODCOMMAND *search = p; + UINT srow = nRow; + while (srow-- > 0) + { + search -= pSndFile->m_nChannels; + if (search->instr) + { + nPlayIns = search->instr; + m_nFoundInstrument = nPlayIns; //used to figure out which instrument to stop on key release. + break; + } + } + } + BOOL bNotPlaying = ((pMainFrm->GetModPlaying() == pModDoc) && (pMainFrm->IsPlaying())) ? FALSE : TRUE; + //pModDoc->PlayNote(p->note, nPlayIns, 0, bNotPlaying, -1, 0, 0, nChn); //rewbs.vstiLive - added extra args + pModDoc->PlayNote(p->note, nPlayIns, 0, bNotPlaying, 4*vol, 0, 0, nChn); //rewbs.vstiLive - added extra args +/* for (UINT kplchrd=0; kplchrd<nPlayChord; kplchrd++) + { + if (chordplaylist[kplchrd]) + { + pModDoc->PlayNote(chordplaylist[kplchrd], nPlayIns, 0, FALSE, -1, 0, 0, nChn); //rewbs.vstiLive - - added extra args + m_dwStatus |= PATSTATUS_CHORDPLAYING; + } + } +*/ + } + } + // -- if recording, handle post note entry behaviour (move cursor etc..) if(bRecordEnabled) { @@ -4326,20 +4390,19 @@ } } - //Move cursor down only if not recording live. - if(bIsLiveRecord == false) + // Set new cursor position (row spacing) + if (!bIsLiveRecord) { if((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) { - if(nRow + m_nSpacing < pSndFile->Patterns[nPat].GetNumRows() || (CMainFrame::m_dwPatternSetup & PATTERN_CONTSCROLL)) { SetCurrentRow(nRow + m_nSpacing, (CMainFrame::m_dwPatternSetup & PATTERN_CONTSCROLL) ? true: false); - m_bLastNoteEntryBlocked=false; + 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. + 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. } DWORD sel = m_dwCursor | (m_nRow << 16); @@ -4378,61 +4441,12 @@ } } } - - // -- play note - if ((CMainFrame::m_dwPatternSetup & (PATTERN_PLAYNEWNOTE|PATTERN_PLAYEDITROW)) || (bRecordEnabled == false)) - { - if ((CMainFrame::m_dwPatternSetup & PATTERN_PLAYEDITROW) && !bIsLiveRecord) - { - // play the whole row - PatternStep(false); - } else - { - // just play the newly inserted note... - if (p->instr) - { - // ...using the already specified instrument - nPlayIns = p->instr; - } else if ((!p->instr) && (p->note <= NOTE_MAX)) - { - // ...or one that can be found on a previous row of this pattern. - MODCOMMAND *search = p; - UINT srow = nRow; - while (srow-- > 0) - { - search -= pSndFile->m_nChannels; - if (search->instr) - { - nPlayIns = search->instr; - m_nFoundInstrument = nPlayIns; //used to figure out which instrument to stop on key release. - break; - } - } - } - BOOL bNotPlaying = ((pMainFrm->GetModPlaying() == pModDoc) && (pMainFrm->IsPlaying())) ? FALSE : TRUE; - //pModDoc->PlayNote(p->note, nPlayIns, 0, bNotPlaying, -1, 0, 0, nChn); //rewbs.vstiLive - added extra args - pModDoc->PlayNote(p->note, nPlayIns, 0, bNotPlaying, 4*vol, 0, 0, nChn); //rewbs.vstiLive - added extra args -/* for (UINT kplchrd=0; kplchrd<nPlayChord; kplchrd++) - { - if (chordplaylist[kplchrd]) - { - pModDoc->PlayNote(chordplaylist[kplchrd], nPlayIns, 0, FALSE, -1, 0, 0, nChn); //rewbs.vstiLive - - added extra args - m_dwStatus |= PATSTATUS_CHORDPLAYING; - } - } -*/ - } - } - - //-- if not recording, restore old command. - if (bRecordEnabled == false) - { - *p = oldcmd; - } } } + +// Enter a chord in the pattern void CViewPattern::TempEnterChord(int note) //----------------------------------------- { @@ -4453,7 +4467,9 @@ MODCOMMAND* p = &prowbase[nChn]; const MODCOMMAND oldcmd = *p; // This is the command we are about to overwrite + const bool bIsLiveRecord = IsLiveRecord(*pMainFrm, *pModDoc, *pSndFile); + const bool bRecordEnabled = IsEditingEnabled(); // -- establish note data //const bool isSplit = HandleSplit(p, note); @@ -4490,7 +4506,7 @@ recordGroup = currentRecordGroup; //record group found UINT n = ((nchordnote-1)/12) * 12 + pChords[nchord].notes[nchno]; - if(IsEditingEnabled()) + if(bRecordEnabled) { if ((nchordch != nChn) && recordGroup && (currentRecordGroup == recordGroup) && (n <= NOTE_MAX)) { @@ -4512,7 +4528,7 @@ } // -- write notedata - if(IsEditingEnabled()) + if(bRecordEnabled) { DWORD sel = (m_nRow << 16) | m_dwCursor; SetCurSel(sel, sel); @@ -4523,14 +4539,6 @@ InvalidateRow(); UpdateIndicator(); } - if ( IsLiveRecord(*pMainFrm, *pModDoc, *pSndFile) == false ) - { - if ((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) - SetCurrentRow(m_nRow+m_nSpacing); - DWORD sel = m_dwCursor | (m_nRow << 16); - SetCurSel(sel, sel); - - } } else { // recording disabled @@ -4538,11 +4546,11 @@ } // -- play note - if ((CMainFrame::m_dwPatternSetup & (PATTERN_PLAYNEWNOTE|PATTERN_PLAYEDITROW)) || (!(IsEditingEnabled()))) + if ((CMainFrame::m_dwPatternSetup & (PATTERN_PLAYNEWNOTE|PATTERN_PLAYEDITROW)) || (!bRecordEnabled)) { if ((CMainFrame::m_dwPatternSetup & PATTERN_PLAYEDITROW) && !bIsLiveRecord) { - // play the whole row + // play the whole row in "step mode" PatternStep(false); } else { @@ -4556,9 +4564,8 @@ // ...or one that can be found on a previous row of this pattern. MODCOMMAND *search = p; UINT srow = m_nRow; - while (srow > 0) + while (srow-- > 0) { - srow--; search -= pSndFile->m_nChannels; if (search->instr) { @@ -4580,6 +4587,16 @@ } } } // end play note + + // Set new cursor position (row spacing) - only when not recording live + if (bRecordEnabled && !bIsLiveRecord) + { + if ((m_nSpacing > 0) && (m_nSpacing <= MAX_SPACING)) + SetCurrentRow(m_nRow + m_nSpacing); + DWORD sel = m_dwCursor | (m_nRow << 16); + SetCurSel(sel, sel); + } + } // end mainframe and moddoc exist } Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2010-10-12 20:17:40 UTC (rev 737) +++ trunk/OpenMPT/mptrack/View_pat.h 2010-10-15 14:22:57 UTC (rev 738) @@ -31,7 +31,7 @@ #define PATSTATUS_PATTERNLOOP 0x4000 // Row Spacing -#define MAX_SPACING 64 +#define MAX_SPACING 64 // MAX_PATTERN_ROWS enum PatternColumns { Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2010-10-12 20:17:40 UTC (rev 737) +++ trunk/OpenMPT/soundlib/Sndfile.h 2010-10-15 14:22:57 UTC (rev 738) @@ -688,7 +688,7 @@ void SetRepeatCount(int n) { m_nRepeatCount = n; } int GetRepeatCount() const { return m_nRepeatCount; } - bool IsPaused() const { return (m_dwSongFlags & SONG_PAUSED) ? true : false; } + bool IsPaused() const { return (m_dwSongFlags & (SONG_PAUSED|SONG_STEP)) ? true : false; } // Added SONG_STEP as it seems to be desirable in most cases to check for this as well. void LoopPattern(PATTERNINDEX nPat, ROWINDEX nRow = 0); void CheckCPUUsage(UINT nCPU); BOOL SetPatternName(PATTERNINDEX nPat, LPCSTR lpszName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |