From: <rel...@us...> - 2007-04-13 22:43:47
|
Revision: 178 http://svn.sourceforge.net/modplug/?rev=178&view=rev Author: relabsoluness Date: 2007-04-13 15:43:39 -0700 (Fri, 13 Apr 2007) Log Message: ----------- . v1.17.02.46 (Still no binaries) + <Relabs> Time calculator for pattern rows using existing modlength calculator function. . <Relabs> The songtitle limit in general tab should now work properly for every format. / <Relabs> Various minor modifications. Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Ctrl_gen.h trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_pat.h trunk/OpenMPT/mptrack/pattern.h trunk/OpenMPT/mptrack/patternContainer.h trunk/OpenMPT/mptrack/resource.h trunk/OpenMPT/mptrack/typedefs.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/mod_specifications.h Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2007-04-13 22:43:39 UTC (rev 178) @@ -2268,6 +2268,11 @@ commands[kcSoloChnOnPatTransition].isDummy = false; commands[kcSoloChnOnPatTransition].Message = "Solo channel on pattern transition"; + commands[kcTimeAtRow].UID = 1780; + commands[kcTimeAtRow].isHidden = false; + commands[kcTimeAtRow].isDummy = false; + commands[kcTimeAtRow].Message = "Show playback time at current row"; + #ifdef _DEBUG for (int i=0; i<kcNumCommands; i++) { if (commands[i].UID != 0) { // ignore unset UIDs Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/CommandSet.h 2007-04-13 22:43:39 UTC (rev 178) @@ -220,7 +220,8 @@ kcShowMacroConfig, kcChangeLoopStatus, kcShowEditMenu, - kcEndPatternEditMisc=kcShowEditMenu, + kcTimeAtRow, + kcEndPatternEditMisc=kcTimeAtRow, kcChannelMute, kcChannelSolo, Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2007-04-13 22:43:39 UTC (rev 178) @@ -11,6 +11,7 @@ // -> CODE#0015 // -> DESC="channels management dlg" #include "Ctrl_pat.h" +#include ".\ctrl_gen.h" // -! NEW_FEATURE#0015 BEGIN_MESSAGE_MAP(CCtrlGeneral, CModControlDlg) @@ -33,6 +34,7 @@ ON_EN_CHANGE(IDC_EDIT_SAMPLEPA, OnSamplePAChanged) ON_CBN_SELCHANGE(IDC_COMBO_RESAMPLING, OnResamplingChanged) ON_MESSAGE(WM_MOD_UPDATEPOSITION, OnUpdatePosition) + ON_EN_SETFOCUS(IDC_EDIT_SONGTITLE, OnEnSetfocusEditSongtitle) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -83,7 +85,7 @@ if(m_pSndFile) m_EditTitle.SetLimitText(m_pSndFile->GetModNameLengthMax()); else - m_EditTitle.SetLimitText(31); + m_EditTitle.SetLimitText(25); // -> CODE#0016 // -> DESC="default tempo update" @@ -302,20 +304,15 @@ void CCtrlGeneral::OnTitleChanged() //--------------------------------- { - CHAR s[35]; if ((!m_pSndFile) || (!m_EditTitle.m_hWnd) || (!m_EditTitle.GetModify())) return; - memset(s, 0, sizeof(s)); - m_EditTitle.GetWindowText(s, sizeof(s)); - s[25] = 0; - if (strcmp(m_pSndFile->m_szNames[0], s)) + + CString title; + m_EditTitle.GetWindowText(title); + if(m_pSndFile->SetTitle(title, title.GetLength()) && m_pModDoc) { - memcpy(m_pSndFile->m_szNames[0], s, 26); - if (m_pModDoc) - { - m_EditTitle.SetModify(FALSE); - m_pModDoc->SetModified(); - m_pModDoc->UpdateAllViews(NULL, HINT_MODGENERAL, this); - } + m_EditTitle.SetModify(FALSE); + m_pModDoc->SetModified(); + m_pModDoc->UpdateAllViews(NULL, HINT_MODGENERAL, this); } } @@ -661,7 +658,17 @@ } +void CCtrlGeneral::OnEnSetfocusEditSongtitle() +//-------------------------------------------- +{ + if(m_pSndFile) + { + m_EditTitle.SetLimitText(m_pSndFile->GetModNameLengthMax()); + } +} + + //////////////////////////////////////////////////////////////////////////////// // // CVuMeter Modified: trunk/OpenMPT/mptrack/Ctrl_gen.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.h 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/Ctrl_gen.h 2007-04-13 22:43:39 UTC (rev 178) @@ -82,6 +82,7 @@ afx_msg void OnReverbChanged(); afx_msg void OnSurroundChanged(); afx_msg void OnEqualizerChanged(); + afx_msg void OnEnSetfocusEditSongtitle(); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2007-04-13 22:43:39 UTC (rev 178) @@ -1923,7 +1923,7 @@ //---------------------------------- { CHAR s[256]; - DWORD dwSongLength = m_SndFile.GetLength(FALSE, TRUE); + DWORD dwSongLength = m_SndFile.GetSongTime(); wsprintf(s, "Approximate song length: %dmn%02ds", dwSongLength/60, dwSongLength%60); CMainFrame::GetMainFrame()->MessageBox(s, NULL, MB_OK|MB_ICONINFORMATION); } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2007-04-13 22:43:39 UTC (rev 178) @@ -13,7 +13,7 @@ #include "CreditStatic.h" #include "hyperEdit.h" #include "bladedll.h" -#include "commctrl.h"; +#include "commctrl.h" // rewbs.memLeak #define CRTDBG_MAP_ALLOC @@ -1382,7 +1382,7 @@ m_bmp.LoadBitmap(MAKEINTRESOURCE(IDB_MPTRACK)); wsprintf(s, "Build Date: %s", buildDateTime.c_str()); SetDlgItemText(IDC_EDIT2, s); - SetDlgItemText(IDC_EDIT3, CMainFrame::GetFullVersionString()); + SetDlgItemText(IDC_EDIT3, CString("Open Modplug Tracker, version ") + CMainFrame::GetFullVersionString()); m_heContact.SetWindowText( "Contact:\r\n\ @@ -1398,7 +1398,7 @@ "|" "Development:|" "Robin Fernandes: mo...@so... (2004-2006)|" - "Relabsoluness: lk...@me... (2005-2006)|" + "rel...@us... (2005-2006)|" "Eric Chavanon: co...@er... (2004-2005)|" "Trevor Nunes: mo...@pl... (2004)|" "Olivier Lapicque: ol...@mo... (1997-2003)|" Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2007-04-13 22:43:39 UTC (rev 178) @@ -104,10 +104,12 @@ ON_COMMAND(ID_CURSORPASTE, OnCursorPaste) ON_COMMAND(ID_PATTERN_AMPLIFY, OnPatternAmplify) ON_COMMAND(ID_CLEAR_SELECTION, OnClearSelectionFromMenu) + ON_COMMAND(ID_SHOWTIMEATROW, OnShowTimeAtRow) ON_COMMAND_RANGE(ID_CHANGE_INSTRUMENT, ID_CHANGE_INSTRUMENT+MAX_INSTRUMENTS, OnSelectInstrument) ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateUndo) ON_COMMAND_RANGE(ID_PLUGSELECT, ID_PLUGSELECT+MAX_MIXPLUGINS, OnSelectPlugin) //rewbs.patPlugName + //}}AFX_MSG_MAP ON_WM_INITMENU() ON_WM_RBUTTONDBLCLK() @@ -1151,7 +1153,7 @@ BuildPluginCtxMenu(hMenu, nChn, pSndFile); } - //------ Header Menu ---------- : + //------ Channel Header Menu ---------- : else if (pt.y <= m_szHeader.cy){ if (ih->ShiftPressed()) { //Don't bring up menu if shift is pressed, else we won't get button up msg. @@ -1183,7 +1185,10 @@ AppendMenu(hMenu, MF_SEPARATOR, 0, ""); if (BuildGrowShrinkCtxMenu(hMenu, ih)) AppendMenu(hMenu, MF_SEPARATOR, 0, ""); + if(BuildMiscCtxMenu(hMenu, ih)) + AppendMenu(hMenu, MF_SEPARATOR, 0, ""); BuildRowInsDelCtxMenu(hMenu, ih); + } ClientToScreen(&pt); @@ -3154,6 +3159,7 @@ case kcChannelUnmuteAll: OnUnmuteAll(); return wParam; case kcToggleChanMuteOnPatTransition: TogglePendingMute((m_dwCursor&0xFFFF)>>3); return wParam; case kcUnmuteAllChnOnPatTransition: OnPendingUnmuteAllChnFromClick(); return wParam; + case kcTimeAtRow: OnShowTimeAtRow(); return wParam; case kcSoloChnOnPatTransition: PendingSoloChn(GetCurrentChannel()); return wParam; case kcTransposeUp: OnTransposeUp(); return wParam; case kcTransposeDown: OnTransposeDown(); return wParam; @@ -4442,6 +4448,16 @@ return true; } +bool CViewPattern::BuildMiscCtxMenu(HMENU hMenu, CInputHandler* ih) +//----------------------------------------------------------------- +{ + if (CMainFrame::m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE) return false; + + AppendMenu(hMenu, MF_STRING, ID_SHOWTIMEATROW, "Show row play time\t" + ih->GetKeyTextFromCommand(kcTimeAtRow)); + return true; + +} + bool CViewPattern::BuildSelectionCtxMenu(HMENU hMenu, CInputHandler* ih) //---------------------------------------------------------------------- { @@ -4842,4 +4858,32 @@ } +void CViewPattern::OnShowTimeAtRow() +//---------------------------------- +{ + CModDoc* pModDoc = GetDocument(); + CSoundFile* pSndFile = (pModDoc) ? pModDoc->GetSoundFile() : 0; + if(!pSndFile) return; + CString msg; + ORDERINDEX currentOrder = SendCtrlMessage(CTRLMSG_GETCURRENTORDER); + if(pSndFile->Order[currentOrder] == m_nPattern) + { + double t = pSndFile->GetPlaybackTimeAt(currentOrder, m_nRow); + 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 + { + const uint32 minutes = static_cast<uint32>(t/60); + const float seconds = t - minutes*60; + msg.Format("Estimate for playback time at order %d(pattern %d), row %d: %d minute(s) %.2f seconds", currentOrder, m_nPattern, m_nRow, minutes, seconds); + } + } + else + msg.Format("Unable to determine the time: pattern at current order(=%d) does not correspond to pattern at pattern view(=pattern %d).", currentOrder, m_nPattern); + + MessageBox(msg); +} + + + Modified: trunk/OpenMPT/mptrack/View_pat.h =================================================================== --- trunk/OpenMPT/mptrack/View_pat.h 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/View_pat.h 2007-04-13 22:43:39 UTC (rev 178) @@ -291,6 +291,7 @@ afx_msg void OnClearSelectionFromMenu(); afx_msg void OnSelectInstrument(UINT nid); afx_msg void OnRunScript(); + afx_msg void OnShowTimeAtRow(); //}}AFX_MSG DECLARE_MESSAGE_MAP() @@ -305,6 +306,7 @@ bool BuildRecordCtxMenu(HMENU hMenu, UINT nChn, CModDoc* pModDoc); bool BuildSoloMuteCtxMenu(HMENU hMenu, CInputHandler* ih, UINT nChn, CSoundFile* pSndFile); bool BuildRowInsDelCtxMenu(HMENU hMenu, CInputHandler* ih); + bool BuildMiscCtxMenu(HMENU hMenu, CInputHandler* ih); bool BuildSelectionCtxMenu(HMENU hMenu, CInputHandler* ih); bool BuildGrowShrinkCtxMenu(HMENU hMenu, CInputHandler* ih); bool BuildNoteInterpolationCtxMenu(HMENU hMenu, CInputHandler* ih, CSoundFile* pSndFile); Modified: trunk/OpenMPT/mptrack/pattern.h =================================================================== --- trunk/OpenMPT/mptrack/pattern.h 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/pattern.h 2007-04-13 22:43:39 UTC (rev 178) @@ -8,8 +8,6 @@ class CPatternContainer; -typedef size_t ROWINDEX; -typedef size_t CHANNELINDEX; //============ class CPattern Modified: trunk/OpenMPT/mptrack/patternContainer.h =================================================================== --- trunk/OpenMPT/mptrack/patternContainer.h 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/patternContainer.h 2007-04-13 22:43:39 UTC (rev 178) @@ -18,7 +18,6 @@ //BEGIN: TYPEDEFS public: typedef vector<MODPATTERN> PATTERNVECTOR; - typedef UINT PATTERNINDEX; //END: TYPEDEFS Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/resource.h 2007-04-13 22:43:39 UTC (rev 178) @@ -969,6 +969,7 @@ #define ID_MOVETUNING 36025 #define ID_COPYTUNING 36026 #define ID_REMOVETUNINGCOLLECTION 36027 +#define ID_SHOWTIMEATROW 36028 #define ID_SELECTINST 36100 #define ID_NETLINK_MPTFR 37001 #define ID_PLUG_RECORDAUTOMATION 37003 Modified: trunk/OpenMPT/mptrack/typedefs.h =================================================================== --- trunk/OpenMPT/mptrack/typedefs.h 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/mptrack/typedefs.h 2007-04-13 22:43:39 UTC (rev 178) @@ -1,6 +1,8 @@ #ifndef TYPEDEFS_H #define TYPEDEFS_H +#include <limits> + #ifdef WIN32 typedef __int8 int8; typedef __int16 int16; @@ -13,7 +15,18 @@ typedef size_t uint64; typedef float float32; +#endif //End WIN32 specific. -#endif +typedef uint32 ROWINDEX; +typedef uint16 CHANNELINDEX; +typedef uint16 ORDERINDEX; +typedef uint16 PATTERNINDEX; +typedef uint16 TEMPO; +typedef uint16 SAMPLEINDEX; +typedef uint16 INSTRUMENTINDEX; +const ORDERINDEX ORDERINDEX_MAX = (std::numeric_limits<ORDERINDEX>::max)(); +const ROWINDEX ROWINDEX_MAX = (std::numeric_limits<ROWINDEX>::max)(); + + #endif Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2007-04-13 22:43:39 UTC (rev 178) @@ -250,6 +250,7 @@ memcpy(&id,lpStream+streamPos,sizeof(DWORD)); if(id != 0x2e697470) return FALSE; // .itp + m_nType = MOD_TYPE_IT; streamPos += sizeof(DWORD); memcpy(&id,lpStream+streamPos,sizeof(DWORD)); @@ -264,9 +265,10 @@ streamPos += sizeof(DWORD); // name string - if (streamPos+len<=dwMemLength && len<=MAX_SAMPLES*32) { - memcpy(&m_szNames[0],lpStream+streamPos,len); + if (streamPos+len<=dwMemLength && len<=sizeof(m_szNames[0])) { + memcpy(m_szNames[0],lpStream+streamPos,len); streamPos += len; + m_szNames[0][sizeof(m_szNames[0])-1] = '\0'; } // Song comments @@ -654,7 +656,8 @@ } // Leave - m_nType = MOD_TYPE_IT; + //m_nType = MOD_TYPE_IT; Relabs.note: Moved to the beginning of loading(April 2007) + m_nMaxPeriod = 0xF000; m_nMinPeriod = 8; @@ -1215,6 +1218,7 @@ // -> CODE#0023 // -> DESC="IT project files (.itp)" BOOL CSoundFile::SaveITProject(LPCSTR lpszFileName) +//------------------------------------------------- { // Check song type Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2007-04-13 22:43:39 UTC (rev 178) @@ -71,7 +71,14 @@ } */ -DWORD CSoundFile::GetLength(BOOL bAdjust, BOOL bTotal) +double CSoundFile::GetLength(BOOL bAdjust, BOOL bTotal) +//------------------------------------------- +{ + bool dummy = false; + return GetLength(dummy, bAdjust, bTotal); +} + +double CSoundFile::GetLength(bool& targetReached, BOOL bAdjust, BOOL bTotal, ORDERINDEX endOrder, ROWINDEX endRow) //---------------------------------------------------- { // -> CODE#0022 @@ -109,6 +116,12 @@ UINT nSpeedCount = 0; nRow = nNextRow; nCurrentPattern = nNextPattern; + if(nCurrentPattern == endOrder && nRow == endRow) + { + targetReached = true; + goto EndMod; + } + // Check if pattern is valid nPattern = Order[nCurrentPattern]; bool positionJumpOnThisRow=false; @@ -365,6 +378,10 @@ } } } + + return dwElapsedTime / 1000.0; + + /* // -> CODE#0022 // -> DESC="alternative BPM/Speed interpretation method" // return (UINT)((dwElapsedTime+500.0) / 1000.0); @@ -375,6 +392,7 @@ return (UINT)((dwElapsedTime + 500.0) / 1000.0); } // -! NEW_FEATURE#0022 + */ } @@ -442,6 +460,7 @@ } if (psmp->uFlags & CHN_PANNING) pChn->nPan = psmp->nPan; } + // Reset envelopes if (bResetEnv) { @@ -2611,6 +2630,7 @@ //rewbs.volOffset: moved offset code to own method as it will be used in several places now void CSoundFile::SampleOffset(UINT nChn, UINT param, bool bPorta) +//--------------------------------------------------------------- { MODCHANNEL *pChn = &Chn[nChn]; @@ -3340,3 +3360,4 @@ } + Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2007-04-13 22:43:39 UTC (rev 178) @@ -377,7 +377,12 @@ CTuningCollection CSoundFile::s_TuningsSharedLocal("Local Tunings"); -CSoundFile::CSoundFile() : m_TuningsTuneSpecific("Tune specific tunings"), PatternSize(*this), Patterns(*this), Order(*this), m_PlaybackEventer(*this) +CSoundFile::CSoundFile() : + m_TuningsTuneSpecific("Tune specific tunings"), + PatternSize(*this), Patterns(*this), + Order(*this), + m_PlaybackEventer(*this), + m_pModSpecs(&IT_SPECS) //---------------------- { m_nType = MOD_TYPE_NONE; @@ -690,6 +695,7 @@ if (m_nType) { + SetModSpecsPointer(); return TRUE; } @@ -1531,37 +1537,37 @@ CMainFrame::GetMainFrame()->MessageBox(str , "MoveChannel(...)", MB_OK | MB_ICONINFORMATION); return true; } - std::vector<UINT> newOrder; - //First creating new order identical to current order... - for(UINT i = 0; i<m_nChannels; i++) - { - newOrder.push_back(i); + std::vector<CHANNELINDEX> newOrder; + //First creating new order identical to current order... + for(UINT i = 0; i<m_nChannels; i++) + { + newOrder.push_back(i); + } + //...and then add the move channel effect. + if(chnFrom < chnTo) + { + CHANNELINDEX temp = newOrder[chnFrom]; + for(UINT i = chnFrom; i<chnTo; i++) + { + newOrder[i] = newOrder[i+1]; + } + newOrder[chnTo] = temp; + } + else //case chnFrom > chnTo(can't be equal, since it has been examined earlier.) + { + CHANNELINDEX temp = newOrder[chnFrom]; + for(UINT i = chnFrom; i>=chnTo+1; i--) + { + newOrder[i] = newOrder[i-1]; + } + newOrder[chnTo] = temp; } - //...and then add the move channel effect. - if(chnFrom < chnTo) - { - UINT temp = newOrder[chnFrom]; - for(UINT i = chnFrom; i<chnTo; i++) - { - newOrder[i] = newOrder[i+1]; - } - newOrder[chnTo] = temp; - } - else //case chnFrom > chnTo(can't be equal, since it has been examined earlier.) - { - UINT temp = newOrder[chnFrom]; - for(UINT i = chnFrom; i>=chnTo+1; i--) - { - newOrder[i] = newOrder[i-1]; - } - newOrder[chnTo] = temp; - } - if(newOrder.size() != ReArrangeChannels(newOrder)) - { - CMainFrame::GetMainFrame()->MessageBox("BUG: Channel number changed in MoveChannel()" , "", MB_OK | MB_ICONINFORMATION); - } - return false; + if(newOrder.size() != ReArrangeChannels(newOrder)) + { + CMainFrame::GetMainFrame()->MessageBox("BUG: Channel number changed in MoveChannel()" , "", MB_OK | MB_ICONINFORMATION); + } + return false; } @@ -2825,74 +2831,38 @@ return string(szNoteNames[abs(note-1)%12]) + Stringify((note-1)/12); } -WORD CSoundFile::GetTempoMin() const {return 32;} -WORD CSoundFile::GetTempoMax() const {return 512;} -ROWINDEX CSoundFile::GetRowMax() const -//------------------------------------ +void CSoundFile::SetModSpecsPointer() +//----------------------------------- { - switch(m_nType) + switch(GetModType()) { case MOD_TYPE_MPT: - return MPTM_SPECS.patternRowsMax; - case MOD_TYPE_MOD: - return MOD_SPECS.patternRowsMax; - case MOD_TYPE_XM: - return XM_SPECS.patternRowsMax; + m_pModSpecs = &MPTM_SPECS; + break; case MOD_TYPE_IT: - return IT_SPECS.patternRowsMax; - case MOD_TYPE_S3M: - return S3M_SPECS.patternRowsMax; - default: - return MAX_PATTERN_ROWS; - } -} - -ROWINDEX CSoundFile::GetRowMin() const -//------------------------------------ -{ - switch(m_nType) - { - case MOD_TYPE_MPT: - return MPTM_SPECS.patternRowsMin; - case MOD_TYPE_MOD: - return MOD_SPECS.patternRowsMin; + m_pModSpecs = &IT_SPECS; + break; case MOD_TYPE_XM: - return XM_SPECS.patternRowsMin; - case MOD_TYPE_IT: - return IT_SPECS.patternRowsMin; + m_pModSpecs = &XM_SPECS; + break; case MOD_TYPE_S3M: - return S3M_SPECS.patternRowsMin; + m_pModSpecs = &S3M_SPECS; + break; + case MOD_TYPE_MOD: default: - return 2; + m_pModSpecs = &MOD_SPECS; + break; } } - -CHANNELINDEX CSoundFile::GetNumChannelMax() const -//----------------------------------- -{ - if(m_nType == MOD_TYPE_MPT) return MPTM_SPECS.channelsMax; - if(m_nType == MOD_TYPE_IT) return max_chans_IT; - if(m_nType == MOD_TYPE_XM) return max_chans_XM; - if(m_nType == MOD_TYPE_MOD) return max_chans_MOD; - if(m_nType == MOD_TYPE_S3M) return max_chans_S3M; - return 4; -} - -CHANNELINDEX CSoundFile::GetNumChannelMin() const -//----------------------------------- -{ - if(m_nType == MOD_TYPE_MPT) return MPTM_SPECS.channelsMin; - else return 4; -} - void CSoundFile::ChangeModTypeTo(const int& newType) //--------------------------------------------------- { const UINT oldInvalidIndex = Patterns.GetInvalidIndex(); const UINT oldIgnoreIndex = Patterns.GetIgnoreIndex(); m_nType = newType; + SetModSpecsPointer(); m_ModFlags.reset(); @@ -2900,6 +2870,27 @@ replace(Order.begin(), Order.end(), oldIgnoreIndex, Patterns.GetIgnoreIndex()); } +bool CSoundFile::SetTitle(const char* titleCandidate, size_t strSize) +//------------------------------------------------------------------- +{ + if(strcmp(m_szNames[0], titleCandidate)) + { + memset(m_szNames[0], 0, sizeof(m_szNames[0])); + memcpy(m_szNames[0], titleCandidate, min(sizeof(m_szNames[0])-1, strSize)); + return true; + } + return false; +} + +double CSoundFile::GetPlaybackTimeAt(ORDERINDEX ord, ROWINDEX row) +//---------------------------------------------------------------- +{ + bool targetReached = false; + const double t = GetLength(targetReached, FALSE, TRUE, ord, row); + if(targetReached) return t; + else return -1; //Given position not found from play sequence. +} + #ifndef TRADITIONAL_MODCOMMAND void CSoundFile::OnSetEffect(MODCOMMAND& mc, EFFECT_ID eID) //--------------------------------------------------------- Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/soundlib/Sndfile.h 2007-04-13 22:43:39 UTC (rev 178) @@ -767,8 +767,6 @@ #include "../mptrack/patternContainer.h" #include "../mptrack/ordertopatterntable.h" -typedef CPatternContainer::PATTERNINDEX PATTERNINDEX; - #include "../mptrack/playbackEventer.h" @@ -789,31 +787,35 @@ const BYTE IT_STANDARD = 0; + //============== class CSoundFile //============== { public: //Typedefs - typedef CPatternContainer::PATTERNINDEX PATTERNINDEX; typedef UINT MODTYPE; public: //Get details(TODO?: Move detail asking to a 'controller') - WORD GetTempoMin() const; - WORD GetTempoMax() const; + TEMPO GetTempoMin() const {return m_pModSpecs->tempoMin;} + TEMPO GetTempoMax() const {return m_pModSpecs->tempoMax;} - ROWINDEX GetRowMax() const; - ROWINDEX GetRowMin() const; + //Using special hack for OMPTs modifed ITs and XMs. + ROWINDEX GetRowMax() const {return (GetType() == MOD_TYPE_IT || GetType() == MOD_TYPE_XM) ? 1024 : min(MAX_PATTERN_ROWS, m_pModSpecs->patternRowsMax);} - CHANNELINDEX GetNumChannelMax() const; - CHANNELINDEX GetNumChannelMin() const; + ROWINDEX GetRowMin() const {return m_pModSpecs->patternRowsMin;} + CHANNELINDEX GetNumChannelMax() const {return min(MAX_BASECHANNELS, m_pModSpecs->channelsMax);} + CHANNELINDEX GetNumChannelMin() const {return m_pModSpecs->channelsMin;} + uint16 GetModNameLengthMax() {return (GetModType() == MOD_TYPE_MPT) ? 25 : m_pModSpecs->modNameLengthMax;} - size_t GetModNameLengthMax() {return 25;} + //Return true if title was changed. + bool SetTitle(const char*, size_t strSize); public: //Misc void ChangeModTypeTo(const int& newType); - // - + MODTYPE GetModType() const {return m_nType;} - // + + //Return value in seconds. + double GetPlaybackTimeAt(ORDERINDEX, ROWINDEX); #ifndef TRADITIONAL_MODCOMMAND void OnSetEffect(MODCOMMAND& mc, EFFECT_ID); @@ -853,11 +855,15 @@ void PortamentoMPT(MODCHANNEL*, int); void PortamentoFineMPT(MODCHANNEL*, int); +private: //Misc private methods. + void SetModSpecsPointer(); + private: //'Controllers' CPlaybackEventer m_PlaybackEventer; private: //Misc data bitset<8> m_ModFlags; + const CModSpecifications* m_pModSpecs; @@ -910,7 +916,7 @@ MODCHANNELSETTINGS ChnSettings[MAX_BASECHANNELS]; // Channels settings CPatternContainer Patterns; //Patterns CPatternSizesMimic PatternSize; // Mimics old PatternsSize-array(is read-only). - COrderToPatternTable Order; //Order[x] gives the pattern index at order x. + COrderToPatternTable Order; // Order[x] gives the index of the pattern located at order x. MODINSTRUMENT Ins[MAX_SAMPLES]; // Instruments INSTRUMENTHEADER *Headers[MAX_INSTRUMENTS]; // Instrument Headers INSTRUMENTHEADER m_defaultInstrument; // Currently only used to get default values for extented properties. @@ -974,8 +980,18 @@ CString GetPatternViewInstrumentName(UINT nInstr, bool returnEmptyInsteadOfNoName = false) const; UINT GetMusicSpeed() const { return m_nMusicSpeed; } UINT GetMusicTempo() const { return m_nMusicTempo; } - DWORD GetLength(BOOL bAdjust, BOOL bTotal=FALSE); - DWORD GetSongTime() { return GetLength(FALSE, TRUE); } + + //Get modlength in various cases: total length, length to + //specific order&row etc. Return value is in seconds. + //NOTE: Also seems to be used for some 'simulate playback'-purposes (Relabs, April 2007) + double GetLength(BOOL bAdjust, BOOL bTotal=FALSE); +private: + double GetLength(bool& targetReached, BOOL bAdjust, BOOL bTotal=FALSE, ORDERINDEX ord = ORDERINDEX_MAX, ROWINDEX row = ROWINDEX_MAX); + +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); } + void SetRepeatCount(int n) { m_nRepeatCount = n; } int GetRepeatCount() const { return m_nRepeatCount; } BOOL IsPaused() const { return (m_dwSongFlags & SONG_PAUSED) ? TRUE : FALSE; } @@ -992,7 +1008,6 @@ //channel settings. Flag can be used to tell whether to completely //reset channels, not only a few settings(for maintaining old behavior). void ResetChannelSettings(CHANNELINDEX chn, BYTE resetStyle); - //For all channels. void ResetChannelSettings(BYTE resetStyle); Modified: trunk/OpenMPT/soundlib/mod_specifications.h =================================================================== --- trunk/OpenMPT/soundlib/mod_specifications.h 2007-04-01 00:28:16 UTC (rev 177) +++ trunk/OpenMPT/soundlib/mod_specifications.h 2007-04-13 22:43:39 UTC (rev 178) @@ -7,20 +7,20 @@ { //NOTE: If changing order, update all initializations below. char fileExtension[10]; - UINT patternsMax; - UINT ordersMax; - UINT channelsMin; - UINT channelsMax; + PATTERNINDEX patternsMax; + ORDERINDEX ordersMax; + CHANNELINDEX channelsMin; + CHANNELINDEX channelsMax; //NOTE: The two above refer to the user editable pattern channels, //not to the internal sound channels. Maybe there should be a separate //setting for those(comment by: Relabs, January 2007). - UINT tempoMin; - UINT tempoMax; - UINT patternRowsMin; - UINT patternRowsMax; - UINT modNameLengthMax; //Meaning 'usable letters', possible null character is not included. - UINT samplesMax; - UINT instrumentsMax; + TEMPO tempoMin; + TEMPO tempoMax; + ROWINDEX patternRowsMin; + ROWINDEX patternRowsMax; + uint16 modNameLengthMax; //Meaning 'usable letters', possible null character is not included. + SAMPLEINDEX samplesMax; + INSTRUMENTINDEX instrumentsMax; }; enum { @@ -48,7 +48,7 @@ 256, //Channel max 32, //Min tempo 512, //Max tempo - 2, //Min pattern rows + 1, //Min pattern rows 1024, //Max pattern rows 256, //Max mod name length 4000, //SamplesMax @@ -70,7 +70,7 @@ 256, //Max tempo 64, //Min pattern rows 64, //Max pattern rows - 25, //Max mod name length + 20, //Max mod name length 31, //SamplesMax 0, //instrumentMax }; @@ -87,10 +87,10 @@ 32, //Min tempo 256, //Max tempo 4, //Min pattern rows - 256, //Max pattern rows - 25, //Max mod name length + 256, //Max pattern rows + 20, //Max mod name length 31, //SamplesMax - 256, //instrumentMax + 256, //instrumentMax }; @@ -106,7 +106,7 @@ 256, //Max tempo 64, //Min pattern rows 64, //Max pattern rows - 25, //Max mod name length + 27, //Max mod name length 31, //SamplesMax 0, //instrumentMax }; @@ -125,7 +125,7 @@ 256, //Max pattern rows 25, //Max mod name length(in ittech.txt: "0000: \xB3'I'\xB3'M'\xB3'P'\xB3'M'\xB3 Song Name, max 26 characters, includes NULL \xB3") 256, //SamplesMax - 256, //instrumentMax + 256, //instrumentMax }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |