' api_mmsys.sbp
' Include file for Multimedia API's


#ifndef _INC_MMSYS
#define _INC_MMSYS


' general constants
Const MAXPNAMELEN            = 32
Const MAXERRORLENGTH         = 256
Const MAX_JOYSTICKOEMVXDNAME = 260

Const MM_MIDI_MAPPER        =  1
Const MM_WAVE_MAPPER        =  2
Const MM_SNDBLST_MIDIOUT    =  3
Const MM_SNDBLST_MIDIIN     =  4
Const MM_SNDBLST_SYNTH      =  5
Const MM_SNDBLST_WAVEOUT    =  6
Const MM_SNDBLST_WAVEIN     =  7
Const MM_ADLIB              =  9
Const MM_MPU401_MIDIOUT     = 10
Const MM_MPU401_MIDIIN      = 11
Const MM_PC_JOYSTICK        = 12

' general data types
TypeDef MMVERSION = DWord
TypeDef VERSION = DWord
TypeDef MMRESULT = DWord

' MMTIME data structure

Type Smpte
	hour As Byte
	min As Byte
	sec As Byte
	frame As Byte
	fps As Byte
	dummy As Byte
	pad[ELM(2)] As Byte
End Type

Type Midi
	songptrpos As DWord
End Type

Type MMTIME
Public
	wType As DWord
	u As DWord
/* union
	ms As DWord
	sample As DWord
	cb As DWord
	ticks As DWord
	smpte As Smpte
	midi As Midi
*/
End Type
TypeDef PMMTIME = *MMTIME
TypeDef LPMMTIME = *MMTIME

Const MAKEFOURCC(ch0, ch1, ch2, ch3) = (((ch0 As Byte) or ((ch1 As Byte)<<8) or ((ch2 As Byte)<<16) or ((ch3 As Byte)<<24)) As DWord)

' types for wType field in MMTIME struct
Const TIME_MS        = &H0001
Const TIME_SAMPLES   = &H0002
Const TIME_BYTES     = &H0004
Const TIME_SMPTE     = &H0008
Const TIME_MIDI      = &H0010
Const TIME_TICKS     = &H0020

'----------------------------------------
' Multimedia Extensions Window Messages

Const MM_JOY1MOVE =       &H3A0			'joystick
Const MM_JOY2MOVE =       &H3A1
Const MM_JOY1ZMOVE =      &H3A2
Const MM_JOY2ZMOVE =      &H3A3
Const MM_JOY1BUTTONDOWN = &H3B5
Const MM_JOY2BUTTONDOWN = &H3B6
Const MM_JOY1BUTTONUP =   &H3B7
Const MM_JOY2BUTTONUP =   &H3B8

Const MM_MCINOTIFY =      &H3B9			'MCI

Const MM_WOM_OPEN =       &H3BB			'waveform output
Const MM_WOM_CLOSE =      &H3BC
Const MM_WOM_DONE =       &H3BD

Const MM_WIM_OPEN =       &H3BE			'waveform input
Const MM_WIM_CLOSE =      &H3BF
Const MM_WIM_DATA =       &H3C0

Const MM_MIM_OPEN =       &H3C1			'MIDI input
Const MM_MIM_CLOSE =      &H3C2
Const MM_MIM_DATA =       &H3C3
Const MM_MIM_LONGDATA =   &H3C4
Const MM_MIM_ERROR =      &H3C5
Const MM_MIM_LONGERROR =  &H3C6

Const MM_MOM_OPEN =       &H3C7			'MIDI output
Const MM_MOM_CLOSE =      &H3C8
Const MM_MOM_DONE =       &H3C9

Const MM_DRVM_OPEN =      &H3D0			'installable drivers
Const MM_DRVM_CLOSE =     &H3D1
Const MM_DRVM_DATA =      &H3D2
Const MM_DRVM_ERROR =     &H3D3

Const MM_STREAM_OPEN	 =  &H3D4
Const MM_STREAM_CLOSE	 =  &H3D5
Const MM_STREAM_DONE	 =  &H3D6
Const MM_STREAM_ERROR	 =  &H3D7

Const MM_MOM_POSITIONCB = &H3CA

Const MM_MCISIGNAL =      &H3CB

Const MM_MIM_MOREDATA =   &H3CC			'MIM_DONE w/ pending events

Const MM_MIXM_LINE_CHANGE =   &H3D0		'mixer line change notify
Const MM_MIXM_CONTROL_CHANGE =&H3D1		'mixer control change notify


'----------------------------------------------
' String resource number bases (internal use)

Const MMSYSERR_BASE =        0
Const WAVERR_BASE =          32
Const MIDIERR_BASE =         64
Const TIMERR_BASE =          96
Const JOYERR_BASE =          160
Const MCIERR_BASE =          256
Const MIXERR_BASE =          1024

Const MCI_STRING_OFFSET =    512
Const MCI_VD_OFFSET =        1024
Const MCI_CD_OFFSET =        1088
Const MCI_WAVE_OFFSET =      1152
Const MCI_SEQ_OFFSET =       1216


'----------------------------------------------
' General error return values

Const MMSYSERR_NOERROR     = 0                    'no error
Const MMSYSERR_ERROR       = (MMSYSERR_BASE + 1)  'unspecified error
Const MMSYSERR_BADDEVICEID = (MMSYSERR_BASE + 2)  'device ID out of range
Const MMSYSERR_NOTENABLED  = (MMSYSERR_BASE + 3)  'driver failed enable
Const MMSYSERR_ALLOCATED   = (MMSYSERR_BASE + 4)  'device already allocated
Const MMSYSERR_INVALHANDLE = (MMSYSERR_BASE + 5)  'device handle is invalid
Const MMSYSERR_NODRIVER    = (MMSYSERR_BASE + 6)  'no device driver present
Const MMSYSERR_NOMEM       = (MMSYSERR_BASE + 7)  'memory allocation error
Const MMSYSERR_NOTSUPPORTED= (MMSYSERR_BASE + 8)  'function isn't supported
Const MMSYSERR_BADERRNUM   = (MMSYSERR_BASE + 9)  'error value out of range
Const MMSYSERR_INVALFLAG   = (MMSYSERR_BASE + 10) 'invalid flag passed
Const MMSYSERR_INVALPARAM  = (MMSYSERR_BASE + 11) 'invalid parameter passed
Const MMSYSERR_HANDLEBUSY  = (MMSYSERR_BASE + 12) 'handle being used
Const MMSYSERR_INVALIDALIAS= (MMSYSERR_BASE + 13) 'specified alias not found
Const MMSYSERR_BADDB       = (MMSYSERR_BASE + 14) 'bad registry database
Const MMSYSERR_KEYNOTFOUND = (MMSYSERR_BASE + 15) 'registry key not found
Const MMSYSERR_READERROR   = (MMSYSERR_BASE + 16) 'registry read error
Const MMSYSERR_WRITEERROR  = (MMSYSERR_BASE + 17) 'registry write error
Const MMSYSERR_DELETEERROR = (MMSYSERR_BASE + 18) 'registry delete error
Const MMSYSERR_VALNOTFOUND = (MMSYSERR_BASE + 19) 'registry value not found
Const MMSYSERR_NODRIVERCB  = (MMSYSERR_BASE + 20) 'driver does not call DriverCallback
Const MMSYSERR_LASTERROR   = (MMSYSERR_BASE + 20) 'last error in range


'--------------------------------------------------------
' Installable driver support

Type _System_DeclareHandle_HDRVR:unused As DWord:End Type
TypeDef HDRVR = *_System_DeclareHandle_HDRVR

Type DRVCONFIGINFOEX
	dwDCISize As DWord
	lpszDCISectionName As LPCWSTR
	lpszDCIAliasName As LPCWSTR
	dnDevNode As DWORD
End Type
TypeDef PDRVCONFIGINFOEX = *DRVCONFIGINFOEX
TypeDef LPDRVCONFIGINFOEX = *DRVCONFIGINFOEX

' Driver messages
Const DRV_LOAD                = &H0001
Const DRV_ENABLE              = &H0002
Const DRV_OPEN                = &H0003
Const DRV_CLOSE               = &H0004
Const DRV_DISABLE             = &H0005
Const DRV_FREE                = &H0006
Const DRV_CONFIGURE           = &H0007
Const DRV_QUERYCONFIGURE      = &H0008
Const DRV_INSTALL             = &H0009
Const DRV_REMOVE              = &H000A
Const DRV_EXITSESSION         = &H000B
Const DRV_POWER               = &H000F
Const DRV_RESERVED            = &H0800
Const DRV_USER                = &H4000

Type DRVCONFIGINFO
	dwDCISize As DWord
	lpszDCISectionName As LPCWSTR
	lpszDCIAliasName As LPCWSTR
End Type
TypeDef PDRVCONFIGINFO = *DRVCONFIGINFO
TypeDef LPDRVCONFIGINFO = *DRVCONFIGINFO

' Supported return values for DRV_CONFIGURE message
Const DRVCNF_CANCEL           = &H0000
Const DRVCNF_OK               = &H0001
Const DRVCNF_RESTART          = &H0002

TypeDef DRIVERPROC = *Function(dwDriverId As DWord, hdrvr As HDRVR, msg As DWord, lParam1 As LPARAM, lParam2 As LPARAM) As LRESULT

Declare Function CloseDriver Lib "winmm" (hDriver As HDRVR, lParam1 As Long, lParam2 As Long) As LRESULT
Declare Function OpenDriver Lib "winmm" (szDriverName As LPCWSTR, szSectionName As LPCWSTR, lParam2 As Long) As HDRVR
Declare Function SendDriverMessage Lib "winmm" (hDriver As HDRVR, message As DWord, lParam1 As Long, lParam2 As Long) As LRESULT
Declare Function GetDriverModuleHandle Lib "winmm" (hDriver As HDRVR) As HMODULE
Declare Function DefDriverProc Lib "winmm" (dwDriverIdentifier As DWord, hdrvr As HDRVR, uMsg As DWord, lParam1 As LPARAM, lParam2 As LPARAM) As LRESULT

Declare Function DrvClose Lib "winmm" Alias "CloseDriver" (hDriver As HDRVR, lParam1 As Long, lParam2 As Long) As LRESULT
Declare Function DrvOpen Lib "winmm" Alias "OpenDriver" (szDriverName As LPCWSTR, szSectionName As LPCWSTR, lParam2 As Long) As HDRVR
Declare Function DrvSendMessage Lib "winmm" Alias "SendDriverMessage" (hDriver As HDRVR, message As DWord, lParam1 As Long, lParam2 As Long) As LRESULT
Declare Function DrvGetModuleHandle Lib "winmm" Alias "GetDriverModuleHandle" (hDriver As HDRVR) As HMODULE
Declare Function DrvDefDriverProc Lib "winmm" Alias "DefDriverProc" (dwDriverIdentifier As DWord, hdrvr As HDRVR, uMsg As DWord, lParam1 As LPARAM, lParam2 As LPARAM) As LRESULT

' return values from DriverProc() function
Const DRV_CANCEL            = DRVCNF_CANCEL
Const DRV_OK                = DRVCNF_OK
Const DRV_RESTART           = DRVCNF_RESTART

Const DRV_MCI_FIRST         = DRV_RESERVED
Const DRV_MCI_LAST          = (DRV_RESERVED + &HFFF)


'--------------------------------------------------------
' Driver callback support
Const CALLBACK_TYPEMASK  = &H00070000     'callback type mask
Const CALLBACK_NULL      = &H00000000     'no callback
Const CALLBACK_WINDOW    = &H00010000     'dwCallback is a HWND
Const CALLBACK_TASK      = &H00020000     'dwCallback is a HTASK
Const CALLBACK_FUNCTION  = &H00030000     'dwCallback is a FARPROC
Const CALLBACK_THREAD    = (CALLBACK_TASK)'thread ID replaces 16 bit task
Const CALLBACK_EVENT     = &H00050000     'dwCallback is an EVENT Handle

TypeDef DRVCALLBACK = *Sub(hdrvr As HDRVR, uMsg As DWord, dwUser As DWord, dw1 As DWord, dw2 As DWord)
TypeDef PDRVCALLBACK = *DRVCALLBACK
TypeDef LPDRVCALLBACK = *DRVCALLBACK


'--------------------------------------------------------
' General MMSYSTEM support

Declare Function mmsystemGetVersion Lib "winmm" () As DWord



'--------------------------------------------------------
' Sound support

#ifdef UNICODE
Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundW" (pszSound As PCWSTR, fuSound As DWord) As BOOL
#else
Declare Function sndPlaySound Lib "winmm" Alias "sndPlaySoundA" (pszSound As PCSTR, fuSound As DWord) As BOOL
#endif

Const SND_SYNC = &H0000
Const SND_ASYNC = &H0001
Const SND_NODEFAULT = &H0002
Const SND_MEMORY = &H0004
Const SND_LOOP = &H0008
Const SND_NOSTOP = &H0010
Const SND_NOWAIT = &H00002000
Const SND_ALIAS = &H00010000
Const SND_ALIAS_ID = &H00110000
Const SND_FILENAME = &H00020000
Const SND_RESOURCE = &H00040004
Const SND_PURGE = &H0040
Const SND_APPLICATION = &H0080
Const SND_ALIAS_START = 0

Const sndAlias(ch0, ch1) = (SND_ALIAS_START + ((&HFF AND ch0) OR (&HFF AND ch1)<<8))

Const SND_ALIAS_SYSTEMASTERISK = sndAlias(&H53, &H2A)
Const SND_ALIAS_SYSTEMQUESTION = sndAlias(&H53, &H3F)
Const SND_ALIAS_SYSTEMHAND = sndAlias(&H53, &H48)
Const SND_ALIAS_SYSTEMEXIT = sndAlias(&H53, &H45)
Const SND_ALIAS_SYSTEMSTART = sndAlias(&H53, &H53)
Const SND_ALIAS_SYSTEMWELCOME = sndAlias(&H53, &H57)
Const SND_ALIAS_SYSTEMEXCLAMATION = sndAlias(&H53, &H21)
Const SND_ALIAS_SYSTEMDEFAULT = sndAlias(&H53, &H44)

#ifdef UNICODE
Declare Function PlaySound Lib "winmm" Alias "PlaySoundW" (pszSound As PCWSTR, hmod As HMODULE, fdwSound As DWord) As BOOL
#else
Declare Function PlaySound Lib "winmm" Alias "PlaySoundA" (pszSound As PCSTR, hmod As HMODULE, fdwSound As DWord) As BOOL
#endif


'--------------------------------------------------------
' Waveform audio support

' waveform audio error return values
Const WAVERR_BADFORMAT    = (WAVERR_BASE + 0)
Const WAVERR_STILLPLAYING = (WAVERR_BASE + 1)
Const WAVERR_UNPREPARED   = (WAVERR_BASE + 2)
Const WAVERR_SYNC         = (WAVERR_BASE + 3)
Const WAVERR_LASTERROR    = (WAVERR_BASE + 3)

' waveform audio data types
Type _System_DeclareHandle_HWAVE:unused As DWord:End Type
TypeDef HWAVE = *_System_DeclareHandle_HWAVE
Type _System_DeclareHandle_HWAVEIN:unused As DWord:End Type
TypeDef HWAVEIN = *_System_DeclareHandle_HWAVEIN
Type _System_DeclareHandle_HWAVEOUT:unused As DWord:End Type
TypeDef HWAVEOUT = *_System_DeclareHandle_HWAVEOUT

TypeDef WAVECALLBACK = DRVCALLBACK
TypeDef LPWAVECALLBACK = *WAVECALLBACK

' wave callback messages
Const WOM_OPEN = MM_WOM_OPEN
Const WOM_CLOSE = MM_WOM_CLOSE
Const WOM_DONE = MM_WOM_DONE
Const WIM_OPEN = MM_WIM_OPEN
Const WIM_CLOSE = MM_WIM_CLOSE
Const WIM_DATA = MM_WIM_DATA

' device ID for wave device mapper
Const WAVE_MAPPER = (-1)

' flags for dwFlags parameter in waveOutOpen() and waveInOpen()
Const WAVE_FORMAT_QUERY = &H0001
Const WAVE_ALLOWSYNC = &H0002
Const WAVE_MAPPED = &H0004
Const WAVE_FORMAT_DIRECT = &H0008
Const WAVE_FORMAT_DIRECT_QUERY = (WAVE_FORMAT_QUERY OR WAVE_FORMAT_DIRECT)

' wave data block header
Type WAVEHDR
	lpData As LPSTR
	dwBufferLength As DWord
	dwBytesRecorded As DWord
	dwUser As DWord
	dwFlags As DWord
	dwLoops As DWord
	lpNext As *WAVEHDR
	reserved As DWord
End Type
TypeDef PWAVEHDR = *WAVEHDR
TypeDef LPWAVEHDR = *WAVEHDR

' flags for dwFlags field of WAVEHDR
Const WHDR_DONE = &H00000001
Const WHDR_PREPARED = &H00000002
Const WHDR_BEGINLOOP = &H00000004
Const WHDR_ENDLOOP = &H00000008
Const WHDR_INQUEUE = &H00000010

' waveform output device capabilities structure
Type WAVEOUTCAPSW
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As WCHAR
	dwFormats As DWord
	wChannels As Word
	wReserved1 As Word
	dwSupport As DWord
End Type
TypeDef PWAVEOUTCAPSW = *WAVEOUTCAPSW
TypeDef LPWAVEOUTCAPSW = *WAVEOUTCAPSW

Type WAVEOUTCAPSA
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As SByte
	dwFormats As DWord
	wChannels As Word
	wReserved1 As Word
	dwSupport As DWord
End Type
TypeDef PWAVEOUTCAPSA = *WAVEOUTCAPSA
TypeDef LPWAVEOUTCAPSA = *WAVEOUTCAPSA

#ifdef UNICODE
TypeDef WAVEOUTCAPS = WAVEOUTCAPSW
TypeDef PWAVEOUTCAPS = PWAVEOUTCAPSW
TypeDef LPWAVEOUTCAPS = LPWAVEOUTCAPSW
#else
TypeDef WAVEOUTCAPS = WAVEOUTCAPSA
TypeDef PWAVEOUTCAPS = PWAVEOUTCAPSA
TypeDef LPWAVEOUTCAPS = LPWAVEOUTCAPSA
#endif

