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.

369 lines
13 KiB

  1. /* (C) Copyright Microsoft Corporation 1991. All Rights Reserved */
  2. /* SoundRec.h
  3. */
  4. /* Revision History.
  5. LaurieGr 7/Jan/91 Ported to WIN32 / WIN16 common code
  6. LaurieGr 16/Feb/94 Merged Daytona and Motown versions
  7. */
  8. /* Set NT type debug flags */
  9. #if DBG
  10. # ifndef DEBUG
  11. # define DEBUG
  12. # endif
  13. #endif
  14. /* Enable Win95 UI code for Windows NT with the new shell */
  15. #if WINVER >= 0x0400
  16. #define CHICAGO
  17. #endif
  18. #include <stdlib.h>
  19. #ifndef RC_INVOKED
  20. #ifndef OLE1_REGRESS
  21. #ifdef INCLUDE_OLESTUBS
  22. #include "oleglue.h"
  23. #endif
  24. #else
  25. #pragma message("OLE1 alert")
  26. #include "server.h"
  27. #endif
  28. #endif
  29. #define SIZEOF(x) (sizeof(x)/sizeof(TCHAR))
  30. typedef BYTE * HPBYTE; /* note a BYTE is NOT the same as a CHAR */
  31. typedef BYTE * NPBYTE; /* A CHAR can be TWO BYTES (UNICODE!!) */
  32. #define FMT_DEFAULT 0x0000
  33. #define FMT_STEREO 0x0010
  34. #define FMT_MONO 0x0000
  35. #define FMT_16BIT 0x0008
  36. #define FMT_8BIT 0x0000
  37. #define FMT_RATE 0x0007 /* 1, 2, 4 */
  38. #define FMT_11k 0x0001
  39. #define FMT_22k 0x0002
  40. #define FMT_44k 0x0004
  41. //
  42. // convertsion routines in wave.c
  43. //
  44. LONG PASCAL wfSamplesToBytes(WAVEFORMATEX* pwf, LONG lSamples);
  45. LONG PASCAL wfBytesToSamples(WAVEFORMATEX* pwf, LONG lBytes);
  46. LONG PASCAL wfSamplesToTime (WAVEFORMATEX* pwf, LONG lSamples);
  47. LONG PASCAL wfTimeToSamples (WAVEFORMATEX* pwf, LONG lTime);
  48. #define wfTimeToBytes(pwf, lTime) wfSamplesToBytes(pwf, wfTimeToSamples(pwf, lTime))
  49. #define wfBytesToTime(pwf, lBytes) wfSamplesToTime(pwf, wfBytesToSamples(pwf, lBytes))
  50. #define wfSamplesToSamples(pwf, lSamples) wfBytesToSamples(pwf, wfSamplesToBytes(pwf, lSamples))
  51. #define wfBytesToBytes(pwf, lBytes) wfSamplesToBytes(pwf, wfBytesToSamples(pwf, lBytes))
  52. //
  53. // function to determine if a WAVEFORMATEX is a valid PCM format we support for
  54. // editing and such.
  55. //
  56. BOOL PASCAL IsWaveFormatPCM(WAVEFORMATEX* pwf);
  57. void PASCAL WaveFormatToString(LPWAVEFORMATEX lpwf, LPTSTR sz);
  58. BOOL PASCAL CreateWaveFormat(LPWAVEFORMATEX lpwf, WORD fmt, UINT uiDeviceID);
  59. BOOL PASCAL CreateDefaultWaveFormat(LPWAVEFORMATEX lpwf, UINT uDeviceID);
  60. //
  61. // used to set focus to a dialog control
  62. //
  63. #define SetDlgFocus(hwnd) SendMessage(ghwndApp, WM_NEXTDLGCTL, (WPARAM)(hwnd), 1L)
  64. #define FAKEITEMNAMEFORLINK
  65. #define SZCODE const TCHAR
  66. /* constants */
  67. #define TIMER_MSEC 50 // msec. for display update
  68. #define SCROLL_RANGE 10000 // scrollbar range
  69. #define SCROLL_LINE_MSEC 100 // scrollbar arrow left/right
  70. #define SCROLL_PAGE_MSEC 1000 // scrollbar page left/right
  71. #define WM_USER_DESTROY (WM_USER+10)
  72. #define WM_USER_KILLSERVER (WM_USER+11)
  73. #define WM_USER_WAITPLAYEND (WM_USER+12)
  74. #define WM_BADREG (WM_USER+125)
  75. #define MAX_WAVEHDRS 10
  76. #define MAX_DELTASECONDS 350
  77. #define MAX_MSECSPERBUFFER 10000
  78. #define MIN_WAVEHDRS 2
  79. #define MIN_DELTASECONDS 5
  80. #define MIN_MSECSPERBUFFER 62
  81. #define DEF_BUFFERDELTASECONDS 60
  82. #define DEF_NUMASYNCWAVEHEADERS 10
  83. #define DEF_MSECSPERASYNCBUFFER 250
  84. /* colors */
  85. #define RGB_PANEL GetSysColor(COLOR_BTNFACE) // main window background
  86. #define RGB_STOP GetSysColor(COLOR_BTNTEXT) // color of "Stop" status text
  87. #define RGB_PLAY GetSysColor(COLOR_BTNTEXT) // color of "Play" status text
  88. #define RGB_RECORD GetSysColor(COLOR_BTNTEXT) // color of "Record" status text
  89. #define RGB_FGNFTEXT GetSysColor(COLOR_BTNTEXT) // NoFlickerText foreground
  90. #define RGB_BGNFTEXT GetSysColor(COLOR_BTNFACE) // NoFlickerText background
  91. #define RGB_FGWAVEDISP RGB( 0, 255, 0) // WaveDisplay foreground
  92. #define RGB_BGWAVEDISP RGB( 0, 0, 0) // WaveDisplay background
  93. #define RGB_DARKSHADOW GetSysColor(COLOR_BTNSHADOW) // dark 3-D shadow
  94. #define RGB_LIGHTSHADOW GetSysColor(COLOR_BTNHIGHLIGHT) // light 3-D shadow
  95. /* a window proc */
  96. typedef LONG (FAR PASCAL * LPWNDPROC) (void);
  97. /* globals from "SoundRec.c" */
  98. extern TCHAR chDecimal;
  99. extern TCHAR gachAppName[]; // 8-character name
  100. extern TCHAR gachAppTitle[]; // full name
  101. extern TCHAR gachHelpFile[]; // name of help file
  102. extern TCHAR gachHtmlHelpFile[]; // name of help file
  103. extern TCHAR gachDefFileExt[]; // 3-character file extension
  104. extern HWND ghwndApp; // main application window
  105. extern HMENU ghmenuApp; // main application menu
  106. extern HANDLE ghAccel; // accelerators
  107. extern HINSTANCE ghInst; // program instance handle
  108. extern TCHAR gachFileName[]; // cur. file name (or UNTITLED)
  109. extern BOOL gfLZero; // leading zeros?
  110. extern BOOL gfIsRTL; // no compile BIDI support
  111. extern BOOL gfDirty; // file was modified and not saved?
  112. // -1 seems to mean "cannot save"
  113. // Damned funny value for a BOOL!!!!
  114. extern BOOL gfClipboard; // current doc is in clipboard
  115. extern HWND ghwndWaveDisplay; // waveform display window handle
  116. extern HWND ghwndScroll; // scroll bar control window handle
  117. extern HWND ghwndPlay; // Play button window handle
  118. extern HWND ghwndStop; // Stop button window handle
  119. extern HWND ghwndRecord; // Record button window handle
  120. extern HWND ghwndForward; // [>>] button
  121. extern HWND ghwndRewind; // [<<] button
  122. extern UINT guiACMHlpMsg; // ACM Help's message value
  123. /* hack fix for the multiple sound card problem */
  124. #define NEWPAUSE
  125. #ifdef NEWPAUSE
  126. extern BOOL gfPaused;
  127. extern BOOL gfPausing;
  128. extern HWAVE ghPausedWave;
  129. extern BOOL gfWasPlaying;
  130. extern BOOL gfWasRecording;
  131. #endif
  132. #ifdef THRESHOLD
  133. extern HWND ghwndSkipStart; // [>N] button
  134. extern HWND ghwndSkipEnd; // [>-] button
  135. #endif // THRESHOLD
  136. extern int gidDefaultButton;// which button should have focus
  137. extern HICON ghiconApp; // Application's icon
  138. extern TCHAR aszUntitled[]; // Untitled string resource
  139. extern TCHAR aszFilter[]; // File name filter
  140. #ifdef FAKEITEMNAMEFORLINK
  141. extern TCHAR aszFakeItemName[]; // Wave
  142. #endif
  143. extern TCHAR aszPositionFormat[];
  144. extern TCHAR aszNoZeroPositionFormat[];
  145. /* globals from "wave.c" */
  146. extern DWORD gcbWaveFormat; // size of WAVEFORMAT
  147. extern WAVEFORMATEX * gpWaveFormat; // format of WAVE file
  148. extern LPTSTR gpszInfo;
  149. extern HPBYTE gpWaveSamples; // pointer to waveoform samples
  150. extern LONG glWaveSamples; // number of samples total in buffer
  151. extern LONG glWaveSamplesValid; // number of samples that are valid
  152. extern LONG glWavePosition; // current wave position in samples
  153. // from start of buffer
  154. extern LONG glStartPlayRecPos; // pos. when play or record started
  155. extern HWAVEOUT ghWaveOut; // wave-out device (if playing)
  156. extern HWAVEIN ghWaveIn; // wave-out device (if recording)
  157. extern DWORD grgbStatusColor; // color of status text
  158. extern HBRUSH ghbrPanel; // color of main window
  159. extern BOOL gfEmbeddedObject; // TRUE if editing embedded OLE object
  160. extern BOOL gfRunWithEmbeddingFlag; // TRUE if we are run with "-Embedding"
  161. extern int gfErrorBox; // TRUE iff we do not want to display an
  162. // error box (e.g. because one is active)
  163. //OLE2 stuff:
  164. extern BOOL gfStandalone; // CG
  165. extern BOOL gfEmbedded; // CG
  166. extern BOOL gfLinked; // CG
  167. extern BOOL gfCloseAtEndOfPlay; // jyg need I say more?
  168. /* SRECNEW.C */
  169. extern BOOL gfInFileNew; // are we doing a File.New op?
  170. void FAR PASCAL LoadACM(void);
  171. void FreeACM(void);
  172. #include "srecids.h"
  173. typedef enum {
  174. enumCancel,
  175. enumSaved,
  176. enumRevert
  177. } PROMPTRESULT;
  178. /* prototypes from "SoundRec.c" */
  179. INT_PTR CALLBACK SoundRecDlgProc(HWND hDlg, UINT wMsg,
  180. WPARAM wParam, LPARAM lParam);
  181. BOOL ResolveIfLink(PTCHAR szFileName);
  182. /* prototypes from "file.c" */
  183. void FAR PASCAL BeginWaveEdit(void);
  184. void FAR PASCAL EndWaveEdit(BOOL fDirty);
  185. PROMPTRESULT FAR PASCAL PromptToSave(BOOL fMustClose, BOOL fSetForground);
  186. void FAR PASCAL UpdateCaption(void);
  187. BOOL FAR PASCAL FileNew(WORD fmt, BOOL fUpdateDisplay, BOOL fNewDlg);
  188. BOOL FAR PASCAL FileOpen(LPCTSTR szFileName);
  189. BOOL FAR PASCAL FileSave(BOOL fSaveAs);
  190. BOOL FAR PASCAL FileRevert(void);
  191. LPCTSTR FAR PASCAL FileName(LPCTSTR szPath);
  192. MMRESULT ReadWaveFile(HMMIO hmmio, LPWAVEFORMATEX* ppWaveFormat,
  193. DWORD *pcbWaveFormat, LPBYTE * ppWaveSamples, DWORD *plWaveSamples,
  194. LPTSTR szFileName, BOOL fCacheRIFF);
  195. BOOL FAR PASCAL WriteWaveFile(HMMIO hmmio, WAVEFORMATEX* pWaveFormat,
  196. UINT cbWaveFormat, HPBYTE pWaveSamples, LONG lWaveSamples);
  197. /* prototypes from "errorbox.c" */
  198. short FAR cdecl ErrorResBox(HWND hwnd, HANDLE hInst, UINT flags,
  199. UINT idAppName, UINT idErrorStr, ...);
  200. /* prototypes from "edit.c" */
  201. void FAR PASCAL InsertFile(BOOL fPaste);
  202. void FAR PASCAL MixWithFile(BOOL fPaste);
  203. void FAR PASCAL DeleteBefore(void);
  204. void FAR PASCAL DeleteAfter(void);
  205. void FAR PASCAL ChangeVolume(BOOL fIncrease);
  206. void FAR PASCAL MakeFaster(void);
  207. void FAR PASCAL MakeSlower(void);
  208. void FAR PASCAL IncreasePitch(void);
  209. void FAR PASCAL DecreasePitch(void);
  210. void FAR PASCAL AddEcho(void);
  211. #if defined(REVERB)
  212. void FAR PASCAL AddReverb(void);
  213. #endif //REVERB
  214. void FAR PASCAL Reverse(void);
  215. /* prototypes from "wave.c" */
  216. BOOL FAR PASCAL AllocWaveBuffer(long lBytes, BOOL fErrorBox, BOOL fExact);
  217. BOOL FAR PASCAL NewWave(WORD fmt,BOOL fNewDlg);
  218. BOOL FAR PASCAL DestroyWave(void);
  219. BOOL FAR PASCAL PlayWave(void);
  220. BOOL FAR PASCAL RecordWave(void);
  221. void FAR PASCAL WaveOutDone(HWAVEOUT hWaveOut, LPWAVEHDR pWaveHdr);
  222. void FAR PASCAL WaveInData(HWAVEIN hWaveIn, LPWAVEHDR pWaveHdr);
  223. void FAR PASCAL StopWave(void);
  224. void FAR PASCAL SnapBack(void);
  225. void FAR PASCAL UpdateDisplay(BOOL fStatusChanged);
  226. void FAR PASCAL FinishPlay(void);
  227. void FAR PASCAL SkipToStart(void);
  228. void FAR PASCAL SkipToEnd(void);
  229. void FAR PASCAL IncreaseThresh(void);
  230. void FAR PASCAL DecreaseThresh(void);
  231. /* prototypes from "init.c" */
  232. BOOL PASCAL AppInit( HINSTANCE hInst, HINSTANCE hPrev);
  233. BOOL PASCAL SoundDialogInit(HWND hwnd, int iCmdShow);
  234. BOOL PASCAL GetIntlSpecs(void);
  235. /* prototype from "wavedisp.c" */
  236. INT_PTR CALLBACK WaveDisplayWndProc(HWND hwnd, UINT wMsg,
  237. WPARAM wParam, LPARAM lParam);
  238. /* prototype from "nftext.c" */
  239. INT_PTR CALLBACK NFTextWndProc(HWND hwnd, UINT wMsg,
  240. WPARAM wParam, LPARAM lParam);
  241. /* prototype from "sframe.c" */
  242. void FAR PASCAL DrawShadowFrame(HDC hdc, LPRECT prc);
  243. INT_PTR CALLBACK SFrameWndProc(HWND hwnd, UINT wMsg,
  244. WPARAM wParam, LPARAM lParam);
  245. /* prototype from "server.c" */
  246. BOOL FAR PASCAL IsClipboardNative(void);
  247. /* prototypes from "srecnew.c" */
  248. BOOL FAR PASCAL NewSndDialog(HINSTANCE hInst, HWND hwndParent,
  249. PWAVEFORMATEX pwfxPrev, UINT cbPrev,
  250. PWAVEFORMATEX *ppWaveFormat, PUINT pcbWaveFormat);
  251. /* start parameters (set in oleglue.c) */
  252. typedef struct tStartParams {
  253. BOOL fOpen;
  254. BOOL fPlay;
  255. BOOL fNew;
  256. BOOL fClose;
  257. TCHAR achOpenFilename[_MAX_PATH];
  258. } StartParams;
  259. extern StartParams gStartParams;
  260. #ifdef DEBUG
  261. int __iDebugLevel;
  262. extern void FAR cdecl dprintfA(LPSTR, ...);
  263. extern void FAR cdecl dprintfW(LPWSTR, ...);
  264. #ifdef UNICODE
  265. #define dprintf dprintfW
  266. #else
  267. #define dprintf dprintfA
  268. #endif
  269. #if 0
  270. #define DPF if (__iDebugLevel > 0) dprintf
  271. #define DPF1 if (__iDebugLevel >= 1) dprintf
  272. #define DPF2 if (__iDebugLevel >= 2) dprintf
  273. #define DPF3 if (__iDebugLevel >= 3) dprintf
  274. #define DPF4 if (__iDebugLevel >= 4) dprintf
  275. #define CPF
  276. #endif
  277. #ifdef PPC
  278. //
  279. // The below line crashes the PPC compiler for NT 3.51
  280. //
  281. #define DPF(a)
  282. #else
  283. #define DPF if (0) ((int (*)(TCHAR *, ...)) 0)
  284. #endif
  285. #define DPF1 if (0) ((int (*)(TCHAR *, ...)) 0)
  286. #define DPF2 if (0) ((int (*)(TCHAR *, ...)) 0)
  287. #define DPF3 if (0) ((int (*)(TCHAR *, ...)) 0)
  288. #define DPF4 if (0) ((int (*)(TCHAR *, ...)) 0)
  289. #define CPF if (0) ((int (*)(TCHAR *, ...)) 0)
  290. #else
  291. #ifdef PPC
  292. //
  293. // The below line crashes the PPC compiler for NT 3.51
  294. //
  295. #define DPF(a)
  296. #else
  297. #define DPF if (0) ((int (*)(TCHAR *, ...)) 0)
  298. #endif
  299. #define DPF1 if (0) ((int (*)(TCHAR *, ...)) 0)
  300. #define DPF2 if (0) ((int (*)(TCHAR *, ...)) 0)
  301. #define DPF3 if (0) ((int (*)(TCHAR *, ...)) 0)
  302. #define DPF4 if (0) ((int (*)(TCHAR *, ...)) 0)
  303. #define CPF if (0) ((int (*)(TCHAR *, ...)) 0)
  304. #endif //DEBUG