From: <man...@us...> - 2013-04-02 20:17:42
|
Revision: 1712 http://sourceforge.net/p/modplug/code/1712 Author: manxorist Date: 2013-04-02 20:17:31 +0000 (Tue, 02 Apr 2013) Log Message: ----------- [Ref] Move all reverb related data into class CReverb. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Snd_rvb.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp trunk/OpenMPT/soundlib/snd_rvb.h Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-04-02 20:17:31 UTC (rev 1712) @@ -538,7 +538,7 @@ #ifndef NO_REVERB // Reverb m_SbReverbDepth.SetRange(1, 16); - m_SbReverbDepth.SetPos(CSoundFile::m_nReverbDepth); + m_SbReverbDepth.SetPos(CSoundFile::m_Reverb.m_Settings.m_nReverbDepth); UINT nSel = 0; for (UINT iRvb=0; iRvb<NUM_REVERBTYPES; iRvb++) { @@ -547,7 +547,7 @@ { UINT n = m_CbnReverbPreset.AddString(pszName); m_CbnReverbPreset.SetItemData(n, iRvb); - if (iRvb == CSoundFile::gnReverbType) nSel = n; + if (iRvb == CSoundFile::m_Reverb.m_Settings.m_nReverbType) nSel = n; } } m_CbnReverbPreset.SetCurSel(nSel); @@ -612,9 +612,9 @@ { #ifndef NO_REVERB UINT n = m_SbReverbDepth.GetPos(); - if (n != CSoundFile::m_nReverbDepth) + if (n != CSoundFile::m_Reverb.m_Settings.m_nReverbDepth) { - if ((n) && (n <= 16)) CSoundFile::m_nReverbDepth = n; + if ((n) && (n <= 16)) CSoundFile::m_Reverb.m_Settings.m_nReverbDepth = n; } #endif } else @@ -724,7 +724,7 @@ { // Reverb depth is dynamically changed UINT nReverbType = m_CbnReverbPreset.GetItemData(m_CbnReverbPreset.GetCurSel()); - if (nReverbType < NUM_REVERBTYPES) CSoundFile::gnReverbType = nReverbType; + if (nReverbType < NUM_REVERBTYPES) CSoundFile::m_Reverb.m_Settings.m_nReverbType = nReverbType; } #endif #ifndef NO_DSP Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-04-02 20:17:31 UTC (rev 1712) @@ -423,8 +423,8 @@ CSoundFile::m_DSP.m_Settings.m_nXBassRange = CMainFrame::GetPrivateProfileLong("Effects", "XBassRange", CSoundFile::m_DSP.m_Settings.m_nXBassRange, iniFile); #endif #ifndef NO_REVERB - CSoundFile::m_nReverbDepth = CMainFrame::GetPrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_nReverbDepth, iniFile); - CSoundFile::gnReverbType = CMainFrame::GetPrivateProfileLong("Effects", "ReverbType", CSoundFile::gnReverbType, iniFile); + CSoundFile::m_Reverb.m_Settings.m_nReverbDepth = CMainFrame::GetPrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_Reverb.m_Settings.m_nReverbDepth, iniFile); + CSoundFile::m_Reverb.m_Settings.m_nReverbType = CMainFrame::GetPrivateProfileLong("Effects", "ReverbType", CSoundFile::m_Reverb.m_Settings.m_nReverbType, iniFile); #endif #ifndef NO_DSP CSoundFile::m_DSP.m_Settings.m_nProLogicDepth = CMainFrame::GetPrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, iniFile); @@ -576,8 +576,8 @@ RegQueryValueEx(key, "XBassRange", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nXBassRange, &dwDWORDSize); #endif #ifndef NO_REVERB - RegQueryValueEx(key, "ReverbDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_nReverbDepth, &dwDWORDSize); - RegQueryValueEx(key, "ReverbType", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::gnReverbType, &dwDWORDSize); + RegQueryValueEx(key, "ReverbDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_Reverb.m_Settings.m_nReverbDepth, &dwDWORDSize); + RegQueryValueEx(key, "ReverbType", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_Reverb.m_Settings.m_nReverbType, &dwDWORDSize); #endif NO_REVERB #ifndef NO_DSP RegQueryValueEx(key, "ProLogicDepth", NULL, &dwREG_DWORD, (LPBYTE)&CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, &dwDWORDSize); @@ -801,8 +801,8 @@ CMainFrame::WritePrivateProfileLong("Effects", "XBassRange", CSoundFile::m_DSP.m_Settings.m_nXBassRange, iniFile); #endif #ifndef NO_REVERB - CMainFrame::WritePrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_nReverbDepth, iniFile); - CMainFrame::WritePrivateProfileLong("Effects", "ReverbType", CSoundFile::gnReverbType, iniFile); + CMainFrame::WritePrivateProfileLong("Effects", "ReverbDepth", CSoundFile::m_Reverb.m_Settings.m_nReverbDepth, iniFile); + CMainFrame::WritePrivateProfileLong("Effects", "ReverbType", CSoundFile::m_Reverb.m_Settings.m_nReverbType, iniFile); #endif #ifndef NO_DSP CMainFrame::WritePrivateProfileLong("Effects", "ProLogicDepth", CSoundFile::m_DSP.m_Settings.m_nProLogicDepth, iniFile); Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-04-02 20:17:31 UTC (rev 1712) @@ -29,15 +29,10 @@ float MixFloatBuffer[MIXBUFFERSIZE * 2]; -#ifndef NO_REVERB -extern UINT gnReverbSend; -#endif - extern LONG gnDryROfsVol; extern LONG gnDryLOfsVol; -extern LONG gnRvbROfsVol; -extern LONG gnRvbLOfsVol; + // 4x256 taps polyphase FIR resampling filter extern short int gFastSinc[]; extern short int gKaiserSinc[]; // 8-taps polyphase @@ -1546,13 +1541,13 @@ #ifndef NO_REVERB if (pbuffer == MixReverbBuffer) { - if (!gnReverbSend) + if (!m_Reverb.gnReverbSend) { - X86_StereoFill(MixReverbBuffer, count, &gnRvbROfsVol, &gnRvbLOfsVol); + X86_StereoFill(MixReverbBuffer, count, &m_Reverb.gnRvbROfsVol, &m_Reverb.gnRvbLOfsVol); } - gnReverbSend += count; - pOfsR = &gnRvbROfsVol; - pOfsL = &gnRvbLOfsVol; + m_Reverb.gnReverbSend += count; + pOfsR = &m_Reverb.gnRvbROfsVol; + pOfsL = &m_Reverb.gnRvbLOfsVol; } #endif bSurround = (pbuffer == MixRearBuffer); Modified: trunk/OpenMPT/soundlib/Snd_rvb.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/soundlib/Snd_rvb.cpp 2013-04-02 20:17:31 UTC (rev 1712) @@ -18,43 +18,52 @@ #pragma warning(disable:4725) // Pentium fdiv bug #pragma warning(disable:4731) // ebp modified -extern int MixReverbBuffer[MIXBUFFERSIZE * 2]; -extern int MixSoundBuffer[MIXBUFFERSIZE * 4]; - extern VOID MPPASMCALL X86_StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); -// Reverb mix buffers -static SWRVBREFDELAY g_RefDelay; -static SWLATEREVERB g_LateReverb; -// Shared reverb state -UINT gnReverbSamples = 0; -UINT gnReverbDecaySamples = 0; -UINT gnReverbSend = 0; -LONG gnRvbROfsVol = 0; -LONG gnRvbLOfsVol = 0; -UINT CSoundFile::gnReverbType = 0; -UINT CSoundFile::m_nReverbDepth = 8; // 50% +CReverbSettings::CReverbSettings() +//-------------------------------- +{ + m_nReverbType = 0; + m_nReverbDepth = 8; // 50% +} -// Internal reverb state -static BOOL g_bLastInPresent = 0; -static BOOL g_bLastOutPresent = 0; -static int g_nLastRvbIn_xl = 0; -static int g_nLastRvbIn_xr = 0; -static int g_nLastRvbIn_yl = 0; -static int g_nLastRvbIn_yr = 0; -static int g_nLastRvbOut_xl = 0; -static int g_nLastRvbOut_xr = 0; -static __int64 gnDCRRvb_Y1 = 0; -static __int64 gnDCRRvb_X1 = 0; +CReverb::CReverb() +//---------------- +{ + // Shared reverb state + gnReverbSamples = 0; + gnReverbDecaySamples = 0; + gnReverbSend = 0; + gnRvbROfsVol = 0; + gnRvbLOfsVol = 0; + + // Internal reverb state + g_bLastInPresent = 0; + g_bLastOutPresent = 0; + g_nLastRvbIn_xl = 0; + g_nLastRvbIn_xr = 0; + g_nLastRvbIn_yl = 0; + g_nLastRvbIn_yr = 0; + g_nLastRvbOut_xl = 0; + g_nLastRvbOut_xr = 0; + gnDCRRvb_Y1 = 0; + gnDCRRvb_X1 = 0; + + // Reverb mix buffers + MemsetZero(g_RefDelay); + MemsetZero(g_LateReverb); + +} + + // Misc functions -LONG OnePoleLowPassCoef(LONG scale, FLOAT g, FLOAT F_c, FLOAT F_s); -LONG mBToLinear(LONG scale, LONG value_mB); -FLOAT mBToLinear(LONG value_mB); -FLOAT pow(FLOAT a, FLOAT b); +static LONG OnePoleLowPassCoef(LONG scale, FLOAT g, FLOAT F_c, FLOAT F_s); +static LONG mBToLinear(LONG scale, LONG value_mB); +static FLOAT mBToLinear(LONG value_mB); typedef struct _SNDMIX_RVBPRESET { @@ -220,8 +229,8 @@ } -void ReverbShutdown() -//------------------- +void CReverb::Shutdown() +//---------------------- { // Clear out all reverb state g_bLastInPresent = FALSE; @@ -243,17 +252,17 @@ } -VOID InitializeReverb(BOOL bReset) -//-------------------------------- +void CReverb::Initialize(BOOL bReset, DWORD MixingFreq) +//----------------------------------------------------- { - if (CSoundFile::gnReverbType >= NUM_REVERBTYPES) CSoundFile::gnReverbType = 0; + if (m_Settings.m_nReverbType >= NUM_REVERBTYPES) m_Settings.m_nReverbType = 0; static PSNDMIX_REVERB_PROPERTIES spCurrentPreset = NULL; - PSNDMIX_REVERB_PROPERTIES pRvbPreset = &gRvbPresets[CSoundFile::gnReverbType].Preset; + PSNDMIX_REVERB_PROPERTIES pRvbPreset = &gRvbPresets[m_Settings.m_nReverbType].Preset; if ((pRvbPreset != spCurrentPreset) || (bReset)) { // Reverb output frequency is half of the dry output rate - FLOAT flOutputFrequency = (FLOAT)CSoundFile::gdwMixingFreq; + FLOAT flOutputFrequency = (FLOAT)MixingFreq; ENVIRONMENTREVERB rvb; // Reset reverb parameters @@ -345,33 +354,33 @@ if (bReset) { gnReverbSamples = 0; - ReverbShutdown(); + Shutdown(); } // Wait at least 5 seconds before shutting down the reverb - if (gnReverbDecaySamples < CSoundFile::gdwMixingFreq*5) + if (gnReverbDecaySamples < MixingFreq*5) { - gnReverbDecaySamples = CSoundFile::gdwMixingFreq*5; + gnReverbDecaySamples = MixingFreq*5; } } // [Reverb level 0(quiet)-100(loud)], [type = REVERBTYPE_XXXX] -BOOL CSoundFile::SetReverbParameters(UINT nDepth, UINT nType) -//----------------------------------------------------------- +bool CReverb::SetReverbParameters(UINT nDepth, UINT nType) +//-------------------------------------------------------- { if (nDepth > 100) nDepth = 100; UINT gain = (nDepth * 16) / 100; if (gain > 16) gain = 16; if (gain < 1) gain = 1; - m_nReverbDepth = gain; - if (nType < NUM_REVERBTYPES) gnReverbType = nType; - return TRUE; + m_Settings.m_nReverbDepth = gain; + if (nType < NUM_REVERBTYPES) m_Settings.m_nReverbType = nType; + return true; } // Reverb -VOID ProcessReverb(UINT nSamples) -//------------------------------- +void CReverb::Process(int *MixSoundBuffer, int *MixReverbBuffer, UINT nSamples) +//----------------------------------------------------------------------------- { UINT nIn, nOut; @@ -380,11 +389,11 @@ if (!(CSoundFile::gdwSysInfo & SYSMIX_ENABLEMMX)) return; // Dynamically adjust reverb master gains LONG lMasterGain; - lMasterGain = ((g_RefDelay.lMasterGain * CSoundFile::m_nReverbDepth) >> 4); + lMasterGain = ((g_RefDelay.lMasterGain * m_Settings.m_nReverbDepth) >> 4); if (lMasterGain > 0x7fff) lMasterGain = 0x7fff; g_RefDelay.ReflectionsGain[0] = (SHORT)lMasterGain; g_RefDelay.ReflectionsGain[1] = (SHORT)lMasterGain; - lMasterGain = ((g_LateReverb.lMasterGain * CSoundFile::m_nReverbDepth) >> 4); + lMasterGain = ((g_LateReverb.lMasterGain * m_Settings.m_nReverbDepth) >> 4); if (lMasterGain > 0x10000) lMasterGain = 0x10000; g_LateReverb.RvbOutGains[0] = (SHORT)((lMasterGain+0x7f) >> 3); // l->l g_LateReverb.RvbOutGains[1] = (SHORT)((lMasterGain+0xff) >> 4); // r->l @@ -393,7 +402,7 @@ // Process Dry/Wet Mix LONG lMaxRvbGain = (g_RefDelay.lMasterGain > g_LateReverb.lMasterGain) ? g_RefDelay.lMasterGain : g_LateReverb.lMasterGain; if (lMaxRvbGain > 32768) lMaxRvbGain = 32768; - LONG lDryVol = (36 - CSoundFile::m_nReverbDepth)>>1; + LONG lDryVol = (36 - m_Settings.m_nReverbDepth)>>1; if (lDryVol < 8) lDryVol = 8; if (lDryVol > 16) lDryVol = 16; lDryVol = 16 - (((16-lDryVol) * lMaxRvbGain) >> 15); @@ -437,14 +446,14 @@ else if (gnReverbSamples > nSamples) gnReverbSamples -= nSamples; else { - if (gnReverbSamples) ReverbShutdown(); + if (gnReverbSamples) Shutdown(); gnReverbSamples = 0; } } -VOID X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, UINT nSamples) -//--------------------------------------------------------------------- +VOID CReverb::X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, UINT nSamples) +//------------------------------------------------------------------------------ { for (UINT i=0; i<nSamples; i++) { @@ -454,8 +463,8 @@ } -UINT X86_ReverbProcessPreFiltering2x(int *pWet, UINT nSamples) -//------------------------------------------------------------ +UINT CReverb::X86_ReverbProcessPreFiltering2x(int *pWet, UINT nSamples) +//--------------------------------------------------------------------- { UINT nOutSamples = 0; int lowpass = g_RefDelay.nCoeffs[0]; @@ -504,8 +513,8 @@ } -UINT X86_ReverbProcessPreFiltering1x(int *pWet, UINT nSamples) -//------------------------------------------------------------ +UINT CReverb::X86_ReverbProcessPreFiltering1x(int *pWet, UINT nSamples) +//--------------------------------------------------------------------- { int lowpass = g_RefDelay.nCoeffs[0]; int y1_l = g_nLastRvbIn_yl, y1_r = g_nLastRvbIn_yr; @@ -525,8 +534,8 @@ } -VOID X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, UINT nSamples) -//------------------------------------------------------------------------------ +VOID CReverb::X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, UINT nSamples) +//--------------------------------------------------------------------------------------- { UINT n0 = nSamples, n; int x1_l = g_nLastRvbOut_xl, x1_r = g_nLastRvbOut_xr; @@ -567,12 +576,14 @@ #define DCR_AMOUNT 9 // Stereo Add + DC removal -VOID MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, UINT nSamples) -//------------------------------------------------------------------------------ +VOID CReverb::MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, UINT nSamples) +//--------------------------------------------------------------------------------------- { + __int64 nDCRRvb_X1 = gnDCRRvb_X1; + __int64 nDCRRvb_Y1 = gnDCRRvb_Y1; _asm { - movq mm4, gnDCRRvb_Y1 // mm4 = [ y1r | y1l ] - movq mm1, gnDCRRvb_X1 // mm5 = [ x1r | x1l ] + movq mm4, nDCRRvb_Y1 // mm4 = [ y1r | y1l ] + movq mm1, nDCRRvb_X1 // mm5 = [ x1r | x1l ] mov ebx, pDry mov ecx, pRvb mov edx, nSamples @@ -594,19 +605,23 @@ psubd mm4, mm0 movq qword ptr [ebx-8], mm3 jnz stereodcr - movq gnDCRRvb_Y1, mm4 - movq gnDCRRvb_X1, mm5 + movq nDCRRvb_Y1, mm4 + movq nDCRRvb_X1, mm5 emms } + gnDCRRvb_X1 = nDCRRvb_X1; + gnDCRRvb_Y1 = nDCRRvb_Y1; } -VOID MMX_ReverbDCRemoval(int *pBuffer, UINT nSamples) -//--------------------------------------------------- +VOID CReverb::MMX_ReverbDCRemoval(int *pBuffer, UINT nSamples) +//------------------------------------------------------------ { + __int64 nDCRRvb_X1 = gnDCRRvb_X1; + __int64 nDCRRvb_Y1 = gnDCRRvb_Y1; _asm { - movq mm4, gnDCRRvb_Y1 // mm4 = [ y1r | y1l ] - movq mm1, gnDCRRvb_X1 // mm5 = [ x1r | x1l ] + movq mm4, nDCRRvb_Y1 // mm4 = [ y1r | y1l ] + movq mm1, nDCRRvb_X1 // mm5 = [ x1r | x1l ] mov ecx, pBuffer mov edx, nSamples stereodcr: @@ -624,10 +639,12 @@ movq mm1, mm5 psubd mm4, mm0 jnz stereodcr - movq gnDCRRvb_Y1, mm4 - movq gnDCRRvb_X1, mm5 + movq nDCRRvb_Y1, mm4 + movq nDCRRvb_X1, mm5 emms } + gnDCRRvb_X1 = nDCRRvb_X1; + gnDCRRvb_Y1 = nDCRRvb_Y1; } @@ -640,8 +657,8 @@ // 3. Insert the result in the reflections delay buffer // -VOID MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, UINT nSamples) -//------------------------------------------------------------------------------- +VOID CReverb::MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, UINT nSamples) +//---------------------------------------------------------------------------------------- { _asm { mov eax, pPreDelay @@ -714,8 +731,8 @@ } DUMMYREFARRAY, *PDUMMYREFARRAY; -VOID MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pOut, UINT nSamples) -//------------------------------------------------------------------------------------------------- +VOID CReverb::MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pOut, UINT nSamples) +//---------------------------------------------------------------------------------------------------------- { _asm { // First stage @@ -840,7 +857,8 @@ // Late reverberation (with SW reflections) // -VOID MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, UINT nSamples) +VOID CReverb::MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, UINT nSamples) +//--------------------------------------------------------------------------------------------------------- { _asm { push ebp @@ -949,7 +967,7 @@ // (1-gcos(w)-sqrt(2g(1-cos w) - g2(1-(cos w)^2))) / (1-g) -LONG OnePoleLowPassCoef(LONG scale, FLOAT g, FLOAT F_c, FLOAT F_s) +static LONG OnePoleLowPassCoef(LONG scale, FLOAT g, FLOAT F_c, FLOAT F_s) //---------------------------------------------------------------- { FLOAT cosw; // cos(2*PI*Fc/Fs) @@ -1003,7 +1021,7 @@ } -LONG mBToLinear(LONG scale, LONG value_mB) +static LONG mBToLinear(LONG scale, LONG value_mB) { // factor = log2(10)/(100*20) const float _factor = 3.321928094887362304f / (100.0f * 20.0f); @@ -1030,7 +1048,7 @@ } -FLOAT mBToLinear(LONG value_mB) +static FLOAT mBToLinear(LONG value_mB) { // factor = log2(10)/(100*20) const float _factor = 3.321928094887362304f / (100.0f * 20.0f); Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-04-02 20:17:31 UTC (rev 1712) @@ -32,6 +32,7 @@ #include "plugins/PlugInterface.h" #include "RowVisitor.h" +#include "snd_rvb.h" #include "../sounddsp/AGC.h" #include "../sounddsp/DSP.h" #include "../sounddsp/EQ.h" @@ -235,6 +236,9 @@ bool m_bITBidiMode; // Process bidi loops like Impulse Tracker (see Fastmix.cpp for an explanation) public: // Static Members +#ifndef NO_REVERB + static CReverb m_Reverb; +#endif #ifndef NO_DSP static CDSP m_DSP; #endif @@ -244,9 +248,6 @@ #ifndef NO_AGC static CAGC m_AGC; #endif -#ifndef NO_REVERB - static UINT m_nReverbDepth, gnReverbType; -#endif static UINT m_nStereoSeparation; static UINT m_nMaxMixChannels; static DWORD gdwSysInfo, gdwSoundSetup, gdwMixingFreq, gnBitsPerSample, gnChannels; @@ -501,8 +502,6 @@ #ifndef NO_AGC static void SetAGC(BOOL b); #endif - // [Reverb level 0(quiet)-100(loud)], [REVERBTYPE_XXXX] - static BOOL SetReverbParameters(UINT nDepth, UINT nType); #ifndef NO_EQ static void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, gdwMixingFreq); } // 0=-12dB, 32=+12dB #endif // NO_EQ Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-04-02 20:17:31 UTC (rev 1712) @@ -36,6 +36,9 @@ DWORD CSoundFile::gdwMixingFreq = 44100; DWORD CSoundFile::gnBitsPerSample = 16; // Mixing data initialized in +#ifndef NO_REVERB +CReverb CSoundFile::m_Reverb; +#endif #ifndef NO_DSP CDSP CSoundFile::m_DSP; #endif @@ -73,12 +76,7 @@ extern int MixRearBuffer[MIXBUFFERSIZE * 2]; #ifndef NO_REVERB -extern UINT gnReverbSend; -extern LONG gnRvbROfsVol; -extern LONG gnRvbLOfsVol; - -extern VOID InitializeReverb(BOOL bReset); -extern void ProcessReverb(UINT nSamples); +extern int MixReverbBuffer[MIXBUFFERSIZE * 2]; #endif // Log tables for pre-amp @@ -160,10 +158,10 @@ if (gdwMixingFreq > MAX_SAMPLE_RATE) gdwMixingFreq = MAX_SAMPLE_RATE; gnDryROfsVol = gnDryLOfsVol = 0; #ifndef NO_REVERB - gnRvbROfsVol = gnRvbLOfsVol = 0; + m_Reverb.gnRvbROfsVol = m_Reverb.gnRvbLOfsVol = 0; #endif #ifndef NO_REVERB - InitializeReverb(bReset); + m_Reverb.Initialize(bReset, gdwMixingFreq); #endif #ifndef NO_DSP m_DSP.Initialize(bReset, gdwMixingFreq, gdwSoundSetup); @@ -289,7 +287,7 @@ lSampleCount = lCount; #ifndef NO_REVERB - gnReverbSend = 0; + m_Reverb.gnReverbSend = 0; #endif // NO_REVERB // Resetting sound buffer @@ -302,7 +300,7 @@ m_nMixStat += CreateStereoMix(lCount); #ifndef NO_REVERB - ProcessReverb(lCount); + m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); @@ -317,7 +315,7 @@ m_nMixStat += CreateStereoMix(lCount); #ifndef NO_REVERB - ProcessReverb(lCount); + m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); Modified: trunk/OpenMPT/soundlib/snd_rvb.h =================================================================== --- trunk/OpenMPT/soundlib/snd_rvb.h 2013-04-02 19:30:32 UTC (rev 1711) +++ trunk/OpenMPT/soundlib/snd_rvb.h 2013-04-02 20:17:31 UTC (rev 1712) @@ -106,20 +106,77 @@ } ENVIRONMENTREVERB, *PENVIRONMENTREVERB; -// Pre/Post resampling and filtering -UINT X86_ReverbProcessPreFiltering1x(int *pWet, UINT nSamples); -UINT X86_ReverbProcessPreFiltering2x(int *pWet, UINT nSamples); -VOID MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, UINT nSamples); -VOID X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, UINT nSamples); -VOID MMX_ReverbDCRemoval(int *pBuffer, UINT nSamples); -VOID X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, UINT nSamples); -// Process pre-diffusion and pre-delay -VOID MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, UINT nSamples); -// Process reflections -VOID MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pMixOut, UINT nSamples); -// Process Late Reverb (SW Reflections): stereo reflections output, 32-bit reverb output, SW reverb gain -VOID MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, UINT nSamples); +//=================== +class CReverbSettings +//=================== +{ +public: + UINT m_nReverbDepth; + UINT m_nReverbType; +public: + CReverbSettings(); +}; + +//=========== +class CReverb +//=========== +{ +public: + CReverbSettings m_Settings; + + // Shared reverb state + UINT gnReverbSend; + LONG gnRvbROfsVol; + LONG gnRvbLOfsVol; + +private: + + UINT gnReverbSamples; + UINT gnReverbDecaySamples; + + // Internal reverb state + BOOL g_bLastInPresent; + BOOL g_bLastOutPresent; + int g_nLastRvbIn_xl; + int g_nLastRvbIn_xr; + int g_nLastRvbIn_yl; + int g_nLastRvbIn_yr; + int g_nLastRvbOut_xl; + int g_nLastRvbOut_xr; + __int64 gnDCRRvb_Y1; + __int64 gnDCRRvb_X1; + + // Reverb mix buffers + SWRVBREFDELAY g_RefDelay; + SWLATEREVERB g_LateReverb; + +public: + CReverb(); + ~CReverb() {} +public: + void Initialize(BOOL bReset, DWORD MixingFreq); + void Process(int *MixSoundBuffer, int *MixReverbBuffer, UINT nSamples); + // [Reverb level 0(quiet)-100(loud)], [REVERBTYPE_XXXX] + bool SetReverbParameters(UINT nDepth, UINT nType); +private: + void Shutdown(); + // Pre/Post resampling and filtering + UINT X86_ReverbProcessPreFiltering1x(int *pWet, UINT nSamples); + UINT X86_ReverbProcessPreFiltering2x(int *pWet, UINT nSamples); + VOID MMX_ReverbProcessPostFiltering1x(const int *pRvb, int *pDry, UINT nSamples); + VOID X86_ReverbProcessPostFiltering2x(const int *pRvb, int *pDry, UINT nSamples); + VOID MMX_ReverbDCRemoval(int *pBuffer, UINT nSamples); + VOID X86_ReverbDryMix(int *pDry, int *pWet, int lDryVol, UINT nSamples); + // Process pre-diffusion and pre-delay + VOID MMX_ProcessPreDelay(PSWRVBREFDELAY pPreDelay, const int *pIn, UINT nSamples); + // Process reflections + VOID MMX_ProcessReflections(PSWRVBREFDELAY pPreDelay, short int *pRefOut, int *pMixOut, UINT nSamples); + // Process Late Reverb (SW Reflections): stereo reflections output, 32-bit reverb output, SW reverb gain + VOID MMX_ProcessLateReverb(PSWLATEREVERB pReverb, short int *pRefOut, int *pMixOut, UINT nSamples); +}; + + ///////////////////////////////////////////////////////////////////////////////// // // I3DL2 reverb presets @@ -199,4 +256,5 @@ #define SNDMIX_REVERB_PRESET_PLATE \ -1000, -200, 1.30f,0.90f, 0,0.002f, 0,0.010f,100.0f, 75.0f + #endif // NO_REVERB This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |