From: <man...@us...> - 2013-06-06 05:02:32
|
Revision: 2307 http://sourceforge.net/p/modplug/code/2307 Author: manxorist Date: 2013-06-06 05:02:26 +0000 (Thu, 06 Jun 2013) Log Message: ----------- [Ref] Move knowledge and state handling of when to clear the MixReverbBuffer into CReverb. [Ref] Add comments describing reverb on/off state handling. [Ref] Call GetProcSupport() directly in CReverb::Process and avoid having to pass it around as a parameter. Modified Paths: -------------- trunk/OpenMPT/sounddsp/Reverb.cpp trunk/OpenMPT/sounddsp/Reverb.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/sounddsp/Reverb.cpp =================================================================== --- trunk/OpenMPT/sounddsp/Reverb.cpp 2013-06-05 21:34:21 UTC (rev 2306) +++ trunk/OpenMPT/sounddsp/Reverb.cpp 2013-06-06 05:02:26 UTC (rev 2307) @@ -396,15 +396,42 @@ } +void CReverb::ProcessPrepare(int *MixReverbBuffer, UINT nSamples) +//--------------------------------------------------------------- +{ + gnReverbSend = 0; // no data sent yet + if(!gnReverbSamples) + { + // reverb had decayed completely, we will probably not process reverb, so no need to clear buffer + return; + } + StereoFill(MixReverbBuffer, nSamples, &gnRvbROfsVol, &gnRvbLOfsVol); +} + + +void CReverb::ProcessWillSend(int *MixReverbBuffer, UINT nSamples) +//---------------------------------------------------------------- +{ + if(!gnReverbSend && !gnReverbSamples) + { + // reverb had decayed completely before, and we did not clear the buffer yet, do it now because we get new data + StereoFill(MixReverbBuffer, nSamples, &gnRvbROfsVol, &gnRvbLOfsVol); + } + gnReverbSend = 1; // we will have to process reverb +} + + // Reverb -void CReverb::Process(int *MixSoundBuffer, int *MixReverbBuffer, UINT nSamples, DWORD sysinfo) -//-------------------------------------------------------------------------------------------- +void CReverb::Process(int *MixSoundBuffer, int *MixReverbBuffer, UINT nSamples) +//----------------------------------------------------------------------------- { UINT nIn, nOut; - if ((!gnReverbSend) && (!gnReverbSamples)) return; - if (!gnReverbSend) StereoFill(MixReverbBuffer, nSamples, &gnRvbROfsVol, &gnRvbLOfsVol); - if (!(sysinfo & PROCSUPPORT_MMX)) return; + if((!gnReverbSend) && (!gnReverbSamples)) + { // no data is sent to reverb and reverb decayed completely + return; + } + if (!(GetProcSupport() & PROCSUPPORT_MMX)) return; // Dynamically adjust reverb master gains LONG lMasterGain; lMasterGain = ((g_RefDelay.lMasterGain * m_Settings.m_nReverbDepth) >> 4); @@ -460,11 +487,11 @@ // Upsample 2x MMX_ReverbProcessPostFiltering1x(MixReverbBuffer, MixSoundBuffer, nSamples); // Automatically shut down if needed - if (gnReverbSend) gnReverbSamples = gnReverbDecaySamples; - else if (gnReverbSamples > nSamples) gnReverbSamples -= nSamples; - else + if(gnReverbSend) gnReverbSamples = gnReverbDecaySamples; // reset decay counter + else if(gnReverbSamples > nSamples) gnReverbSamples -= nSamples; // decay + else // decayed { - if (gnReverbSamples) Shutdown(); + Shutdown(); gnReverbSamples = 0; } } Modified: trunk/OpenMPT/sounddsp/Reverb.h =================================================================== --- trunk/OpenMPT/sounddsp/Reverb.h 2013-06-05 21:34:21 UTC (rev 2306) +++ trunk/OpenMPT/sounddsp/Reverb.h 2013-06-06 05:02:26 UTC (rev 2307) @@ -126,12 +126,13 @@ CReverbSettings m_Settings; // Shared reverb state - UINT gnReverbSend; LONG gnRvbROfsVol; LONG gnRvbLOfsVol; private: + UINT gnReverbSend; + UINT gnReverbSamples; UINT gnReverbDecaySamples; @@ -153,10 +154,19 @@ public: CReverb(); - ~CReverb() {} public: void Initialize(BOOL bReset, DWORD MixingFreq); - void Process(int *MixSoundBuffer, int *MixReverbBuffer, UINT nSamples, DWORD sysinfo); + + // call once before calling Process + void ProcessPrepare(int *MixReverbBuffer, UINT nSamples); + + // call after ProcessPrepare and before you are putting data into MixReverbBuffer, + // can be called multiple times or never (if no data is sent to reverb) + void ProcessWillSend(int *MixReverbBuffer, UINT nSamples); + + // call once after all data has been sent + void Process(int *MixSoundBuffer, int *MixReverbBuffer, UINT nSamples); + // [Reverb level 0(quiet)-100(loud)], [REVERBTYPE_XXXX] bool SetReverbParameters(UINT nDepth, UINT nType); private: Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-05 21:34:21 UTC (rev 2306) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-06-06 05:02:26 UTC (rev 2307) @@ -1515,11 +1515,8 @@ #ifndef NO_REVERB if (pbuffer == MixReverbBuffer) { - if (!m_Reverb.gnReverbSend) - { - StereoFill(MixReverbBuffer, count, &m_Reverb.gnRvbROfsVol, &m_Reverb.gnRvbLOfsVol); - } - m_Reverb.gnReverbSend += count; + // notify reverb that there will be data in the reverb buffer to be processed + m_Reverb.ProcessWillSend(MixReverbBuffer, count); pOfsR = &m_Reverb.gnRvbROfsVol; pOfsL = &m_Reverb.gnRvbLOfsVol; } Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-05 21:34:21 UTC (rev 2306) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-06-06 05:02:26 UTC (rev 2307) @@ -283,10 +283,6 @@ lSampleCount = lCount; -#ifndef NO_REVERB - m_Reverb.gnReverbSend = 0; -#endif // NO_REVERB - if(nMixStatCount == 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 @@ -296,6 +292,9 @@ // Resetting sound buffer StereoFill(MixSoundBuffer, lCount, &gnDryROfsVol, &gnDryLOfsVol); +#ifndef NO_REVERB + m_Reverb.ProcessPrepare(MixReverbBuffer, lCount); +#endif // NO_REVERB if (m_MixerSettings.gnChannels >= 2) { @@ -303,7 +302,7 @@ CreateStereoMix(lCount); #ifndef NO_REVERB - m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount, GetProcSupport()); + m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); @@ -318,7 +317,7 @@ CreateStereoMix(lCount); #ifndef NO_REVERB - m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount, GetProcSupport()); + m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |