Leaked source code of windows server 2003
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.

93 lines
3.4 KiB

  1. // DirectSoundFXCompressorPage.cpp : Implementation of CDirectSoundFXCompressorPage
  2. #include "stdafx.h"
  3. #include "Dsdmoprp.h"
  4. #include "DirectSoundFXCompressorPage.h"
  5. /////////////////////////////////////////////////////////////////////////////
  6. // CDirectSoundFXCompressorPage
  7. CDirectSoundFXCompressorPage::CDirectSoundFXCompressorPage()
  8. {
  9. m_dwTitleID = IDS_TITLEDirectSoundFXCompressorPage;
  10. m_dwHelpFileID = IDS_HELPFILEDirectSoundFXCompressorPage;
  11. m_dwDocStringID = IDS_DOCSTRINGDirectSoundFXCompressorPage;
  12. m_rgpHandlers[0] = &m_sliderGain;
  13. m_rgpHandlers[1] = &m_sliderAttack;
  14. m_rgpHandlers[2] = &m_sliderRelease;
  15. m_rgpHandlers[3] = &m_sliderThreshold;
  16. m_rgpHandlers[4] = &m_sliderRatio;
  17. m_rgpHandlers[5] = &m_sliderPredelay;
  18. m_rgpHandlers[6] = NULL;
  19. }
  20. STDMETHODIMP CDirectSoundFXCompressorPage::SetObjects(ULONG nObjects, IUnknown **ppUnk)
  21. {
  22. if (nObjects < 1 || nObjects > 1)
  23. return E_UNEXPECTED;
  24. HRESULT hr = ppUnk[0]->QueryInterface(IID_IDirectSoundFXCompressor, reinterpret_cast<void**>(&m_IDSFXCompressor));
  25. return hr;
  26. }
  27. STDMETHODIMP CDirectSoundFXCompressorPage::Apply(void)
  28. {
  29. if (!m_IDSFXCompressor)
  30. return E_UNEXPECTED;
  31. DSFXCompressor dsfxcompressor;
  32. ZeroMemory(&dsfxcompressor, sizeof(DSFXCompressor));
  33. dsfxcompressor.fGain = m_sliderGain.GetValue();
  34. dsfxcompressor.fAttack = m_sliderAttack.GetValue();
  35. dsfxcompressor.fRelease = m_sliderRelease.GetValue();
  36. dsfxcompressor.fThreshold = m_sliderThreshold.GetValue();
  37. dsfxcompressor.fRatio = m_sliderRatio.GetValue();
  38. dsfxcompressor.fPredelay = m_sliderPredelay.GetValue();
  39. HRESULT hr = m_IDSFXCompressor->SetAllParameters(&dsfxcompressor);
  40. if (FAILED(hr))
  41. return hr;
  42. SetDirty(FALSE);
  43. return S_OK;
  44. }
  45. LRESULT CDirectSoundFXCompressorPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  46. {
  47. if (!m_IDSFXCompressor)
  48. return 1;
  49. DSFXCompressor dsfxcompressor;
  50. ZeroMemory(&dsfxcompressor, sizeof(DSFXCompressor));
  51. m_IDSFXCompressor->GetAllParameters(&dsfxcompressor);
  52. m_sliderGain.Init(GetDlgItem(IDC_SLIDER_Gain), GetDlgItem(IDC_EDIT_Gain), -60, 60, false);
  53. m_sliderGain.SetValue(dsfxcompressor.fGain);
  54. m_sliderAttack.Init(GetDlgItem(IDC_SLIDER_Attack), GetDlgItem(IDC_EDIT_Attack), static_cast<float>(.01), 500, false);
  55. m_sliderAttack.SetValue(dsfxcompressor.fAttack);
  56. m_sliderRelease.Init(GetDlgItem(IDC_SLIDER_Release), GetDlgItem(IDC_EDIT_Release), 50, 3000, false);
  57. m_sliderRelease.SetValue(dsfxcompressor.fRelease);
  58. m_sliderThreshold.Init(GetDlgItem(IDC_SLIDER_Threshold), GetDlgItem(IDC_EDIT_Threshold), -60, 0, false);
  59. m_sliderThreshold.SetValue(dsfxcompressor.fThreshold);
  60. m_sliderRatio.Init(GetDlgItem(IDC_SLIDER_Ratio), GetDlgItem(IDC_EDIT_Ratio), 1, 100, false);
  61. m_sliderRatio.SetValue(dsfxcompressor.fRatio);
  62. m_sliderPredelay.Init(GetDlgItem(IDC_SLIDER_Predelay), GetDlgItem(IDC_EDIT_Predelay), 0, 4, false);
  63. m_sliderPredelay.SetValue(dsfxcompressor.fPredelay);
  64. return 1;
  65. }
  66. LRESULT CDirectSoundFXCompressorPage::OnControlMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  67. {
  68. LRESULT lr = MessageHandlerChain(m_rgpHandlers, uMsg, wParam, lParam, bHandled);
  69. if (bHandled)
  70. SetDirty(TRUE);
  71. return lr;
  72. }