From: <man...@us...> - 2013-10-17 10:36:41
|
Revision: 2911 http://sourceforge.net/p/modplug/code/2911 Author: manxorist Date: 2013-10-17 10:36:28 +0000 (Thu, 17 Oct 2013) Log Message: ----------- [Fix] Limit WFIR cutoff frequency setting to meaningful range. [Fix] Correct importing of old registry based cutoff settings. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/soundlib/Tables.cpp Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-15 14:10:23 UTC (rev 2910) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-10-17 10:36:28 UTC (rev 2911) @@ -861,8 +861,17 @@ //rewbs.resamplerConf CString s; m_CEditWFIRCutoff.GetWindowText(s); - if (s != "") - TrackerSettings::Instance().m_ResamplerSettings.gdWFIRCutoff = atoi(s)/100.0; + if(s != "") + { + double newCutoff = atoi(s)/100.0; + Limit(newCutoff, 0.0, 1.0); + TrackerSettings::Instance().m_ResamplerSettings.gdWFIRCutoff = newCutoff; + } + { + CHAR s[64]; + wsprintf(s, "%d", static_cast<int>((TrackerSettings::Instance().m_ResamplerSettings.gdWFIRCutoff*100))); + m_CEditWFIRCutoff.SetWindowText(s); + } //TrackerSettings::Instance().m_ResamplerSettings.gbWFIRType set in OnWFIRTypeChange m_CEditRampUp.GetWindowText(s); Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-15 14:10:23 UTC (rev 2910) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2013-10-17 10:36:28 UTC (rev 2911) @@ -404,6 +404,7 @@ m_ResamplerSettings.gbWFIRType = static_cast<BYTE>(CMainFrame::GetPrivateProfileDWord("Sound Settings", "XMMSModplugResamplerWFIRType", m_ResamplerSettings.gbWFIRType, iniFile)); //gdWFIRCutoff = static_cast<double>(CMainFrame::GetPrivateProfileLong("Sound Settings", "ResamplerWFIRCutoff", gdWFIRCutoff * 100.0, iniFile)) / 100.0; m_ResamplerSettings.gdWFIRCutoff = static_cast<double>(CMainFrame::GetPrivateProfileLong("Sound Settings", "ResamplerWFIRCutoff", Util::Round<long>(m_ResamplerSettings.gdWFIRCutoff * 100.0), iniFile)) / 100.0; + Limit(m_ResamplerSettings.gdWFIRCutoff, 0.0, 1.0); // Ramping... first try to read the old setting, then the new ones const long volRamp = CMainFrame::GetPrivateProfileLong("Sound Settings", "VolumeRampSamples", -1, iniFile); @@ -701,7 +702,10 @@ dwDWORDSize = sizeof(m_ResamplerSettings.gbWFIRType); RegQueryValueEx(key, "XMMSModplugResamplerWFIRType", NULL, &dwREG_DWORD, (LPBYTE)&m_ResamplerSettings.gbWFIRType, &dwDWORDSize); dwDWORDSize = sizeof(m_ResamplerSettings.gdWFIRCutoff); - RegQueryValueEx(key, "ResamplerWFIRCutoff", NULL, &dwREG_DWORD, (LPBYTE)&m_ResamplerSettings.gdWFIRCutoff, &dwDWORDSize); + DWORD tmpWFIRCutoff = Util::Round<DWORD>(100.0 * m_ResamplerSettings.gdWFIRCutoff); + RegQueryValueEx(key, "ResamplerWFIRCutoff", NULL, &dwREG_DWORD, (LPBYTE)&tmpWFIRCutoff, &dwDWORDSize); + m_ResamplerSettings.gdWFIRCutoff = tmpWFIRCutoff / 100.0; + Limit(m_ResamplerSettings.gdWFIRCutoff, 0.0, 1.0); dwDWORDSize = sizeof(m_MixerSettings.glVolumeRampUpSamples); RegQueryValueEx(key, "VolumeRampSamples", NULL, &dwREG_DWORD, (LPBYTE)&m_MixerSettings.glVolumeRampUpSamples, &dwDWORDSize); m_MixerSettings.glVolumeRampDownSamples = m_MixerSettings.glVolumeRampUpSamples; Modified: trunk/OpenMPT/soundlib/Tables.cpp =================================================================== --- trunk/OpenMPT/soundlib/Tables.cpp 2013-10-15 14:10:23 UTC (rev 2910) +++ trunk/OpenMPT/soundlib/Tables.cpp 2013-10-17 10:36:28 UTC (rev 2911) @@ -838,6 +838,12 @@ static void getsinc(SINC_TYPE *psinc, double beta, double lowpass_factor) { + if(lowpass_factor >= 0.999) + { + // Avoid mixer overflows. + // 1.0 itself does not make much sense. + lowpass_factor = 0.999; + } const double izero_beta = izero(beta); const double kPi = 4.0*atan(1.0)*lowpass_factor; for (int isrc=0; isrc<8*SINC_PHASES; isrc++) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |