From: <sag...@us...> - 2014-11-29 00:15:36
|
Revision: 4613 http://sourceforge.net/p/modplug/code/4613 Author: saga-games Date: 2014-11-29 00:15:19 +0000 (Sat, 29 Nov 2014) Log Message: ----------- [Ref] Change the confusing CSoundFile::SetCurrentPos method into CSoundFile::ResetPlayPos, which is the same as SetCurrentPos(0) -- apart from a single call site, this was the only usage of this function. [Mod] OpenMPT: Version is now 1.24.00.18 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-11-29 00:07:22 UTC (rev 4612) +++ trunk/OpenMPT/common/versionNumber.h 2014-11-29 00:15:19 UTC (rev 4613) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 24 #define VER_MINOR 00 -#define VER_MINORMINOR 17 +#define VER_MINORMINOR 18 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-11-29 00:07:22 UTC (rev 4612) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-11-29 00:15:19 UTC (rev 4613) @@ -1379,7 +1379,7 @@ PausePlayback(); GenerateStopNotification(); - m_pSndFile->SetCurrentPos(0); + m_pSndFile->ResetPlayPos(); m_pSndFile->ResetChannels(); UnsetPlaybackSoundFile(); @@ -1600,7 +1600,7 @@ { m_WaveFile.m_SongFlags.reset(SONG_PAUSED); m_WaveFile.SetRepeatCount(-1); - m_WaveFile.SetCurrentPos(0); + m_WaveFile.ResetPlayPos(); ModCommand *m = m_WaveFile.Patterns[0]; if(m) Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-11-29 00:07:22 UTC (rev 4612) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2014-11-29 00:15:19 UTC (rev 4613) @@ -1010,8 +1010,7 @@ uint64 l = static_cast<uint64>(m_SndFile.GetSongTime() + 0.5) * samplerate * std::max<uint64>(1, 1 + m_SndFile.GetRepeatCount()); // Reset song position tracking - m_SndFile.InitializeVisitedRows(); - m_SndFile.SetCurrentPos(0); + m_SndFile.ResetPlayPos(); m_SndFile.m_SongFlags.reset(SONG_PATTERNLOOP); ORDERINDEX startOrder = 0; if(m_Settings.minOrder != ORDERINDEX_INVALID && m_Settings.maxOrder != ORDERINDEX_INVALID) Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-29 00:07:22 UTC (rev 4612) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-29 00:15:19 UTC (rev 4613) @@ -758,7 +758,7 @@ m_SndFile.m_SongFlags.set(SONG_LINEARSLIDES); } } - m_SndFile.SetCurrentPos(0); + m_SndFile.ResetPlayPos(); return TRUE; } @@ -1689,7 +1689,8 @@ const mpt::PathString fileName = drive + dir + name; const mpt::PathString fileExt = ext; - // Saving as wave file + const ORDERINDEX currentOrd = m_SndFile.m_PlayState.m_nCurrentOrder; + const ROWINDEX currentRow = m_SndFile.m_PlayState.m_nRow; int nRenderPasses = 1; // Channel mode @@ -1740,7 +1741,6 @@ } } - UINT pos = m_SndFile.GetCurrentPos(); pMainFrm->PauseMod(); int oldRepeat = m_SndFile.GetRepeatCount(); @@ -1756,7 +1756,7 @@ if(i > 0) m_SndFile.ChnSettings[i - 1].dwFlags.set(CHN_MUTE); // Was this channel actually muted? Don't process it then. - if(usedChannels[i] == false) + if(!usedChannels[i]) continue; // Add channel number & name (if available) to path string if(strcmp(m_SndFile.ChnSettings[i].szName, "")) @@ -1842,7 +1842,9 @@ } m_SndFile.SetRepeatCount(oldRepeat); - m_SndFile.SetCurrentPos(pos); + m_SndFile.GetLength(eAdjust, GetLengthTarget(currentOrd, currentRow)); + m_SndFile.m_PlayState.m_nNextOrder = currentOrd; + m_SndFile.m_PlayState.m_nNextRow = currentRow; CMainFrame::UpdateAudioParameters(m_SndFile, true); } @@ -2092,7 +2094,7 @@ pMainFrm->PauseMod(); CriticalSection cs; m_SndFile.m_SongFlags.reset(SONG_STEP | SONG_PATTERNLOOP); - m_SndFile.SetCurrentPos(0); + m_SndFile.ResetPlayPos(); //m_SndFile.visitedSongRows.Initialize(true); m_SndFile.m_PlayState.m_lTotalSampleCount = 0; Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-11-29 00:07:22 UTC (rev 4612) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-11-29 00:15:19 UTC (rev 4613) @@ -897,36 +897,30 @@ if ((m_nRestartPos >= Order.size()) || (Order[m_nRestartPos] >= Patterns.Size())) m_nRestartPos = 0; - // When reading a file made with an older version of MPT, it might be necessary to upgrade some settings automatically. - if(m_dwLastSavedWithVersion) - { - UpgradeModule(); - } - +#ifndef NO_VST // plugin loader std::string notFoundText; - std::vector<PLUGINDEX> notFoundIDs; + std::vector<SNDMIXPLUGININFO *> notFoundIDs; -#ifndef NO_VST if (gpMixPluginCreateProc && (loadFlags & loadPluginData)) { - for(PLUGINDEX iPlug = 0; iPlug < MAX_MIXPLUGINS; iPlug++) + for(PLUGINDEX plug = 0; plug < MAX_MIXPLUGINS; plug++) { - if(m_MixPlugins[iPlug].IsValidPlugin()) + if(m_MixPlugins[plug].IsValidPlugin()) { - gpMixPluginCreateProc(m_MixPlugins[iPlug], *this); - if (m_MixPlugins[iPlug].pMixPlugin) + gpMixPluginCreateProc(m_MixPlugins[plug], *this); + if (m_MixPlugins[plug].pMixPlugin) { // plugin has been found - m_MixPlugins[iPlug].pMixPlugin->RestoreAllParameters(m_MixPlugins[iPlug].defaultProgram); + m_MixPlugins[plug].pMixPlugin->RestoreAllParameters(m_MixPlugins[plug].defaultProgram); } else { // plugin not found - add to list bool found = false; - for(std::vector<PLUGINDEX>::iterator i = notFoundIDs.begin(); i != notFoundIDs.end(); ++i) + for(std::vector<SNDMIXPLUGININFO *>::const_iterator i = notFoundIDs.begin(); i != notFoundIDs.end(); ++i) { - if(m_MixPlugins[*i].Info.dwPluginId2 == m_MixPlugins[iPlug].Info.dwPluginId2 - && m_MixPlugins[*i].Info.dwPluginId1 == m_MixPlugins[iPlug].Info.dwPluginId1) + if((**i).dwPluginId2 == (**i).dwPluginId2 + && (**i).dwPluginId1 == (**i).dwPluginId1) { found = true; break; @@ -935,9 +929,9 @@ if(!found) { - notFoundText.append(m_MixPlugins[iPlug].GetLibraryName()); + notFoundText.append(m_MixPlugins[plug].GetLibraryName()); notFoundText.append("\n"); - notFoundIDs.push_back(iPlug); // add this to the list of missing IDs so we will find the needed plugins later when calling KVRAudio + notFoundIDs.push_back(&m_MixPlugins[plug].Info); // add this to the list of missing IDs so we will find the needed plugins later when calling KVRAudio } } } @@ -951,21 +945,20 @@ if(notFoundIDs.size() == 1) { notFoundText = "The following plugin has not been found:\n\n" + notFoundText + "\nDo you want to search for it online?"; - } - else + } else { - notFoundText = "The following plugins have not been found:\n\n" + notFoundText + "\nDo you want to search for them online?"; + notFoundText = "The following plugins have not been found:\n\n" + notFoundText + "\nDo you want to search for them online?"; } if (Reporting::Confirm(mpt::ToWide(mpt::CharsetUTF8, notFoundText.c_str()), L"OpenMPT - Plugins missing", false, true) == cnfYes) { - std::string sUrl = "http://resources.openmpt.org/plugins/search.php?p="; - for(std::vector<PLUGINDEX>::iterator i = notFoundIDs.begin(); i != notFoundIDs.end(); ++i) + std::string url = "http://resources.openmpt.org/plugins/search.php?p="; + for(std::vector<SNDMIXPLUGININFO *>::const_iterator i = notFoundIDs.begin(); i != notFoundIDs.end(); ++i) { - sUrl += mpt::fmt::HEX0<8>(LittleEndian(m_MixPlugins[*i].Info.dwPluginId2)); - sUrl += m_MixPlugins[*i].GetLibraryName(); - sUrl += "%0a"; + url += mpt::fmt::HEX0<8>(LittleEndian((**i).dwPluginId2)); + url += (**i).szLibraryName; + url += "%0a"; } - CTrackApp::OpenURL(mpt::PathString::FromUTF8(sUrl)); + CTrackApp::OpenURL(mpt::PathString::FromUTF8(url)); } } #endif // NO_VST @@ -973,17 +966,23 @@ // Set up mix levels SetMixLevels(m_nMixLevels); - if(GetType() != MOD_TYPE_NONE) + if(GetType() == MOD_TYPE_NONE) { - SetModSpecsPointer(m_pModSpecs, GetBestSaveFormat()); - const ORDERINDEX CacheSize = ModSequenceSet::s_nCacheSize; // workaround reference to static const member problem - const ORDERINDEX nMinLength = std::min(CacheSize, GetModSpecifications().ordersMax); - if (Order.GetLength() < nMinLength) - Order.resize(nMinLength); - return true; + return false; } - return false; + SetModSpecsPointer(m_pModSpecs, GetBestSaveFormat()); + const ORDERINDEX CacheSize = ModSequenceSet::s_nCacheSize; // workaround reference to static const member problem + const ORDERINDEX nMinLength = std::min(CacheSize, GetModSpecifications().ordersMax); + if (Order.GetLength() < nMinLength) + Order.resize(nMinLength); + + // When reading a file made with an older version of MPT, it might be necessary to upgrade some settings automatically. + if(m_dwLastSavedWithVersion) + { + UpgradeModule(); + } + return true; } @@ -1059,27 +1058,19 @@ } -UINT CSoundFile::GetCurrentPos() const -//------------------------------------ -{ - UINT pos = 0; - - for (UINT i=0; i<m_PlayState.m_nCurrentOrder; i++) if (Order[i] < Patterns.Size()) - pos += Patterns[Order[i]].GetNumRows(); - return pos + m_PlayState.m_nRow; -} - double CSoundFile::GetCurrentBPM() const //-------------------------------------- { double bpm; - if (m_nTempoMode == tempo_mode_modern) // With modern mode, we trust that true bpm - { // is close enough to what user chose. + if (m_nTempoMode == tempo_mode_modern) + { + // With modern mode, we trust that true bpm is close enough to what user chose. bpm = static_cast<double>(m_PlayState.m_nMusicTempo); // This avoids oscillation due to tick-to-tick corrections. } else - { //with other modes, we calculate it: - double ticksPerBeat = m_PlayState.m_nMusicSpeed * m_PlayState.m_nCurrentRowsPerBeat; //ticks/beat = ticks/row * rows/beat + { + //with other modes, we calculate it: + double ticksPerBeat = m_PlayState.m_nMusicSpeed * m_PlayState.m_nCurrentRowsPerBeat; //ticks/beat = ticks/row * rows/beat double samplesPerBeat = m_PlayState.m_nSamplesPerTick * ticksPerBeat; //samps/beat = samps/tick * ticks/beat bpm = m_MixerSettings.gdwMixingFreq/samplesPerBeat * 60; //beats/sec = samps/sec / samps/beat } //beats/min = beats/sec * 60 @@ -1087,73 +1078,28 @@ return bpm; } -void CSoundFile::SetCurrentPos(UINT nPos) -//--------------------------------------- + +void CSoundFile::ResetPlayPos() +//----------------------------- { - ORDERINDEX nPattern; - ModChannel::ResetFlags resetMask = (!nPos) ? ModChannel::resetSetPosFull : ModChannel::resetSetPosBasic; + for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) + m_PlayState.Chn[i].Reset(ModChannel::resetSetPosFull, *this, i); - for (CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) - m_PlayState.Chn[i].Reset(resetMask, *this, i); + InitializeVisitedRows(); + m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED); - if(nPos == 0) - { - m_PlayState.m_nGlobalVolume = m_nDefaultGlobalVolume; - m_PlayState.m_nMusicSpeed = m_nDefaultSpeed; - m_PlayState.m_nMusicTempo = m_nDefaultTempo; + m_PlayState.m_nGlobalVolume = m_nDefaultGlobalVolume; + m_PlayState.m_nMusicSpeed = m_nDefaultSpeed; + m_PlayState.m_nMusicTempo = m_nDefaultTempo; - // do not ramp global volume when starting playback - m_PlayState.m_lHighResRampingGlobalVolume = m_PlayState.m_nGlobalVolume<<VOLUMERAMPPRECISION; - m_PlayState.m_nGlobalVolumeDestination = m_PlayState.m_nGlobalVolume; - m_PlayState.m_nSamplesToGlobalVolRampDest = 0; - m_PlayState.m_nGlobalVolumeRampAmount = 0; + // do not ramp global volume when starting playback + m_PlayState.m_lHighResRampingGlobalVolume = m_PlayState.m_nGlobalVolume<<VOLUMERAMPPRECISION; + m_PlayState.m_nGlobalVolumeDestination = m_PlayState.m_nGlobalVolume; + m_PlayState.m_nSamplesToGlobalVolRampDest = 0; + m_PlayState.m_nGlobalVolumeRampAmount = 0; - visitedSongRows.Initialize(true); - } - m_SongFlags.reset(SONG_FADINGSONG | SONG_ENDREACHED); - for (nPattern = 0; nPattern < Order.size(); nPattern++) - { - ORDERINDEX ord = Order[nPattern]; - if(ord == Order.GetIgnoreIndex()) continue; - if (ord == Order.GetInvalidPatIndex()) break; - if (ord < Patterns.Size()) - { - if (nPos < (UINT)Patterns[ord].GetNumRows()) break; - nPos -= Patterns[ord].GetNumRows(); - } - } - // Buggy position ? - if ((nPattern >= Order.size()) - || (Order[nPattern] >= Patterns.Size()) - || (nPos >= Patterns[Order[nPattern]].GetNumRows())) - { - nPos = 0; - nPattern = 0; - } - UINT nRow = nPos; - if ((nRow) && (Order[nPattern] < Patterns.Size())) - { - ModCommand *p = Patterns[Order[nPattern]]; - if ((p) && (nRow < Patterns[Order[nPattern]].GetNumRows())) - { - bool bOk = false; - while ((!bOk) && (nRow > 0)) - { - UINT n = nRow * m_nChannels; - for (UINT k=0; k<m_nChannels; k++, n++) - { - if (p[n].note) - { - bOk = true; - break; - } - } - if (!bOk) nRow--; - } - } - } - m_PlayState.m_nNextOrder = nPattern; - m_PlayState.m_nNextRow = nRow; + m_PlayState.m_nNextOrder = 0; + m_PlayState.m_nNextRow = 0; m_PlayState.m_nTickCount = m_PlayState.m_nMusicSpeed; m_PlayState.m_nBufferCount = 0; m_PlayState.m_nPatternDelay = 0; @@ -1194,7 +1140,7 @@ if (!nOrder) { - SetCurrentPos(0); + ResetPlayPos(); } else { m_PlayState.m_nNextOrder = nOrder; @@ -1276,7 +1222,7 @@ void CSoundFile::RecalculateGainForAllPlugs() //------------------------------------------- { - for (UINT iPlug=0; iPlug<MAX_MIXPLUGINS; iPlug++) + for (PLUGINDEX iPlug = 0; iPlug < MAX_MIXPLUGINS; iPlug++) { if (!m_MixPlugins[iPlug].pMixPlugin) continue; //most common branch @@ -1289,6 +1235,7 @@ } } + //end rewbs.VSTCompliance void CSoundFile::ResetChannels() Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-11-29 00:07:22 UTC (rev 4612) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-11-29 00:15:19 UTC (rev 4613) @@ -97,13 +97,13 @@ struct GetLengthType { double duration; // total time in seconds - ROWINDEX lastRow; // last parsed row (see lastOrder remark) - ROWINDEX endRow; // last row before module loops (see endOrder remark) + ROWINDEX lastRow; // last parsed row (if no target is specified, this is the first row that is parsed twice, i.e. not the *last* played order) + ROWINDEX endRow; // last row before module loops (UNDEFINED if a target is specified) ROWINDEX startRow; // first row of parsed subsong - ORDERINDEX lastOrder; // last parsed order (if no target is specified, this is the first order that is parsed twice, i.e. not the *last* played order) + ORDERINDEX lastOrder; // last parsed order (see lastRow remark) ORDERINDEX endOrder; // last order before module loops (UNDEFINED if a target is specified) ORDERINDEX startOrder; // first order of parsed subsong - bool targetReached; // true if the specified order/row combination has been reached while going through the module + bool targetReached; // true if the specified order/row combination or duration has been reached while going through the module GetLengthType() : duration(0.0) @@ -601,7 +601,6 @@ INSTRUMENTINDEX GetNumInstruments() const { return m_nInstruments; } SAMPLEINDEX GetNumSamples() const { return m_nSamples; } - UINT GetCurrentPos() const; PATTERNINDEX GetCurrentPattern() const { return m_PlayState.m_nPattern; } ORDERINDEX GetCurrentOrder() const { return m_PlayState.m_nCurrentOrder; } CHANNELINDEX GetNumChannels() const { return m_nChannels; } @@ -619,7 +618,7 @@ void DontLoopPattern(PATTERNINDEX nPat, ROWINDEX nRow = 0); //rewbs.playSongFromCursor CHANNELINDEX GetMixStat() const { return m_nMixStat; } void ResetMixStat() { m_nMixStat = 0; } - void SetCurrentPos(UINT nPos); + void ResetPlayPos(); void SetCurrentOrder(ORDERINDEX nOrder); std::string GetTitle() const { return songName; } bool SetTitle(const std::string &newTitle); // Return true if title was changed. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |