/binding/win32/mmsystem.d

http://github.com/wilkie/djehuty · D · 3905 lines · 2894 code · 594 blank · 417 comment · 69 complexity · c70baf485c6bd2c12e08c20d5c506953 MD5 · raw file

Large files are truncated click here to view the full file

  1. /*
  2. * mmsystem.d
  3. *
  4. * This module binds MMSystem.h to D. The original copyright notice is
  5. * preserved below.
  6. *
  7. * Author: Dave Wilkinson
  8. * Originated: November 25th, 2009
  9. *
  10. */
  11. module binding.win32.mmsystem;
  12. import binding.win32.windef;
  13. import binding.win32.winnt;
  14. import binding.win32.winuser;
  15. extern(System):
  16. /*==========================================================================
  17. *
  18. * mmsystem.h -- Include file for Multimedia API's
  19. *
  20. * Version 4.00
  21. *
  22. * Copyright (C) 1992-1998 Microsoft Corporation. All Rights Reserved.
  23. *
  24. *--------------------------------------------------------------------------
  25. *
  26. * Define: Prevent inclusion of:
  27. * -------------- --------------------------------------------------------
  28. * MMNODRV Installable driver support
  29. * MMNOSOUND Sound support
  30. * MMNOWAVE Waveform support
  31. * MMNOMIDI MIDI support
  32. * MMNOAUX Auxiliary audio support
  33. * MMNOMIXER Mixer support
  34. * MMNOTIMER Timer support
  35. * MMNOJOY Joystick support
  36. * MMNOMCI MCI support
  37. * MMNOMMIO Multimedia file I/O support
  38. * MMNOMMSYSTEM General MMSYSTEM functions
  39. *
  40. *==========================================================================
  41. */
  42. /****************************************************************************
  43. General constants and data types
  44. ****************************************************************************/
  45. /* general constants */
  46. const auto MAXPNAMELEN = 32 ; /* max product name length (including NULL) */
  47. const auto MAXERRORLENGTH = 256 ; /* max error text length (including NULL) */
  48. const auto MAX_JOYSTICKOEMVXDNAME = 260 ; /* max oem vxd name length (including NULL) */
  49. /*
  50. * Microsoft Manufacturer and Product ID's (these have been moved to
  51. * MMREG.H for Windows 4.00 and above).
  52. */
  53. const auto MM_MIDI_MAPPER = 1 ; /* MIDI Mapper */
  54. const auto MM_WAVE_MAPPER = 2 ; /* Wave Mapper */
  55. const auto MM_SNDBLST_MIDIOUT = 3 ; /* Sound Blaster MIDI output port */
  56. const auto MM_SNDBLST_MIDIIN = 4 ; /* Sound Blaster MIDI input port */
  57. const auto MM_SNDBLST_SYNTH = 5 ; /* Sound Blaster internal synthesizer */
  58. const auto MM_SNDBLST_WAVEOUT = 6 ; /* Sound Blaster waveform output */
  59. const auto MM_SNDBLST_WAVEIN = 7 ; /* Sound Blaster waveform input */
  60. const auto MM_ADLIB = 9 ; /* Ad Lib-compatible synthesizer */
  61. const auto MM_MPU401_MIDIOUT = 10 ; /* MPU401-compatible MIDI output port */
  62. const auto MM_MPU401_MIDIIN = 11 ; /* MPU401-compatible MIDI input port */
  63. const auto MM_PC_JOYSTICK = 12 ; /* Joystick adapter */
  64. /* general data types */
  65. alias UINT MMVERSION; /* major (high byte), minor (low byte) */
  66. alias UINT VERSION; /* major (high byte), minor (low byte) */
  67. alias UINT MMRESULT; /* error return code, 0 means no error */
  68. /* call as if(err=xxxx(...)) Error(err); else */
  69. alias UINT *LPUINT;
  70. /* MMTIME data align(2) structure */
  71. align(2) struct MMTIME {
  72. UINT wType; /* indicates the contents of the align(2) union */
  73. align(2) union _inner_union {
  74. DWORD ms; /* milliseconds */
  75. DWORD sample; /* samples */
  76. DWORD cb; /* byte count */
  77. DWORD ticks; /* ticks in MIDI stream */
  78. /* SMPTE */
  79. align(2) struct _inner_struct {
  80. BYTE hour; /* hours */
  81. BYTE min; /* minutes */
  82. BYTE sec; /* seconds */
  83. BYTE frame; /* frames */
  84. BYTE fps; /* frames per second */
  85. BYTE dummy; /* pad */
  86. BYTE pad[2];
  87. }
  88. _inner_struct smpte;
  89. /* MIDI */
  90. align(2) struct _inner_struct2 {
  91. DWORD songptrpos; /* song pointer position */
  92. }
  93. _inner_struct2 midi;
  94. }
  95. _inner_union u;
  96. }
  97. alias MMTIME* PMMTIME;
  98. alias MMTIME *NPMMTIME;
  99. alias MMTIME* LPMMTIME;
  100. /* types for wType field in MMTIME align(2) struct */
  101. const auto TIME_MS = 0x0001 ; /* time in milliseconds */
  102. const auto TIME_SAMPLES = 0x0002 ; /* number of wave samples */
  103. const auto TIME_BYTES = 0x0004 ; /* current byte offset */
  104. const auto TIME_SMPTE = 0x0008 ; /* SMPTE time */
  105. const auto TIME_MIDI = 0x0010 ; /* MIDI time */
  106. const auto TIME_TICKS = 0x0020 ; /* Ticks within MIDI stream */
  107. /*
  108. *
  109. *
  110. */
  111. template MAKEFOURCC(char ch0, char ch1, char ch2, char ch3) {
  112. const auto MAKEFOURCC =
  113. (cast(DWORD)cast(BYTE)(ch0) | (cast(DWORD)cast(BYTE)(ch1) << 8) |
  114. (cast(DWORD)cast(BYTE)(ch2) << 16) | (cast(DWORD)cast(BYTE)(ch3) << 24 ));
  115. }
  116. /****************************************************************************
  117. Multimedia Extensions Window Messages
  118. ****************************************************************************/
  119. const auto MM_JOY1MOVE = 0x3A0 ; /* joystick */
  120. const auto MM_JOY2MOVE = 0x3A1;
  121. const auto MM_JOY1ZMOVE = 0x3A2;
  122. const auto MM_JOY2ZMOVE = 0x3A3;
  123. const auto MM_JOY1BUTTONDOWN = 0x3B5;
  124. const auto MM_JOY2BUTTONDOWN = 0x3B6;
  125. const auto MM_JOY1BUTTONUP = 0x3B7;
  126. const auto MM_JOY2BUTTONUP = 0x3B8;
  127. const auto MM_MCINOTIFY = 0x3B9 ; /* MCI */
  128. const auto MM_WOM_OPEN = 0x3BB ; /* waveform output */
  129. const auto MM_WOM_CLOSE = 0x3BC;
  130. const auto MM_WOM_DONE = 0x3BD;
  131. const auto MM_WIM_OPEN = 0x3BE ; /* waveform input */
  132. const auto MM_WIM_CLOSE = 0x3BF;
  133. const auto MM_WIM_DATA = 0x3C0;
  134. const auto MM_MIM_OPEN = 0x3C1 ; /* MIDI input */
  135. const auto MM_MIM_CLOSE = 0x3C2;
  136. const auto MM_MIM_DATA = 0x3C3;
  137. const auto MM_MIM_LONGDATA = 0x3C4;
  138. const auto MM_MIM_ERROR = 0x3C5;
  139. const auto MM_MIM_LONGERROR = 0x3C6;
  140. const auto MM_MOM_OPEN = 0x3C7 ; /* MIDI output */
  141. const auto MM_MOM_CLOSE = 0x3C8;
  142. const auto MM_MOM_DONE = 0x3C9;
  143. /* these are also in msvideo.h */
  144. const auto MM_DRVM_OPEN = 0x3D0; /* installable drivers */
  145. const auto MM_DRVM_CLOSE = 0x3D1;
  146. const auto MM_DRVM_DATA = 0x3D2;
  147. const auto MM_DRVM_ERROR = 0x3D3;
  148. /* these are used by msacm.h */
  149. const auto MM_STREAM_OPEN = 0x3D4;
  150. const auto MM_STREAM_CLOSE = 0x3D5;
  151. const auto MM_STREAM_DONE = 0x3D6;
  152. const auto MM_STREAM_ERROR = 0x3D7;
  153. const auto MM_MOM_POSITIONCB = 0x3CA ; /* Callback for MEVT_POSITIONCB */
  154. const auto MM_MCISIGNAL = 0x3CB;
  155. const auto MM_MIM_MOREDATA = 0x3CC ; /* MIM_DONE w/ pending events */
  156. const auto MM_MIXM_LINE_CHANGE = 0x3D0 ; /* mixer line change notify */
  157. const auto MM_MIXM_CONTROL_CHANGE = 0x3D1 ; /* mixer control change notify */
  158. /****************************************************************************
  159. String resource number bases (internal use)
  160. ****************************************************************************/
  161. const auto MMSYSERR_BASE = 0;
  162. const auto WAVERR_BASE = 32;
  163. const auto MIDIERR_BASE = 64;
  164. const auto TIMERR_BASE = 96;
  165. const auto JOYERR_BASE = 160;
  166. const auto MCIERR_BASE = 256;
  167. const auto MIXERR_BASE = 1024;
  168. const auto MCI_STRING_OFFSET = 512;
  169. const auto MCI_VD_OFFSET = 1024;
  170. const auto MCI_CD_OFFSET = 1088;
  171. const auto MCI_WAVE_OFFSET = 1152;
  172. const auto MCI_SEQ_OFFSET = 1216;
  173. /****************************************************************************
  174. General error return values
  175. ****************************************************************************/
  176. /* general error return values */
  177. const auto MMSYSERR_NOERROR = 0 ; /* no error */
  178. const auto MMSYSERR_ERROR = (MMSYSERR_BASE + 1) ; /* unspecified error */
  179. const auto MMSYSERR_BADDEVICEID = (MMSYSERR_BASE + 2) ; /* device ID out of range */
  180. const auto MMSYSERR_NOTENABLED = (MMSYSERR_BASE + 3) ; /* driver failed enable */
  181. const auto MMSYSERR_ALLOCATED = (MMSYSERR_BASE + 4) ; /* device already allocated */
  182. const auto MMSYSERR_INVALHANDLE = (MMSYSERR_BASE + 5) ; /* device handle is invalid */
  183. const auto MMSYSERR_NODRIVER = (MMSYSERR_BASE + 6) ; /* no device driver present */
  184. const auto MMSYSERR_NOMEM = (MMSYSERR_BASE + 7) ; /* memory allocation error */
  185. const auto MMSYSERR_NOTSUPPORTED = (MMSYSERR_BASE + 8) ; /* function isn't supported */
  186. const auto MMSYSERR_BADERRNUM = (MMSYSERR_BASE + 9) ; /* error value out of range */
  187. const auto MMSYSERR_INVALFLAG = (MMSYSERR_BASE + 10) ; /* invalid flag passed */
  188. const auto MMSYSERR_INVALPARAM = (MMSYSERR_BASE + 11) ; /* invalid parameter passed */
  189. const auto MMSYSERR_HANDLEBUSY = (MMSYSERR_BASE + 12) ; /* handle being used */
  190. /* simultaneously on another */
  191. /* thread (eg callback) */
  192. const auto MMSYSERR_INVALIDALIAS = (MMSYSERR_BASE + 13) ; /* specified alias not found */
  193. const auto MMSYSERR_BADDB = (MMSYSERR_BASE + 14) ; /* bad registry database */
  194. const auto MMSYSERR_KEYNOTFOUND = (MMSYSERR_BASE + 15) ; /* registry key not found */
  195. const auto MMSYSERR_READERROR = (MMSYSERR_BASE + 16) ; /* registry read error */
  196. const auto MMSYSERR_WRITEERROR = (MMSYSERR_BASE + 17) ; /* registry write error */
  197. const auto MMSYSERR_DELETEERROR = (MMSYSERR_BASE + 18) ; /* registry delete error */
  198. const auto MMSYSERR_VALNOTFOUND = (MMSYSERR_BASE + 19) ; /* registry value not found */
  199. const auto MMSYSERR_NODRIVERCB = (MMSYSERR_BASE + 20) ; /* driver does not call DriverCallback */
  200. const auto MMSYSERR_MOREDATA = (MMSYSERR_BASE + 21) ; /* more data to be returned */
  201. const auto MMSYSERR_LASTERROR = (MMSYSERR_BASE + 21) ; /* last error in range */
  202. alias HANDLE HDRVR;
  203. /****************************************************************************
  204. Installable driver support
  205. ****************************************************************************/
  206. version(MMNODRV) {
  207. }
  208. else {
  209. align(2) struct DRVCONFIGINFOEX {
  210. DWORD dwDCISize;
  211. LPCWSTR lpszDCISectionName;
  212. LPCWSTR lpszDCIAliasName;
  213. DWORD dnDevNode;
  214. }
  215. alias DRVCONFIGINFOEX* PDRVCONFIGINFOEX;
  216. alias DRVCONFIGINFOEX *NPDRVCONFIGINFOEX;
  217. alias DRVCONFIGINFOEX* LPDRVCONFIGINFOEX;
  218. /* Driver messages */
  219. const auto DRV_LOAD = 0x0001;
  220. const auto DRV_ENABLE = 0x0002;
  221. const auto DRV_OPEN = 0x0003;
  222. const auto DRV_CLOSE = 0x0004;
  223. const auto DRV_DISABLE = 0x0005;
  224. const auto DRV_FREE = 0x0006;
  225. const auto DRV_CONFIGURE = 0x0007;
  226. const auto DRV_QUERYCONFIGURE = 0x0008;
  227. const auto DRV_INSTALL = 0x0009;
  228. const auto DRV_REMOVE = 0x000A;
  229. const auto DRV_EXITSESSION = 0x000B;
  230. const auto DRV_POWER = 0x000F;
  231. const auto DRV_RESERVED = 0x0800;
  232. const auto DRV_USER = 0x4000;
  233. /* LPARAM of DRV_CONFIGURE message */
  234. align(2) struct DRVCONFIGINFO {
  235. DWORD dwDCISize;
  236. LPCWSTR lpszDCISectionName;
  237. LPCWSTR lpszDCIAliasName;
  238. }
  239. alias DRVCONFIGINFO* PDRVCONFIGINFO;
  240. alias DRVCONFIGINFO *NPDRVCONFIGINFO;
  241. alias DRVCONFIGINFO* LPDRVCONFIGINFO;
  242. /* Supported return values for DRV_CONFIGURE message */
  243. const auto DRVCNF_CANCEL = 0x0000;
  244. const auto DRVCNF_OK = 0x0001;
  245. const auto DRVCNF_RESTART = 0x0002;
  246. /* installable driver function prototypes */
  247. alias LRESULT function(DWORD_PTR, HDRVR, UINT, LPARAM, LPARAM) DRIVERPROC;
  248. LRESULT CloseDriver( HDRVR hDriver, LPARAM lParam1, LPARAM lParam2);
  249. HDRVR OpenDriver( LPCWSTR szDriverName, LPCWSTR szSectionName, LPARAM lParam2);
  250. LRESULT SendDriverMessage( HDRVR hDriver, UINT message, LPARAM lParam1, LPARAM lParam2);
  251. HMODULE DrvGetModuleHandle( HDRVR hDriver);
  252. HMODULE GetDriverModuleHandle( HDRVR hDriver);
  253. LRESULT DefDriverProc( DWORD_PTR dwDriverIdentifier, HDRVR hdrvr, UINT uMsg, LPARAM lParam1, LPARAM lParam2);
  254. /* return values from DriverProc() function */
  255. const auto DRV_CANCEL = DRVCNF_CANCEL;
  256. const auto DRV_OK = DRVCNF_OK;
  257. const auto DRV_RESTART = DRVCNF_RESTART;
  258. const auto DRV_MCI_FIRST = DRV_RESERVED;
  259. const auto DRV_MCI_LAST = (DRV_RESERVED + 0xFFF);
  260. }
  261. /****************************************************************************
  262. Driver callback support
  263. ****************************************************************************/
  264. /* flags used with waveOutOpen(), waveInOpen(), midiInOpen(), and */
  265. /* midiOutOpen() to specify the type of the dwCallback parameter. */
  266. const auto CALLBACK_TYPEMASK = 0x00070000 ; /* callback type mask */
  267. const auto CALLBACK_NULL = 0x00000000 ; /* no callback */
  268. const auto CALLBACK_WINDOW = 0x00010000 ; /* dwCallback is a HWND */
  269. const auto CALLBACK_TASK = 0x00020000 ; /* dwCallback is a HTASK */
  270. const auto CALLBACK_FUNCTION = 0x00030000 ; /* dwCallback is a FARPROC */
  271. const auto CALLBACK_THREAD = (CALLBACK_TASK); /* thread ID replaces 16 bit task */
  272. const auto CALLBACK_EVENT = 0x00050000 ; /* dwCallback is an EVENT Handle */
  273. alias void function(HDRVR hdrvr, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) DRVCALLBACK;
  274. alias DRVCALLBACK *LPDRVCALLBACK;
  275. alias DRVCALLBACK *PDRVCALLBACK;
  276. /****************************************************************************
  277. General MMSYSTEM support
  278. ****************************************************************************/
  279. version(MMNOMMSYSTEM) {
  280. }
  281. else {
  282. UINT mmsystemGetVersion();
  283. }
  284. /****************************************************************************
  285. Sound support
  286. ****************************************************************************/
  287. version(MMNOSOUND) {
  288. }
  289. else {
  290. BOOL sndPlaySoundA( LPCSTR pszSound, UINT fuSound);
  291. BOOL sndPlaySoundW( LPCWSTR pszSound, UINT fuSound);
  292. version(UNICODE) {
  293. alias sndPlaySoundW sndPlaySound;
  294. }
  295. else {
  296. alias sndPlaySoundA sndPlaySound;
  297. }
  298. /*
  299. * flag values for fuSound and fdwSound arguments on [snd]PlaySound
  300. */
  301. const auto SND_SYNC = 0x0000 ; /* play synchronously (default) */
  302. const auto SND_ASYNC = 0x0001 ; /* play asynchronously */
  303. const auto SND_NODEFAULT = 0x0002 ; /* silence (!default) if sound not found */
  304. const auto SND_MEMORY = 0x0004 ; /* pszSound points to a memory file */
  305. const auto SND_LOOP = 0x0008 ; /* loop the sound until next sndPlaySound */
  306. const auto SND_NOSTOP = 0x0010 ; /* don't stop any currently playing sound */
  307. const auto SND_NOWAIT = 0x00002000L ; /* don't wait if the driver is busy */
  308. const auto SND_ALIAS = 0x00010000L ; /* name is a registry alias */
  309. const auto SND_ALIAS_ID = 0x00110000L ; /* alias is a predefined ID */
  310. const auto SND_FILENAME = 0x00020000L ; /* name is file name */
  311. const auto SND_RESOURCE = 0x00040004L ; /* name is resource name or atom */
  312. const auto SND_PURGE = 0x0040 ; /* purge non-static events for task */
  313. const auto SND_APPLICATION = 0x0080 ; /* look for application specific association */
  314. const auto SND_SENTRY = 0x00080000L ; /* Generate a SoundSentry event with this sound */
  315. const auto SND_SYSTEM = 0x00200000L ; /* Treat this as a system sound */
  316. const auto SND_ALIAS_START = 0 ; /* alias base */
  317. template sndAlias(char ch0, char ch1) {
  318. const DWORD sndAlias = (SND_ALIAS_START + cast(DWORD)cast(BYTE)(ch0) | (cast(DWORD)cast(BYTE)(ch1) << 8));
  319. }
  320. const auto SND_ALIAS_SYSTEMASTERISK = sndAlias!('S', '*');
  321. const auto SND_ALIAS_SYSTEMQUESTION = sndAlias!('S', '?');
  322. const auto SND_ALIAS_SYSTEMHAND = sndAlias!('S', 'H');
  323. const auto SND_ALIAS_SYSTEMEXIT = sndAlias!('S', 'E');
  324. const auto SND_ALIAS_SYSTEMSTART = sndAlias!('S', 'S');
  325. const auto SND_ALIAS_SYSTEMWELCOME = sndAlias!('S', 'W');
  326. const auto SND_ALIAS_SYSTEMEXCLAMATION = sndAlias!('S', '!');
  327. const auto SND_ALIAS_SYSTEMDEFAULT = sndAlias!('S', 'D');
  328. BOOL PlaySoundA( LPCSTR pszSound, HMODULE hmod, DWORD fdwSound);
  329. BOOL PlaySoundW( LPCWSTR pszSound, HMODULE hmod, DWORD fdwSound);
  330. version(UNICODE) {
  331. alias PlaySoundW PlaySound;
  332. }
  333. else {
  334. alias PlaySoundA PlaySound;
  335. }
  336. }
  337. /****************************************************************************
  338. Waveform audio support
  339. ****************************************************************************/
  340. version(MMNOWAVE) {
  341. }
  342. else {
  343. /* waveform audio error return values */
  344. const auto WAVERR_BADFORMAT = (WAVERR_BASE + 0) ; /* unsupported wave format */
  345. const auto WAVERR_STILLPLAYING = (WAVERR_BASE + 1) ; /* still something playing */
  346. const auto WAVERR_UNPREPARED = (WAVERR_BASE + 2) ; /* header not prepared */
  347. const auto WAVERR_SYNC = (WAVERR_BASE + 3) ; /* device is synchronous */
  348. const auto WAVERR_LASTERROR = (WAVERR_BASE + 3) ; /* last error in range */
  349. /* waveform audio data types */
  350. alias HANDLE HWAVE;
  351. alias HANDLE HWAVEIN;
  352. alias HANDLE HWAVEOUT;
  353. alias HWAVEIN *LPHWAVEIN;
  354. alias HWAVEOUT *LPHWAVEOUT;
  355. alias DRVCALLBACK WAVECALLBACK;
  356. alias WAVECALLBACK *LPWAVECALLBACK;
  357. /* wave callback messages */
  358. const auto WOM_OPEN = MM_WOM_OPEN;
  359. const auto WOM_CLOSE = MM_WOM_CLOSE;
  360. const auto WOM_DONE = MM_WOM_DONE;
  361. const auto WIM_OPEN = MM_WIM_OPEN;
  362. const auto WIM_CLOSE = MM_WIM_CLOSE;
  363. const auto WIM_DATA = MM_WIM_DATA;
  364. /* device ID for wave device mapper */
  365. const auto WAVE_MAPPER = (cast(UINT)-1);
  366. /* flags for dwFlags parameter in waveOutOpen() and waveInOpen() */
  367. const auto WAVE_FORMAT_QUERY = 0x0001;
  368. const auto WAVE_ALLOWSYNC = 0x0002;
  369. const auto WAVE_MAPPED = 0x0004;
  370. const auto WAVE_FORMAT_DIRECT = 0x0008;
  371. const auto WAVE_FORMAT_DIRECT_QUERY = (WAVE_FORMAT_QUERY | WAVE_FORMAT_DIRECT);
  372. /* wave data block header */
  373. align(2) struct WAVEHDR {
  374. ubyte* lpData; /* pointer to locked data buffer */
  375. DWORD dwBufferLength; /* length of data buffer */
  376. DWORD dwBytesRecorded; /* used for input only */
  377. DWORD_PTR dwUser; /* for client's use */
  378. DWORD dwFlags; /* assorted flags (see defines) */
  379. DWORD dwLoops; /* loop control counter */
  380. WAVEHDR* lpNext; /* reserved for driver */
  381. DWORD_PTR reserved; /* reserved for driver */
  382. }
  383. alias WAVEHDR* PWAVEHDR;
  384. alias WAVEHDR* NPWAVEHDR;
  385. alias WAVEHDR* LPWAVEHDR;
  386. /* flags for dwFlags field of WAVEHDR */
  387. const auto WHDR_DONE = 0x00000001 ; /* done bit */
  388. const auto WHDR_PREPARED = 0x00000002 ; /* set if this header has been prepared */
  389. const auto WHDR_BEGINLOOP = 0x00000004 ; /* loop start block */
  390. const auto WHDR_ENDLOOP = 0x00000008 ; /* loop end block */
  391. const auto WHDR_INQUEUE = 0x00000010 ; /* reserved for driver */
  392. /* waveform output device capabilities align(2) structure */
  393. align(2) struct WAVEOUTCAPSA {
  394. WORD wMid; /* manufacturer ID */
  395. WORD wPid; /* product ID */
  396. MMVERSION vDriverVersion; /* version of the driver */
  397. CHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  398. DWORD dwFormats; /* formats supported */
  399. WORD wChannels; /* number of sources supported */
  400. WORD wReserved1; /* packing */
  401. DWORD dwSupport; /* functionality supported by driver */
  402. }
  403. alias WAVEOUTCAPSA* PWAVEOUTCAPSA;
  404. alias WAVEOUTCAPSA* NPWAVEOUTCAPSA;
  405. alias WAVEOUTCAPSA* LPWAVEOUTCAPSA;
  406. align(2) struct WAVEOUTCAPSW {
  407. WORD wMid; /* manufacturer ID */
  408. WORD wPid; /* product ID */
  409. MMVERSION vDriverVersion; /* version of the driver */
  410. WCHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  411. DWORD dwFormats; /* formats supported */
  412. WORD wChannels; /* number of sources supported */
  413. WORD wReserved1; /* packing */
  414. DWORD dwSupport; /* functionality supported by driver */
  415. }
  416. alias WAVEOUTCAPSW* PWAVEOUTCAPSW;
  417. alias WAVEOUTCAPSW* NPWAVEOUTCAPSW;
  418. alias WAVEOUTCAPSW* LPWAVEOUTCAPSW;
  419. version(UNICODE) {
  420. alias WAVEOUTCAPSW WAVEOUTCAPS;
  421. alias PWAVEOUTCAPSW PWAVEOUTCAPS;
  422. alias NPWAVEOUTCAPSW NPWAVEOUTCAPS;
  423. alias LPWAVEOUTCAPSW LPWAVEOUTCAPS;
  424. }
  425. else {
  426. alias WAVEOUTCAPSA WAVEOUTCAPS;
  427. alias PWAVEOUTCAPSA PWAVEOUTCAPS;
  428. alias NPWAVEOUTCAPSA NPWAVEOUTCAPS;
  429. alias LPWAVEOUTCAPSA LPWAVEOUTCAPS;
  430. }
  431. align(2) struct WAVEOUTCAPS2A {
  432. WORD wMid; /* manufacturer ID */
  433. WORD wPid; /* product ID */
  434. MMVERSION vDriverVersion; /* version of the driver */
  435. CHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  436. DWORD dwFormats; /* formats supported */
  437. WORD wChannels; /* number of sources supported */
  438. WORD wReserved1; /* packing */
  439. DWORD dwSupport; /* functionality supported by driver */
  440. GUID ManufacturerGuid; /* for extensible MID mapping */
  441. GUID ProductGuid; /* for extensible PID mapping */
  442. GUID NameGuid; /* for name lookup in registry */
  443. }
  444. alias WAVEOUTCAPS2A* PWAVEOUTCAPS2A;
  445. alias WAVEOUTCAPS2A* NPWAVEOUTCAPS2A;
  446. alias WAVEOUTCAPS2A* LPWAVEOUTCAPS2A;
  447. align(2) struct WAVEOUTCAPS2W {
  448. WORD wMid; /* manufacturer ID */
  449. WORD wPid; /* product ID */
  450. MMVERSION vDriverVersion; /* version of the driver */
  451. WCHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  452. DWORD dwFormats; /* formats supported */
  453. WORD wChannels; /* number of sources supported */
  454. WORD wReserved1; /* packing */
  455. DWORD dwSupport; /* functionality supported by driver */
  456. GUID ManufacturerGuid; /* for extensible MID mapping */
  457. GUID ProductGuid; /* for extensible PID mapping */
  458. GUID NameGuid; /* for name lookup in registry */
  459. }
  460. alias WAVEOUTCAPS2W* PWAVEOUTCAPS2W;
  461. alias WAVEOUTCAPS2W* NPWAVEOUTCAPS2W;
  462. alias WAVEOUTCAPS2W* LPWAVEOUTCAPS2W;
  463. version(UNICODE) {
  464. alias WAVEOUTCAPS2W WAVEOUTCAPS2;
  465. alias PWAVEOUTCAPS2W PWAVEOUTCAPS2;
  466. alias NPWAVEOUTCAPS2W NPWAVEOUTCAPS2;
  467. alias LPWAVEOUTCAPS2W LPWAVEOUTCAPS2;
  468. }
  469. else {
  470. alias WAVEOUTCAPS2A WAVEOUTCAPS2;
  471. alias PWAVEOUTCAPS2A PWAVEOUTCAPS2;
  472. alias NPWAVEOUTCAPS2A NPWAVEOUTCAPS2;
  473. alias LPWAVEOUTCAPS2A LPWAVEOUTCAPS2;
  474. }
  475. /* flags for dwSupport field of WAVEOUTCAPS */
  476. const auto WAVECAPS_PITCH = 0x0001 ; /* supports pitch control */
  477. const auto WAVECAPS_PLAYBACKRATE = 0x0002 ; /* supports playback rate control */
  478. const auto WAVECAPS_VOLUME = 0x0004 ; /* supports volume control */
  479. const auto WAVECAPS_LRVOLUME = 0x0008 ; /* separate left-right volume control */
  480. const auto WAVECAPS_SYNC = 0x0010;
  481. const auto WAVECAPS_SAMPLEACCURATE = 0x0020;
  482. /* waveform input device capabilities align(2) structure */
  483. align(2) struct WAVEINCAPSA {
  484. WORD wMid; /* manufacturer ID */
  485. WORD wPid; /* product ID */
  486. MMVERSION vDriverVersion; /* version of the driver */
  487. CHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  488. DWORD dwFormats; /* formats supported */
  489. WORD wChannels; /* number of channels supported */
  490. WORD wReserved1; /* align(2) structure packing */
  491. }
  492. alias WAVEINCAPSA* PWAVEINCAPSA;
  493. alias WAVEINCAPSA* NPWAVEINCAPSA;
  494. alias WAVEINCAPSA* LPWAVEINCAPSA;
  495. align(2) struct WAVEINCAPSW {
  496. WORD wMid; /* manufacturer ID */
  497. WORD wPid; /* product ID */
  498. MMVERSION vDriverVersion; /* version of the driver */
  499. WCHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  500. DWORD dwFormats; /* formats supported */
  501. WORD wChannels; /* number of channels supported */
  502. WORD wReserved1; /* align(2) structure packing */
  503. }
  504. alias WAVEINCAPSW* PWAVEINCAPSW;
  505. alias WAVEINCAPSW* NPWAVEINCAPSW;
  506. alias WAVEINCAPSW* LPWAVEINCAPSW;
  507. version(UNICODE) {
  508. alias WAVEINCAPSW WAVEINCAPS;
  509. alias PWAVEINCAPSW PWAVEINCAPS;
  510. alias NPWAVEINCAPSW NPWAVEINCAPS;
  511. alias LPWAVEINCAPSW LPWAVEINCAPS;
  512. }
  513. else {
  514. alias WAVEINCAPSA WAVEINCAPS;
  515. alias PWAVEINCAPSA PWAVEINCAPS;
  516. alias NPWAVEINCAPSA NPWAVEINCAPS;
  517. alias LPWAVEINCAPSA LPWAVEINCAPS;
  518. }
  519. align(2) struct WAVEINCAPS2A {
  520. WORD wMid; /* manufacturer ID */
  521. WORD wPid; /* product ID */
  522. MMVERSION vDriverVersion; /* version of the driver */
  523. CHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  524. DWORD dwFormats; /* formats supported */
  525. WORD wChannels; /* number of channels supported */
  526. WORD wReserved1; /* align(2) structure packing */
  527. GUID ManufacturerGuid; /* for extensible MID mapping */
  528. GUID ProductGuid; /* for extensible PID mapping */
  529. GUID NameGuid; /* for name lookup in registry */
  530. }
  531. alias WAVEINCAPS2A* PWAVEINCAPS2A;
  532. alias WAVEINCAPS2A* NPWAVEINCAPS2A;
  533. alias WAVEINCAPS2A* LPWAVEINCAPS2A;
  534. align(2) struct WAVEINCAPS2W {
  535. WORD wMid; /* manufacturer ID */
  536. WORD wPid; /* product ID */
  537. MMVERSION vDriverVersion; /* version of the driver */
  538. WCHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  539. DWORD dwFormats; /* formats supported */
  540. WORD wChannels; /* number of channels supported */
  541. WORD wReserved1; /* align(2) structure packing */
  542. GUID ManufacturerGuid; /* for extensible MID mapping */
  543. GUID ProductGuid; /* for extensible PID mapping */
  544. GUID NameGuid; /* for name lookup in registry */
  545. }
  546. alias WAVEINCAPS2W* PWAVEINCAPS2W;
  547. alias WAVEINCAPS2W* NPWAVEINCAPS2W;
  548. alias WAVEINCAPS2W* LPWAVEINCAPS2W;
  549. version(UNICODE) {
  550. alias WAVEINCAPS2W WAVEINCAPS2;
  551. alias PWAVEINCAPS2W PWAVEINCAPS2;
  552. alias NPWAVEINCAPS2W NPWAVEINCAPS2;
  553. alias LPWAVEINCAPS2W LPWAVEINCAPS2;
  554. }
  555. else {
  556. alias WAVEINCAPS2A WAVEINCAPS2;
  557. alias PWAVEINCAPS2A PWAVEINCAPS2;
  558. alias NPWAVEINCAPS2A NPWAVEINCAPS2;
  559. alias LPWAVEINCAPS2A LPWAVEINCAPS2;
  560. }
  561. /* defines for dwFormat field of WAVEINCAPS and WAVEOUTCAPS */
  562. const auto WAVE_INVALIDFORMAT = 0x00000000 ; /* invalid format */
  563. const auto WAVE_FORMAT_1M08 = 0x00000001 ; /* 11.025 kHz, Mono, 8-bit */
  564. const auto WAVE_FORMAT_1S08 = 0x00000002 ; /* 11.025 kHz, Stereo, 8-bit */
  565. const auto WAVE_FORMAT_1M16 = 0x00000004 ; /* 11.025 kHz, Mono, 16-bit */
  566. const auto WAVE_FORMAT_1S16 = 0x00000008 ; /* 11.025 kHz, Stereo, 16-bit */
  567. const auto WAVE_FORMAT_2M08 = 0x00000010 ; /* 22.05 kHz, Mono, 8-bit */
  568. const auto WAVE_FORMAT_2S08 = 0x00000020 ; /* 22.05 kHz, Stereo, 8-bit */
  569. const auto WAVE_FORMAT_2M16 = 0x00000040 ; /* 22.05 kHz, Mono, 16-bit */
  570. const auto WAVE_FORMAT_2S16 = 0x00000080 ; /* 22.05 kHz, Stereo, 16-bit */
  571. const auto WAVE_FORMAT_4M08 = 0x00000100 ; /* 44.1 kHz, Mono, 8-bit */
  572. const auto WAVE_FORMAT_4S08 = 0x00000200 ; /* 44.1 kHz, Stereo, 8-bit */
  573. const auto WAVE_FORMAT_4M16 = 0x00000400 ; /* 44.1 kHz, Mono, 16-bit */
  574. const auto WAVE_FORMAT_4S16 = 0x00000800 ; /* 44.1 kHz, Stereo, 16-bit */
  575. const auto WAVE_FORMAT_44M08 = 0x00000100 ; /* 44.1 kHz, Mono, 8-bit */
  576. const auto WAVE_FORMAT_44S08 = 0x00000200 ; /* 44.1 kHz, Stereo, 8-bit */
  577. const auto WAVE_FORMAT_44M16 = 0x00000400 ; /* 44.1 kHz, Mono, 16-bit */
  578. const auto WAVE_FORMAT_44S16 = 0x00000800 ; /* 44.1 kHz, Stereo, 16-bit */
  579. const auto WAVE_FORMAT_48M08 = 0x00001000 ; /* 48 kHz, Mono, 8-bit */
  580. const auto WAVE_FORMAT_48S08 = 0x00002000 ; /* 48 kHz, Stereo, 8-bit */
  581. const auto WAVE_FORMAT_48M16 = 0x00004000 ; /* 48 kHz, Mono, 16-bit */
  582. const auto WAVE_FORMAT_48S16 = 0x00008000 ; /* 48 kHz, Stereo, 16-bit */
  583. const auto WAVE_FORMAT_96M08 = 0x00010000 ; /* 96 kHz, Mono, 8-bit */
  584. const auto WAVE_FORMAT_96S08 = 0x00020000 ; /* 96 kHz, Stereo, 8-bit */
  585. const auto WAVE_FORMAT_96M16 = 0x00040000 ; /* 96 kHz, Mono, 16-bit */
  586. const auto WAVE_FORMAT_96S16 = 0x00080000 ; /* 96 kHz, Stereo, 16-bit */
  587. /* OLD general waveform format align(2) structure (information common to all formats) */
  588. align(2) struct WAVEFORMAT {
  589. WORD wFormatTag; /* format type */
  590. WORD nChannels; /* number of channels (i.e. mono, stereo, etc.) */
  591. DWORD nSamplesPerSec; /* sample rate */
  592. DWORD nAvgBytesPerSec; /* for buffer estimation */
  593. WORD nBlockAlign; /* block size of data */
  594. }
  595. alias WAVEFORMAT* PWAVEFORMAT;
  596. alias WAVEFORMAT *NPWAVEFORMAT;
  597. alias WAVEFORMAT* LPWAVEFORMAT;
  598. /* flags for wFormatTag field of WAVEFORMAT */
  599. const auto WAVE_FORMAT_PCM = 1;
  600. /* specific waveform format align(2) structure for PCM data */
  601. align(2) struct PCMWAVEFORMAT {
  602. WAVEFORMAT wf;
  603. WORD wBitsPerSample;
  604. }
  605. alias PCMWAVEFORMAT* PPCMWAVEFORMAT;
  606. alias PCMWAVEFORMAT *NPPCMWAVEFORMAT;
  607. alias PCMWAVEFORMAT* LPPCMWAVEFORMAT;
  608. /*
  609. * extended waveform format align(2) structure used for all non-PCM formats. this
  610. * align(2) structure is common to all non-PCM formats.
  611. */
  612. align(2) struct WAVEFORMATEX {
  613. WORD wFormatTag; /* format type */
  614. WORD nChannels; /* number of channels (i.e. mono, stereo...) */
  615. DWORD nSamplesPerSec; /* sample rate */
  616. DWORD nAvgBytesPerSec; /* for buffer estimation */
  617. WORD nBlockAlign; /* block size of data */
  618. WORD wBitsPerSample; /* number of bits per sample of mono data */
  619. WORD cbSize; /* the count in bytes of the size of */
  620. /* extra information (after cbSize) */
  621. }
  622. alias WAVEFORMATEX* PWAVEFORMATEX;
  623. alias WAVEFORMATEX *NPWAVEFORMATEX;
  624. alias WAVEFORMATEX* LPWAVEFORMATEX;
  625. alias WAVEFORMATEX *LPCWAVEFORMATEX;
  626. /* waveform audio function prototypes */
  627. UINT waveOutGetNumDevs();
  628. MMRESULT waveOutGetDevCapsA( UINT_PTR uDeviceID, LPWAVEOUTCAPSA pwoc, UINT cbwoc);
  629. MMRESULT waveOutGetDevCapsW( UINT_PTR uDeviceID, LPWAVEOUTCAPSW pwoc, UINT cbwoc);
  630. version(UNICODE) {
  631. alias waveOutGetDevCapsW waveOutGetDevCaps;
  632. }
  633. else {
  634. alias waveOutGetDevCapsA waveOutGetDevCaps;
  635. }
  636. MMRESULT waveOutGetVolume( HWAVEOUT hwo, LPDWORD pdwVolume);
  637. MMRESULT waveOutSetVolume( HWAVEOUT hwo, DWORD dwVolume);
  638. MMRESULT waveOutGetErrorTextA( MMRESULT mmrError, LPSTR pszText, UINT cchText);
  639. MMRESULT waveOutGetErrorTextW( MMRESULT mmrError, LPWSTR pszText, UINT cchText);
  640. version(UNICODE) {
  641. alias waveOutGetErrorTextW waveOutGetErrorText;
  642. }
  643. else {
  644. alias waveOutGetErrorTextA waveOutGetErrorText;
  645. }
  646. MMRESULT waveOutOpen( LPHWAVEOUT phwo, UINT uDeviceID,
  647. LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
  648. MMRESULT waveOutClose( HWAVEOUT hwo);
  649. MMRESULT waveOutPrepareHeader( HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
  650. MMRESULT waveOutUnprepareHeader( HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
  651. MMRESULT waveOutWrite( HWAVEOUT hwo, LPWAVEHDR pwh, UINT cbwh);
  652. MMRESULT waveOutPause( HWAVEOUT hwo);
  653. MMRESULT waveOutRestart( HWAVEOUT hwo);
  654. MMRESULT waveOutReset( HWAVEOUT hwo);
  655. MMRESULT waveOutBreakLoop( HWAVEOUT hwo);
  656. MMRESULT waveOutGetPosition( HWAVEOUT hwo, LPMMTIME pmmt, UINT cbmmt);
  657. MMRESULT waveOutGetPitch( HWAVEOUT hwo, LPDWORD pdwPitch);
  658. MMRESULT waveOutSetPitch( HWAVEOUT hwo, DWORD dwPitch);
  659. MMRESULT waveOutGetPlaybackRate( HWAVEOUT hwo, LPDWORD pdwRate);
  660. MMRESULT waveOutSetPlaybackRate( HWAVEOUT hwo, DWORD dwRate);
  661. MMRESULT waveOutGetID( HWAVEOUT hwo, LPUINT puDeviceID);
  662. MMRESULT waveOutMessage( HWAVEOUT hwo, UINT uMsg, DWORD_PTR dw1, DWORD_PTR dw2);
  663. UINT waveInGetNumDevs();
  664. MMRESULT waveInGetDevCapsA( UINT_PTR uDeviceID, LPWAVEINCAPSA pwic, UINT cbwic);
  665. MMRESULT waveInGetDevCapsW( UINT_PTR uDeviceID, LPWAVEINCAPSW pwic, UINT cbwic);
  666. version(UNICODE) {
  667. alias waveInGetDevCapsW waveInGetDevCaps;
  668. }
  669. else {
  670. alias waveInGetDevCapsA waveInGetDevCaps;
  671. }
  672. MMRESULT waveInGetErrorTextA(MMRESULT mmrError, LPSTR pszText, UINT cchText);
  673. MMRESULT waveInGetErrorTextW(MMRESULT mmrError, LPWSTR pszText, UINT cchText);
  674. version(UNICODE) {
  675. alias waveInGetErrorTextW waveInGetErrorText;
  676. }
  677. else {
  678. alias waveInGetErrorTextA waveInGetErrorText;
  679. }
  680. MMRESULT waveInOpen( LPHWAVEIN phwi, UINT uDeviceID,
  681. LPCWAVEFORMATEX pwfx, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
  682. MMRESULT waveInClose( HWAVEIN hwi);
  683. MMRESULT waveInPrepareHeader( HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
  684. MMRESULT waveInUnprepareHeader( HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
  685. MMRESULT waveInAddBuffer( HWAVEIN hwi, LPWAVEHDR pwh, UINT cbwh);
  686. MMRESULT waveInStart( HWAVEIN hwi);
  687. MMRESULT waveInStop( HWAVEIN hwi);
  688. MMRESULT waveInReset( HWAVEIN hwi);
  689. MMRESULT waveInGetPosition( HWAVEIN hwi, LPMMTIME pmmt, UINT cbmmt);
  690. MMRESULT waveInGetID( HWAVEIN hwi, LPUINT puDeviceID);
  691. MMRESULT waveInMessage( HWAVEIN hwi, UINT uMsg, DWORD_PTR dw1, DWORD_PTR dw2);
  692. }
  693. /****************************************************************************
  694. MIDI audio support
  695. ****************************************************************************/
  696. version(MMNOMIDI) {
  697. }
  698. else {
  699. /* MIDI error return values */
  700. const auto MIDIERR_UNPREPARED = (MIDIERR_BASE + 0) ; /* header not prepared */
  701. const auto MIDIERR_STILLPLAYING = (MIDIERR_BASE + 1) ; /* still something playing */
  702. const auto MIDIERR_NOMAP = (MIDIERR_BASE + 2) ; /* no configured instruments */
  703. const auto MIDIERR_NOTREADY = (MIDIERR_BASE + 3) ; /* hardware is still busy */
  704. const auto MIDIERR_NODEVICE = (MIDIERR_BASE + 4) ; /* port no longer connected */
  705. const auto MIDIERR_INVALIDSETUP = (MIDIERR_BASE + 5) ; /* invalid MIF */
  706. const auto MIDIERR_BADOPENMODE = (MIDIERR_BASE + 6) ; /* operation unsupported w/ open mode */
  707. const auto MIDIERR_DONT_CONTINUE = (MIDIERR_BASE + 7) ; /* thru device 'eating' a message */
  708. const auto MIDIERR_LASTERROR = (MIDIERR_BASE + 7) ; /* last error in range */
  709. /* MIDI audio data types */
  710. alias HANDLE HMIDI;
  711. alias HANDLE HMIDIIN;
  712. alias HANDLE HMIDIOUT;
  713. alias HANDLE HMIDISTRM;
  714. alias HMIDI *LPHMIDI;
  715. alias HMIDIIN *LPHMIDIIN;
  716. alias HMIDIOUT *LPHMIDIOUT;
  717. alias HMIDISTRM *LPHMIDISTRM;
  718. alias DRVCALLBACK MIDICALLBACK;
  719. alias MIDICALLBACK *LPMIDICALLBACK;
  720. const auto MIDIPATCHSIZE = 128;
  721. alias WORD[MIDIPATCHSIZE] PATCHARRAY;
  722. alias WORD *LPPATCHARRAY;
  723. alias WORD[MIDIPATCHSIZE] KEYARRAY;
  724. alias WORD *LPKEYARRAY;
  725. /* MIDI callback messages */
  726. const auto MIM_OPEN = MM_MIM_OPEN;
  727. const auto MIM_CLOSE = MM_MIM_CLOSE;
  728. const auto MIM_DATA = MM_MIM_DATA;
  729. const auto MIM_LONGDATA = MM_MIM_LONGDATA;
  730. const auto MIM_ERROR = MM_MIM_ERROR;
  731. const auto MIM_LONGERROR = MM_MIM_LONGERROR;
  732. const auto MOM_OPEN = MM_MOM_OPEN;
  733. const auto MOM_CLOSE = MM_MOM_CLOSE;
  734. const auto MOM_DONE = MM_MOM_DONE;
  735. const auto MIM_MOREDATA = MM_MIM_MOREDATA;
  736. const auto MOM_POSITIONCB = MM_MOM_POSITIONCB;
  737. /* device ID for MIDI mapper */
  738. const auto MIDIMAPPER = (cast(UINT)-1);
  739. const auto MIDI_MAPPER = (cast(UINT)-1);
  740. /* flags for dwFlags parm of midiInOpen() */
  741. const auto MIDI_IO_STATUS = 0x00000020L;
  742. /* flags for wFlags parm of midiOutCachePatches(), midiOutCacheDrumPatches() */
  743. const auto MIDI_CACHE_ALL = 1;
  744. const auto MIDI_CACHE_BESTFIT = 2;
  745. const auto MIDI_CACHE_QUERY = 3;
  746. const auto MIDI_UNCACHE = 4;
  747. /* MIDI output device capabilities align(2) structure */
  748. align(2) struct MIDIOUTCAPSA {
  749. WORD wMid; /* manufacturer ID */
  750. WORD wPid; /* product ID */
  751. MMVERSION vDriverVersion; /* version of the driver */
  752. CHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  753. WORD wTechnology; /* type of device */
  754. WORD wVoices; /* # of voices (internal synth only) */
  755. WORD wNotes; /* max # of notes (internal synth only) */
  756. WORD wChannelMask; /* channels used (internal synth only) */
  757. DWORD dwSupport; /* functionality supported by driver */
  758. }
  759. alias MIDIOUTCAPSA* PMIDIOUTCAPSA;
  760. alias MIDIOUTCAPSA* NPMIDIOUTCAPSA;
  761. alias MIDIOUTCAPSA* LPMIDIOUTCAPSA;
  762. align(2) struct MIDIOUTCAPSW {
  763. WORD wMid; /* manufacturer ID */
  764. WORD wPid; /* product ID */
  765. MMVERSION vDriverVersion; /* version of the driver */
  766. WCHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  767. WORD wTechnology; /* type of device */
  768. WORD wVoices; /* # of voices (internal synth only) */
  769. WORD wNotes; /* max # of notes (internal synth only) */
  770. WORD wChannelMask; /* channels used (internal synth only) */
  771. DWORD dwSupport; /* functionality supported by driver */
  772. }
  773. alias MIDIOUTCAPSW* PMIDIOUTCAPSW;
  774. alias MIDIOUTCAPSW* NPMIDIOUTCAPSW;
  775. alias MIDIOUTCAPSW* LPMIDIOUTCAPSW;
  776. version(UNICODE) {
  777. alias MIDIOUTCAPSW MIDIOUTCAPS;
  778. alias PMIDIOUTCAPSW PMIDIOUTCAPS;
  779. alias NPMIDIOUTCAPSW NPMIDIOUTCAPS;
  780. alias LPMIDIOUTCAPSW LPMIDIOUTCAPS;
  781. }
  782. else {
  783. alias MIDIOUTCAPSA MIDIOUTCAPS;
  784. alias PMIDIOUTCAPSA PMIDIOUTCAPS;
  785. alias NPMIDIOUTCAPSA NPMIDIOUTCAPS;
  786. alias LPMIDIOUTCAPSA LPMIDIOUTCAPS;
  787. }
  788. align(2) struct MIDIOUTCAPS2A {
  789. WORD wMid; /* manufacturer ID */
  790. WORD wPid; /* product ID */
  791. MMVERSION vDriverVersion; /* version of the driver */
  792. CHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  793. WORD wTechnology; /* type of device */
  794. WORD wVoices; /* # of voices (internal synth only) */
  795. WORD wNotes; /* max # of notes (internal synth only) */
  796. WORD wChannelMask; /* channels used (internal synth only) */
  797. DWORD dwSupport; /* functionality supported by driver */
  798. GUID ManufacturerGuid; /* for extensible MID mapping */
  799. GUID ProductGuid; /* for extensible PID mapping */
  800. GUID NameGuid; /* for name lookup in registry */
  801. }
  802. alias MIDIOUTCAPS2A* PMIDIOUTCAPS2A;
  803. alias MIDIOUTCAPS2A* NPMIDIOUTCAPS2A;
  804. alias MIDIOUTCAPS2A* LPMIDIOUTCAPS2A;
  805. align(2) struct MIDIOUTCAPS2W {
  806. WORD wMid; /* manufacturer ID */
  807. WORD wPid; /* product ID */
  808. MMVERSION vDriverVersion; /* version of the driver */
  809. WCHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  810. WORD wTechnology; /* type of device */
  811. WORD wVoices; /* # of voices (internal synth only) */
  812. WORD wNotes; /* max # of notes (internal synth only) */
  813. WORD wChannelMask; /* channels used (internal synth only) */
  814. DWORD dwSupport; /* functionality supported by driver */
  815. GUID ManufacturerGuid; /* for extensible MID mapping */
  816. GUID ProductGuid; /* for extensible PID mapping */
  817. GUID NameGuid; /* for name lookup in registry */
  818. }
  819. alias MIDIOUTCAPS2W* PMIDIOUTCAPS2W;
  820. alias MIDIOUTCAPS2W* NPMIDIOUTCAPS2W;
  821. alias MIDIOUTCAPS2W* LPMIDIOUTCAPS2W;
  822. version(UNICODE) {
  823. alias MIDIOUTCAPS2W MIDIOUTCAPS2;
  824. alias PMIDIOUTCAPS2W PMIDIOUTCAPS2;
  825. alias NPMIDIOUTCAPS2W NPMIDIOUTCAPS2;
  826. alias LPMIDIOUTCAPS2W LPMIDIOUTCAPS2;
  827. }
  828. else {
  829. alias MIDIOUTCAPS2A MIDIOUTCAPS2;
  830. alias PMIDIOUTCAPS2A PMIDIOUTCAPS2;
  831. alias NPMIDIOUTCAPS2A NPMIDIOUTCAPS2;
  832. alias LPMIDIOUTCAPS2A LPMIDIOUTCAPS2;
  833. }
  834. /* flags for wTechnology field of MIDIOUTCAPS align(2) structure */
  835. const auto MOD_MIDIPORT = 1 ; /* output port */
  836. const auto MOD_SYNTH = 2 ; /* generic internal synth */
  837. const auto MOD_SQSYNTH = 3 ; /* square wave internal synth */
  838. const auto MOD_FMSYNTH = 4 ; /* FM internal synth */
  839. const auto MOD_MAPPER = 5 ; /* MIDI mapper */
  840. const auto MOD_WAVETABLE = 6 ; /* hardware wavetable synth */
  841. const auto MOD_SWSYNTH = 7 ; /* software synth */
  842. /* flags for dwSupport field of MIDIOUTCAPS align(2) structure */
  843. const auto MIDICAPS_VOLUME = 0x0001 ; /* supports volume control */
  844. const auto MIDICAPS_LRVOLUME = 0x0002 ; /* separate left-right volume control */
  845. const auto MIDICAPS_CACHE = 0x0004;
  846. const auto MIDICAPS_STREAM = 0x0008 ; /* driver supports midiStreamOut directly */
  847. /* MIDI input device capabilities align(2) structure */
  848. align(2) struct MIDIINCAPSA {
  849. WORD wMid; /* manufacturer ID */
  850. WORD wPid; /* product ID */
  851. MMVERSION vDriverVersion; /* version of the driver */
  852. CHAR szPname[MAXPNAMELEN]; /* product name (NULL terminated string) */
  853. DWORD dwSupport; /* functionality supported by driver */
  854. }
  855. alias MIDIINCAPSA* PMIDIINCAPSA;
  856. alias MIDIINCAPSA* NPMIDIINCAPSA;
  857. alias MIDIINCAPSA* LPMIDIINCAPSA;
  858. align(2) struct MIDIINCAPSW {
  859. WORD wMid; /* manufacturer ID */
  860. WORD wPid; /* product ID */
  861. MMVERSION vDriverVersion; /* version of the driver */
  862. WCHAR szPname[MAXPNAMELEN]; /* product name (NULL terminated string) */
  863. DWORD dwSupport; /* functionality supported by driver */
  864. }
  865. alias MIDIINCAPSW* PMIDIINCAPSW;
  866. alias MIDIINCAPSW* NPMIDIINCAPSW;
  867. alias MIDIINCAPSW* LPMIDIINCAPSW;
  868. version(UNICODE) {
  869. alias MIDIINCAPSW MIDIINCAPS;
  870. alias PMIDIINCAPSW PMIDIINCAPS;
  871. alias NPMIDIINCAPSW NPMIDIINCAPS;
  872. alias LPMIDIINCAPSW LPMIDIINCAPS;
  873. }
  874. else {
  875. alias MIDIINCAPSA MIDIINCAPS;
  876. alias PMIDIINCAPSA PMIDIINCAPS;
  877. alias NPMIDIINCAPSA NPMIDIINCAPS;
  878. alias LPMIDIINCAPSA LPMIDIINCAPS;
  879. }
  880. align(2) struct MIDIINCAPS2A {
  881. WORD wMid; /* manufacturer ID */
  882. WORD wPid; /* product ID */
  883. MMVERSION vDriverVersion; /* version of the driver */
  884. CHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  885. DWORD dwSupport; /* functionality supported by driver */
  886. GUID ManufacturerGuid; /* for extensible MID mapping */
  887. GUID ProductGuid; /* for extensible PID mapping */
  888. GUID NameGuid; /* for name lookup in registry */
  889. }
  890. alias MIDIINCAPS2A* PMIDIINCAPS2A;
  891. alias MIDIINCAPS2A* NPMIDIINCAPS2A;
  892. alias MIDIINCAPS2A* LPMIDIINCAPS2A;
  893. align(2) struct MIDIINCAPS2W {
  894. WORD wMid; /* manufacturer ID */
  895. WORD wPid; /* product ID */
  896. MMVERSION vDriverVersion; /* version of the driver */
  897. WCHAR[MAXPNAMELEN] szPname; /* product name (NULL terminated string) */
  898. DWORD dwSupport; /* functionality supported by driver */
  899. GUID ManufacturerGuid; /* for extensible MID mapping */
  900. GUID ProductGuid; /* for extensible PID mapping */
  901. GUID NameGuid; /* for name lookup in registry */
  902. }
  903. alias MIDIINCAPS2W* PMIDIINCAPS2W;
  904. alias MIDIINCAPS2W* NPMIDIINCAPS2W;
  905. alias MIDIINCAPS2W* LPMIDIINCAPS2W;
  906. version(UNICODE) {
  907. alias MIDIINCAPS2W MIDIINCAPS2;
  908. alias PMIDIINCAPS2W PMIDIINCAPS2;
  909. alias NPMIDIINCAPS2W NPMIDIINCAPS2;
  910. alias LPMIDIINCAPS2W LPMIDIINCAPS2;
  911. }
  912. else {
  913. alias MIDIINCAPS2A MIDIINCAPS2;
  914. alias PMIDIINCAPS2A PMIDIINCAPS2;
  915. alias NPMIDIINCAPS2A NPMIDIINCAPS2;
  916. alias LPMIDIINCAPS2A LPMIDIINCAPS2;
  917. }
  918. /* MIDI data block header */
  919. align(2) struct MIDIHDR {
  920. LPSTR lpData; /* pointer to locked data block */
  921. DWORD dwBufferLength; /* length of data in data block */
  922. DWORD dwBytesRecorded; /* used for input only */
  923. DWORD_PTR dwUser; /* for client's use */
  924. DWORD dwFlags; /* assorted flags (see defines) */
  925. MIDIHDR* lpNext; /* reserved for driver */
  926. DWORD_PTR reserved; /* reserved for driver */
  927. DWORD dwOffset; /* Callback offset into buffer */
  928. DWORD_PTR[8] dwReserved; /* Reserved for MMSYSTEM */
  929. }
  930. alias MIDIHDR* PMIDIHDR;
  931. alias MIDIHDR *NPMIDIHDR;
  932. alias MIDIHDR* LPMIDIHDR;
  933. align(2) struct MIDIEVENT {
  934. DWORD dwDeltaTime; /* Ticks since last event */
  935. DWORD dwStreamID; /* Reserved; must be zero */
  936. DWORD dwEvent; /* Event type and parameters */
  937. DWORD[1] dwParms; /* Parameters if this is a long event */
  938. }
  939. align(2) struct MIDISTRMBUFFVER {
  940. DWORD dwVersion; /* Stream buffer format version */
  941. DWORD dwMid; /* Manufacturer ID as defined in MMREG.H */
  942. DWORD dwOEMVersion; /* Manufacturer version for custom ext */
  943. }
  944. /* flags for dwFlags field of MIDIHDR align(2) structure */
  945. const auto MHDR_DONE = 0x00000001 ; /* done bit */
  946. const auto MHDR_PREPARED = 0x00000002 ; /* set if header prepared */
  947. const auto MHDR_INQUEUE = 0x00000004 ; /* reserved for driver */
  948. const auto MHDR_ISSTRM = 0x00000008 ; /* Buffer is stream buffer */
  949. /* */
  950. /* Type codes which go in the high byte of the event DWORD of a stream buffer */
  951. /* */
  952. /* Type codes 00-7F contain parameters within the low 24 bits */
  953. /* Type codes 80-FF contain a length of their parameter in the low 24 */
  954. /* bits, followed by their parameter data in the buffer. The event */
  955. /* DWORD contains the exact byte length; the parm data itself must be */
  956. /* padded to be an even multiple of 4 bytes long. */
  957. /* */
  958. const auto MEVT_F_SHORT = 0x00000000L;
  959. const auto MEVT_F_LONG = 0x80000000L;
  960. const auto MEVT_F_CALLBACK = 0x40000000L;
  961. template MEVT_EVENTTYPE(DWORD x) {
  962. const auto MEVT_EVENTTYPE = (cast(BYTE)(((x)>>24)&0xFF));
  963. }
  964. template MEVT_EVENTPARM(DWORD x) {
  965. const auto MEVT_EVENTPARM = (cast(DWORD)((x)&0x00FFFFFFL));
  966. }
  967. const auto MEVT_SHORTMSG = (cast(BYTE)0x00) ; /* parm = shortmsg for midiOutShortMsg */
  968. const auto MEVT_TEMPO = (cast(BYTE)0x01) ; /* parm = new tempo in microsec/qn */
  969. const auto MEVT_NOP = (cast(BYTE)0x02) ; /* parm = unused; does nothing */
  970. /* 0x04-0x7F reserved */
  971. const auto MEVT_LONGMSG = (cast(BYTE)0x80) ; /* parm = bytes to send verbatim */
  972. const auto MEVT_COMMENT = (cast(BYTE)0x82) ; /* parm = comment data */
  973. const auto MEVT_VERSION = (cast(BYTE)0x84) ; /* parm = MIDISTRMBUFFVER align(2) struct */
  974. /* 0x81-0xFF reserved */
  975. const auto MIDISTRM_ERROR = (-2);
  976. /* */
  977. /* Structures and defines for midiStreamProperty */
  978. /* */
  979. const auto MIDIPROP_SET = 0x80000000L;
  980. const auto MIDIPROP_GET = 0x40000000L;
  981. /* These are intentionally both non-zero so the app cannot accidentally */
  982. /* leave the operation off and happen to appear to work due to default */
  983. /* action. */
  984. const auto MIDIPROP_TIMEDIV = 0x00000001L;
  985. const auto MIDIPROP_TEMPO = 0x00000002L;
  986. align(2) struct MIDIPROPTIMEDIV {
  987. DWORD cbStruct;
  988. DWORD dwTimeDiv;
  989. }
  990. alias MIDIPROPTIMEDIV* LPMIDIPROPTIMEDIV;
  991. align(2) struct MIDIPROPTEMPO {
  992. DWORD cbStruct;
  993. DWORD dwTempo;
  994. }
  995. alias MIDIPROPTEMPO* LPMIDIPROPTEMPO;
  996. /* MIDI function prototypes */
  997. UINT midiOutGetNumDevs();
  998. MMRESULT midiStreamOpen( LPHMIDISTRM phms, LPUINT puDeviceID, DWORD cMidi, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen);
  999. MMRESULT midiStreamClose( HMIDISTRM hms);
  1000. MMRESULT midiStreamProperty( HMIDISTRM hms, LPBYTE lppropdata, DWORD dwProperty);
  1001. MMRESULT midiStreamPosition( HMIDISTRM hms, LPMMTIME lpmmt, UINT cbmmt);
  1002. MMRESULT midiStreamOut( HMIDISTRM hms, LPMIDIH