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.

257 lines
11 KiB

  1. // DirectSoundFXI3DL2ReverbPage.cpp : Implementation of CDirectSoundFXI3DL2ReverbPage
  2. #include "stdafx.h"
  3. #include "Dsdmoprp.h"
  4. #include "DirectSoundFXI3DL2ReverbPage.h"
  5. DSFXI3DL2Reverb CDirectSoundFXI3DL2ReverbPage::Presets[] =
  6. {
  7. {I3DL2_ENVIRONMENT_PRESET_DEFAULT},
  8. {I3DL2_ENVIRONMENT_PRESET_GENERIC},
  9. {I3DL2_ENVIRONMENT_PRESET_PADDEDCELL},
  10. {I3DL2_ENVIRONMENT_PRESET_ROOM},
  11. {I3DL2_ENVIRONMENT_PRESET_BATHROOM},
  12. {I3DL2_ENVIRONMENT_PRESET_LIVINGROOM},
  13. {I3DL2_ENVIRONMENT_PRESET_STONEROOM},
  14. {I3DL2_ENVIRONMENT_PRESET_AUDITORIUM},
  15. {I3DL2_ENVIRONMENT_PRESET_CONCERTHALL},
  16. {I3DL2_ENVIRONMENT_PRESET_CAVE},
  17. {I3DL2_ENVIRONMENT_PRESET_ARENA},
  18. {I3DL2_ENVIRONMENT_PRESET_HANGAR},
  19. {I3DL2_ENVIRONMENT_PRESET_CARPETEDHALLWAY},
  20. {I3DL2_ENVIRONMENT_PRESET_HALLWAY},
  21. {I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR},
  22. {I3DL2_ENVIRONMENT_PRESET_ALLEY},
  23. {I3DL2_ENVIRONMENT_PRESET_FOREST},
  24. {I3DL2_ENVIRONMENT_PRESET_CITY},
  25. {I3DL2_ENVIRONMENT_PRESET_MOUNTAINS},
  26. {I3DL2_ENVIRONMENT_PRESET_QUARRY},
  27. {I3DL2_ENVIRONMENT_PRESET_PLAIN},
  28. {I3DL2_ENVIRONMENT_PRESET_PARKINGLOT},
  29. {I3DL2_ENVIRONMENT_PRESET_SEWERPIPE},
  30. {I3DL2_ENVIRONMENT_PRESET_UNDERWATER},
  31. {I3DL2_ENVIRONMENT_PRESET_SMALLROOM},
  32. {I3DL2_ENVIRONMENT_PRESET_MEDIUMROOM},
  33. {I3DL2_ENVIRONMENT_PRESET_LARGEROOM},
  34. {I3DL2_ENVIRONMENT_PRESET_MEDIUMHALL},
  35. {I3DL2_ENVIRONMENT_PRESET_LARGEHALL},
  36. {I3DL2_ENVIRONMENT_PRESET_PLATE},
  37. };
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CDirectSoundFXI3DL2ReverbPage
  40. CDirectSoundFXI3DL2ReverbPage::CDirectSoundFXI3DL2ReverbPage()
  41. {
  42. m_dwTitleID = IDS_TITLEDirectSoundFXI3DL2ReverbPage;
  43. m_dwHelpFileID = IDS_HELPFILEDirectSoundFXI3DL2ReverbPage;
  44. m_dwDocStringID = IDS_DOCSTRINGDirectSoundFXI3DL2ReverbPage;
  45. m_rgpHandlers[0] = &m_sliderRoom;
  46. m_rgpHandlers[1] = &m_sliderRoomHF;
  47. m_rgpHandlers[2] = &m_sliderRoomRolloffFactor;
  48. m_rgpHandlers[3] = &m_sliderDecayTime;
  49. m_rgpHandlers[4] = &m_sliderDecayHFRatio;
  50. m_rgpHandlers[5] = &m_sliderReflections;
  51. m_rgpHandlers[6] = &m_sliderReflectionsDelay;
  52. m_rgpHandlers[7] = &m_sliderReverb;
  53. m_rgpHandlers[8] = &m_sliderReverbDelay;
  54. m_rgpHandlers[9] = &m_sliderDiffusion;
  55. m_rgpHandlers[10] = &m_sliderDensity;
  56. m_rgpHandlers[11] = &m_sliderHFReference;
  57. m_rgpHandlers[12] = &m_sliderQuality;
  58. m_rgpHandlers[13] = NULL;
  59. }
  60. STDMETHODIMP CDirectSoundFXI3DL2ReverbPage::SetObjects(ULONG nObjects, IUnknown **ppUnk)
  61. {
  62. if (nObjects < 1 || nObjects > 1)
  63. return E_UNEXPECTED;
  64. HRESULT hr = ppUnk[0]->QueryInterface(IID_IDirectSoundFXI3DL2Reverb, reinterpret_cast<void**>(&m_IDSFXI3DL2Reverb));
  65. return hr;
  66. }
  67. STDMETHODIMP CDirectSoundFXI3DL2ReverbPage::Apply(void)
  68. {
  69. if (!m_IDSFXI3DL2Reverb)
  70. return E_UNEXPECTED;
  71. DSFXI3DL2Reverb dsfxi3dl2reverb;
  72. ZeroMemory(&dsfxi3dl2reverb, sizeof(DSFXI3DL2Reverb));
  73. dsfxi3dl2reverb.lRoom = static_cast<LONG>(m_sliderRoom.GetValue());
  74. dsfxi3dl2reverb.lRoomHF = static_cast<LONG>(m_sliderRoomHF.GetValue());
  75. dsfxi3dl2reverb.flRoomRolloffFactor = m_sliderRoomRolloffFactor.GetValue();
  76. dsfxi3dl2reverb.flDecayTime = m_sliderDecayTime.GetValue();
  77. dsfxi3dl2reverb.flDecayHFRatio = m_sliderDecayHFRatio.GetValue();
  78. dsfxi3dl2reverb.lReflections = static_cast<LONG>(m_sliderReflections.GetValue());
  79. dsfxi3dl2reverb.flReflectionsDelay = m_sliderReflectionsDelay.GetValue();
  80. dsfxi3dl2reverb.lReverb = static_cast<LONG>(m_sliderReverb.GetValue());
  81. dsfxi3dl2reverb.flReverbDelay = m_sliderReverbDelay.GetValue();
  82. dsfxi3dl2reverb.flDiffusion = m_sliderDiffusion.GetValue();
  83. dsfxi3dl2reverb.flDensity = m_sliderDensity.GetValue();
  84. dsfxi3dl2reverb.flHFReference = m_sliderHFReference.GetValue();
  85. HRESULT hr = m_IDSFXI3DL2Reverb->SetAllParameters(&dsfxi3dl2reverb);
  86. if (FAILED(hr))
  87. return hr;
  88. hr = m_IDSFXI3DL2Reverb->SetQuality(static_cast<long>(m_sliderQuality.GetValue()));
  89. if (FAILED(hr))
  90. return hr;
  91. SetDirty(FALSE);
  92. return S_OK;
  93. }
  94. LRESULT CDirectSoundFXI3DL2ReverbPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  95. {
  96. if (!m_IDSFXI3DL2Reverb)
  97. return 1;
  98. DSFXI3DL2Reverb dsfxi3dl2reverb;
  99. ZeroMemory(&dsfxi3dl2reverb, sizeof(DSFXI3DL2Reverb));
  100. m_IDSFXI3DL2Reverb->GetAllParameters(&dsfxi3dl2reverb);
  101. LONG lQuality = 0;
  102. m_IDSFXI3DL2Reverb->GetQuality(&lQuality);
  103. m_sliderRoom.Init(GetDlgItem(IDC_SLIDER_Room), GetDlgItem(IDC_EDIT_Room), DSFX_I3DL2REVERB_ROOM_MIN, DSFX_I3DL2REVERB_ROOM_MAX, true);
  104. m_sliderRoom.SetValue(static_cast<float>(dsfxi3dl2reverb.lRoom));
  105. m_sliderRoomHF.Init(GetDlgItem(IDC_SLIDER_RoomHF), GetDlgItem(IDC_EDIT_RoomHF), DSFX_I3DL2REVERB_ROOMHF_MIN, DSFX_I3DL2REVERB_ROOMHF_MAX, true);
  106. m_sliderRoomHF.SetValue(static_cast<float>(dsfxi3dl2reverb.lRoomHF));
  107. m_sliderRoomRolloffFactor.Init(GetDlgItem(IDC_SLIDER_RoomRolloffFactor), GetDlgItem(IDC_EDIT_RoomRolloffFactor), DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MIN, DSFX_I3DL2REVERB_ROOMROLLOFFFACTOR_MAX, false);
  108. m_sliderRoomRolloffFactor.SetValue(dsfxi3dl2reverb.flRoomRolloffFactor);
  109. m_sliderDecayTime.Init(GetDlgItem(IDC_SLIDER_DecayTime), GetDlgItem(IDC_EDIT_DecayTime), DSFX_I3DL2REVERB_DECAYTIME_MIN, DSFX_I3DL2REVERB_DECAYTIME_MAX, false);
  110. m_sliderDecayTime.SetValue(dsfxi3dl2reverb.flDecayTime);
  111. m_sliderDecayHFRatio.Init(GetDlgItem(IDC_SLIDER_DecayHFRatio), GetDlgItem(IDC_EDIT_DecayHFRatio), DSFX_I3DL2REVERB_DECAYHFRATIO_MIN, DSFX_I3DL2REVERB_DECAYHFRATIO_MAX, false);
  112. m_sliderDecayHFRatio.SetValue(dsfxi3dl2reverb.flDecayHFRatio);
  113. m_sliderReflections.Init(GetDlgItem(IDC_SLIDER_Reflections), GetDlgItem(IDC_EDIT_Reflections), DSFX_I3DL2REVERB_REFLECTIONS_MIN, DSFX_I3DL2REVERB_REFLECTIONS_MAX, true);
  114. m_sliderReflections.SetValue(static_cast<float>(dsfxi3dl2reverb.lReflections));
  115. m_sliderReflectionsDelay.Init(GetDlgItem(IDC_SLIDER_ReflectionsDelay), GetDlgItem(IDC_EDIT_ReflectionsDelay), DSFX_I3DL2REVERB_REFLECTIONSDELAY_MIN, DSFX_I3DL2REVERB_REFLECTIONSDELAY_MAX, false);
  116. m_sliderReflectionsDelay.SetValue(dsfxi3dl2reverb.flReflectionsDelay);
  117. m_sliderReverb.Init(GetDlgItem(IDC_SLIDER_Reverb), GetDlgItem(IDC_EDIT_Reverb), DSFX_I3DL2REVERB_REVERB_MIN, DSFX_I3DL2REVERB_REVERB_MAX, true);
  118. m_sliderReverb.SetValue(static_cast<float>(dsfxi3dl2reverb.lReverb));
  119. m_sliderReverbDelay.Init(GetDlgItem(IDC_SLIDER_ReverbDelay), GetDlgItem(IDC_EDIT_ReverbDelay), DSFX_I3DL2REVERB_REVERBDELAY_MIN, DSFX_I3DL2REVERB_REVERBDELAY_MAX, false);
  120. m_sliderReverbDelay.SetValue(dsfxi3dl2reverb.flReverbDelay);
  121. m_sliderDiffusion.Init(GetDlgItem(IDC_SLIDER_Diffusion), GetDlgItem(IDC_EDIT_Diffusion), DSFX_I3DL2REVERB_DIFFUSION_MIN, DSFX_I3DL2REVERB_DIFFUSION_MAX, false);
  122. m_sliderDiffusion.SetValue(dsfxi3dl2reverb.flDiffusion);
  123. m_sliderDensity.Init(GetDlgItem(IDC_SLIDER_Density), GetDlgItem(IDC_EDIT_Density), DSFX_I3DL2REVERB_DENSITY_MIN, DSFX_I3DL2REVERB_DENSITY_MAX, false);
  124. m_sliderDensity.SetValue(dsfxi3dl2reverb.flDensity);
  125. m_sliderHFReference.Init(GetDlgItem(IDC_SLIDER_HFReference), GetDlgItem(IDC_EDIT_HFReference), DSFX_I3DL2REVERB_HFREFERENCE_MIN, DSFX_I3DL2REVERB_HFREFERENCE_MAX, false);
  126. m_sliderHFReference.SetValue(dsfxi3dl2reverb.flHFReference);
  127. m_sliderQuality.Init(GetDlgItem(IDC_SLIDER_Quality), GetDlgItem(IDC_EDIT_Quality), DSFX_I3DL2REVERB_QUALITY_MIN, DSFX_I3DL2REVERB_QUALITY_MAX, true);
  128. m_sliderQuality.SetValue(static_cast<float>(lQuality));
  129. FillCombo(GetDlgItem(IDC_PRESET));
  130. return 1;
  131. }
  132. LRESULT CDirectSoundFXI3DL2ReverbPage::OnControlMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  133. {
  134. LRESULT lr = MessageHandlerChain(m_rgpHandlers, uMsg, wParam, lParam, bHandled);
  135. if (bHandled)
  136. {
  137. //Mark the Page as Dirty
  138. SetDirty(TRUE);
  139. //Clear the ComboBox
  140. ::SendMessage(GetDlgItem(IDC_PRESET),CB_SETCURSEL, static_cast<WPARAM>(-1),static_cast<LPARAM>(0));
  141. }
  142. return lr;
  143. }
  144. void CDirectSoundFXI3DL2ReverbPage::FillCombo(HWND hWnd)
  145. {
  146. CONST int BUFFERLEN=256; //Maximum size of the string for the DropDown.
  147. TCHAR tchBuffer[BUFFERLEN];
  148. LRESULT lr;
  149. int cCh;
  150. //We're going to fillup the DropDown Listbox with strings and data
  151. for (int i=0;i<NUMPRESETS;i++)
  152. {
  153. //Load the Strings
  154. cCh = LoadString(_Module.GetResourceInstance(),IDS_PRESETDefault + i, tchBuffer, BUFFERLEN);
  155. // 0 indicates an error -- bail
  156. ATLASSERT(cCh != 0);
  157. //Put the string in the dropdown
  158. //lr will be the index in the dropdown where the item was put
  159. lr =::SendMessage(hWnd,CB_ADDSTRING,(WPARAM) 0,(LPARAM) tchBuffer);
  160. ATLASSERT(lr != CB_ERR && lr != CB_ERRSPACE);
  161. //Put the index into the preset array that goes with the string
  162. //into the itemdata for the dropdown
  163. lr = ::SendMessage(hWnd,CB_SETITEMDATA,(WPARAM) lr,(LPARAM) i);
  164. ATLASSERT(lr != CB_ERR);
  165. //Don't select anything to start
  166. ::SendMessage(hWnd,CB_SETCURSEL,(WPARAM)-1,(LPARAM)0);
  167. }
  168. }
  169. LRESULT CDirectSoundFXI3DL2ReverbPage::OnComboControlMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  170. {
  171. LRESULT lr = 0;
  172. bHandled = FALSE;
  173. HWND hWnd;
  174. switch(uMsg)
  175. {
  176. case WM_COMMAND:
  177. if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_PRESET)
  178. {
  179. hWnd = reinterpret_cast<HWND>(lParam);
  180. //Get the Index of the Current Selection
  181. lr = ::SendMessage(hWnd, CB_GETCURSEL, static_cast<WPARAM>(0), static_cast<LPARAM>(0));
  182. if (lr == CB_ERR)
  183. break;
  184. //Get the ItemData -- This is the index into the Presets Array
  185. lr = ::SendMessage(hWnd, CB_GETITEMDATA, static_cast<WPARAM>(lr), static_cast<LPARAM>(0));
  186. if (lr == CB_ERR)
  187. break;
  188. //Set the object with the presets
  189. m_IDSFXI3DL2Reverb->SetAllParameters(&Presets[lr]);
  190. //Retrive the values from the object
  191. DSFXI3DL2Reverb dsfxi3dl2reverb;
  192. ZeroMemory(&dsfxi3dl2reverb, sizeof(DSFXI3DL2Reverb));
  193. m_IDSFXI3DL2Reverb->GetAllParameters(&dsfxi3dl2reverb);
  194. //Set the sliders
  195. m_sliderRoom.SetValue(static_cast<float>(dsfxi3dl2reverb.lRoom));
  196. m_sliderRoomHF.SetValue(static_cast<float>(dsfxi3dl2reverb.lRoomHF));
  197. m_sliderRoomRolloffFactor.SetValue(dsfxi3dl2reverb.flRoomRolloffFactor);
  198. m_sliderDecayTime.SetValue(dsfxi3dl2reverb.flDecayTime);
  199. m_sliderDecayHFRatio.SetValue(dsfxi3dl2reverb.flDecayHFRatio);
  200. m_sliderReflections.SetValue(static_cast<float>(dsfxi3dl2reverb.lReflections));
  201. m_sliderReflectionsDelay.SetValue(dsfxi3dl2reverb.flReflectionsDelay);
  202. m_sliderReverb.SetValue(static_cast<float>(dsfxi3dl2reverb.lReverb));
  203. m_sliderReverbDelay.SetValue(dsfxi3dl2reverb.flReverbDelay);
  204. m_sliderDiffusion.SetValue(dsfxi3dl2reverb.flDiffusion);
  205. m_sliderDensity.SetValue(dsfxi3dl2reverb.flDensity);
  206. m_sliderHFReference.SetValue(dsfxi3dl2reverb.flHFReference);
  207. bHandled = TRUE;
  208. SetDirty(TRUE);
  209. }
  210. }
  211. return 0;
  212. }