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.

105 lines
3.5 KiB

  1. // DirectSoundFXChorusPage.cpp : Implementation of CDirectSoundFXChorusPage
  2. #include "stdafx.h"
  3. #include "Dsdmoprp.h"
  4. #include "DirectSoundFXChorusPage.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CDirectSoundFXChorusPage
  7. const CRadioChoice::ButtonEntry g_rgWaveButtons[] =
  8. {
  9. IDC_RADIO_TRIANGLE, DSFXCHORUS_WAVE_TRIANGLE,
  10. IDC_RADIO_SIN, DSFXCHORUS_WAVE_SIN,
  11. 0
  12. };
  13. CDirectSoundFXChorusPage::CDirectSoundFXChorusPage()
  14. : m_radioWaveform(g_rgWaveButtons)
  15. {
  16. m_dwTitleID = IDS_TITLEDirectSoundFXChorusPage;
  17. m_dwHelpFileID = IDS_HELPFILEDirectSoundFXChorusPage;
  18. m_dwDocStringID = IDS_DOCSTRINGDirectSoundFXChorusPage;
  19. m_rgpHandlers[0] = &m_sliderWetDryMix;
  20. m_rgpHandlers[1] = &m_sliderDepth;
  21. m_rgpHandlers[2] = &m_sliderFeedback;
  22. m_rgpHandlers[3] = &m_sliderFrequency;
  23. m_rgpHandlers[4] = &m_sliderDelay;
  24. m_rgpHandlers[5] = &m_sliderPhase;
  25. m_rgpHandlers[6] = &m_radioWaveform;
  26. m_rgpHandlers[7] = NULL;
  27. }
  28. STDMETHODIMP CDirectSoundFXChorusPage::SetObjects(ULONG nObjects, IUnknown **ppUnk)
  29. {
  30. if (nObjects < 1 || nObjects > 1)
  31. return E_UNEXPECTED;
  32. HRESULT hr = ppUnk[0]->QueryInterface(IID_IDirectSoundFXChorus, reinterpret_cast<void**>(&m_IDSFXChorus));
  33. return hr;
  34. }
  35. STDMETHODIMP CDirectSoundFXChorusPage::Apply(void)
  36. {
  37. if (!m_IDSFXChorus)
  38. return E_UNEXPECTED;
  39. DSFXChorus dsfxchorus;
  40. ZeroMemory(&dsfxchorus, sizeof(DSFXChorus));
  41. dsfxchorus.fWetDryMix = m_sliderWetDryMix.GetValue();
  42. dsfxchorus.fDepth = m_sliderDepth.GetValue();
  43. dsfxchorus.fFeedback = m_sliderFeedback.GetValue();
  44. dsfxchorus.fFrequency = m_sliderFrequency.GetValue();
  45. dsfxchorus.fDelay = m_sliderDelay.GetValue();
  46. dsfxchorus.lPhase = static_cast<short>(m_sliderPhase.GetValue());
  47. dsfxchorus.lWaveform = m_radioWaveform.GetChoice(*this);
  48. HRESULT hr = m_IDSFXChorus->SetAllParameters(&dsfxchorus);
  49. if (FAILED(hr))
  50. return hr;
  51. SetDirty(FALSE);
  52. return S_OK;
  53. }
  54. LRESULT CDirectSoundFXChorusPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  55. {
  56. if (!m_IDSFXChorus)
  57. return 1;
  58. DSFXChorus dsfxchorus;
  59. ZeroMemory(&dsfxchorus, sizeof(DSFXChorus));
  60. m_IDSFXChorus->GetAllParameters(&dsfxchorus);
  61. m_sliderWetDryMix.Init(GetDlgItem(IDC_SLIDER_WetDryMix), GetDlgItem(IDC_EDIT_WetDryMix), 0, 100, false);
  62. m_sliderWetDryMix.SetValue(dsfxchorus.fWetDryMix);
  63. m_sliderDepth.Init(GetDlgItem(IDC_SLIDER_Depth), GetDlgItem(IDC_EDIT_Depth), 0, 100, false);
  64. m_sliderDepth.SetValue(dsfxchorus.fDepth);
  65. m_sliderFeedback.Init(GetDlgItem(IDC_SLIDER_Feedback), GetDlgItem(IDC_EDIT_Feedback), -99, 99, false);
  66. m_sliderFeedback.SetValue(dsfxchorus.fFeedback);
  67. m_sliderFrequency.Init(GetDlgItem(IDC_SLIDER_Frequency), GetDlgItem(IDC_EDIT_Frequency), 0, 10, false);
  68. m_sliderFrequency.SetValue(dsfxchorus.fFrequency);
  69. m_sliderDelay.Init(GetDlgItem(IDC_SLIDER_Delay), GetDlgItem(IDC_EDIT_Delay), 0, 20, false);
  70. m_sliderDelay.SetValue(dsfxchorus.fDelay);
  71. m_sliderPhase.Init(GetDlgItem(IDC_SLIDER_Phase), GetDlgItem(IDC_EDIT_Phase), 0, 4, true);
  72. m_sliderPhase.SetValue(static_cast<float>(dsfxchorus.lPhase));
  73. m_radioWaveform.SetChoice(*this, dsfxchorus.lWaveform);
  74. return 1;
  75. }
  76. LRESULT CDirectSoundFXChorusPage::OnControlMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  77. {
  78. LRESULT lr = MessageHandlerChain(m_rgpHandlers, uMsg, wParam, lParam, bHandled);
  79. if (bHandled)
  80. SetDirty(TRUE);
  81. return lr;
  82. }