' flags for dwSupport field of WAVEOUTCAPS
Const WAVECAPS_PITCH = &H0001
Const WAVECAPS_PLAYBACKRATE = &H0002
Const WAVECAPS_VOLUME = &H0004
Const WAVECAPS_LRVOLUME = &H0008
Const WAVECAPS_SYNC = &H0010
Const WAVECAPS_SAMPLEACCURATE = &H0020
Const WAVECAPS_DIRECTSOUND = &H0040

' waveform input device capabilities structure
Type WAVEINCAPSW
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As WCHAR
	dwFormats As DWord
	wChannels As Word
	wReserved1 As Word
End Type
TypeDef PWAVEINCAPSW = *WAVEINCAPSW
TypeDef LPWAVEINCAPSW = *WAVEINCAPSW

Type WAVEINCAPSA
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As SByte
	dwFormats As DWord
	wChannels As Word
	wReserved1 As Word
End Type
TypeDef PWAVEINCAPSA = *WAVEINCAPSA
TypeDef LPWAVEINCAPSA = *WAVEINCAPSA

#ifdef UNICODE
TypeDef WAVEINCAPS = WAVEINCAPSW
TypeDef PWAVEINCAPS = PWAVEINCAPSW
TypeDef LPWAVEINCAPS = LPWAVEINCAPSW
#else
TypeDef WAVEINCAPS = WAVEINCAPSA
TypeDef PWAVEINCAPS = PWAVEINCAPSA
TypeDef LPWAVEINCAPS = LPWAVEINCAPSA
#endif

' defines for dwFormat field of WAVEINCAPS and WAVEOUTCAPS
Const WAVE_INVALIDFORMAT     = &H00000000       ' invalid format
Const WAVE_FORMAT_1M08       = &H00000001       ' 11.025 kHz, Mono,   8-bit 
Const WAVE_FORMAT_1S08       = &H00000002       ' 11.025 kHz, Stereo, 8-bit 
Const WAVE_FORMAT_1M16       = &H00000004       ' 11.025 kHz, Mono,   16-bit
Const WAVE_FORMAT_1S16       = &H00000008       ' 11.025 kHz, Stereo, 16-bit
Const WAVE_FORMAT_2M08       = &H00000010       ' 22.05  kHz, Mono,   8-bit 
Const WAVE_FORMAT_2S08       = &H00000020       ' 22.05  kHz, Stereo, 8-bit 
Const WAVE_FORMAT_2M16       = &H00000040       ' 22.05  kHz, Mono,   16-bit
Const WAVE_FORMAT_2S16       = &H00000080       ' 22.05  kHz, Stereo, 16-bit
Const WAVE_FORMAT_4M08       = &H00000100       ' 44.1   kHz, Mono,   8-bit 
Const WAVE_FORMAT_4S08       = &H00000200       ' 44.1   kHz, Stereo, 8-bit 
Const WAVE_FORMAT_4M16       = &H00000400       ' 44.1   kHz, Mono,   16-bit
Const WAVE_FORMAT_4S16       = &H00000800       ' 44.1   kHz, Stereo, 16-bit

' OLD general waveform format structure (information common to all formats)
Type Align(1) WAVEFORMAT
	wFormatTag As Word
	nChannels As Word
	nSamplesPerSec As DWord
	nAvgBytesPerSec As DWord
	nBlockAlign As Word
End Type
TypeDef PWAVEFORMAT = *WAVEFORMAT
TypeDef LPWAVEFORMAT = *WAVEFORMAT

' flags for wFormatTag field of WAVEFORMAT
Const WAVE_FORMAT_PCM = 1

' specific waveform format structure for PCM data
Type Align(1) PCMWAVEFORMAT
	wf As WAVEFORMAT
	wBitsPerSample As Word
End Type
TypeDef PPCMWAVEFORMAT = *PCMWAVEFORMAT
TypeDef LPPCMWAVEFORMAT = *PCMWAVEFORMAT

Type Align(1) WAVEFORMATEX
	wFormatTag As Word
	nChannels As Word
	nSamplesPerSec As DWord
	nAvgBytesPerSec As DWord
	nBlockAlign As Word
	wBitsPerSample As Word
	cbSize As Word
End Type
TypeDef PWAVEFORMATEX = *WAVEFORMATEX
TypeDef LPWAVEFORMATEX = *WAVEFORMATEX
TypeDef LPCWAVEFORMATEX = *WAVEFORMATEX

' waveform audio function prototypes
Declare Function waveOutGetNumDevs Lib "winmm" () As DWord
#ifdef UNICODE
Declare Function waveOutGetDevCaps Lib "winmm" Alias "waveOutGetDevCapsW" (uDeviceID As DWord, ByRef pwoc As WAVEOUTCAPSW, cbwoc As DWord) As MMRESULT
#else
Declare Function waveOutGetDevCaps Lib "winmm" Alias "waveOutGetDevCapsA" (uDeviceID As DWord, ByRef pwoc As WAVEOUTCAPS, cbwoc As DWord) As MMRESULT
#endif
Declare Function waveOutGetVolume Lib "winmm" (hwo As HWAVEOUT, ByRef pdwVolume As DWord) As MMRESULT
Declare Function waveOutSetVolume Lib "winmm" (hwo As HWAVEOUT, dwVolume As DWord) As MMRESULT
#ifdef UNICODE
Declare Function waveOutGetErrorText Lib "winmm" Alias "waveOutGetErrorTextW" (mmrError As MMRESULT, pszText As LPWSTR, cchText As DWord) As MMRESULT
#else
Declare Function waveOutGetErrorText Lib "winmm" Alias "waveOutGetErrorTextA" (mmrError As MMRESULT, pszText As LPSTR, cchText As DWord) As MMRESULT
#endif
Declare Function waveOutOpen Lib "winmm" (ByRef phwo As HWAVEOUT, uDeviceID As DWord, ByRef pwfx As WAVEFORMATEX, dwCallback As DWord, dwInstance As DWord, fdwOpen As DWord) As MMRESULT
Declare Function waveOutClose Lib "winmm" (hwo As HWAVEOUT) As MMRESULT
Declare Function waveOutPrepareHeader Lib "winmm" (hwo As HWAVEOUT, ByRef pwh As WAVEHDR, cbwh As DWord) As MMRESULT
Declare Function waveOutUnprepareHeader Lib "winmm" (hwo As HWAVEOUT, ByRef pwh As WAVEHDR, cbwh As DWord) As MMRESULT
Declare Function waveOutWrite Lib "winmm" (hwo As HWAVEOUT, ByRef pwh As WAVEHDR, cbwh As DWord) As MMRESULT
Declare Function waveOutPause Lib "winmm" (hwo As HWAVEOUT) As MMRESULT
Declare Function waveOutRestart Lib "winmm" (hwo As HWAVEOUT) As MMRESULT
Declare Function waveOutReset Lib "winmm" (hwo As HWAVEOUT) As MMRESULT
Declare Function waveOutBreakLoop Lib "winmm" (hwo As HWAVEOUT) As MMRESULT
Declare Function waveOutGetPosition Lib "winmm" (hwo As HWAVEOUT, ByRef pmmt As MMTIME, cbmmt As DWord) As MMRESULT
Declare Function waveOutGetPitch Lib "winmm" (hwo As HWAVEOUT, ByRef pdwPitch As DWord) As MMRESULT
Declare Function waveOutSetPitch Lib "winmm" (hwo As HWAVEOUT, dwPitch As DWord) As MMRESULT
Declare Function waveOutGetPlaybackRate Lib "winmm" (hwo As HWAVEOUT, ByRef pdwRate As DWord) As MMRESULT
Declare Function waveOutSetPlaybackRate Lib "winmm" (hwo As HWAVEOUT, dwRate As DWord) As MMRESULT
Declare Function waveOutGetID Lib "winmm" (hwo As HWAVEOUT, ByRef puDeviceID As DWord) As MMRESULT
Declare Function waveOutMessage Lib "winmm" (hwo As HWAVEOUT, uMsg As DWord, dw1 As DWord, dw2 As DWord) As MMRESULT

Declare Function waveInGetNumDevs Lib "winmm" () As DWord
#ifdef UNICODE
Declare Function waveInGetDevCaps Lib "winmm" Alias "waveInGetDevCapsW" (uDeviceID As DWord, ByRef pwic As WAVEINCAPSW, cbwic As DWord) As MMRESULT
Declare Function waveInGetErrorText Lib "winmm" Alias "waveInGetErrorTextW" (mmrError As MMRESULT, pszText As LPWSTR, cchText As DWord) As MMRESULT
#else
Declare Function waveInGetDevCaps Lib "winmm" Alias "waveInGetDevCapsA" (uDeviceID As DWord, ByRef pwic As WAVEINCAPS, cbwic As DWord) As MMRESULT
Declare Function waveInGetErrorText Lib "winmm" Alias "waveInGetErrorTextA" (mmrError As MMRESULT, pszText As LPSTR, cchText As DWord) As MMRESULT
#endif
Declare Function waveInOpen Lib "winmm" (ByRef phwi As HWAVEIN, uDeviceID As DWord, ByRef pwfx As WAVEFORMATEX, dwCallback As DWord, dwInstance As DWord, fdwOpen As DWord) As MMRESULT
Declare Function waveInClose Lib "winmm" (hwi As HWAVEIN) As MMRESULT
Declare Function waveInPrepareHeader Lib "winmm" (hwi As HWAVEIN, ByRef pwh As WAVEHDR, cbwh As DWord) As MMRESULT
Declare Function waveInUnprepareHeader Lib "winmm" (hwi As HWAVEIN, ByRef pwh As WAVEHDR, cbwh As DWord) As MMRESULT
Declare Function waveInAddBuffer Lib "winmm" (hwi As HWAVEIN, ByRef pwh As WAVEHDR, cbwh As DWord) As MMRESULT
Declare Function waveInStart Lib "winmm" (hwi As HWAVEIN) As MMRESULT
Declare Function waveInStop Lib "winmm" (hwi As HWAVEIN) As MMRESULT
Declare Function waveInReset Lib "winmm" (hwi As HWAVEIN) As MMRESULT
Declare Function waveInGetPosition Lib "winmm" (hwi As HWAVEIN, ByRef pmmt As MMTIME, cbmmt As DWord) As MMRESULT
Declare Function waveInGetID Lib "winmm" (hwi As HWAVEIN, ByRef puDeviceID As DWord) As MMRESULT
Declare Function waveInMessage Lib "winmm" (hwi As HWAVEIN, uMsg As DWord, dw1 As DWord, dw2 As DWord) As MMRESULT



'--------------------------------------------------------
' MIDI audio support

' MIDI error return values
Const MIDIERR_UNPREPARED = (MIDIERR_BASE + 0)
Const MIDIERR_STILLPLAYING = (MIDIERR_BASE + 1)
Const MIDIERR_NOMAP = (MIDIERR_BASE + 2)
Const MIDIERR_NOTREADY = (MIDIERR_BASE + 3)
Const MIDIERR_NODEVICE = (MIDIERR_BASE + 4)
Const MIDIERR_INVALIDSETUP = (MIDIERR_BASE + 5)
Const MIDIERR_BADOPENMODE = (MIDIERR_BASE + 6)
Const MIDIERR_DONT_CONTINUE = (MIDIERR_BASE + 7)
Const MIDIERR_LASTERROR = (MIDIERR_BASE + 7)

' MIDI audio data types
Type _System_DeclareHandle_HMIDI:unused As DWord:End Type
TypeDef HMIDI = *_System_DeclareHandle_HMIDI
Type _System_DeclareHandle_HMIDIIN:unused As DWord:End Type
TypeDef HMIDIIN = *_System_DeclareHandle_HMIDIIN
Type _System_DeclareHandle_HMIDIOUT:unused As DWord:End Type
TypeDef HMIDIOUT = *_System_DeclareHandle_HMIDIOUT
Type _System_DeclareHandle_HMIDISTRM:unused As DWord:End Type
TypeDef HMIDISTRM = *_System_DeclareHandle_HMIDISTRM

TypeDef MIDICALLBACK = DRVCALLBACK
TypeDef LPMIDICALLBACK = *MIDICALLBACK

Const MIDIPATCHSIZE  = 128

TypeDef LPPATCHARRAY = *Word
TypeDef LPKEYARRAY = *Word

' MIDI callback messages
Const MIM_OPEN = MM_MIM_OPEN
Const MIM_CLOSE = MM_MIM_CLOSE
Const MIM_DATA = MM_MIM_DATA
Const MIM_LONGDATA = MM_MIM_LONGDATA
Const MIM_ERROR = MM_MIM_ERROR
Const MIM_LONGERROR = MM_MIM_LONGERROR
Const MOM_OPEN = MM_MOM_OPEN
Const MOM_CLOSE = MM_MOM_CLOSE
Const MOM_DONE = MM_MOM_DONE
Const MIM_MOREDATA = MM_MIM_MOREDATA
Const MOM_POSITIONCB = MM_MOM_POSITIONCB

' device ID for MIDI mapper
Const MIDIMAPPER = (-1)
Const MIDI_MAPPER = (-1)

Const MIDI_IO_STATUS = &H00000020

' flags for wFlags parm of midiOutCachePatches(), midiOutCacheDrumPatches()
Const MIDI_CACHE_ALL = 1
Const MIDI_CACHE_BESTFIT = 2
Const MIDI_CACHE_QUERY = 3
Const MIDI_UNCACHE = 4

' MIDI output device capabilities structure
Type MIDIOUTCAPSW
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As WCHAR
	wTechnology As Word
	wVoices As Word
	wNotes As Word
	wChannelMask As Word
	dwSupport As DWord
End Type
TypeDef PMIDIOUTCAPSW = *MIDIOUTCAPSW
TypeDef LPMIDIOUTCAPSW = *MIDIOUTCAPSW

Type MIDIOUTCAPSA
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As SByte
	wTechnology As Word
	wVoices As Word
	wNotes As Word
	wChannelMask As Word
	dwSupport As DWord
End Type
TypeDef PMIDIOUTCAPSA = *MIDIOUTCAPSA
TypeDef LPMIDIOUTCAPSA = *MIDIOUTCAPSA

#ifdef UNICODE
TypeDef MIDIOUTCAPS = MIDIOUTCAPSW
TypeDef PMIDIOUTCAPS = PMIDIOUTCAPSW
TypeDef LPMIDIOUTCAPS = LPMIDIOUTCAPSW
#else
TypeDef MIDIOUTCAPS = MIDIOUTCAPSA
TypeDef PMIDIOUTCAPS = PMIDIOUTCAPSA
TypeDef LPMIDIOUTCAPS = LPMIDIOUTCAPSA
#endif

' flags for wTechnology field of MIDIOUTCAPS structure
Const MOD_MIDIPORT = 1
Const MOD_SYNTH = 2
Const MOD_SQSYNTH = 3
Const MOD_FMSYNTH = 4
Const MOD_MAPPER = 5

' flags for dwSupport field of MIDIOUTCAPS structure
Const MIDICAPS_VOLUME = &H0001
Const MIDICAPS_LRVOLUME = &H0002
Const MIDICAPS_CACHE = &H0004
Const MIDICAPS_STREAM = &H0008

' MIDI input device capabilities structure
Type MIDIINCAPSW
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As Char
	dwSupport As DWord
End Type
TypeDef PMIDIINCAPSW = *MIDIINCAPSW
TypeDef LPMIDIINCAPSW = *MIDIINCAPSW

Type MIDIINCAPSA
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As Char
	dwSupport As DWord
End Type
TypeDef PMIDIINCAPSA = *MIDIINCAPSA
TypeDef LPMIDIINCAPSA = *MIDIINCAPSA

#ifdef UNICODE
TypeDef MIDIINCAPS = MIDIINCAPSW
TypeDef PMIDIINCAPS = PMIDIINCAPSW
TypeDef LPMIDIINCAPS = LPMIDIINCAPSW
#else
TypeDef MIDIINCAPS = MIDIINCAPSA
TypeDef PMIDIINCAPS = PMIDIINCAPSA
TypeDef LPMIDIINCAPS = LPMIDIINCAPSA
#endif

' MIDI data block header
Type MIDIHDR
	lpData As LPSTR
	dwBufferLength As DWord
	dwBytesRecorded As DWord
	dwUser As DWord
	dwFlags As DWord
	lpNext As *MIDIHDR
	reserved As DWord
	dwOffset As DWord
	dwReserved[ELM(8)] As DWord
End Type
TypeDef PMIDIHDR = *MIDIHDR
TypeDef LPMIDIHDR = *MIDIHDR

Type MIDIEVENT
	dwDeltaTime As DWord
	dwStreamID As DWord
	dwEvent As DWord
	dwParms[ELM(1)] As DWord
End Type

Type MIDISTRMBUFFVER
	dwVersion As DWord
	dwMid As DWord
	dwOEMVersion As DWord
End Type

' flags for dwFlags field of MIDIHDR structure
Const MHDR_DONE = &H00000001
Const MHDR_PREPARED = &H00000002
Const MHDR_INQUEUE = &H00000004
Const MHDR_ISSTRM = &H00000008

Const MEVT_F_SHORT = &H00000000
Const MEVT_F_LONG = &H80000000
Const MEVT_F_CALLBACK = &H40000000
Const MEVT_EVENTTYPE(x) = ((x>>24) AND &HFF)
Const MEVT_EVENTPARM(x) = (x AND &H00FFFFFF)
Const MEVT_SHORTMSG = (&H00)
Const MEVT_TEMPO = (&H01)
Const MEVT_NOP = (&H02)
Const MEVT_LONGMSG = (&H80)
Const MEVT_COMMENT = (&H82)
Const MEVT_VERSION = (&H84)

Const MIDISTRM_ERROR = (-2)

' Structures and defines for midiStreamProperty
Const MIDIPROP_SET = &H80000000
Const MIDIPROP_GET = &H40000000
Const MIDIPROP_TIMEDIV = &H00000001
Const MIDIPROP_TEMPO = &H00000002

Type MIDIPROPTIMEDIV
	cbStruct As DWord
	dwTimeDiv As DWord
End Type
TypeDef LPMIDIPROPTIMEDIV = *MIDIPROPTIMEDIV

Type MIDIPROPTEMPO
	cbStruct As DWord
	dwTempo As DWord
End Type
TypeDef LPMIDIPROPTEMPO = *MIDIPROPTEMPO


