From: <man...@us...> - 2013-09-03 13:11:40
|
Revision: 2627 http://sourceforge.net/p/modplug/code/2627 Author: manxorist Date: 2013-09-03 13:11:31 +0000 (Tue, 03 Sep 2013) Log Message: ----------- [Ref] Explicitly reset used channels mixer statistics externally to CSoundFile::Read(). Calculate statistics over the interval as maximum used channels instead of a approximation of average used channels. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-09-01 10:31:18 UTC (rev 2626) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-09-03 13:11:31 UTC (rev 2627) @@ -195,6 +195,7 @@ } } std::size_t module_impl::read_wrapper( std::size_t count, std::int16_t * left, std::int16_t * right, std::int16_t * rear_left, std::int16_t * rear_right ) { + m_sndFile->ResetMixStat(); std::size_t count_read = 0; while ( count > 0 ) { std::int16_t * const buffers[4] = { left + count_read, right + count_read, rear_left + count_read, rear_right + count_read }; @@ -212,6 +213,7 @@ return count_read; } std::size_t module_impl::read_wrapper( std::size_t count, float * left, float * right, float * rear_left, float * rear_right ) { + m_sndFile->ResetMixStat(); std::size_t count_read = 0; while ( count > 0 ) { float * const buffers[4] = { left + count_read, right + count_read, rear_left + count_read, rear_right + count_read }; @@ -229,6 +231,7 @@ return count_read; } std::size_t module_impl::read_interleaved_wrapper( std::size_t count, std::size_t channels, std::int16_t * interleaved ) { + m_sndFile->ResetMixStat(); std::size_t count_read = 0; while ( count > 0 ) { AudioReadTargetGainBuffer<std::int16_t> target(*m_Dither, interleaved + count_read * channels, 0, m_Gain); @@ -245,6 +248,7 @@ return count_read; } std::size_t module_impl::read_interleaved_wrapper( std::size_t count, std::size_t channels, float * interleaved ) { + m_sndFile->ResetMixStat(); std::size_t count_read = 0; while ( count > 0 ) { AudioReadTargetGainBuffer<float> target(*m_Dither, interleaved + count_read * channels, 0, m_Gain); @@ -599,7 +603,7 @@ return m_sndFile->m_nRow; } std::int32_t module_impl::get_current_playing_channels() const { - return m_sndFile->m_nMixChannels; + return m_sndFile->GetMixStat(); } float module_impl::get_current_channel_vu_left( std::int32_t channel ) const { if ( channel < 0 || channel >= m_sndFile->GetNumChannels() ) { Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-09-01 10:31:18 UTC (rev 2626) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-09-03 13:11:31 UTC (rev 2627) @@ -1059,8 +1059,10 @@ } // Add an entry to the notification history - Notification notification(notifyType, notifyItem, notificationtimestamp, m_pSndFile->m_nRow, m_pSndFile->m_nTickCount, m_pSndFile->m_nCurrentOrder, m_pSndFile->m_nPattern, m_pSndFile->m_nMixStat); + Notification notification(notifyType, notifyItem, notificationtimestamp, m_pSndFile->m_nRow, m_pSndFile->m_nTickCount, m_pSndFile->m_nCurrentOrder, m_pSndFile->m_nPattern, m_pSndFile->GetMixStat()); + m_pSndFile->ResetMixStat(); + if(m_pSndFile->m_SongFlags[SONG_ENDREACHED]) notification.type.set(Notification::EOS); if(notifyType[Notification::Sample]) Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-09-01 10:31:18 UTC (rev 2626) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-09-03 13:11:31 UTC (rev 2627) @@ -1591,7 +1591,7 @@ if (nsamples > 0) goto SampleLooping; nchmixed += addmix?1:0; } - m_nMixStat += nchused; + m_nMixStat = std::max<CHANNELINDEX>(m_nMixStat, nchused); } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-09-01 10:31:18 UTC (rev 2626) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-09-03 13:11:31 UTC (rev 2627) @@ -327,7 +327,9 @@ UINT m_nDefaultSpeed, m_nDefaultTempo, m_nDefaultGlobalVolume; FlagSet<SongFlags> m_SongFlags; CHANNELINDEX m_nMixChannels; - UINT m_nMixStat; +private: + CHANNELINDEX m_nMixStat; +public: samplecount_t m_nBufferCount; double m_dBufferDiff; UINT m_nTickCount; @@ -472,6 +474,8 @@ void PatternTransitionChnUnmuteAll(); double GetCurrentBPM() const; 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 SetCurrentOrder(ORDERINDEX nOrder); std::string GetTitle() const { return songName; } Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-09-01 10:31:18 UTC (rev 2626) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-09-03 13:11:31 UTC (rev 2627) @@ -96,6 +96,7 @@ { if(bReset) { + ResetMixStat(); gnDryLOfsVol = 0; gnDryROfsVol = 0; } @@ -145,8 +146,6 @@ { ALWAYS_ASSERT(m_MixerSettings.IsValid()); - int mixStatCount = 0; - bool mixPlugins = false; for(PLUGINDEX i = 0; i < MAX_MIXPLUGINS; ++i) { @@ -220,12 +219,6 @@ const samplecount_t countChunk = std::min<samplecount_t>(MIXBUFFERSIZE, std::min<samplecount_t>(m_nBufferCount, countToRender)); - if(mixStatCount == 0) - { // reset mixer channel count before we are calling CreateStereoMix the first time this round, if we are not updating the mixer state, we do not reset statistics - m_nMixStat = 0; - } - mixStatCount++; - CreateStereoMix(countChunk); #ifndef NO_REVERB @@ -269,11 +262,6 @@ // mix done - if(mixStatCount > 0) - { - m_nMixStat = (m_nMixStat + mixStatCount - 1) / mixStatCount; // round up - } - return countRendered; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |