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.

135 lines
3.3 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: sirens.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * This module contains the functions used by the Access Pack features to
  7. * provide audible feedback.
  8. *
  9. * History:
  10. * 4 Feb 93 Gregoryw Created.
  11. \***************************************************************************/
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. #define TONE_HIGH_FREQ 2000 // High tone frequency (Hz)
  15. #define TONE_HIGH_LEN 75 // High tone duration (ms)
  16. #define TONE_LOW_FREQ 500 // Low tone frequency (Hz)
  17. #define TONE_LOW_LEN 75 // Low tone duration (ms)
  18. #define TONE_CLICK_FREQ 400 // Key click tone frequency (Hz)
  19. #define TONE_CLICK_LEN 4 // Key click tone duration (ms)
  20. #define TONE_SILENT 10
  21. #define SIREN_LOW_FREQ 1200 // Lowest freq for siren (Hz)
  22. #define SIREN_HIGH_FREQ 2000 // Highest freq for siren (Hz)
  23. #define SIREN_INTERVAL 100 // +/- interval SIREN_LOW_FREQ <-> SIREN_HIGH_FREQ
  24. /***************************************************************************\
  25. * HighBeep
  26. *
  27. * Send a high beep to the beep device
  28. *
  29. * History:
  30. \***************************************************************************/
  31. BOOL HighBeep(void)
  32. {
  33. BOOL Status;
  34. LeaveCrit();
  35. Status = UserBeep(TONE_HIGH_FREQ, TONE_HIGH_LEN);
  36. EnterCrit();
  37. return Status;
  38. }
  39. /***************************************************************************\
  40. * LowBeep
  41. *
  42. * Send a low beep to the beep device
  43. *
  44. * History:
  45. \***************************************************************************/
  46. BOOL LowBeep(void)
  47. {
  48. BOOL Status;
  49. LeaveCrit();
  50. Status = UserBeep(TONE_LOW_FREQ, TONE_LOW_LEN);
  51. EnterCrit();
  52. return Status;
  53. }
  54. /***************************************************************************\
  55. * KeyClick
  56. *
  57. * Send a key click to the beep device
  58. *
  59. * History:
  60. \***************************************************************************/
  61. BOOL KeyClick(void)
  62. {
  63. BOOL Status;
  64. LeaveCrit();
  65. Status = UserBeep(TONE_CLICK_FREQ, TONE_CLICK_LEN);
  66. EnterCrit();
  67. return Status;
  68. }
  69. /***************************************************************************\
  70. * UpSiren
  71. *
  72. * Generate an up-siren tone.
  73. *
  74. * History:
  75. \***************************************************************************/
  76. BOOL UpSiren(void)
  77. {
  78. DWORD freq;
  79. BOOL BeepStatus = TRUE;
  80. LeaveCrit();
  81. for (freq = SIREN_LOW_FREQ;
  82. BeepStatus && freq <= SIREN_HIGH_FREQ;
  83. freq += SIREN_INTERVAL) {
  84. BeepStatus = UserBeep(freq, (DWORD)1);
  85. }
  86. EnterCrit();
  87. return BeepStatus;
  88. }
  89. /***************************************************************************\
  90. * DownSiren
  91. *
  92. * Generate a down-siren tone.
  93. *
  94. * History:
  95. \***************************************************************************/
  96. BOOL DownSiren(void)
  97. {
  98. DWORD freq;
  99. BOOL BeepStatus = TRUE;
  100. LeaveCrit();
  101. for (freq = SIREN_HIGH_FREQ;
  102. BeepStatus && freq >= SIREN_LOW_FREQ;
  103. freq -= SIREN_INTERVAL) {
  104. BeepStatus = UserBeep(freq, (DWORD)1);
  105. }
  106. EnterCrit();
  107. return BeepStatus;
  108. }
  109. BOOL DoBeep(BEEPPROC BeepProc, UINT Count)
  110. {
  111. while (Count--) {
  112. (*BeepProc)();
  113. UserSleep(100);
  114. }
  115. return TRUE;
  116. }