Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.6 KiB

  1. // DirectSoundFXDistortionPage.cpp : Implementation of CDirectSoundFXDistortionPage
  2. #include "stdafx.h"
  3. #include "Dsdmoprp.h"
  4. #include "DirectSoundFXDistortionPage.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CDirectSoundFXDistortionPage
  7. CDirectSoundFXDistortionPage::CDirectSoundFXDistortionPage()
  8. {
  9. m_dwTitleID = IDS_TITLEDirectSoundFXDistortionPage;
  10. m_dwHelpFileID = IDS_HELPFILEDirectSoundFXDistortionPage;
  11. m_dwDocStringID = IDS_DOCSTRINGDirectSoundFXDistortionPage;
  12. m_rgpHandlers[0] = &m_sliderGain;
  13. m_rgpHandlers[1] = &m_sliderEdge;
  14. m_rgpHandlers[2] = &m_sliderPostEQCenterFrequency;
  15. m_rgpHandlers[3] = &m_sliderPostEQBandwidth;
  16. m_rgpHandlers[4] = &m_sliderPreLowpassCutoff;
  17. m_rgpHandlers[5] = NULL;
  18. }
  19. STDMETHODIMP CDirectSoundFXDistortionPage::SetObjects(ULONG nObjects, IUnknown **ppUnk)
  20. {
  21. if (nObjects < 1 || nObjects > 1)
  22. return E_UNEXPECTED;
  23. HRESULT hr = ppUnk[0]->QueryInterface(IID_IDirectSoundFXDistortion, reinterpret_cast<void**>(&m_IDSFXDistortion));
  24. return hr;
  25. }
  26. STDMETHODIMP CDirectSoundFXDistortionPage::Apply(void)
  27. {
  28. if (!m_IDSFXDistortion)
  29. return E_UNEXPECTED;
  30. DSFXDistortion dsfxdistortion;
  31. ZeroMemory(&dsfxdistortion, sizeof(DSFXDistortion));
  32. dsfxdistortion.fGain = m_sliderGain.GetValue();
  33. dsfxdistortion.fEdge = m_sliderEdge.GetValue();
  34. dsfxdistortion.fPostEQCenterFrequency = m_sliderPostEQCenterFrequency.GetValue();
  35. dsfxdistortion.fPostEQBandwidth = m_sliderPostEQBandwidth.GetValue();
  36. dsfxdistortion.fPreLowpassCutoff = m_sliderPreLowpassCutoff.GetValue();
  37. HRESULT hr = m_IDSFXDistortion->SetAllParameters(&dsfxdistortion);
  38. if (FAILED(hr))
  39. return hr;
  40. hr = m_IDSFXDistortion->GetAllParameters(&dsfxdistortion);
  41. if (FAILED(hr))
  42. return hr;
  43. m_sliderGain.SetValue(dsfxdistortion.fGain);
  44. m_sliderEdge.SetValue(dsfxdistortion.fEdge);
  45. m_sliderPostEQCenterFrequency.SetValue(dsfxdistortion.fPostEQCenterFrequency);
  46. m_sliderPostEQBandwidth.SetValue(dsfxdistortion.fPostEQBandwidth);
  47. m_sliderPreLowpassCutoff.SetValue(dsfxdistortion.fPreLowpassCutoff);
  48. SetDirty(FALSE);
  49. return S_OK;
  50. }
  51. LRESULT CDirectSoundFXDistortionPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  52. {
  53. if (!m_IDSFXDistortion)
  54. return 1;
  55. DSFXDistortion dsfxdistortion;
  56. ZeroMemory(&dsfxdistortion, sizeof(DSFXDistortion));
  57. m_IDSFXDistortion->GetAllParameters(&dsfxdistortion);
  58. m_sliderGain.Init(GetDlgItem(IDC_SLIDER_Gain), GetDlgItem(IDC_EDIT_Gain), -60, 0, false);
  59. m_sliderGain.SetValue(dsfxdistortion.fGain);
  60. m_sliderEdge.Init(GetDlgItem(IDC_SLIDER_Edge), GetDlgItem(IDC_EDIT_Edge), 0, 100, false);
  61. m_sliderEdge.SetValue(dsfxdistortion.fEdge);
  62. m_sliderPostEQCenterFrequency.Init(GetDlgItem(IDC_SLIDER_PostEQCenterFrequency), GetDlgItem(IDC_EDIT_PostEQCenterFrequency), 100, 8000, true);
  63. m_sliderPostEQCenterFrequency.SetValue(dsfxdistortion.fPostEQCenterFrequency);
  64. m_sliderPostEQBandwidth.Init(GetDlgItem(IDC_SLIDER_PostEQBandwidth), GetDlgItem(IDC_EDIT_PostEQBandwidth), 100, 8000 , true);
  65. m_sliderPostEQBandwidth.SetValue(dsfxdistortion.fPostEQBandwidth);
  66. m_sliderPreLowpassCutoff.Init(GetDlgItem(IDC_SLIDER_PreLowpassCutoff), GetDlgItem(IDC_EDIT_PreLowpassCutoff), 100, 8000 , true);
  67. m_sliderPreLowpassCutoff.SetValue(dsfxdistortion.fPreLowpassCutoff);
  68. return 1;
  69. }
  70. LRESULT CDirectSoundFXDistortionPage::OnControlMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  71. {
  72. LRESULT lr = MessageHandlerChain(m_rgpHandlers, uMsg, wParam, lParam, bHandled);
  73. if (bHandled)
  74. SetDirty(TRUE);
  75. return lr;
  76. }