' MIDI function prototypes
Declare Function midiOutGetNumDevs Lib "winmm" () As DWord
Declare Function midiStreamOpen Lib "winmm" (ByRef phms As HMIDISTRM, ByRef puDeviceID As DWord, cMidi As DWord, dwCallback As DWord, dwInstance As DWord, fdwOpen As DWord) As MMRESULT
Declare Function midiStreamClose Lib "winmm" (hms As HMIDISTRM) As MMRESULT
Declare Function midiStreamProperty Lib "winmm" (hms As HMIDISTRM, lppropdata As *Byte, dwProperty As DWord) As MMRESULT
Declare Function midiStreamPosition Lib "winmm" (hms As HMIDISTRM, ByRef lpmmt As MMTIME, cbmmt As DWord) As MMRESULT
Declare Function midiStreamOut Lib "winmm" (hms As HMIDISTRM, ByRef pmh As MIDIHDR, cbmh As DWord) As MMRESULT
Declare Function midiStreamPause Lib "winmm" (hms As HMIDISTRM) As MMRESULT
Declare Function midiStreamRestart Lib "winmm" (hms As HMIDISTRM) As MMRESULT
Declare Function midiStreamStop Lib "winmm" (hms As HMIDISTRM) As MMRESULT

Declare Function midiConnect Lib "winmm" (hmi As HMIDI, hmo As HMIDIOUT, pReserved As VoidPtr) As MMRESULT
Declare Function midiDisconnect Lib "winmm" (hmi As HMIDI, hmo As HMIDIOUT, pReserved As VoidPtr) As MMRESULT
#ifdef UNICODE
Declare Function midiOutGetDevCaps Lib "winmm" Alias "midiOutGetDevCapsW" (uDeviceID As DWord, ByRef pmoc  As MIDIOUTCAPSW, cbmoc As DWord) As MMRESULT
#else
Declare Function midiOutGetDevCaps Lib "winmm" Alias "midiOutGetDevCapsA" (uDeviceID As DWord, ByRef pmoc  As MIDIOUTCAPS, cbmoc As DWord) As MMRESULT
#endif
Declare Function midiOutGetVolume Lib "winmm" (hmo As HMIDIOUT, ByRef pdwVolume As DWord) As MMRESULT
Declare Function midiOutSetVolume Lib "winmm" (hmo As HMIDIOUT, dwVolume As DWord) As MMRESULT
#ifdef UNICODE
Declare Function midiOutGetErrorText Lib "winmm" Alias "midiOutGetErrorTextW" (mmrError As MMRESULT, pszText As LPWSTR, cchText As DWord) As MMRESULT
#else
Declare Function midiOutGetErrorText Lib "winmm" Alias "midiOutGetErrorTextA" (mmrError As MMRESULT, pszText As LPSTR, cchText As DWord) As MMRESULT
#endif
Declare Function midiOutOpen Lib "winmm" (ByRef phmo As HMIDIOUT, uDeviceID As DWord, dwCallback As DWord, dwInstance As DWord, fdwOpen As DWord) As MMRESULT
Declare Function midiOutClose Lib "winmm" (hmo As HMIDIOUT) As MMRESULT
Declare Function midiOutPrepareHeader Lib "winmm" (hmo As HMIDIOUT, ByRef pmh As MIDIHDR, cbmh As DWord) As MMRESULT
Declare Function midiOutUnprepareHeader Lib "winmm" (hmo As HMIDIOUT, ByRef pmh As MIDIHDR, cbmh As DWord) As MMRESULT
Declare Function midiOutShortMsg Lib "winmm" (hmo As HMIDIOUT, dwMsg As DWord) As MMRESULT
Declare Function midiOutLongMsg Lib "winmm" (hmo As HMIDIOUT, ByRef pmh As MIDIHDR, cbmh As DWord) As MMRESULT
Declare Function midiOutReset Lib "winmm" (hmo As HMIDIOUT) As MMRESULT
Declare Function midiOutCachePatches Lib "winmm" (hmo As HMIDIOUT, uBank As DWord, ByRef pwpa As Word, fuCache As DWord) As MMRESULT
Declare Function midiOutCacheDrumPatches Lib "winmm" (hmo As HMIDIOUT, uPatch As DWord, ByRef pwkya As Word, fuCache As DWord) As MMRESULT
Declare Function midiOutGetID Lib "winmm" (hmo As HMIDIOUT, ByRef puDeviceID As DWord) As MMRESULT
Declare Function midiOutMessage Lib "winmm" (hmo As HMIDIOUT, uMsg As DWord, dw1 As DWord, dw2 As DWord) As MMRESULT

Declare Function midiInGetNumDevs Lib "winmm" () As DWord
#ifdef UNICODE
Declare Function midiInGetDevCaps Lib "winmm" Alias "midiInGetDevCapsW" (uDeviceID As DWord, ByRef pmic As MIDIINCAPSW, cbmic As DWord) As MMRESULT
Declare Function midiInGetErrorText Lib "winmm" Alias "midiInGetErrorTextW" (mmrError As MMRESULT, pszText As LPWSTR, cchText As DWord) As MMRESULT
#else
Declare Function midiInGetDevCaps Lib "winmm" Alias "midiInGetDevCapsA" (uDeviceID As DWord, ByRef pmic As MIDIINCAPS, cbmic As DWord) As MMRESULT
Declare Function midiInGetErrorText Lib "winmm" Alias "midiInGetErrorTextA" (mmrError As MMRESULT, pszText As LPSTR, cchText As DWord) As MMRESULT
#endif
Declare Function midiInOpen Lib "winmm" (ByRef phmi As HMIDIIN, uDeviceID As DWord, dwCallback As DWord, dwInstance As DWord, fdwOpen As DWord) As MMRESULT
Declare Function midiInClose Lib "winmm" (hmi As HMIDIIN) As MMRESULT
Declare Function midiInPrepareHeader Lib "winmm" (hmi As HMIDIIN, ByRef pmh As MIDIHDR, cbmh As DWord) As MMRESULT
Declare Function midiInUnprepareHeader Lib "winmm" (hmi As HMIDIIN, ByRef pmh As MIDIHDR, cbmh As DWord) As MMRESULT
Declare Function midiInAddBuffer Lib "winmm" (hmi As HMIDIIN, ByRef pmh As MIDIHDR, cbmh As DWord) As MMRESULT
Declare Function midiInStart Lib "winmm" (hmi As HMIDIIN) As MMRESULT
Declare Function midiInStop Lib "winmm" (hmi As HMIDIIN) As MMRESULT
Declare Function midiInReset Lib "winmm" (hmi As HMIDIIN) As MMRESULT
Declare Function midiInGetID Lib "winmm" (hmi As HMIDIIN, ByRef puDeviceID As DWord) As MMRESULT
Declare Function midiInMessage Lib "winmm" (hmi As HMIDIIN, uMsg As DWord, dw1 As DWord, dw2 As DWord) As MMRESULT


'--------------------------------------------------------
' Auxiliary audio support

' device ID for aux device mapper
Const AUX_MAPPER = (-1)

' Auxiliary audio device capabilities structure
Type AUXCAPSW
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As WCHAR
	wTechnology As Word
	wReserved1 As Word
	dwSupport As DWord
End Type
TypeDef PAUXCAPSW = *AUXCAPSW
TypeDef NPAUXCAPSW = *AUXCAPSW
TypeDef LPAUXCAPSW = *AUXCAPSW

Type AUXCAPSA
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As SByte
	wTechnology As Word
	wReserved1 As Word
	dwSupport As DWord
End Type
TypeDef PAUXCAPSA = *AUXCAPSA
TypeDef NPAUXCAPSA = *AUXCAPSA
TypeDef LPAUXCAPSA = *AUXCAPSA

#ifdef UNICODE
TypeDef AUXCAPS = AUXCAPSW
TypeDef PAUXCAPS = PAUXCAPSW
TypeDef NPAUXCAPS = NPAUXCAPSW
TypeDef LPAUXCAPS = LPAUXCAPSW
#else
TypeDef AUXCAPS = AUXCAPSA
TypeDef PAUXCAPS = PAUXCAPSA
TypeDef NPAUXCAPS = NPAUXCAPSA
TypeDef LPAUXCAPS = LPAUXCAPSA
#endif

Const AUXCAPS_CDAUDIO = 1
Const AUXCAPS_AUXIN = 2

Const AUXCAPS_VOLUME = &H0001
Const AUXCAPS_LRVOLUME = &H0002

' auxiliary audio function prototypes
Declare Function auxGetNumDevs Lib "winmm" () As DWord
#ifdef UNICODE
Declare Function auxGetDevCaps Lib "winmm" Alias "auxGetDevCapsW" (uDeviceID As DWord, pac As *AUXCAPSW, cbac As DWord) As MMRESULT
#else
Declare Function auxGetDevCaps Lib "winmm" Alias "auxGetDevCapsA" (uDeviceID As DWord, pac As *AUXCAPS, cbac As DWord) As MMRESULT
#endif
Declare Function auxSetVolume Lib "winmm" (uDeviceID As DWord, dwVolume As DWord) As MMRESULT
Declare Function auxGetVolume Lib "winmm" (uDeviceID As DWord, pdwVolume As *DWord) As MMRESULT
Declare Function auxOutMessage Lib "winmm" (uDeviceID As DWord, uMsg As DWord, dw1 As DWord, dw2 As DWord) As MMRESULT


'--------------------------------------------------------
' Mixer Support

TypeDef HMIXEROBJ = VoidPtr
TypeDef LPHMIXEROBJ = HMIXEROBJ
TypeDef HMIXER = VoidPtr
TypeDef LPHMIXER = *HMIXER

Const MIXER_SHORT_NAME_CHARS = 16
Const MIXER_LONG_NAME_CHARS = 64

Const MIXERR_INVALLINE = (MIXERR_BASE + 0)
Const MIXERR_INVALCONTROL = (MIXERR_BASE + 1)
Const MIXERR_INVALVALUE = (MIXERR_BASE + 2)
Const MIXERR_LASTERROR = (MIXERR_BASE + 2)

Const MIXER_OBJECTF_HANDLE = &H80000000
Const MIXER_OBJECTF_MIXER = &H00000000
Const MIXER_OBJECTF_HMIXER = (MIXER_OBJECTF_HANDLE OR MIXER_OBJECTF_MIXER)
Const MIXER_OBJECTF_WAVEOUT = &H10000000
Const MIXER_OBJECTF_HWAVEOUT = (MIXER_OBJECTF_HANDLE OR MIXER_OBJECTF_WAVEOUT)
Const MIXER_OBJECTF_WAVEIN = &H20000000
Const MIXER_OBJECTF_HWAVEIN = (MIXER_OBJECTF_HANDLE OR MIXER_OBJECTF_WAVEIN)
Const MIXER_OBJECTF_MIDIOUT = &H30000000
Const MIXER_OBJECTF_HMIDIOUT = (MIXER_OBJECTF_HANDLE OR MIXER_OBJECTF_MIDIOUT)
Const MIXER_OBJECTF_MIDIIN = &H40000000
Const MIXER_OBJECTF_HMIDIIN = (MIXER_OBJECTF_HANDLE OR MIXER_OBJECTF_MIDIIN)
Const MIXER_OBJECTF_AUX = &H50000000

Declare Function mixerGetNumDevs Lib "winmm" () As DWord

Type MIXERCAPSW
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As WCHAR
	fdwSupport As DWord
	cDestinations As DWord
End Type
TypeDef PMIXERCAPSW = *MIXERCAPSW
TypeDef LPMIXERCAPSW = *MIXERCAPSW

Type MIXERCAPSA
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As SByte
	fdwSupport As DWord
	cDestinations As DWord
End Type
TypeDef PMIXERCAPSA = *MIXERCAPSA
TypeDef LPMIXERCAPSA = *MIXERCAPSA

#ifdef UNICODE
TypeDef MIXERCAPS = MIXERCAPSW
TypeDef PMIXERCAPS = PMIXERCAPSW
TypeDef LPMIXERCAPS = LPMIXERCAPSW
Declare Function mixerGetDevCaps Lib "winmm" Alias "mixerGetDevCapsW" (uMxId As DWord, pmxcaps As *MIXERCAPSW, cbmxcaps As DWord) As MMRESULT
#else
TypeDef MIXERCAPS = MIXERCAPSA
TypeDef PMIXERCAPS = PMIXERCAPSA
TypeDef LPMIXERCAPS = LPMIXERCAPSA
Declare Function mixerGetDevCaps Lib "winmm" Alias "mixerGetDevCapsA" (uMxId As DWord, pmxcaps As *MIXERCAPS, cbmxcaps As DWord) As MMRESULT
#endif

Declare Function mixerOpen Lib "winmm" (phmx As *HMIXER, uMxId As DWord, dwCallback As DWord, dwInstance As DWord, fdwOpen As DWord) As MMRESULT
Declare Function mixerClose Lib "winmm" (hmx As HMIXER) As MMRESULT
Declare Function mixerMessage Lib "winmm" (hmx As HMIXER, uMsg As DWord, dwParam1 As DWord, dwParam2 As DWord) As DWord

#ifdef UNICODE
Type TARGET
	dwType As DWord
	dwDeviceID As DWord
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As WCHAR
End Type
#else
Type TARGET
	dwType As DWord
	dwDeviceID As DWord
	wMid As Word
	wPid As Word
	vDriverVersion As MMVERSION
	szPname[ELM(MAXPNAMELEN)] As SByte
End Type
#endif

Type MIXERLINEW
	cbStruct As DWord
	dwDestination As DWord
	dwSource As DWord
	dwLineID As DWord
	fdwLine As DWord
	dwUser As DWord
	dwComponentType As DWord
	cChannels As DWord
	cConnections As DWord
	cControls As DWord
	szShortName[ELM(MIXER_SHORT_NAME_CHARS)] As WCHAR
	szName[ELM(MIXER_LONG_NAME_CHARS)] As WCHAR
	Target As TARGET
End Type
TypeDef PMIXERLINEW = *MIXERLINEW
TypeDef LPMIXERLINEW = *MIXERLINEW

Type MIXERLINEA
	cbStruct As DWord
	dwDestination As DWord
	dwSource As DWord
	dwLineID As DWord
	fdwLine As DWord
	dwUser As DWord
	dwComponentType As DWord
	cChannels As DWord
	cConnections As DWord
	cControls As DWord
	szShortName[ELM(MIXER_SHORT_NAME_CHARS)] As SByte
	szName[ELM(MIXER_LONG_NAME_CHARS)] As SByte
	Target As TARGET
End Type
TypeDef PMIXERLINEA = *MIXERLINEA
TypeDef LPMIXERLINEA = *MIXERLINEA

#ifdef UNICODE
TypeDef MIXERLINE = MIXERLINEA
TypeDef PMIXERLINE = PMIXERLINEA
TypeDef LPMIXERLINE = LPMIXERLINEA
#else
TypeDef MIXERLINE = MIXERLINEW
TypeDef PMIXERLINE = PMIXERLINEW
TypeDef LPMIXERLINE = LPMIXERLINEW
#endif

' MIXERLINE.fdwLine
Const MIXERLINE_LINEF_ACTIVE = &H00000001
Const MIXERLINE_LINEF_DISCONNECTED = &H00008000
Const MIXERLINE_LINEF_SOURCE = &H80000000

' MIXERLINE.dwComponentType
Const MIXERLINE_COMPONENTTYPE_DST_FIRST = &H00000000
Const MIXERLINE_COMPONENTTYPE_DST_UNDEFINED = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 0)
Const MIXERLINE_COMPONENTTYPE_DST_DIGITAL = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 1)
Const MIXERLINE_COMPONENTTYPE_DST_LINE = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 2)
Const MIXERLINE_COMPONENTTYPE_DST_MONITOR = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 3)
Const MIXERLINE_COMPONENTTYPE_DST_SPEAKERS = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 4)
Const MIXERLINE_COMPONENTTYPE_DST_HEADPHONES = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 5)
Const MIXERLINE_COMPONENTTYPE_DST_TELEPHONE = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 6)
Const MIXERLINE_COMPONENTTYPE_DST_WAVEIN = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 7)
Const MIXERLINE_COMPONENTTYPE_DST_VOICEIN = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)
Const MIXERLINE_COMPONENTTYPE_DST_LAST = (MIXERLINE_COMPONENTTYPE_DST_FIRST + 8)

Const MIXERLINE_COMPONENTTYPE_SRC_FIRST = &H00001000
Const MIXERLINE_COMPONENTTYPE_SRC_UNDEFINED = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 0)
Const MIXERLINE_COMPONENTTYPE_SRC_DIGITAL = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 1)
Const MIXERLINE_COMPONENTTYPE_SRC_LINE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 2)
Const MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 3)
Const MIXERLINE_COMPONENTTYPE_SRC_SYNTHESIZER = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 4)
Const MIXERLINE_COMPONENTTYPE_SRC_COMPACTDISC = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 5)
Const MIXERLINE_COMPONENTTYPE_SRC_TELEPHONE = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 6)
Const MIXERLINE_COMPONENTTYPE_SRC_PCSPEAKER = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 7)
Const MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 8)
Const MIXERLINE_COMPONENTTYPE_SRC_AUXILIARY = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 9)
Const MIXERLINE_COMPONENTTYPE_SRC_ANALOG = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10)
Const MIXERLINE_COMPONENTTYPE_SRC_LAST = (MIXERLINE_COMPONENTTYPE_SRC_FIRST + 10)

' MIXERLINE.Target.dwType
Const MIXERLINE_TARGETTYPE_UNDEFINED = 0
Const MIXERLINE_TARGETTYPE_WAVEOUT = 1
Const MIXERLINE_TARGETTYPE_WAVEIN = 2
Const MIXERLINE_TARGETTYPE_MIDIOUT = 3
Const MIXERLINE_TARGETTYPE_MIDIIN = 4
Const MIXERLINE_TARGETTYPE_AUX = 5

#ifdef UNICODE
Declare Function mixerGetLineInfo Lib "winmm" Alias "mixerGetLineInfoW" (hmxobj As HMIXEROBJ, pmxl As *MIXERLINEW, fdwInfo As DWord) As MMRESULT
#else
Declare Function mixerGetLineInfo Lib "winmm" Alias "mixerGetLineInfoA" (hmxobj As HMIXEROBJ, pmxl As *MIXERLINE, fdwInfo As DWord) As MMRESULT
#endif

Const MIXER_GETLINEINFOF_DESTINATION = &H00000000
Const MIXER_GETLINEINFOF_SOURCE = &H00000001
Const MIXER_GETLINEINFOF_LINEID = &H00000002
Const MIXER_GETLINEINFOF_COMPONENTTYPE = &H00000003
Const MIXER_GETLINEINFOF_TARGETTYPE = &H00000004
Const MIXER_GETLINEINFOF_QUERYMASK = &H0000000F

Declare Function mixerGetID Lib "winmm" (hmxobj As HMIXEROBJ, puMxId As *DWord, fdwId As DWord) As MMRESULT

Type MIXERCONTROLW
	cbStruct As DWord
	dwControlID As DWord
	dwControlType As DWord
	fdwControl As DWord
	cMultipleItems As DWord
	szShortName[ELM(MIXER_SHORT_NAME_CHARS)] As WCHAR
	szName[ELM(MIXER_LONG_NAME_CHARS)] As WCHAR
	Bounds[ELM(6)] As DWord
	Metrics[ELM(6)] As DWord
End Type
TypeDef PMIXERCONTROLW = *MIXERCONTROLW
TypeDef LPMIXERCONTROLW = *MIXERCONTROLW

Type MIXERCONTROLA
	cbStruct As DWord
	dwControlID As DWord
	dwControlType As DWord
	fdwControl As DWord
	cMultipleItems As DWord
	szShortName[ELM(MIXER_SHORT_NAME_CHARS)] As SByte
	szName[ELM(MIXER_LONG_NAME_CHARS)] As SByte
	Bounds[ELM(6)] As DWord
	Metrics[ELM(6)] As DWord
End Type
TypeDef PMIXERCONTROLA = *MIXERCONTROLA
TypeDef LPMIXERCONTROLA = *MIXERCONTROLA

#ifdef UNICODE
TypeDef MIXERCONTROL = MIXERCONTROLW
TypeDef PMIXERCONTROL = PMIXERCONTROLW
TypeDef LPMIXERCONTROL = LPMIXERCONTROLW
#else
TypeDef MIXERCONTROL = MIXERCONTROLA
TypeDef PMIXERCONTROL = PMIXERCONTROLA
TypeDef LPMIXERCONTROL = LPMIXERCONTROLA
#endif

' MIXERCONTROL.fdwControl
Const MIXERCONTROL_CONTROLF_UNIFORM = &H00000001
Const MIXERCONTROL_CONTROLF_MULTIPLE = &H00000002
Const MIXERCONTROL_CONTROLF_DISABLED = &H80000000

' MIXERCONTROL_CONTROLTYPE_xxx
Const MIXERCONTROL_CT_CLASS_MASK = &HF0000000
Const MIXERCONTROL_CT_CLASS_CUSTOM = &H00000000
Const MIXERCONTROL_CT_CLASS_METER = &H10000000
Const MIXERCONTROL_CT_CLASS_SWITCH = &H20000000
Const MIXERCONTROL_CT_CLASS_NUMBER = &H30000000
Const MIXERCONTROL_CT_CLASS_SLIDER = &H40000000
Const MIXERCONTROL_CT_CLASS_FADER = &H50000000
Const MIXERCONTROL_CT_CLASS_TIME = &H60000000
Const MIXERCONTROL_CT_CLASS_LIST = &H70000000
Const MIXERCONTROL_CT_SUBCLASS_MASK = &H0F000000
Const MIXERCONTROL_CT_SC_SWITCH_BOOLEAN = &H00000000
Const MIXERCONTROL_CT_SC_SWITCH_BUTTON = &H01000000
Const MIXERCONTROL_CT_SC_METER_POLLED = &H00000000
Const MIXERCONTROL_CT_SC_TIME_MICROSECS = &H00000000
Const MIXERCONTROL_CT_SC_TIME_MILLISECS = &H01000000
Const MIXERCONTROL_CT_SC_LIST_SINGLE = &H00000000
Const MIXERCONTROL_CT_SC_LIST_MULTIPLE = &H01000000
Const MIXERCONTROL_CT_UNITS_MASK = &H00FF0000
Const MIXERCONTROL_CT_UNITS_CUSTOM = &H00000000
Const MIXERCONTROL_CT_UNITS_BOOLEAN = &H00010000
Const MIXERCONTROL_CT_UNITS_SIGNED = &H00020000
Const MIXERCONTROL_CT_UNITS_UNSIGNED = &H00030000
Const MIXERCONTROL_CT_UNITS_DECIBELS = &H00040000
Const MIXERCONTROL_CT_UNITS_PERCENT = &H00050000

' MIXERCONTROL.dwControlType
Const MIXERCONTROL_CONTROLTYPE_CUSTOM = (MIXERCONTROL_CT_CLASS_CUSTOM OR MIXERCONTROL_CT_UNITS_CUSTOM)
Const MIXERCONTROL_CONTROLTYPE_BOOLEANMETER = (MIXERCONTROL_CT_CLASS_METER OR MIXERCONTROL_CT_SC_METER_POLLED OR MIXERCONTROL_CT_UNITS_BOOLEAN)
Const MIXERCONTROL_CONTROLTYPE_SIGNEDMETER = (MIXERCONTROL_CT_CLASS_METER OR MIXERCONTROL_CT_SC_METER_POLLED OR MIXERCONTROL_CT_UNITS_SIGNED)
Const MIXERCONTROL_CONTROLTYPE_PEAKMETER = (MIXERCONTROL_CONTROLTYPE_SIGNEDMETER + 1)
Const MIXERCONTROL_CONTROLTYPE_UNSIGNEDMETER = (MIXERCONTROL_CT_CLASS_METER OR MIXERCONTROL_CT_SC_METER_POLLED OR MIXERCONTROL_CT_UNITS_UNSIGNED)
Const MIXERCONTROL_CONTROLTYPE_BOOLEAN = (MIXERCONTROL_CT_CLASS_SWITCH OR MIXERCONTROL_CT_SC_SWITCH_BOOLEAN OR MIXERCONTROL_CT_UNITS_BOOLEAN)
Const MIXERCONTROL_CONTROLTYPE_ONOFF = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 1)
Const MIXERCONTROL_CONTROLTYPE_MUTE = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 2)
Const MIXERCONTROL_CONTROLTYPE_MONO = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 3)
Const MIXERCONTROL_CONTROLTYPE_LOUDNESS = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 4)
Const MIXERCONTROL_CONTROLTYPE_STEREOENH = (MIXERCONTROL_CONTROLTYPE_BOOLEAN + 5)
Const MIXERCONTROL_CONTROLTYPE_BUTTON = (MIXERCONTROL_CT_CLASS_SWITCH OR MIXERCONTROL_CT_SC_SWITCH_BUTTON OR MIXERCONTROL_CT_UNITS_BOOLEAN)
Const MIXERCONTROL_CONTROLTYPE_DECIBELS = (MIXERCONTROL_CT_CLASS_NUMBER OR MIXERCONTROL_CT_UNITS_DECIBELS)
Const MIXERCONTROL_CONTROLTYPE_SIGNED = (MIXERCONTROL_CT_CLASS_NUMBER OR MIXERCONTROL_CT_UNITS_SIGNED)
Const MIXERCONTROL_CONTROLTYPE_UNSIGNED = (MIXERCONTROL_CT_CLASS_NUMBER OR MIXERCONTROL_CT_UNITS_UNSIGNED)
Const MIXERCONTROL_CONTROLTYPE_PERCENT = (MIXERCONTROL_CT_CLASS_NUMBER OR MIXERCONTROL_CT_UNITS_PERCENT)
Const MIXERCONTROL_CONTROLTYPE_SLIDER = (MIXERCONTROL_CT_CLASS_SLIDER OR MIXERCONTROL_CT_UNITS_SIGNED)
Const MIXERCONTROL_CONTROLTYPE_PAN = (MIXERCONTROL_CONTROLTYPE_SLIDER + 1)
Const MIXERCONTROL_CONTROLTYPE_QSOUNDPAN = (MIXERCONTROL_CONTROLTYPE_SLIDER + 2)
Const MIXERCONTROL_CONTROLTYPE_FADER = (MIXERCONTROL_CT_CLASS_FADER OR MIXERCONTROL_CT_UNITS_UNSIGNED)
Const MIXERCONTROL_CONTROLTYPE_VOLUME = (MIXERCONTROL_CONTROLTYPE_FADER + 1)
Const MIXERCONTROL_CONTROLTYPE_BASS = (MIXERCONTROL_CONTROLTYPE_FADER + 2)
Const MIXERCONTROL_CONTROLTYPE_TREBLE = (MIXERCONTROL_CONTROLTYPE_FADER + 3)
Const MIXERCONTROL_CONTROLTYPE_EQUALIZER = (MIXERCONTROL_CONTROLTYPE_FADER + 4)
Const MIXERCONTROL_CONTROLTYPE_SINGLESELECT = (MIXERCONTROL_CT_CLASS_LIST OR MIXERCONTROL_CT_SC_LIST_SINGLE OR MIXERCONTROL_CT_UNITS_BOOLEAN)
Const MIXERCONTROL_CONTROLTYPE_MUX = (MIXERCONTROL_CONTROLTYPE_SINGLESELECT + 1)
Const MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT = (MIXERCONTROL_CT_CLASS_LIST OR MIXERCONTROL_CT_SC_LIST_MULTIPLE OR MIXERCONTROL_CT_UNITS_BOOLEAN)
Const MIXERCONTROL_CONTROLTYPE_MIXER = (MIXERCONTROL_CONTROLTYPE_MULTIPLESELECT + 1)
Const MIXERCONTROL_CONTROLTYPE_MICROTIME = (MIXERCONTROL_CT_CLASS_TIME OR MIXERCONTROL_CT_SC_TIME_MICROSECS OR MIXERCONTROL_CT_UNITS_UNSIGNED)
Const MIXERCONTROL_CONTROLTYPE_MILLITIME = (MIXERCONTROL_CT_CLASS_TIME OR MIXERCONTROL_CT_SC_TIME_MILLISECS OR MIXERCONTROL_CT_UNITS_UNSIGNED)

Type MIXERLINECONTROLSW
	cbStruct As DWord
	dwLineID As DWord
	dwControl_ID_Type As DWord
	cControls As DWord
	cbmxctrl As DWord
	pamxctrl As *MIXERCONTROLW
End Type
TypeDef PMIXERLINECONTROLSW = *MIXERLINECONTROLSW
TypeDef LPMIXERLINECONTROLSW = *MIXERLINECONTROLSW

Type MIXERLINECONTROLSA
	cbStruct As DWord
	dwLineID As DWord
	dwControl_ID_Type As DWord
	cControls As DWord
	cbmxctrl As DWord
	pamxctrl As *MIXERCONTROL
End Type
TypeDef PMIXERLINECONTROLSA = *MIXERLINECONTROLSA
TypeDef LPMIXERLINECONTROLSA = *MIXERLINECONTROLSA

#ifdef UNICODE
TypeDef MIXERLINECONTROLS = MIXERLINECONTROLSW
TypeDef PMIXERLINECONTROLS = PMIXERLINECONTROLSW
TypeDef LPMIXERLINECONTROLS = LPMIXERLINECONTROLSW
Declare Function mixerGetLineControls Lib "winmm" Alias "mixerGetLineControlsA" (hmxobj As HMIXEROBJ, pmxlc As *MIXERLINECONTROLSW, fdwControls As DWord) As MMRESULT
#else
TypeDef MIXERLINECONTROLS = MIXERLINECONTROLSA
TypeDef PMIXERLINECONTROLS = PMIXERLINECONTROLSA
TypeDef LPMIXERLINECONTROLS = LPMIXERLINECONTROLSA
Declare Function mixerGetLineControls Lib "winmm" Alias "mixerGetLineControlsA" (hmxobj As HMIXEROBJ, pmxlc As *MIXERLINECONTROLS, fdwControls As DWord) As MMRESULT
#endif

Const MIXER_GETLINECONTROLSF_ALL = &H00000000
Const MIXER_GETLINECONTROLSF_ONEBYID = &H00000001
Const MIXER_GETLINECONTROLSF_ONEBYTYPE = &H00000002
Const MIXER_GETLINECONTROLSF_QUERYMASK = &H0000000F

Type MIXERCONTROLDETAILS
	cbStruct As DWord
	dwControlID As DWord
	cChannels As DWord
	cMultipleItems As DWord
	cbDetails As DWord
	paDetails As VoidPtr
End Type
TypeDef PMIXERCONTROLDETAILS = *MIXERCONTROLDETAILS
TypeDef LPMIXERCONTROLDETAILS = *MIXERCONTROLDETAILS

Type MIXERCONTROLDETAILS_LISTTEXTW
	dwParam1 As DWord
	dwParam2 As DWord
	szName[ELM(MIXER_LONG_NAME_CHARS)] As WCHAR
End Type
TypeDef PMIXERCONTROLDETAILS_LISTTEXTW = *MIXERCONTROLDETAILS_LISTTEXTW
TypeDef LPMIXERCONTROLDETAILS_LISTTEXTW = *MIXERCONTROLDETAILS_LISTTEXTW

Type MIXERCONTROLDETAILS_LISTTEXTA
	dwParam1 As DWord
	dwParam2 As DWord
	szName[ELM(MIXER_LONG_NAME_CHARS)] As SByte
End Type
TypeDef PMIXERCONTROLDETAILS_LISTTEXTA = *MIXERCONTROLDETAILS_LISTTEXTA
TypeDef LPMIXERCONTROLDETAILS_LISTTEXTA = *MIXERCONTROLDETAILS_LISTTEXTA

#ifdef UNICODE
TypeDef MIXERCONTROLDETAILS_LISTTEXT = MIXERCONTROLDETAILS_LISTTEXTW
TypeDef PMIXERCONTROLDETAILS_LISTTEXT = PMIXERCONTROLDETAILS_LISTTEXTW
TypeDef LPMIXERCONTROLDETAILS_LISTTEXT = LPMIXERCONTROLDETAILS_LISTTEXTW
#else
TypeDef MIXERCONTROLDETAILS_LISTTEXT = MIXERCONTROLDETAILS_LISTTEXTA
TypeDef PMIXERCONTROLDETAILS_LISTTEXT = PMIXERCONTROLDETAILS_LISTTEXTA
TypeDef LPMIXERCONTROLDETAILS_LISTTEXT = LPMIXERCONTROLDETAILS_LISTTEXTA
#endif

Type MIXERCONTROLDETAILS_BOOLEAN
	fValue As Long
End Type
TypeDef PMIXERCONTROLDETAILS_BOOLEAN = *MIXERCONTROLDETAILS_BOOLEAN
TypeDef LPMIXERCONTROLDETAILS_BOOLEAN = *MIXERCONTROLDETAILS_BOOLEAN

Type MIXERCONTROLDETAILS_SIGNED
	lValue As Long
End Type
TypeDef PMIXERCONTROLDETAILS_SIGNED = *MIXERCONTROLDETAILS_SIGNED
TypeDef LPMIXERCONTROLDETAILS_SIGNED = *MIXERCONTROLDETAILS_SIGNED

Type MIXERCONTROLDETAILS_UNSIGNED
	dwValue As DWord
End Type
TypeDef PMIXERCONTROLDETAILS_UNSIGNED = *MIXERCONTROLDETAILS_UNSIGNED
TypeDef LPMIXERCONTROLDETAILS_UNSIGNED = *MIXERCONTROLDETAILS_UNSIGNED

Declare Function mixerGetControlDetailsA Lib "winmm" (hmxobj As HMIXEROBJ, pmxcd As *MIXERCONTROLDETAILS, fdwDetails As DWord) As MMRESULT
Declare Function mixerGetControlDetailsW Lib "winmm" (hmxobj As HMIXEROBJ, pmxcd As *MIXERCONTROLDETAILS, fdwDetails As DWord) As MMRESULT
#ifdef UNICODE
Declare Function mixerGetControlDetails Lib "winmm" Alias "mixerGetControlDetailsW" (hmxobj As HMIXEROBJ, pmxcd As *MIXERCONTROLDETAILS, fdwDetails As DWord) As MMRESULT
#else
Declare Function mixerGetControlDetails Lib "winmm" Alias "mixerGetControlDetailsA" (hmxobj As HMIXEROBJ, pmxcd As *MIXERCONTROLDETAILS, fdwDetails As DWord) As MMRESULT
#endif

Const MIXER_GETCONTROLDETAILSF_VALUE = &H00000000
Const MIXER_GETCONTROLDETAILSF_LISTTEXT = &H00000001
Const MIXER_GETCONTROLDETAILSF_QUERYMASK = &H0000000F

Declare Function mixerSetControlDetails Lib "winmm" (hmxobj As HMIXEROBJ, pmxcd As *MIXERCONTROLDETAILS, fdwDetails As DWord) As MMRESULT

Const MIXER_SETCONTROLDETAILSF_VALUE = &H00000000
Const MIXER_SETCONTROLDETAILSF_CUSTOM = &H00000001
Const MIXER_SETCONTROLDETAILSF_QUERYMASK = &H0000000F


'--------------------------------------------------------
' Timer support

' timer error
Const TIMERR_NOERROR = (0)
Const TIMERR_NOCANDO = (TIMERR_BASE+1)
Const TIMERR_STRUCT = (TIMERR_BASE+33)

TypeDef LPTIMECALLBACK = *Sub(uTimerID As DWord, uMsg As DWord, dwUser As DWord, dw1 As DWord, dw2 As DWord)

Const TIME_ONESHOT = &H0000
Const TIME_PERIODIC = &H0001

Const TIME_CALLBACK_FUNCTION = &H0000
Const TIME_CALLBACK_EVENT_SET = &H0010
Const TIME_CALLBACK_EVENT_PULSE = &H0020

' timer device capabilities data structure
Type TIMECAPS
	wPeriodMin As DWord
	wPeriodMax As DWord
End Type
TypeDef PTIMECAPS = *TIMECAPS
TypeDef NPTIMECAPS = *TIMECAPS
TypeDef LPTIMECAPS = *TIMECAPS

' timer function prototypes
Declare Function timeGetSystemTime Lib "winmm" (pmmt As *MMTIME, cbmmt As DWord) As MMRESULT
Declare Function timeGetTime Lib "winmm" () As DWord
Declare Function timeSetEvent Lib "winmm" (uDelay As DWord, uResolution As DWord, fptc As LPTIMECALLBACK, dwUser As DWord, fuEvent As DWord) As MMRESULT
Declare Function timeKillEvent Lib "winmm" (uTimerID As DWord) As MMRESULT
Declare Function timeGetDevCaps Lib "winmm" (ptc As *TIMECAPS, cbtc As DWord) As MMRESULT
Declare Function timeBeginPeriod Lib "winmm" (uPeriod As DWord) As MMRESULT
Declare Function timeEndPeriod Lib "winmm" (uPeriod As DWord) As MMRESULT


'--------------------------------------------------------
' Joystick support

' joystick error
Const JOYERR_NOERROR = (0)
Const JOYERR_PARMS = (JOYERR_BASE+5)
Const JOYERR_NOCANDO = (JOYERR_BASE+6)
Const JOYERR_UNPLUGGED = (JOYERR_BASE+7)

' constants used with JOYINFO and JOYINFOEX structures and MM_JOY* messages
Const JOY_BUTTON1 = &H0001
Const JOY_BUTTON2 = &H0002
Const JOY_BUTTON3 = &H0004
Const JOY_BUTTON4 = &H0008
Const JOY_BUTTON1CHG = &H0100
Const JOY_BUTTON2CHG = &H0200
Const JOY_BUTTON3CHG = &H0400
Const JOY_BUTTON4CHG = &H0800

' constants used with JOYINFOEX
Const JOY_BUTTON5 = &H00000010
Const JOY_BUTTON6 = &H00000020
Const JOY_BUTTON7 = &H00000040
Const JOY_BUTTON8 = &H00000080
Const JOY_BUTTON9 = &H00000100
Const JOY_BUTTON10 = &H00000200
Const JOY_BUTTON11 = &H00000400
Const JOY_BUTTON12 = &H00000800
Const JOY_BUTTON13 = &H00001000
Const JOY_BUTTON14 = &H00002000
Const JOY_BUTTON15 = &H00004000
Const JOY_BUTTON16 = &H00008000
Const JOY_BUTTON17 = &H00010000
Const JOY_BUTTON18 = &H00020000
Const JOY_BUTTON19 = &H00040000
Const JOY_BUTTON20 = &H00080000
Const JOY_BUTTON21 = &H00100000
Const JOY_BUTTON22 = &H00200000
Const JOY_BUTTON23 = &H00400000
Const JOY_BUTTON24 = &H00800000
Const JOY_BUTTON25 = &H01000000
Const JOY_BUTTON26 = &H02000000
Const JOY_BUTTON27 = &H04000000
Const JOY_BUTTON28 = &H08000000
Const JOY_BUTTON29 = &H10000000
Const JOY_BUTTON30 = &H20000000
Const JOY_BUTTON31 = &H40000000
Const JOY_BUTTON32 = &H80000000

' constants used with JOYINFOEX structure
Const JOY_POVCENTERED = (-1)
Const JOY_POVFORWARD = 0
Const JOY_POVRIGHT = 9000
Const JOY_POVBACKWARD = 18000
Const JOY_POVLEFT = 27000

Const JOY_RETURNX = &H00000001
Const JOY_RETURNY = &H00000002
Const JOY_RETURNZ = &H00000004
Const JOY_RETURNR = &H00000008
Const JOY_RETURNU = &H00000010
Const JOY_RETURNV = &H00000020
Const JOY_RETURNPOV = &H00000040
Const JOY_RETURNBUTTONS = &H00000080
Const JOY_RETURNRAWDATA = &H00000100
Const JOY_RETURNPOVCTS = &H00000200
Const JOY_RETURNCENTERED = &H00000400
Const JOY_USEDEADZONE = &H00000800
Const JOY_RETURNALL = (JOY_RETURNX OR JOY_RETURNY OR JOY_RETURNZ OR JOY_RETURNR OR JOY_RETURNU OR JOY_RETURNV OR JOY_RETURNPOV OR JOY_RETURNBUTTONS)
Const JOY_CAL_READALWAYS = &H00010000
Const JOY_CAL_READXYONLY = &H00020000
Const JOY_CAL_READ3 = &H00040000
Const JOY_CAL_READ4 = &H00080000
Const JOY_CAL_READXONLY = &H00100000
Const JOY_CAL_READYONLY = &H00200000
Const JOY_CAL_READ5 = &H00400000
Const JOY_CAL_READ6 = &H00800000
Const JOY_CAL_READZONLY = &H01000000
Const JOY_CAL_READRONLY = &H02000000
Const JOY_CAL_READUONLY = &H04000000
Const JOY_CAL_READVONLY = &H08000000

' joystick ID constants
Const JOYSTICKID1 = 0
Const JOYSTICKID2 = 1

' joystick driver capabilites
Const JOYCAPS_HASZ = &H0001
Const JOYCAPS_HASR = &H0002
Const JOYCAPS_HASU = &H0004
Const JOYCAPS_HASV = &H0008
Const JOYCAPS_HASPOV = &H0010
Const JOYCAPS_POV4DIR = &H0020
Const JOYCAPS_POVCTS = &H0040

Type JOYCAPSW
	wMid As Word
	wPid As Word
	szPname[ELM(MAXPNAMELEN)] As WCHAR
	wXmin As DWord
	wXmax As DWord
	wYmin As DWord
	wYmax As DWord
	wZmin As DWord
	wZmax As DWord
	wNumButtons As DWord
	wPeriodMin As DWord
	wPeriodMax As DWord
	wRmin As DWord
	wRmax As DWord
	wUmin As DWord
	wUmax As DWord
	wVmin As DWord
	wVmax As DWord
	wCaps As DWord
	wMaxAxes As DWord
	wNumAxes As DWord
	wMaxButtons As DWord
	szRegKey[ELM(MAXPNAMELEN)] As WCHAR
	szOEMVxD[ELM(MAX_JOYSTICKOEMVXDNAME)] As WCHAR
End Type
TypeDef PJOYCAPSW = *JOYCAPSW
TypeDef NPJOYCAPSW = *JOYCAPSW
TypeDef LPJOYCAPSW = *JOYCAPSW

Type JOYCAPSA
	wMid As Word
	wPid As Word
	szPname[ELM(MAXPNAMELEN)] As SByte
	wXmin As DWord
	wXmax As DWord
	wYmin As DWord
	wYmax As DWord
	wZmin As DWord
	wZmax As DWord
	wNumButtons As DWord
	wPeriodMin As DWord
	wPeriodMax As DWord
	wRmin As DWord
	wRmax As DWord
	wUmin As DWord
	wUmax As DWord
	wVmin As DWord
	wVmax As DWord
	wCaps As DWord
	wMaxAxes As DWord
	wNumAxes As DWord
	wMaxButtons As DWord
	szRegKey[ELM(MAXPNAMELEN)] As SByte
	szOEMVxD[ELM(MAX_JOYSTICKOEMVXDNAME)] As SByte
End Type
TypeDef PJOYCAPSA = *JOYCAPSA
TypeDef NPJOYCAPSA = *JOYCAPSA
TypeDef LPJOYCAPSA = *JOYCAPSA

#ifdef UNICODE
TypeDef JOYCAPS = JOYCAPSW
TypeDef PJOYCAPS = PJOYCAPSW
TypeDef NPJOYCAPS = NPJOYCAPSW
TypeDef LPJOYCAPS = LPJOYCAPSW
#else
TypeDef JOYCAPS = JOYCAPSA
TypeDef PJOYCAPS = PJOYCAPSA
TypeDef NPJOYCAPS = NPJOYCAPSA
TypeDef LPJOYCAPS = LPJOYCAPSA
#endif

Type JOYINFO
	wXpos As DWord
	wYpos As DWord
	wZpos As DWord
	wButtons As DWord
End Type
TypeDef PJOYINFO = *JOYINFO
TypeDef NPJOYINFO = *JOYINFO
TypeDef LPJOYINFO = *JOYINFO

Type JOYINFOEX
	dwSize As DWord
	dwFlags As DWord
	dwXpos As DWord
	dwYpos As DWord
	dwZpos As DWord
	dwRpos As DWord
	dwUpos As DWord
	dwVpos As DWord
	dwButtons As DWord
	dwButtonNumber As DWord
	dwPOV As DWord
	dwReserved1 As DWord
	dwReserved2 As DWord
End Type
TypeDef PJOYINFOEX = *JOYINFOEX
TypeDef NPJOYINFOEX = *JOYINFOEX
TypeDef LPJOYINFOEX = *JOYINFOEX

' joystick function prototypes
Declare Function joyGetNumDevs Lib "winmm" () As DWord
#ifdef UNICODE
Declare Function joyGetDevCaps Lib "winmm" Alias "joyGetDevCapsW" (uJoyID As DWord, pjc As *JOYCAPSW, cbjc As DWord) As MMRESULT
#else
Declare Function joyGetDevCaps Lib "winmm" Alias "joyGetDevCapsA" (uJoyID As DWord, pjc As *JOYCAPS, cbjc As DWord) As MMRESULT
#endif
Declare Function joyGetPos Lib "winmm" (uJoyID As DWord, pji As *JOYINFO) As MMRESULT
Declare Function joyGetPosEx Lib "winmm" (uJoyID As DWord, pji As *JOYINFOEX) As MMRESULT
Declare Function joyGetThreshold Lib "winmm" (uJoyID As DWord, puThreshold As *DWord) As MMRESULT
Declare Function joyReleaseCapture Lib "winmm" (uJoyID As DWord) As MMRESULT
Declare Function joySetCapture Lib "winmm" (hwnd As HWND, uJoyID As DWord, uPeriod As DWord, fChanged As BOOL) As MMRESULT
Declare Function joySetThreshold Lib "winmm" (uJoyID As DWord, uThreshold As DWord) As MMRESULT


'--------------------------------------------------------
' Multimedia File I/O support

' MMIO error return values
Const MMIOERR_BASE = 256
Const MMIOERR_FILENOTFOUND = (MMIOERR_BASE + 1)
Const MMIOERR_OUTOFMEMORY = (MMIOERR_BASE + 2)
Const MMIOERR_CANNOTOPEN = (MMIOERR_BASE + 3)
Const MMIOERR_CANNOTCLOSE = (MMIOERR_BASE + 4)
Const MMIOERR_CANNOTREAD = (MMIOERR_BASE + 5)
Const MMIOERR_CANNOTWRITE = (MMIOERR_BASE + 6)
Const MMIOERR_CANNOTSEEK = (MMIOERR_BASE + 7)
Const MMIOERR_CANNOTEXPAND = (MMIOERR_BASE + 8)
Const MMIOERR_CHUNKNOTFOUND = (MMIOERR_BASE + 9)
Const MMIOERR_UNBUFFERED = (MMIOERR_BASE + 10)
Const MMIOERR_PATHNOTFOUND = (MMIOERR_BASE + 11)
Const MMIOERR_ACCESSDENIED = (MMIOERR_BASE + 12)
Const MMIOERR_SHARINGVIOLATION = (MMIOERR_BASE + 13)
Const MMIOERR_NETWORKERROR = (MMIOERR_BASE + 14)
Const MMIOERR_TOOMANYOPENFILES = (MMIOERR_BASE + 15)
Const MMIOERR_INVALIDFILE = (MMIOERR_BASE + 16)

' MMIO constants
Const CFSEPCHAR = "+"

' MMIO data types
TypeDef FOURCC = DWord
TypeDef HPSTR = *Char
TypeDef HMMIO = VoidPtr

TypeDef LPMMIOPROC = *Function(lpmmioinfo As LPSTR, uMsg As DWord, lParam1 As LPARAM, lParam2 As LPARAM) As LRESULT

Type MMIOINFO
	dwFlags As DWord
	fccIOProc As FOURCC
	pIOProc As LPMMIOPROC
	wErrorRet As DWord
	htask As HTASK
	cchBuffer As Long
	pchBuffer As HPSTR
	pchNext As HPSTR
	pchEndRead As HPSTR
	pchEndWrite As HPSTR
	lBufOffset As Long
	lDiskOffset As Long
	adwInfo[ELM(3)] As DWord
	dwReserved1 As DWord
	dwReserved2 As DWord
	hmmio As HMMIO
End Type
TypeDef PMMIOINFO = *MMIOINFO
TypeDef NPMMIOINFO = *MMIOINFO
TypeDef LPMMIOINFO = *MMIOINFO

Type MMCKINFO
	ckid As FOURCC
	cksize As DWord
	fccType As FOURCC
	dwDataOffset As DWord
	dwFlags As DWord
End Type
TypeDef PMMCKINFO = *MMCKINFO
TypeDef NPMMCKINFO = *MMCKINFO
TypeDef LPMMCKINFO = *MMCKINFO

Const MMIO_RWMODE = &H00000003
Const MMIO_SHAREMODE = &H00000070
Const MMIO_CREATE = &H00001000
Const MMIO_PARSE = &H00000100
Const MMIO_DELETE = &H00000200
Const MMIO_EXIST = &H00004000
Const MMIO_ALLOCBUF = &H00010000
Const MMIO_GETTEMP = &H00020000
Const MMIO_DIRTY = &H10000000
Const MMIO_READ = &H00000000
Const MMIO_WRITE = &H00000001
Const MMIO_READWRITE = &H00000002
Const MMIO_COMPAT = &H00000000
Const MMIO_EXCLUSIVE = &H00000010
Const MMIO_DENYWRITE = &H00000020
Const MMIO_DENYREAD = &H00000030
Const MMIO_DENYNONE = &H00000040
Const MMIO_FHOPEN = &H0010
Const MMIO_EMPTYBUF = &H0010
Const MMIO_TOUPPER = &H0010
Const MMIO_INSTALLPROC = &H00010000
Const MMIO_GLOBALPROC = &H10000000
Const MMIO_REMOVEPROC = &H00020000
Const MMIO_UNICODEPROC = &H01000000
Const MMIO_FINDPROC = &H00040000
Const MMIO_FINDCHUNK = &H0010
Const MMIO_FINDRIFF = &H0020
Const MMIO_FINDLIST = &H0040
Const MMIO_CREATERIFF = &H0020
Const MMIO_CREATELIST = &H0040

Const MMIOM_READ = MMIO_READ
Const MMIOM_WRITE = MMIO_WRITE
Const MMIOM_SEEK = 2
Const MMIOM_OPEN = 3
Const MMIOM_CLOSE = 4
Const MMIOM_WRITEFLUSH = 5
Const MMIOM_RENAME = 6
Const MMIOM_USER = &H8000

Const FOURCC_RIFF = MAKEFOURCC(&H52, &H49, &H46, &H46)
Const FOURCC_LIST = MAKEFOURCC(&H4C, &H49, &H53, &H54)
Const FOURCC_DOS = MAKEFOURCC(&H44, &H4F, &H53, &H20)
Const FOURCC_MEM = MAKEFOURCC(&H4D, &H45, &H4D, &H20)

Const SEEK_SET = 0
Const SEEK_CUR = 1
Const SEEK_END = 2

Const MMIO_DEFAULTBUFFER = 8192

Function mmioFOURCC(ch0 As String, ch1 As String, ch2 As String, ch3 As String) As FOURCC
	mmioFOURCC = MAKEFOURCC(Asc(ch0), Asc(ch1), Asc(ch2), Asc(ch3))
End Function

' MMIO function prototypes
#ifdef UNICODE
Declare Function mmioStringToFOURCC Lib "winmm" Alias "mmioStringToFOURCCW" (sz As LPWSTR, uFlags As DWord) As FOURCC
Declare Function mmioInstallIOProc Lib "winmm" Alias "mmioInstallIOProcW" (fccIOProc As FOURCC, pIOProc As LPMMIOPROC, dwFlags As DWord) As LPMMIOPROC
Declare Function mmioOpen Lib "winmm" Alias "mmioOpenW" (pszFileName As LPWSTR, pmmioinfo As *MMIOINFO, fdwOpen As DWord) As HMMIO
Declare Function mmioRename Lib "winmm" Alias "mmioRenameW" (pszFileName As LPSTR, pszNewFileName As LPWSTR, pmmioinfo As *MMIOINFO, fdwRename As DWord) As MMRESULT
#else
Declare Function mmioStringToFOURCC Lib "winmm" Alias "mmioStringToFOURCCA" (sz As LPSTR, uFlags As DWord) As FOURCC
Declare Function mmioInstallIOProc Lib "winmm" Alias "mmioInstallIOProcA" (fccIOProc As FOURCC, pIOProc As LPMMIOPROC, dwFlags As DWord) As LPMMIOPROC
Declare Function mmioOpen Lib "winmm" Alias "mmioOpenA" (pszFileName As LPSTR, pmmioinfo As *MMIOINFO, fdwOpen As DWord) As HMMIO
Declare Function mmioRename Lib "winmm" Alias "mmioRenameA" (pszFileName As LPSTR, pszNewFileName As LPSTR, pmmioinfo As *MMIOINFO, fdwRename As DWord) As MMRESULT
#endif
Declare Function mmioClose Lib "winmm" (hmmio As HMMIO, fuClose As DWord) As MMRESULT
Declare Function mmioRead Lib "winmm" (hmmio As HMMIO, pch As HPSTR, cch As Long) As Long
Declare Function mmioWrite Lib "winmm" (hmmio As HMMIO, pch As HPSTR, cch As Long) As Long
Declare Function mmioSeek Lib "winmm" (hmmio As HMMIO, lOffset As Long, iOrigin As Long) As Long
Declare Function mmioGetInfo Lib "winmm" (hmmio As HMMIO, pmmioinfo As *MMIOINFO, fuInfo As DWord) As MMRESULT
Declare Function mmioSetInfo Lib "winmm" (hmmio As HMMIO, pmmioinfo As *MMIOINFO, fuInfo As DWord) As MMRESULT
Declare Function mmioSetBuffer Lib "winmm" (hmmio As HMMIO, pchBuffer As LPSTR, cchBuffer As Long, fuBuffer As DWord) As MMRESULT
Declare Function mmioFlush Lib "winmm" (hmmio As HMMIO, fuFlush As DWord) As MMRESULT
Declare Function mmioAdvance Lib "winmm" (hmmio As HMMIO, pmmioinfo As *MMIOINFO, fuAdvance As DWord) As MMRESULT
Declare Function mmioSendMessage Lib "winmm" (hmmio As HMMIO, uMsg As DWord, lParam1 As LPARAM, lParam2 As LPARAM) As LRESULT
Declare Function mmioDescend Lib "winmm" (hmmio As HMMIO, pmmcki As *MMCKINFO, pmmckiParent As *MMCKINFO, fuDescend As DWord) As MMRESULT
Declare Function mmioAscend Lib "winmm" (hmmio As HMMIO, pmmcki As *MMCKINFO, fuAscend As DWord) As MMRESULT
Declare Function mmioCreateChunk Lib "winmm" (hmmio As HMMIO, pmmcki As *MMCKINFO, fuCreate As DWord) As MMRESULT


'--------------------------------------------------------
' MCI support

TypeDef MCIERROR = DWord
TypeDef MCIDEVICEID = DWord
TypeDef YIELDPROC = *Function(mciId As MCIDEVICEID, dwYieldData As DWord) As DWord

' MCI Functions
#ifdef UNICODE
Declare Function mciSendCommand Lib "winmm" Alias "mciSendCommandW" (mciId As MCIDEVICEID, uMsg As DWord, dwParam1 As DWord, ByRef dwParam2 As Any) As MCIERROR
Declare Function mciSendString Lib "winmm" Alias "mciSendStringW" (lpstrCommand As LPWSTR, lpstrReturnString As LPWSTR, uReturnLength As DWord, hwndCallback As HWND) As MCIERROR
Declare Function mciGetDeviceID Lib "winmm" Alias "mciGetDeviceIDW" (pszDevice As LPWSTR) As MCIDEVICEID
Declare Function mciGetErrorString Lib "winmm" Alias "mciGetErrorStringA" (mcierr As MCIERROR, pszText As LPWSTR, cchText As DWord) As BOOL
#else
Declare Function mciSendCommand Lib "winmm" Alias "mciSendCommandA" (mciId As MCIDEVICEID, uMsg As DWord, dwParam1 As DWord, ByRef dwParam2 As Any) As MCIERROR
Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (lpstrCommand As LPSTR, lpstrReturnString As LPSTR, uReturnLength As DWord, hwndCallback As HWND) As MCIERROR
Declare Function mciGetDeviceID Lib "winmm" Alias "mciGetDeviceIDA" (pszDevice As LPSTR) As MCIDEVICEID
Declare Function mciGetErrorString Lib "winmm" Alias "mciGetErrorStringA" (mcierr As MCIERROR, pszText As LPSTR, cchText As DWord) As BOOL
#endif

Declare Function mciSetYieldProc Lib "winmm" (mciId As MCIDEVICEID, fpYieldProc As YIELDPROC, dwYieldData As DWord) As BOOL
Declare Function mciGetCreatorTask Lib "winmm" (mciId As MCIDEVICEID) As HTASK
Declare Function mciGetYieldProc Lib "winmm" (mciId As MCIDEVICEID, pdwYieldData As *DWord) As YIELDPROC
Declare Function mciExecute Lib "winmm" (pszCommand As LPSTR) As BOOL

Const MCIERR_INVALID_DEVICE_ID = (MCIERR_BASE + 1)
Const MCIERR_UNRECOGNIZED_KEYWORD = (MCIERR_BASE + 3)
Const MCIERR_UNRECOGNIZED_COMMAND = (MCIERR_BASE + 5)
Const MCIERR_HARDWARE = (MCIERR_BASE + 6)
Const MCIERR_INVALID_DEVICE_NAME = (MCIERR_BASE + 7)
Const MCIERR_OUT_OF_MEMORY = (MCIERR_BASE + 8)
Const MCIERR_DEVICE_OPEN = (MCIERR_BASE + 9)
Const MCIERR_CANNOT_LOAD_DRIVER = (MCIERR_BASE + 10)
Const MCIERR_MISSING_COMMAND_STRING = (MCIERR_BASE + 11)
Const MCIERR_PARAM_OVERFLOW = (MCIERR_BASE + 12)
Const MCIERR_MISSING_STRING_ARGUMENT = (MCIERR_BASE + 13)
Const MCIERR_BAD_INTEGER = (MCIERR_BASE + 14)
Const MCIERR_PARSER_INTERNAL = (MCIERR_BASE + 15)
Const MCIERR_DRIVER_INTERNAL = (MCIERR_BASE + 16)
Const MCIERR_MISSING_PARAMETER = (MCIERR_BASE + 17)
Const MCIERR_UNSUPPORTED_FUNCTION = (MCIERR_BASE + 18)
Const MCIERR_FILE_NOT_FOUND = (MCIERR_BASE + 19)
Const MCIERR_DEVICE_NOT_READY = (MCIERR_BASE + 20)
Const MCIERR_INTERNAL = (MCIERR_BASE + 21)
Const MCIERR_DRIVER = (MCIERR_BASE + 22)
Const MCIERR_CANNOT_USE_ALL = (MCIERR_BASE + 23)
Const MCIERR_MULTIPLE = (MCIERR_BASE + 24)
Const MCIERR_EXTENSION_NOT_FOUND = (MCIERR_BASE + 25)
Const MCIERR_OUTOFRANGE = (MCIERR_BASE + 26)
Const MCIERR_FLAGS_NOT_COMPATIBLE = (MCIERR_BASE + 28)
Const MCIERR_FILE_NOT_SAVED = (MCIERR_BASE + 30)
Const MCIERR_DEVICE_TYPE_REQUIRED = (MCIERR_BASE + 31)
Const MCIERR_DEVICE_LOCKED = (MCIERR_BASE + 32)
Const MCIERR_DUPLICATE_ALIAS = (MCIERR_BASE + 33)
Const MCIERR_BAD_CONSTANT = (MCIERR_BASE + 34)
Const MCIERR_MUST_USE_SHAREABLE = (MCIERR_BASE + 35)
Const MCIERR_MISSING_DEVICE_NAME = (MCIERR_BASE + 36)
Const MCIERR_BAD_TIME_FORMAT = (MCIERR_BASE + 37)
Const MCIERR_NO_CLOSING_QUOTE = (MCIERR_BASE + 38)
Const MCIERR_DUPLICATE_FLAGS = (MCIERR_BASE + 39)
Const MCIERR_INVALID_FILE = (MCIERR_BASE + 40)
Const MCIERR_NULL_PARAMETER_BLOCK = (MCIERR_BASE + 41)
Const MCIERR_UNNAMED_RESOURCE = (MCIERR_BASE + 42)
Const MCIERR_NEW_REQUIRES_ALIAS = (MCIERR_BASE + 43)
Const MCIERR_NOTIFY_ON_AUTO_OPEN = (MCIERR_BASE + 44)
Const MCIERR_NO_ELEMENT_ALLOWED = (MCIERR_BASE + 45)
Const MCIERR_NONAPPLICABLE_FUNCTION = (MCIERR_BASE + 46)
Const MCIERR_ILLEGAL_FOR_AUTO_OPEN = (MCIERR_BASE + 47)
Const MCIERR_FILENAME_REQUIRED = (MCIERR_BASE + 48)
Const MCIERR_EXTRA_CHARACTERS = (MCIERR_BASE + 49)
Const MCIERR_DEVICE_NOT_INSTALLED = (MCIERR_BASE + 50)
Const MCIERR_GET_CD = (MCIERR_BASE + 51)
Const MCIERR_SET_CD = (MCIERR_BASE + 52)
Const MCIERR_SET_DRIVE = (MCIERR_BASE + 53)
Const MCIERR_DEVICE_LENGTH = (MCIERR_BASE + 54)
Const MCIERR_DEVICE_ORD_LENGTH = (MCIERR_BASE + 55)
Const MCIERR_NO_INTEGER = (MCIERR_BASE + 56)

Const MCIERR_WAVE_OUTPUTSINUSE = (MCIERR_BASE + 64)
Const MCIERR_WAVE_SETOUTPUTINUSE = (MCIERR_BASE + 65)
Const MCIERR_WAVE_INPUTSINUSE = (MCIERR_BASE + 66)
Const MCIERR_WAVE_SETINPUTINUSE = (MCIERR_BASE + 67)
Const MCIERR_WAVE_OUTPUTUNSPECIFIED = (MCIERR_BASE + 68)
Const MCIERR_WAVE_INPUTUNSPECIFIED = (MCIERR_BASE + 69)
Const MCIERR_WAVE_OUTPUTSUNSUITABLE = (MCIERR_BASE + 70)
Const MCIERR_WAVE_SETOUTPUTUNSUITABLE = (MCIERR_BASE + 71)
Const MCIERR_WAVE_INPUTSUNSUITABLE = (MCIERR_BASE + 72)
Const MCIERR_WAVE_SETINPUTUNSUITABLE = (MCIERR_BASE + 73)

Const MCIERR_SEQ_DIV_INCOMPATIBLE = (MCIERR_BASE + 80)
Const MCIERR_SEQ_PORT_INUSE = (MCIERR_BASE + 81)
Const MCIERR_SEQ_PORT_NONEXISTENT = (MCIERR_BASE + 82)
Const MCIERR_SEQ_PORT_MAPNODEVICE = (MCIERR_BASE + 83)
Const MCIERR_SEQ_PORT_MISCERROR = (MCIERR_BASE + 84)
Const MCIERR_SEQ_TIMER = (MCIERR_BASE + 85)
Const MCIERR_SEQ_PORTUNSPECIFIED = (MCIERR_BASE + 86)
Const MCIERR_SEQ_NOMIDIPRESENT = (MCIERR_BASE + 87)

Const MCIERR_NO_WINDOW = (MCIERR_BASE + 90)
Const MCIERR_CREATEWINDOW = (MCIERR_BASE + 91)
Const MCIERR_FILE_READ = (MCIERR_BASE + 92)
Const MCIERR_FILE_WRITE = (MCIERR_BASE + 93)
Const MCIERR_NO_IDENTITY = (MCIERR_BASE + 94)
Const MCIERR_CUSTOM_DRIVER_BASE = (MCIERR_BASE + 256)

Const MCI_FIRST = DRV_MCI_FIRST
Const MCI_OPEN = &H0803
Const MCI_CLOSE = &H0804
Const MCI_ESCAPE = &H0805
Const MCI_PLAY = &H0806
Const MCI_SEEK = &H0807
Const MCI_STOP = &H0808
Const MCI_PAUSE = &H0809
Const MCI_INFO = &H080A
Const MCI_GETDEVCAPS = &H080B
Const MCI_SPIN = &H080C
Const MCI_SET = &H080D
Const MCI_STEP = &H080E
Const MCI_RECORD = &H080F
Const MCI_SYSINFO = &H0810
Const MCI_BREAK = &H0811
Const MCI_SAVE = &H0813
Const MCI_STATUS = &H0814
Const MCI_CUE = &H0830
Const MCI_REALIZE = &H0840
Const MCI_WINDOW = &H0841
Const MCI_PUT = &H0842
Const MCI_WHERE = &H0843
Const MCI_FREEZE = &H0844
Const MCI_UNFREEZE = &H0845
Const MCI_LOAD = &H0850
Const MCI_CUT = &H0851
Const MCI_COPY = &H0852
Const MCI_PASTE = &H0853
Const MCI_UPDATE = &H0854
Const MCI_RESUME = &H0855
Const MCI_DELETE = &H0856

Const MCI_USER_MESSAGES = (DRV_MCI_FIRST + &H400)
Const MCI_LAST = &H0FFF

Const MCI_ALL_DEVICE_ID = (-1)

' constants for predefined MCI device types
Const MCI_DEVTYPE_VCR =               513
Const MCI_DEVTYPE_VIDEODISC =         514
Const MCI_DEVTYPE_OVERLAY =           515
Const MCI_DEVTYPE_CD_AUDIO =          516
Const MCI_DEVTYPE_DAT =               517
Const MCI_DEVTYPE_SCANNER =           518
Const MCI_DEVTYPE_ANIMATION =         519
Const MCI_DEVTYPE_DIGITAL_VIDEO =     520
Const MCI_DEVTYPE_OTHER =             521
Const MCI_DEVTYPE_WAVEFORM_AUDIO =    522
Const MCI_DEVTYPE_SEQUENCER =         523
Const MCI_DEVTYPE_FIRST =             MCI_DEVTYPE_VCR
Const MCI_DEVTYPE_LAST =              MCI_DEVTYPE_SEQUENCER
Const MCI_DEVTYPE_FIRST_USER =        &H1000

' return values for 'status mode' command
Const MCI_MODE_NOT_READY =            MCI_STRING_OFFSET + 12
Const MCI_MODE_STOP =                 MCI_STRING_OFFSET + 13
Const MCI_MODE_PLAY =                 MCI_STRING_OFFSET + 14
Const MCI_MODE_RECORD =               MCI_STRING_OFFSET + 15
Const MCI_MODE_SEEK =                 MCI_STRING_OFFSET + 16
Const MCI_MODE_PAUSE =                MCI_STRING_OFFSET + 17
Const MCI_MODE_OPEN =                 MCI_STRING_OFFSET + 18

'--------------------------------------------------------
' Time Format(used in MCI_SET_PARAMS, MCI_STATUS_PARAMS)

Const MCI_FORMAT_MILLISECONDS =       0
Const MCI_FORMAT_HMS =                1
Const MCI_FORMAT_MSF =                2
Const MCI_FORMAT_FRAMES =             3
Const MCI_FORMAT_SMPTE_24 =           4
Const MCI_FORMAT_SMPTE_25 =           5
Const MCI_FORMAT_SMPTE_30 =           6
Const MCI_FORMAT_SMPTE_30DROP =       7
Const MCI_FORMAT_BYTES =              8
Const MCI_FORMAT_SAMPLES =            9
Const MCI_FORMAT_TMSF =               10

'------------
' MCI Macros

'MSF
Function MCI_MSF_MINUTE(msf As DWord) As Byte
	Return (&HFF and msf) As Byte
End Function
Function MCI_MSF_SECOND(msf As DWord) As Byte
	Return (&HFF and (msf>> 8)) As Byte
End Function
Function MCI_MSF_FRAME(msf As DWord) As Byte
	Return (&HFF and (msf>>16)) As Byte
End Function
Function MCI_MAKE_MSF(minutes As Byte, seconds As Byte, frames As Byte) As DWord
	Return MAKELONG(minutes,MAKEWORD(seconds,frames))
End Function

'TMSF
Function MCI_TMSF_TRACK(tmsf As DWord) As Byte
	Return (&HFF and (tmsf)) As Byte
End Function
Function MCI_TMSF_MINUTE(tmsf As DWord) As Byte
	Return (&HFF and (((tmsf)) >> 8)) As Byte
End Function
Function MCI_TMSF_SECOND(tmsf As DWord) As Byte
	Return (&HFF and ((tmsf)>>16)) As Byte
End Function
Function MCI_TMSF_FRAME(tmsf As DWord) As Byte
	Return (&HFF and ((tmsf)>>24)) As Byte
End Function
Function MCI_MAKE_TMSF(tracks As Byte, minutes As Byte, seconds As Byte, frames As Byte) As DWord
	Return MAKELONG(MAKEWORD(tracks,minutes),MAKEWORD(seconds,frames))
End Function

'HMS
Function MCI_HMS_HOUR(hms As DWord) As Byte
	Return (&HFF and (hms)) As Byte
End Function
Function MCI_HMS_MINUTE(hms As DWord) As Byte
	Return (&HFF and ((hms)>> 8)) As Byte
End Function
Function MCI_HMS_SECOND(hms As DWord) As Byte
	Return (&HFF and ((hms)>>16)) As Byte
End Function
Function MCI_MAKE_HMS(hours As Byte, minutes As Byte, seconds As Byte) As DWord
	Return MAKELONG(hours,MAKEWORD(minutes,seconds))
End Function

' flags for wParam of MM_MCINOTIFY message
Const MCI_NOTIFY_SUCCESSFUL = &H0001
Const MCI_NOTIFY_SUPERSEDED = &H0002
Const MCI_NOTIFY_ABORTED = &H0004
Const MCI_NOTIFY_FAILURE = &H0008

' common flags for dwFlags parameter of MCI command messages
Const MCI_NOTIFY =                    &H00000001
Const MCI_WAIT =                      &H00000002
Const MCI_FROM =                      &H00000004
Const MCI_TO =                        &H00000008
Const MCI_TRACK =                     &H00000010

' flags for dwFlags parameter of MCI_OPEN command message
Const MCI_OPEN_SHAREABLE =            &H00000100
Const MCI_OPEN_ELEMENT =              &H00000200
Const MCI_OPEN_ALIAS =                &H00000400
Const MCI_OPEN_ELEMENT_ID =           &H00000800
Const MCI_OPEN_TYPE_ID =              &H00001000
Const MCI_OPEN_TYPE =                 &H00002000

' flags for dwFlags parameter of MCI_SEEK command message
Const MCI_SEEK_TO_START = &H00000100
Const MCI_SEEK_TO_END = &H00000200

' flags for dwFlags parameter of MCI_STATUS command message
Const MCI_STATUS_ITEM = &H00000100
Const MCI_STATUS_START = &H00000200

' flags for dwItem field of the MCI_STATUS_PARMS parameter block
Const MCI_STATUS_LENGTH = &H00000001
Const MCI_STATUS_POSITION = &H00000002
Const MCI_STATUS_NUMBER_OF_TRACKS = &H00000003
Const MCI_STATUS_MODE = &H00000004
Const MCI_STATUS_MEDIA_PRESENT = &H00000005
Const MCI_STATUS_TIME_FORMAT = &H00000006
Const MCI_STATUS_READY = &H00000007
Const MCI_STATUS_CURRENT_TRACK = &H00000008

' flags for dwFlags parameter of MCI_INFO command message
Const MCI_INFO_PRODUCT = &H00000100
Const MCI_INFO_FILE = &H00000200
Const MCI_INFO_MEDIA_UPC = &H00000400
Const MCI_INFO_MEDIA_IDENTITY = &H00000800
Const MCI_INFO_NAME = &H00001000
Const MCI_INFO_COPYRIGHT = &H00002000

' flags for dwFlags parameter of MCI_GETDEVCAPS command message
Const MCI_GETDEVCAPS_ITEM = &H00000100

' flags for dwItem field of the MCI_GETDEVCAPS_PARMS parameter block
Const MCI_GETDEVCAPS_CAN_RECORD = &H00000001
Const MCI_GETDEVCAPS_HAS_AUDIO = &H00000002
Const MCI_GETDEVCAPS_HAS_VIDEO = &H00000003
Const MCI_GETDEVCAPS_DEVICE_TYPE = &H00000004
Const MCI_GETDEVCAPS_USES_FILES = &H00000005
Const MCI_GETDEVCAPS_COMPOUND_DEVICE = &H00000006
Const MCI_GETDEVCAPS_CAN_EJECT = &H00000007
Const MCI_GETDEVCAPS_CAN_PLAY = &H00000008
Const MCI_GETDEVCAPS_CAN_SAVE = &H00000009

' flags for dwFlags parameter of MCI_SYSINFO command message
Const MCI_SYSINFO_QUANTITY = &H00000100
Const MCI_SYSINFO_OPEN = &H00000200
Const MCI_SYSINFO_NAME = &H00000400
Const MCI_SYSINFO_INSTALLNAME = &H00000800

' flags for dwFlags parameter of MCI_SET command message
Const MCI_SET_DOOR_OPEN = &H00000100
Const MCI_SET_DOOR_CLOSED = &H00000200
Const MCI_SET_TIME_FORMAT = &H00000400
Const MCI_SET_AUDIO = &H00000800
Const MCI_SET_VIDEO = &H00001000
Const MCI_SET_ON = &H00002000
Const MCI_SET_OFF = &H00004000

' flags for dwAudio field of MCI_SET_PARMS or MCI_SEQ_SET_PARMS
Const MCI_SET_AUDIO_ALL = &H00000000
Const MCI_SET_AUDIO_LEFT = &H00000001
Const MCI_SET_AUDIO_RIGHT = &H00000002

' flags for dwFlags parameter of MCI_BREAK command message
Const MCI_BREAK_KEY = &H00000100
Const MCI_BREAK_HWND = &H00000200
Const MCI_BREAK_OFF = &H00000400

' flags for dwFlags parameter of MCI_RECORD command message
Const MCI_RECORD_INSERT = &H00000100
Const MCI_RECORD_OVERWRITE = &H00000200

' flags for dwFlags parameter of MCI_SAVE command message
Const MCI_SAVE_FILE = &H00000100

' flags for dwFlags parameter of MCI_LOAD command message
Const MCI_LOAD_FILE = &H00000100

Type MCI_GENERIC_PARMS
	dwCallback As DWord
End Type
TypeDef PMCI_GENERIC_PARMS = *MCI_GENERIC_PARMS
TypeDef LPMCI_GENERIC_PARMS = *MCI_GENERIC_PARMS

Type MCI_OPEN_PARMS
	dwCallback As DWord
	wDeviceID As DWord
	lpstrDeviceType As LPSTR
	lpstrElementName As LPSTR
	lpstrAlias As LPSTR
End Type
TypeDef PMCI_OPEN_PARMS = *MCI_OPEN_PARMS
TypeDef LPMCI_OPEN_PARMS = *MCI_OPEN_PARMS

Type MCI_PLAY_PARMS
	dwCallback As DWord
	dwFrom As DWord
	dwTo As DWord
End Type
TypeDef PMCI_PLAY_PARMS = *MCI_PLAY_PARMS
TypeDef LPMCI_PLAY_PARMS = *MCI_PLAY_PARMS

Type MCI_SEEK_PARMS
	dwCallback As DWord
	dwTo As DWord
End Type
TypeDef PMCI_SEEK_PARMS = *MCI_SEEK_PARMS
TypeDef LPMCI_SEEK_PARMS = *MCI_SEEK_PARMS

Type MCI_STATUS_PARMS
	dwCallback As DWord
	dwReturn As DWord
	dwItem As DWord
	dwTrack As DWord
End Type
TypeDef PMCI_STATUS_PARMS = *MCI_STATUS_PARMS
TypeDef LPMCI_STATUS_PARMS = *MCI_STATUS_PARMS

Type MCI_INFO_PARMSW
	dwCallback As DWord
	lpstrReturn As LPWSTR
	dwRetSize As DWord
End Type
TypeDef PMCI_INFO_PARMSW = *MCI_INFO_PARMSW
TypeDef LPMCI_INFO_PARMSW = *MCI_INFO_PARMSW

Type MCI_INFO_PARMSA
	dwCallback As DWord
	lpstrReturn As LPSTR
	dwRetSize As DWord
End Type
TypeDef PMCI_INFO_PARMSA = *MCI_INFO_PARMSA
TypeDef LPMCI_INFO_PARMSA = *MCI_INFO_PARMSA

#ifdef UNICODE
TypeDef MCI_INFO_PARMS = MCI_INFO_PARMSW
TypeDef PMCI_INFO_PARMS = PMCI_INFO_PARMSW
TypeDef LPMCI_INFO_PARMS = LPMCI_INFO_PARMSW
#else
TypeDef MCI_INFO_PARMS = MCI_INFO_PARMSA
TypeDef PMCI_INFO_PARMS = PMCI_INFO_PARMSA
TypeDef LPMCI_INFO_PARMS = LPMCI_INFO_PARMSA
#endif

Type MCI_GETDEVCAPS_PARMS
	dwCallback As DWord
	dwReturn As DWord
	dwItem As DWord
End Type
TypeDef PMCI_GETDEVCAPS_PARMS = *MCI_GETDEVCAPS_PARMS
TypeDef LPMCI_GETDEVCAPS_PARMS = *MCI_GETDEVCAPS_PARMS

Type MCI_SYSINFO_PARMSW
	dwCallback As DWord
	lpstrReturn As LPWSTR
	dwRetSize As DWord
	dwNumber As DWord
	wDeviceType As DWord
End Type
TypeDef PMCI_SYSINFO_PARMSW = *MCI_SYSINFO_PARMSW
TypeDef LPMCI_SYSINFO_PARMSW = *MCI_SYSINFO_PARMSW

Type MCI_SYSINFO_PARMSA
	dwCallback As DWord
	lpstrReturn As LPSTR
	dwRetSize As DWord
	dwNumber As DWord
	wDeviceType As DWord
End Type
TypeDef PMCI_SYSINFO_PARMSA = *MCI_SYSINFO_PARMSA
TypeDef LPMCI_SYSINFO_PARMSA = *MCI_SYSINFO_PARMSA

#ifdef UNICODE
TypeDef MCI_SYSINFO_PARMS = MCI_SYSINFO_PARMSW
TypeDef PMCI_SYSINFO_PARMS = PMCI_SYSINFO_PARMSW
TypeDef LPMCI_SYSINFO_PARMS = LPMCI_SYSINFO_PARMSW
#else
TypeDef MCI_SYSINFO_PARMS = MCI_SYSINFO_PARMSA
TypeDef PMCI_SYSINFO_PARMS = PMCI_SYSINFO_PARMSA
TypeDef LPMCI_SYSINFO_PARMS = LPMCI_SYSINFO_PARMSA
#endif

Type MCI_SET_PARMS
	dwCallback As DWord
	dwTimeFormat As DWord
	dwAudio As DWord
End Type
TypeDef PMCI_SET_PARMS = *MCI_SET_PARMS
TypeDef LPMCI_SET_PARMS = *MCI_SET_PARMS

Type MCI_BREAK_PARMS
	dwCallback As DWord
	nVirtKey As Long
	hwndBreak As HWND
End Type
TypeDef PMCI_BREAK_PARMS = *MCI_BREAK_PARMS
TypeDef LPMCI_BREAK_PARMS = *MCI_BREAK_PARMS

Type MCI_SAVE_PARMSW
	dwCallback As DWord
	lpfilename As LPWSTR
End Type
TypeDef PMCI_SAVE_PARMSW = *MCI_SAVE_PARMSW
TypeDef LPMCI_SAVE_PARMSW = *MCI_SAVE_PARMSW

Type MCI_SAVE_PARMSA
	dwCallback As DWord
	lpfilename As LPSTR
End Type
TypeDef PMCI_SAVE_PARMSA = *MCI_SAVE_PARMSA
TypeDef LPMCI_SAVE_PARMSA = *MCI_SAVE_PARMSA

#ifdef UNICODE
TypeDef MCI_SAVE_PARMS = MCI_SAVE_PARMSW
TypeDef PMCI_SAVE_PARMS = PMCI_SAVE_PARMSW
TypeDef LPMCI_SAVE_PARMS = LPMCI_SAVE_PARMSW
#else
TypeDef MCI_SAVE_PARMS = MCI_SAVE_PARMSA
TypeDef PMCI_SAVE_PARMS = PMCI_SAVE_PARMSA
TypeDef LPMCI_SAVE_PARMS = LPMCI_SAVE_PARMSA
#endif

Type MCI_LOAD_PARMSW
	dwCallback As DWord
	lpfilename As LPWSTR
End Type
TypeDef PMCI_LOAD_PARMSW = *MCI_LOAD_PARMSW
TypeDef LPMCI_LOAD_PARMSW = *MCI_LOAD_PARMSW

Type MCI_LOAD_PARMSA
	dwCallback As DWord
	lpfilename As LPSTR
End Type
TypeDef PMCI_LOAD_PARMSA = *MCI_LOAD_PARMSA
TypeDef LPMCI_LOAD_PARMSA = *MCI_LOAD_PARMSA

#ifdef UNICODE
TypeDef MCI_LOAD_PARMS = MCI_LOAD_PARMSW
TypeDef PMCI_LOAD_PARMS = PMCI_LOAD_PARMSW
TypeDef LPMCI_LOAD_PARMS = LPMCI_LOAD_PARMSW
#else
TypeDef MCI_LOAD_PARMS = MCI_LOAD_PARMSA
TypeDef PMCI_LOAD_PARMS = PMCI_LOAD_PARMSA
TypeDef LPMCI_LOAD_PARMS = LPMCI_LOAD_PARMSA
#endif

Type MCI_RECORD_PARMS
	dwCallback As DWord
	dwFrom As DWord
	dwTo As DWord
End Type
TypeDef PMCI_RECORD_PARMS = *MCI_RECORD_PARMS
TypeDef LPMCI_RECORD_PARMS = *MCI_RECORD_PARMS

' MCI extensions for videodisc devices
Const MCI_VD_MODE_PARK =              (MCI_VD_OFFSET + 1)
Const MCI_VD_MEDIA_CLV =              (MCI_VD_OFFSET + 2)
Const MCI_VD_MEDIA_CAV =              (MCI_VD_OFFSET + 3)
Const MCI_VD_MEDIA_OTHER =            (MCI_VD_OFFSET + 4)
Const MCI_VD_FORMAT_TRACK =           &H4001
Const MCI_VD_PLAY_REVERSE =           &H00010000
Const MCI_VD_PLAY_FAST =              &H00020000
Const MCI_VD_PLAY_SPEED =             &H00040000
Const MCI_VD_PLAY_SCAN =              &H00080000
Const MCI_VD_PLAY_SLOW =              &H00100000
Const MCI_VD_SEEK_REVERSE =           &H00010000
Const MCI_VD_STATUS_SPEED =           &H00004002
Const MCI_VD_STATUS_FORWARD =         &H00004003
Const MCI_VD_STATUS_MEDIA_TYPE =      &H00004004
Const MCI_VD_STATUS_SIDE =            &H00004005
Const MCI_VD_STATUS_DISC_SIZE =       &H00004006
Const MCI_VD_GETDEVCAPS_CLV =         &H00010000
Const MCI_VD_GETDEVCAPS_CAV =         &H00020000
Const MCI_VD_SPIN_UP =                &H00010000
Const MCI_VD_SPIN_DOWN =              &H00020000
Const MCI_VD_GETDEVCAPS_CAN_REVERSE = &H00004002
Const MCI_VD_GETDEVCAPS_FAST_RATE =   &H00004003
Const MCI_VD_GETDEVCAPS_SLOW_RATE =   &H00004004
Const MCI_VD_GETDEVCAPS_NORMAL_RATE = &H00004005
Const MCI_VD_STEP_FRAMES =            &H00010000
Const MCI_VD_STEP_REVERSE =           &H00020000
Const MCI_VD_ESCAPE_STRING =          &H00000100

Type MCI_VD_PLAY_PARMS
	dwCallback As DWord
	dwFrom As DWord
	dwTo As DWord
	dwSpeed As DWord
End Type
TypeDef PMCI_VD_PLAY_PARMS = *MCI_VD_PLAY_PARMS
TypeDef LPMCI_VD_PLAY_PARMS = *MCI_VD_PLAY_PARMS

Type MCI_VD_STEP_PARMS
	dwCallback As DWord
	dwFrames As DWord
End Type
TypeDef PMCI_VD_STEP_PARMS = *MCI_VD_STEP_PARMS
TypeDef LPMCI_VD_STEP_PARMS = *MCI_VD_STEP_PARMS

Type MCI_VD_ESCAPE_PARMSW
	dwCallback As DWord
	lpstrCommand As LPWSTR
End Type
TypeDef PMCI_VD_ESCAPE_PARMSW = *MCI_VD_ESCAPE_PARMSW
TypeDef LPMCI_VD_ESCAPE_PARMSW = *MCI_VD_ESCAPE_PARMSW

Type MCI_VD_ESCAPE_PARMSA
	dwCallback As DWord
	lpstrCommand As LPSTR
End Type
TypeDef PMCI_VD_ESCAPE_PARMSA = *MCI_VD_ESCAPE_PARMSA
TypeDef LPMCI_VD_ESCAPE_PARMSA = *MCI_VD_ESCAPE_PARMSA

#ifdef UNICODE
TypeDef MCI_VD_ESCAPE_PARMS = MCI_VD_ESCAPE_PARMSW
TypeDef PMCI_VD_ESCAPE_PARMS = PMCI_VD_ESCAPE_PARMSW
TypeDef LPMCI_VD_ESCAPE_PARMS = LPMCI_VD_ESCAPE_PARMSW
#else
TypeDef MCI_VD_ESCAPE_PARMS = MCI_VD_ESCAPE_PARMSA
TypeDef PMCI_VD_ESCAPE_PARMS = PMCI_VD_ESCAPE_PARMSA
TypeDef LPMCI_VD_ESCAPE_PARMS = LPMCI_VD_ESCAPE_PARMSA
#endif

' MCI extensions for CD audio devices
Const MCI_CDA_STATUS_TYPE_TRACK = &H00004001
Const MCI_CDA_TRACK_AUDIO = (MCI_CD_OFFSET + 0)
Const MCI_CDA_TRACK_OTHER = (MCI_CD_OFFSET + 1)

' MCI extensions for waveform audio devices
Const MCI_WAVE_PCM =                   (MCI_WAVE_OFFSET + 0)
Const MCI_WAVE_MAPPER =                (MCI_WAVE_OFFSET + 1)
Const MCI_WAVE_OPEN_BUFFER =           &H00010000
Const MCI_WAVE_SET_FORMATTAG =         &H00010000
Const MCI_WAVE_SET_CHANNELS =          &H00020000
Const MCI_WAVE_SET_SAMPLESPERSEC =     &H00040000
Const MCI_WAVE_SET_AVGBYTESPERSEC =    &H00080000
Const MCI_WAVE_SET_BLOCKALIGN =        &H00100000
Const MCI_WAVE_SET_BITSPERSAMPLE =     &H00200000
Const MCI_WAVE_INPUT =                 &H00400000
Const MCI_WAVE_OUTPUT =                &H00800000
Const MCI_WAVE_STATUS_FORMATTAG =      &H00004001
Const MCI_WAVE_STATUS_CHANNELS =       &H00004002
Const MCI_WAVE_STATUS_SAMPLESPERSEC =  &H00004003
Const MCI_WAVE_STATUS_AVGBYTESPERSEC = &H00004004
Const MCI_WAVE_STATUS_BLOCKALIGN =     &H00004005
Const MCI_WAVE_STATUS_BITSPERSAMPLE =  &H00004006
Const MCI_WAVE_STATUS_LEVEL =          &H00004007
Const MCI_WAVE_SET_ANYINPUT =          &H04000000
Const MCI_WAVE_SET_ANYOUTPUT =         &H08000000
Const MCI_WAVE_GETDEVCAPS_INPUTS =     &H00004001
Const MCI_WAVE_GETDEVCAPS_OUTPUTS =    &H00004002

Type MCI_WAVE_OPEN_PARMSW
	dwCallback As DWord
	wDeviceID As MCIDEVICEID
	lpstrDeviceType As LPWSTR
	lpstrElementName As LPWSTR
	lpstrAlias As LPWSTR
	dwBufferSeconds As DWord
End Type
TypeDef PMCI_WAVE_OPEN_PARMSW = *MCI_WAVE_OPEN_PARMSW
TypeDef LPMCI_WAVE_OPEN_PARMSW = *MCI_WAVE_OPEN_PARMSW

Type MCI_WAVE_OPEN_PARMSA
	dwCallback As DWord
	wDeviceID As MCIDEVICEID
	lpstrDeviceType As LPSTR
	lpstrElementName As LPSTR
	lpstrAlias As LPSTR
	dwBufferSeconds As DWord
End Type
TypeDef PMCI_WAVE_OPEN_PARMSA = *MCI_WAVE_OPEN_PARMSA
TypeDef LPMCI_WAVE_OPEN_PARMSA = *MCI_WAVE_OPEN_PARMSA

#ifdef UNICODE
TypeDef MCI_WAVE_OPEN_PARMS = MCI_WAVE_OPEN_PARMSW
TypeDef PMCI_WAVE_OPEN_PARMS = PMCI_WAVE_OPEN_PARMSW
TypeDef LPMCI_WAVE_OPEN_PARMS = LPMCI_WAVE_OPEN_PARMSW
#else
TypeDef MCI_WAVE_OPEN_PARMS = MCI_WAVE_OPEN_PARMSA
TypeDef PMCI_WAVE_OPEN_PARMS = PMCI_WAVE_OPEN_PARMSA
TypeDef LPMCI_WAVE_OPEN_PARMS = LPMCI_WAVE_OPEN_PARMSA
#endif

Type MCI_WAVE_DELETE_PARMS
	dwCallback As DWord
	dwFrom As DWord
	dwTo As DWord
End Type
TypeDef PMCI_WAVE_DELETE_PARMS = *MCI_WAVE_DELETE_PARMS
TypeDef LPMCI_WAVE_DELETE_PARMS = *MCI_WAVE_DELETE_PARMS

Type MCI_WAVE_SET_PARMS
	dwCallback As DWord
	dwTimeFormat As DWord
	dwAudio As DWord
	wInput As DWord
	wOutput As DWord
	wFormatTag As Word
	wReserved2 As Word
	nChannels As Word
	wReserved3 As Word
	nSamplesPerSec As DWord
	nAvgBytesPerSec As DWord
	nBlockAlign As Word
	wReserved4 As Word
	wBitsPerSample As Word
	wReserved5 As Word
End Type
TypeDef PMCI_WAVE_SET_PARMS = *MCI_WAVE_SET_PARMS
TypeDef LPMCI_WAVE_SET_PARMS = *MCI_WAVE_SET_PARMS

' MCI extensions for MIDI sequencer devices
Const MCI_SEQ_DIV_PPQN =         (0 + MCI_SEQ_OFFSET)
Const MCI_SEQ_DIV_SMPTE_24 =     (1 + MCI_SEQ_OFFSET)
Const MCI_SEQ_DIV_SMPTE_25 =     (2 + MCI_SEQ_OFFSET)
Const MCI_SEQ_DIV_SMPTE_30DROP = (3 + MCI_SEQ_OFFSET)
Const MCI_SEQ_DIV_SMPTE_30 =     (4 + MCI_SEQ_OFFSET)
Const MCI_SEQ_FORMAT_SONGPTR =   &H4001
Const MCI_SEQ_FILE =             &H4002
Const MCI_SEQ_MIDI =             &H4003
Const MCI_SEQ_SMPTE =            &H4004
Const MCI_SEQ_NONE =             65533
Const MCI_SEQ_MAPPER =           65535
Const MCI_SEQ_STATUS_TEMPO =     &H00004002
Const MCI_SEQ_STATUS_PORT =      &H00004003
Const MCI_SEQ_STATUS_SLAVE =     &H00004007
Const MCI_SEQ_STATUS_MASTER =    &H00004008
Const MCI_SEQ_STATUS_OFFSET =    &H00004009
Const MCI_SEQ_STATUS_DIVTYPE =   &H0000400A
Const MCI_SEQ_STATUS_NAME =      &H0000400B
Const MCI_SEQ_STATUS_COPYRIGHT = &H0000400C
Const MCI_SEQ_SET_TEMPO =        &H00010000
Const MCI_SEQ_SET_PORT =         &H00020000
Const MCI_SEQ_SET_SLAVE =        &H00040000
Const MCI_SEQ_SET_MASTER =       &H00080000
Const MCI_SEQ_SET_OFFSET =       &H01000000

Type MCI_SEQ_SET_PARMS
	dwCallback As DWord
	dwTimeFormat As DWord
	dwAudio As DWord
	dwTempo As DWord
	dwPort As DWord
	dwSlave As DWord
	dwMaster As DWord
	dwOffset As DWord
End Type
TypeDef PMCI_SEQ_SET_PARMS = *MCI_SEQ_SET_PARMS
TypeDef LPMCI_SEQ_SET_PARMS = *MCI_SEQ_SET_PARMS

' MCI extensions for animation devices
Const MCI_ANIM_OPEN_WS =                &H00010000
Const MCI_ANIM_OPEN_PARENT =            &H00020000
Const MCI_ANIM_OPEN_NOSTATIC =          &H00040000
Const MCI_ANIM_PLAY_SPEED =             &H00010000
Const MCI_ANIM_PLAY_REVERSE =           &H00020000
Const MCI_ANIM_PLAY_FAST =              &H00040000
Const MCI_ANIM_PLAY_SLOW =              &H00080000
Const MCI_ANIM_PLAY_SCAN =              &H00100000
Const MCI_ANIM_STEP_REVERSE =           &H00010000
Const MCI_ANIM_STEP_FRAMES =            &H00020000
Const MCI_ANIM_STATUS_SPEED =           &H00004001
Const MCI_ANIM_STATUS_FORWARD =         &H00004002
Const MCI_ANIM_STATUS_HWND =            &H00004003
Const MCI_ANIM_STATUS_HPAL =            &H00004004
Const MCI_ANIM_STATUS_STRETCH =         &H00004005
Const MCI_ANIM_INFO_TEXT =              &H00010000
Const MCI_ANIM_GETDEVCAPS_CAN_REVERSE = &H00004001
Const MCI_ANIM_GETDEVCAPS_FAST_RATE =   &H00004002
Const MCI_ANIM_GETDEVCAPS_SLOW_RATE =   &H00004003
Const MCI_ANIM_GETDEVCAPS_NORMAL_RATE = &H00004004
Const MCI_ANIM_GETDEVCAPS_PALETTES =    &H00004006
Const MCI_ANIM_GETDEVCAPS_CAN_STRETCH = &H00004007
Const MCI_ANIM_GETDEVCAPS_MAX_WINDOWS = &H00004008
Const MCI_ANIM_REALIZE_NORM =           &H00010000
Const MCI_ANIM_REALIZE_BKGD =           &H00020000
Const MCI_ANIM_WINDOW_HWND =            &H00010000
Const MCI_ANIM_WINDOW_STATE =           &H00040000
Const MCI_ANIM_WINDOW_TEXT =            &H00080000
Const MCI_ANIM_WINDOW_ENABLE_STRETCH =  &H00100000
Const MCI_ANIM_WINDOW_DISABLE_STRETCH = &H00200000
Const MCI_ANIM_WINDOW_DEFAULT =         &H00000000
Const MCI_ANIM_RECT =                   &H00010000
Const MCI_ANIM_PUT_SOURCE =             &H00020000
Const MCI_ANIM_PUT_DESTINATION =        &H00040000
Const MCI_ANIM_WHERE_SOURCE =           &H00020000
Const MCI_ANIM_WHERE_DESTINATION =      &H00040000
Const MCI_ANIM_UPDATE_HDC =             &H00020000

Type MCI_ANIM_OPEN_PARMSW
	dwCallback As DWord
	wDeviceID As MCIDEVICEID
	lpstrDeviceType As LPWSTR
	lpstrElementName As LPWSTR
	lpstrAlias As LPWSTR
	dwStyle As DWord
	hWndParent As HWND
End Type
TypeDef PMCI_ANIM_OPEN_PARMSW = *MCI_ANIM_OPEN_PARMSW
TypeDef LPMCI_ANIM_OPEN_PARMSW = *MCI_ANIM_OPEN_PARMSW

Type MCI_ANIM_OPEN_PARMSA
	dwCallback As DWord
	wDeviceID As MCIDEVICEID
	lpstrDeviceType As LPSTR
	lpstrElementName As LPSTR
	lpstrAlias As LPSTR
	dwStyle As DWord
	hWndParent As HWND
End Type
TypeDef PMCI_ANIM_OPEN_PARMSA = *MCI_ANIM_OPEN_PARMSA
TypeDef LPMCI_ANIM_OPEN_PARMSA = *MCI_ANIM_OPEN_PARMSA

#ifdef UNICODE
TypeDef MCI_ANIM_OPEN_PARMS = MCI_ANIM_OPEN_PARMSW
TypeDef PMCI_ANIM_OPEN_PARMS = PMCI_ANIM_OPEN_PARMSW
TypeDef LPMCI_ANIM_OPEN_PARMS = LPMCI_ANIM_OPEN_PARMSW
#else
TypeDef MCI_ANIM_OPEN_PARMS = MCI_ANIM_OPEN_PARMSA
TypeDef PMCI_ANIM_OPEN_PARMS = PMCI_ANIM_OPEN_PARMSA
TypeDef LPMCI_ANIM_OPEN_PARMS = LPMCI_ANIM_OPEN_PARMSA
#endif

Type MCI_ANIM_PLAY_PARMS
	dwCallback As DWord
	dwFrom As DWord
	dwTo As DWord
	dwSpeed As DWord
End Type
TypeDef PMCI_ANIM_PLAY_PARMS = *MCI_ANIM_PLAY_PARMS
TypeDef LPMCI_ANIM_PLAY_PARMS = *MCI_ANIM_PLAY_PARMS

Type MCI_ANIM_STEP_PARMS
	dwCallback As DWord
	dwFrames As DWord
End Type
TypeDef PMCI_ANIM_STEP_PARMS = *MCI_ANIM_STEP_PARMS
TypeDef LPMCI_ANIM_STEP_PARMS = *MCI_ANIM_STEP_PARMS

Type MCI_ANIM_WINDOW_PARMSA
	dwCallback As DWord
	hWnd As HWND
	nCmdShow As DWord
	lpstrText As LPSTR
End Type
TypeDef PMCI_ANIM_WINDOW_PARMSA = *MCI_ANIM_WINDOW_PARMSA
TypeDef LPMCI_ANIM_WINDOW_PARMSA = *MCI_ANIM_WINDOW_PARMSA
TypeDef MCI_ANIM_WINDOW_PARMS = MCI_ANIM_WINDOW_PARMSA
TypeDef PMCI_ANIM_WINDOW_PARMS = PMCI_ANIM_WINDOW_PARMSA
TypeDef LPMCI_ANIM_WINDOW_PARMS = LPMCI_ANIM_WINDOW_PARMSA

Type MCI_ANIM_RECT_PARMS
	dwCallback As DWord
	rc As RECT
End Type
TypeDef PMCI_ANIM_RECT_PARMS = *MCI_ANIM_RECT_PARMS
TypeDef LPMCI_ANIM_RECT_PARMS = *MCI_ANIM_RECT_PARMS

Type MCI_ANIM_UPDATE_PARMS
	dwCallback As DWord
	rc As RECT
	hDC As HDC
End Type
TypeDef PMCI_ANIM_UPDATE_PARMS = *MCI_ANIM_UPDATE_PARMS
TypeDef LPMCI_ANIM_UPDATE_PARMS = *MCI_ANIM_UPDATE_PARMS

' MCI extensions for video overlay devices
Const MCI_OVLY_OPEN_WS =                &H00010000
Const MCI_OVLY_OPEN_PARENT =            &H00020000
Const MCI_OVLY_STATUS_HWND =            &H00004001
Const MCI_OVLY_STATUS_STRETCH =         &H00004002
Const MCI_OVLY_INFO_TEXT =              &H00010000
Const MCI_OVLY_GETDEVCAPS_CAN_STRETCH = &H00004001
Const MCI_OVLY_GETDEVCAPS_CAN_FREEZE =  &H00004002
Const MCI_OVLY_GETDEVCAPS_MAX_WINDOWS = &H00004003
Const MCI_OVLY_WINDOW_HWND =            &H00010000
Const MCI_OVLY_WINDOW_STATE =           &H00040000
Const MCI_OVLY_WINDOW_TEXT =            &H00080000
Const MCI_OVLY_WINDOW_ENABLE_STRETCH =  &H00100000
Const MCI_OVLY_WINDOW_DISABLE_STRETCH = &H00200000
Const MCI_OVLY_WINDOW_DEFAULT =         &H00000000
Const MCI_OVLY_RECT =                   &H00010000
Const MCI_OVLY_PUT_SOURCE =             &H00020000
Const MCI_OVLY_PUT_DESTINATION =        &H00040000
Const MCI_OVLY_PUT_FRAME =              &H00080000
Const MCI_OVLY_PUT_VIDEO =              &H00100000
Const MCI_OVLY_WHERE_SOURCE =           &H00020000
Const MCI_OVLY_WHERE_DESTINATION =      &H00040000
Const MCI_OVLY_WHERE_FRAME =            &H00080000
Const MCI_OVLY_WHERE_VIDEO =            &H00100000

Type MCI_OVLY_OPEN_PARMSW
	dwCallback As DWord
	wDeviceID As MCIDEVICEID
	lpstrDeviceType As LPWSTR
	lpstrElementName As LPWSTR
	lpstrAlias As LPWSTR
	dwStyle As DWord
	hWndParent As HWND
End Type
TypeDef PMCI_OVLY_OPEN_PARMSW = *MCI_OVLY_OPEN_PARMSW
TypeDef LPMCI_OVLY_OPEN_PARMSW = *MCI_OVLY_OPEN_PARMSW

Type MCI_OVLY_OPEN_PARMSA
	dwCallback As DWord
	wDeviceID As MCIDEVICEID
	lpstrDeviceType As LPSTR
	lpstrElementName As LPSTR
	lpstrAlias As LPSTR
	dwStyle As DWord
	hWndParent As HWND
End Type
TypeDef PMCI_OVLY_OPEN_PARMSA = *MCI_OVLY_OPEN_PARMSA
TypeDef LPMCI_OVLY_OPEN_PARMSA = *MCI_OVLY_OPEN_PARMSA

#ifdef UNICODE
TypeDef MCI_OVLY_OPEN_PARMS = MCI_OVLY_OPEN_PARMSW
TypeDef PMCI_OVLY_OPEN_PARMS = PMCI_OVLY_OPEN_PARMSW
TypeDef LPMCI_OVLY_OPEN_PARMS = LPMCI_OVLY_OPEN_PARMSW
#else
TypeDef MCI_OVLY_OPEN_PARMS = MCI_OVLY_OPEN_PARMSA
TypeDef PMCI_OVLY_OPEN_PARMS = PMCI_OVLY_OPEN_PARMSA
TypeDef LPMCI_OVLY_OPEN_PARMS = LPMCI_OVLY_OPEN_PARMSA
#endif

Type MCI_OVLY_WINDOW_PARMSA
	dwCallback As DWord
	hWnd As HWND
	nCmdShow As DWord
	lpstrText As LPSTR
End Type
TypeDef PMCI_OVLY_WINDOW_PARMSA = *MCI_OVLY_WINDOW_PARMSA
TypeDef LPMCI_OVLY_WINDOW_PARMSA = *MCI_OVLY_WINDOW_PARMSA

Type MCI_OVLY_WINDOW_PARMSW
	dwCallback As DWord
	hWnd As HWND
	nCmdShow As DWord
	lpstrText As LPWSTR
End Type
TypeDef PMCI_OVLY_WINDOW_PARMSW = *MCI_OVLY_WINDOW_PARMSW
TypeDef LPMCI_OVLY_WINDOW_PARMSW = *MCI_OVLY_WINDOW_PARMSW

#ifdef UNICODE
TypeDef MCI_OVLY_WINDOW_PARMS = MCI_OVLY_WINDOW_PARMSW
TypeDef PMCI_OVLY_WINDOW_PARMS = PMCI_OVLY_WINDOW_PARMSW
TypeDef LPMCI_OVLY_WINDOW_PARMS = LPMCI_OVLY_WINDOW_PARMSW
#else
TypeDef MCI_OVLY_WINDOW_PARMS = MCI_OVLY_WINDOW_PARMSA
TypeDef PMCI_OVLY_WINDOW_PARMS = PMCI_OVLY_WINDOW_PARMSA
TypeDef LPMCI_OVLY_WINDOW_PARMS = LPMCI_OVLY_WINDOW_PARMSA
#endif

Type MCI_OVLY_RECT_PARMS
	dwCallback As DWord
	rc As RECT
End Type
TypeDef PMCI_OVLY_RECT_PARMS = *MCI_OVLY_RECT_PARMS
TypeDef LPMCI_OVLY_RECT_PARMS = *MCI_OVLY_RECT_PARMS

Type MCI_OVLY_SAVE_PARMSW
	dwCallback As DWord
	lpfilename As LPWSTR
	rc As RECT
End Type
TypeDef PMCI_OVLY_SAVE_PARMSW = *MCI_OVLY_SAVE_PARMSW
TypeDef LPMCI_OVLY_SAVE_PARMSW = *MCI_OVLY_SAVE_PARMSW

Type MCI_OVLY_SAVE_PARMSA
	dwCallback As DWord
	lpfilename As LPSTR
	rc As RECT
End Type
TypeDef PMCI_OVLY_SAVE_PARMSA = *MCI_OVLY_SAVE_PARMSA
TypeDef LPMCI_OVLY_SAVE_PARMSA = *MCI_OVLY_SAVE_PARMSA

#ifdef UNICODE
TypeDef MCI_OVLY_SAVE_PARMS = MCI_OVLY_SAVE_PARMSW
TypeDef PMCI_OVLY_SAVE_PARMS = PMCI_OVLY_SAVE_PARMSW
TypeDef LPMCI_OVLY_SAVE_PARMS = LPMCI_OVLY_SAVE_PARMSW
#else
TypeDef MCI_OVLY_SAVE_PARMS = MCI_OVLY_SAVE_PARMSA
TypeDef PMCI_OVLY_SAVE_PARMS = PMCI_OVLY_SAVE_PARMSA
TypeDef LPMCI_OVLY_SAVE_PARMS = LPMCI_OVLY_SAVE_PARMSA
#endif

Type MCI_OVLY_LOAD_PARMSW
	dwCallback As DWord
	lpfilename As LPWSTR
	rc As RECT
End Type
TypeDef PMCI_OVLY_LOAD_PARMSW = *MCI_OVLY_LOAD_PARMSW
TypeDef LPMCI_OVLY_LOAD_PARMSW = *MCI_OVLY_LOAD_PARMSW

Type MCI_OVLY_LOAD_PARMSA
	dwCallback As DWord
	lpfilename As LPSTR
	rc As RECT
End Type
TypeDef PMCI_OVLY_LOAD_PARMSA = *MCI_OVLY_LOAD_PARMSA
TypeDef LPMCI_OVLY_LOAD_PARMSA = *MCI_OVLY_LOAD_PARMSA

#ifdef UNICODE
TypeDef MCI_OVLY_LOAD_PARMS = MCI_OVLY_LOAD_PARMSW
TypeDef PMCI_OVLY_LOAD_PARMS = PMCI_OVLY_LOAD_PARMSW
TypeDef LPMCI_OVLY_LOAD_PARMS = LPMCI_OVLY_LOAD_PARMSW
#else
TypeDef MCI_OVLY_LOAD_PARMS = MCI_OVLY_LOAD_PARMSA
TypeDef PMCI_OVLY_LOAD_PARMS = PMCI_OVLY_LOAD_PARMSA
TypeDef LPMCI_OVLY_LOAD_PARMS = LPMCI_OVLY_LOAD_PARMSA
#endif

' DISPLAY Driver extensions
Const NEWTRANSPARENT = 3
Const QUERYROPSUPPORT = 40

' DIB Driver extensions
Const SELECTDIB = 41
Const DIBINDEX(n) = MAKELONG(n,&H10FF)

#endif '_INC_MMSYS
