PageRenderTime 110ms CodeModel.GetById 4ms app.highlight 92ms RepoModel.GetById 1ms app.codeStats 1ms

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

Large files files are truncated, but you can click here to view the full file