From: <sag...@us...> - 2010-10-22 16:00:45
|
Revision: 748 http://modplug.svn.sourceforge.net/modplug/?rev=748&view=rev Author: saga-games Date: 2010-10-22 16:00:37 +0000 (Fri, 22 Oct 2010) Log Message: ----------- [Reg] The "Position aware timer" option is gone. It is now always used. It was optional in the first place because of some buggy code, which is now fixed: [Imp] Cleaned up the mess associated to GetLength and made the parameters more intuitive. As a result, GetLength is now only called once when changing to a different order or when exporting to WAV, instead of three calls. [Fix] Order list: When jumping to an order which is normally not played, the song variables are now reset (previously, if the main song had f.e. a global volume fade out at the end, this was retained when switching to an unplayed order, effectively muting all sub songs). [Mod] OpenMPT: Version is now 1.19.00.10 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/version.h trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2010-10-22 16:00:37 UTC (rev 748) @@ -316,12 +316,15 @@ pSndFile->m_nCurrentPattern = m_nScrollPos; pSndFile->SetCurrentOrder(m_nScrollPos); pSndFile->m_dwSongFlags |= dwPaused; - if (!(dwPaused & SONG_PATTERNLOOP)) pSndFile->GetLength(TRUE); // update channel parameters + //if (!(dwPaused & SONG_PATTERNLOOP)) // why? + { + // update channel parameters and play time + m_pModDoc->SetElapsedTime(m_nScrollPos, 0); + } if (bIsPlaying) pMainFrm->ResetNotificationBuffer(); END_CRITICAL(); } m_pParent->SetCurrentPattern(n); - m_pModDoc->SetElapsedTime(m_nScrollPos, 0); } } UpdateInfoText(); @@ -672,8 +675,8 @@ p += str.size(); *p++ = ' '; } - *p++ = 0x0D; - *p++ = 0x0A; + *p++ = '\r'; + *p++ = '\n'; *p = 0; } GlobalUnlock(hCpy); Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2010-10-22 16:00:37 UTC (rev 748) @@ -465,7 +465,7 @@ if(vIniVersion < MAKE_VERSION_NUMERIC(1,19,00,07)) m_dwPatternSetup &= ~0x800; // this was previously deprecated and is now used for something else if(vIniVersion < MPT_VERSION_NUMERIC) - m_dwPatternSetup &= ~(0x200000|0x400000); // various deprecated old options + m_dwPatternSetup &= ~(0x200000|0x400000|0x10000000); // various deprecated old options m_nRowSpacing = GetPrivateProfileDWord("Pattern Editor", "RowSpacing", 16, iniFile); m_nRowSpacing2 = GetPrivateProfileDWord("Pattern Editor", "RowSpacing2", 4, iniFile); Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2010-10-22 16:00:37 UTC (rev 748) @@ -192,7 +192,7 @@ #define PATTERN_AUTODELAY 0x2000000 // automatically insert delay commands in pattern when entering notes #define PATTERN_NOTEFADE 0x4000000 // alt. note fade behaviour when entering notes #define PATTERN_OVERFLOWPASTE 0x8000000 // continue paste in the next pattern instead of cutting off -#define PATTERN_POSITIONAWARETIMER 0x10000000 // try to set the timer in the statusbar when jumping around in modules +//#define PATTERN_POSITIONAWARETIMER 0x10000000 // try to set the timer in the statusbar when jumping around in modules (deprecated, it generated too much load in the code due to some bugs, hence it was made optional. those bugs are now resolved, so there's no point in keeping this flag.) #define PATTERN_RESETCHANNELS 0x20000000 // reset channels when looping #define PATTERN_LIVEUPDATETREE 0x40000000 // update active sample / instr icons in treeview Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2010-10-22 16:00:37 UTC (rev 748) @@ -1587,8 +1587,8 @@ if (wsdlg.m_bSelectPlay) { m_SndFile.SetCurrentOrder(wsdlg.m_nMinOrder); + m_SndFile.GetLength(true, wsdlg.m_nMinOrder, 0); m_SndFile.m_nCurrentPattern = wsdlg.m_nMinOrder; - m_SndFile.GetLength(TRUE, FALSE); m_SndFile.m_nMaxOrderPosition = wsdlg.m_nMaxOrder + 1; } if(dwcdlg.DoModal() != IDOK) break; @@ -1597,8 +1597,10 @@ // Restore channels' flags if(wsdlg.m_bChannelMode) { - for(int i = 0 ; i < nRenderPasses ; i++) + for(CHANNELINDEX i = 0; i < m_SndFile.GetNumChannels(); i++) + { m_SndFile.ChnSettings[i].dwFlags = channelFlags[i]; + } } // Restore instruments' / samples' flags if(wsdlg.m_bInstrumentMode) @@ -1619,7 +1621,6 @@ } m_SndFile.SetCurrentPos(pos); - m_SndFile.GetLength(TRUE); CMainFrame::UpdateAudioParameters(TRUE); } @@ -1677,7 +1678,6 @@ dwcdlg.m_dwSongLimit = wsdlg.m_dwSongLimit; dwcdlg.DoModal(); m_SndFile.SetCurrentPos(pos); - m_SndFile.GetLength(TRUE); CMainFrame::UpdateAudioParameters(TRUE); } @@ -3318,7 +3318,7 @@ END_CRITICAL(); // set playback timer in the status bar - SetElapsedTime(nOrd, nRow, true); + SetElapsedTime(nOrd, nRow); if (pModPlaying != this) { @@ -3373,7 +3373,7 @@ END_CRITICAL(); // set playback timer in the status bar - SetElapsedTime(nOrd, nRow, true); + SetElapsedTime(nOrd, nRow); if (pModPlaying != this) { pMainFrm->PlayMod(this, followSonghWnd, m_dwNotifyType|MPTNOTIFY_POSITION|MPTNOTIFY_VUMETERS); //rewbs.fix2977 @@ -3431,7 +3431,7 @@ END_CRITICAL(); // set playback timer in the status bar - SetElapsedTime(nOrd, nRow, true); + SetElapsedTime(nOrd, nRow); if (pModPlaying != this) { @@ -3660,22 +3660,17 @@ } -// Sets playback timer to playback time at given position. If 'bReset' is true, -// timer is reset if playback position timer is not enabled. -void CModDoc::SetElapsedTime(ORDERINDEX nOrd, ROWINDEX nRow, bool bReset) -//----------------------------------------------------------------------- +// Sets playback timer to playback time at given position. +// At the same time, the playback parameters (global volume, channel volume and stuff like that) are calculated for this position. +void CModDoc::SetElapsedTime(ORDERINDEX nOrd, ROWINDEX nRow) +//---------------------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if(pMainFrm == NULL) return; - if(CMainFrame::m_dwPatternSetup & PATTERN_POSITIONAWARETIMER) - { - double dPatternPlaytime = max(0, m_SndFile.GetPlaybackTimeAt(nOrd, nRow)); - pMainFrm->SetElapsedTime((DWORD) (dPatternPlaytime * 1000)); - } - else if(bReset) - pMainFrm->ResetElapsedTime(); + const double dPatternPlaytime = m_SndFile.GetPlaybackTimeAt(nOrd, nRow, false); + pMainFrm->SetElapsedTime((DWORD) (max(0, dPatternPlaytime) * 1000)); } Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/mptrack/Moddoc.h 2010-10-22 16:00:37 UTC (rev 748) @@ -306,7 +306,7 @@ void TogglePluginEditor(UINT m_nCurrentPlugin); //rewbs.patPlugNames void RecordParamChange(int slot, long param); void LearnMacro(int macro, long param); - void SetElapsedTime(ORDERINDEX nOrd, ROWINDEX nRow, bool bReset = false); + void SetElapsedTime(ORDERINDEX nOrd, ROWINDEX nRow); bool RemoveChannels(bool bChnMask[MAX_BASECHANNELS]); Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2010-10-22 16:00:37 UTC (rev 748) @@ -554,7 +554,8 @@ LPCSTR pszListName, pszDescription; } OPTGENDESC; -enum { +enum +{ OPTGEN_PLAYNEWNOTES=0, OPTGEN_PLAYEDITROW, OPTGEN_CENTERROW, @@ -606,10 +607,9 @@ {PATTERN_OLDCTXMENUSTYLE, "Old style pattern context menu", "Check this option to hide unavailable items in the pattern editor context menu. Uncheck to grey-out unavailable items instead."}, {PATTERN_SYNCMUTE, "Maintain sample sync on mute", "Samples continue to be processed when channels are muted (like in IT2 and FT2)"}, {PATTERN_AUTODELAY, "Automatic delay commands", "Automatically insert appropriate note-delay commands when recording notes during live playback."}, - {PATTERN_NOTEFADE, "Note fade on key up", "Enable to fade/stop notes on key up in pattern tab." }, + {PATTERN_NOTEFADE, "Note fade on key up", "Enable to fade / stop notes on key up in pattern tab." }, {PATTERN_OVERFLOWPASTE, "Overflow paste mode", "Wrap pasted pattern data into next pattern. This is useful for creating echo channels."}, - {PATTERN_POSITIONAWARETIMER, "Position aware timer", "If enabled, timer will show the playback position time if possible instead of running timer."}, - {PATTERN_RESETCHANNELS, "Reset channels on loop", "If enabled, channels will be reset to their initial state when song looping is enabled.\nNote: This does not affect manual song loops (i.e. triggered by pattern commands)"}, + {PATTERN_RESETCHANNELS, "Reset channels on loop", "If enabled, channels will be reset to their initial state when song looping is enabled.\nNote: This does not affect manual song loops (i.e. triggered by pattern commands) and is recommended to be enabled."}, {PATTERN_LIVEUPDATETREE,"Update sample status in tree", "If enabled, active samples and instruments will be indicated by a different icon in the treeview."} }; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2010-10-22 16:00:37 UTC (rev 748) @@ -5410,7 +5410,7 @@ ORDERINDEX currentOrder = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); if(pSndFile->Order[currentOrder] == m_nPattern) { - const double t = pSndFile->GetPlaybackTimeAt(currentOrder, m_nRow); + const double t = pSndFile->GetPlaybackTimeAt(currentOrder, m_nRow, true); if(t < 0) msg.Format("Unable to determine the time. Possible cause: No order %d, row %d found from play sequence", currentOrder, m_nRow); else Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/mptrack/version.h 2010-10-22 16:00:37 UTC (rev 748) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 19 #define VER_MINOR 00 -#define VER_MINORMINOR 09 +#define VER_MINORMINOR 10 //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/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2010-10-22 16:00:37 UTC (rev 748) @@ -73,17 +73,26 @@ } */ -double CSoundFile::GetLength(BOOL bAdjust, BOOL bTotal) -//------------------------------------------- +double CSoundFile::GetLength(bool bAdjust, ORDERINDEX endOrder, ROWINDEX endRow) +//------------------------------------------------------------------------------ { bool dummy = false; - double result = GetLength(dummy, bAdjust, bTotal); - InitializeVisitedRows(true); // forget that we went over the whole module. + double result = GetLength(dummy, bAdjust, endOrder, endRow); + if(!bAdjust) + { + InitializeVisitedRows(true); // forget that we went over the whole module. + } return result; } -double CSoundFile::GetLength(bool& targetReached, BOOL bAdjust, BOOL bTotal, ORDERINDEX endOrder, ROWINDEX endRow) -//---------------------------------------------------------------------------------------------------------------- + +// Get mod length in various cases. Parameters: +// &targetReached: Will be set to true if the specified order/row combination has been reached while going through the module. +// bAdjust: If enabled, the mod parameters (such as global volume, speed, tempo, etc...) will be memorized (if the target has been reached) when leaving the function (i.e. they won't be reset to the previous values) +// endOrder: Order which should be reached (ORDERINDEX_INVALID means whole song) +// endRow: Row in that order that should be reached +double CSoundFile::GetLength(bool& targetReached, bool bAdjust, ORDERINDEX endOrder, ROWINDEX endRow) +//--------------------------------------------------------------------------------------------------- { // -> CODE#0022 // -> DESC="alternative BPM/Speed interpretation method" @@ -96,7 +105,6 @@ double dElapsedTime=0.0; // -! NEW_FEATURE#0022 UINT nMusicSpeed = m_nDefaultSpeed, nMusicTempo = m_nDefaultTempo, nNextRow = 0; - UINT nMaxRow = 0, nMaxPattern = 0; LONG nGlbVol = m_nDefaultGlobalVolume, nOldGlbVolSlide = 0; vector<BYTE> instr; vector<UINT> notes; @@ -114,8 +122,6 @@ patloop.resize(m_nChannels, 0); patloopstart.resize(m_nChannels, 0); for(CHANNELINDEX icv = 0; icv < m_nChannels; icv++) chnvols[icv] = ChnSettings[icv].nVolume; - nMaxRow = m_nNextRow; - nMaxPattern = m_nNextPattern; nCurrentPattern = nNextPattern = 0; nPattern = Order[0]; nRow = nNextRow = 0; @@ -192,18 +198,6 @@ for(UINT ipck = 0; ipck < m_nChannels; ipck++) patloop[ipck] = dElapsedTime; } - if (!bTotal) - { - if ((nCurrentPattern > nMaxPattern) || ((nCurrentPattern == nMaxPattern) && (nRow >= nMaxRow))) - { - if (bAdjust) - { - m_nMusicSpeed = nMusicSpeed; - m_nMusicTempo = nMusicTempo; - } - break; - } - } MODCHANNEL *pChn = Chn; MODCOMMAND *p = Patterns[nPattern] + nRow * m_nChannels; @@ -222,7 +216,7 @@ { // Position Jump case CMD_POSITIONJUMP: - positionJumpOnThisRow=true; + positionJumpOnThisRow = true; nNextPattern = (ORDERINDEX)param; nNextPatStartRow = 0; // FT2 E60 bug // see http://lpchip.com/modplug/viewtopic.php?t=2769 - FastTracker resets Dxx if Bxx is called _after_ Dxx @@ -430,17 +424,20 @@ case tempo_mode_alternative: dElapsedTime += 60000.0 / (1.65625 * (double)(nMusicSpeed * nMusicTempo)); break; case tempo_mode_modern: - dElapsedTime += 60000.0/(double)nMusicTempo / (double)m_nCurrentRowsPerBeat; break; + dElapsedTime += 60000.0 / (double)nMusicTempo / (double)m_nCurrentRowsPerBeat; break; case tempo_mode_classic: default: dElapsedTime += (2500.0 * (double)nSpeedCount) / (double)nMusicTempo; } } - if ((bAdjust) && (!bTotal)) + // Store final variables + if (bAdjust && (targetReached || endOrder == ORDERINDEX_INVALID || endRow == ROWINDEX_INVALID)) { m_nGlobalVolume = nGlbVol; m_nOldGlbVolSlide = nOldGlbVolSlide; - for (UINT n=0; n<m_nChannels; n++) + m_nMusicSpeed = nMusicSpeed; + m_nMusicTempo = nMusicTempo; + for (CHANNELINDEX n = 0; n < m_nChannels; n++) { Chn[n].nGlobalVol = chnvols[n]; if (notes[n]) Chn[n].nNewNote = notes[n]; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2010-10-22 16:00:37 UTC (rev 748) @@ -3052,11 +3052,12 @@ return false; } -double CSoundFile::GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row) -//---------------------------------------------------------------- + +double CSoundFile::GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row, bool resetVars) +//-------------------------------------------------------------------------------- { bool targetReached = false; - const double t = GetLength(targetReached, FALSE, TRUE, ord, row); + const double t = GetLength(targetReached, !resetVars, ord, row); if(targetReached) return t; else return -1; //Given position not found from play sequence. } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2010-10-22 14:26:03 UTC (rev 747) +++ trunk/OpenMPT/soundlib/Sndfile.h 2010-10-22 16:00:37 UTC (rev 748) @@ -494,8 +494,9 @@ public: //Misc void ChangeModTypeTo(const MODTYPE& newType); - //Returns value in seconds. If given position won't be played at all, returns -1. - double GetPlaybackTimeAt(ORDERINDEX, ROWINDEX); + // Returns value in seconds. If given position won't be played at all, returns -1. + // If resetVars is true, the state of various playback variables will be retained. + double GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row, bool resetVars); uint16 GetModFlags() const {return m_ModFlags;} void SetModFlags(const uint16 v) {m_ModFlags = v;} @@ -676,15 +677,15 @@ UINT GetMusicSpeed() const { return m_nMusicSpeed; } UINT GetMusicTempo() const { return m_nMusicTempo; } - double GetLength(BOOL bAdjust, BOOL bTotal=FALSE); + double GetLength(bool bAdjust, ORDERINDEX ord = ORDERINDEX_MAX, ROWINDEX row = ROWINDEX_MAX); private: //Get modlength in various cases: total length, length to //specific order&row etc. Return value is in seconds. - double GetLength(bool& targetReached, BOOL bAdjust, BOOL bTotal=FALSE, ORDERINDEX ord = ORDERINDEX_MAX, ROWINDEX row = ROWINDEX_MAX); + double GetLength(bool& targetReached, bool bAdjust, ORDERINDEX ord, ROWINDEX row); public: //Returns song length in seconds. - DWORD GetSongTime() { return static_cast<DWORD>((m_nTempoMode == tempo_mode_alternative) ? GetLength(FALSE, TRUE)+1.0 : GetLength(FALSE, TRUE)+0.5); } + DWORD GetSongTime() { return static_cast<DWORD>((m_nTempoMode == tempo_mode_alternative) ? GetLength(false) + 1.0 : GetLength(false) + 0.5); } void SetRepeatCount(int n) { m_nRepeatCount = n; } int GetRepeatCount() const { return m_nRepeatCount; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |