From: <sag...@us...> - 2014-11-19 21:32:00
|
Revision: 4603 http://sourceforge.net/p/modplug/code/4603 Author: saga-games Date: 2014-11-19 21:31:48 +0000 (Wed, 19 Nov 2014) Log Message: ----------- [Fix] Sample tab: No longer crash when silencing a single sample (http://bugs.openmpt.org/view.php?id=610) [Imp] Song length estimation: When there are multiple subsongs, also display the total length. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Moddoc.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-11-19 18:09:53 UTC (rev 4602) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-11-19 21:31:48 UTC (rev 4603) @@ -2279,12 +2279,12 @@ SampleSelectionPoints selection = GetSelectionPoints(); // never apply silence to a sample that has no selection - if(selection.selectionActive == true) + const SmpLength len = selection.nEnd - selection.nStart; + if(selection.selectionActive && len > 1) { ModSample &sample = m_sndFile.GetSample(m_nSample); m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_update, "Silence", selection.nStart, selection.nEnd); - SmpLength len = selection.nEnd - selection.nStart; if (sample.uFlags[CHN_STEREO]) { int smplsize = sample.GetBytesPerSample(); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-19 18:09:53 UTC (rev 4602) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-11-19 21:31:48 UTC (rev 4603) @@ -2224,13 +2224,15 @@ { CString s = _T("Approximate song length: "); std::vector<GetLengthType> lengths = m_SndFile.GetLength(eNoAdjust, GetLengthTarget(true)); + double totalLength = 0.0; for(size_t i = 0; i < lengths.size(); i++) { + double songLength = lengths[i].duration; if(lengths.size() > 1) { - s.AppendFormat(_T("\nSong %u, starting at order %u: "), i + 1, lengths[i].startOrder); + totalLength += songLength; + s.AppendFormat(_T("\nSong %u, starting at order %u:\t"), i + 1, lengths[i].startOrder); } - double songLength = lengths[i].duration; if(songLength != std::numeric_limits<double>::infinity()) { songLength = Util::Round(songLength); @@ -2240,6 +2242,10 @@ s += _T("Song too long!"); } } + if(lengths.size() > 1 && totalLength != std::numeric_limits<double>::infinity()) + { + s.AppendFormat(_T("\n\nTotal length:\t%.0fmn%02.0fs"), std::floor(totalLength / 60.0), std::fmod(totalLength, 60.0)); + } Reporting::Information(s); } @@ -2649,23 +2655,19 @@ CHANNELINDEX CModDoc::FindAvailableChannel() const //------------------------------------------------ { - CHANNELINDEX nStoppedChannel = CHANNELINDEX_INVALID; + CHANNELINDEX stoppedChannel = m_SndFile.GetNumChannels(); // Search for available channel - for(CHANNELINDEX j = MAX_CHANNELS - 1; j >= m_SndFile.m_nChannels; j--) + for(CHANNELINDEX i = MAX_CHANNELS - 1; i >= m_SndFile.GetNumChannels(); i--) { - const ModChannel &chn = m_SndFile.m_PlayState.Chn[j]; + const ModChannel &chn = m_SndFile.m_PlayState.Chn[i]; if(!chn.nLength) - return j; + return i; else if(chn.dwFlags[CHN_NOTEFADE]) - nStoppedChannel = j; + stoppedChannel = i; } - // Nothing found: return one that's stopped - if(nStoppedChannel != CHANNELINDEX_INVALID) - return nStoppedChannel; - - //Last resort: go for first virtual channel. - return m_SndFile.m_nChannels; + // Nothing found: return one that's stopped, or as a last resort, the first virtual channel. + return stoppedChannel; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |