dsound.bmx 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. Strict
  2. Import Pub.Win32
  3. Import "dsound.cpp"
  4. Const DIRECTSOUND_VERSION=$0700
  5. Const DSSCL_NORMAL=$00000001
  6. Const DSSCL_PRIORITY=$00000002
  7. Const DSSCL_EXCLUSIVE=$00000003
  8. Const DSSCL_WRITEPRIMARY=$00000004
  9. Const DSCAPS_PRIMARYMONO=$00000001
  10. Const DSCAPS_PRIMARYSTEREO=$00000002
  11. Const DSCAPS_PRIMARY8BIT=$00000004
  12. Const DSCAPS_PRIMARY16BIT=$00000008
  13. Const DSCAPS_CONTINUOUSRATE=$00000010
  14. Const DSCAPS_EMULDRIVER=$00000020
  15. Const DSCAPS_CERTIFIED=$00000040
  16. Const DSCAPS_SECONDARYMONO=$00000100
  17. Const DSCAPS_SECONDARYSTEREO=$00000200
  18. Const DSCAPS_SECONDARY8BIT=$00000400
  19. Const DSCAPS_SECONDARY16BIT=$00000800
  20. Const DSSPEAKER_HEADPHONE=$00000001
  21. Const DSSPEAKER_MONO=$00000002
  22. Const DSSPEAKER_QUAD=$00000003
  23. Const DSSPEAKER_STEREO=$00000004
  24. Const DSSPEAKER_SURROUND=$00000005
  25. Const DSSPEAKER_5POINT1=$00000006
  26. Const DSSPEAKER_GEOMETRY_MIN=$00000005
  27. Const DSSPEAKER_GEOMETRY_NARROW=$0000000A
  28. Const DSSPEAKER_GEOMETRY_WIDE=$00000014
  29. Const DSSPEAKER_GEOMETRY_MAX=$000000B4
  30. Const DSBCAPS_PRIMARYBUFFER=$00000001
  31. Const DSBCAPS_STATIC=$00000002
  32. Const DSBCAPS_LOCHARDWARE=$00000004
  33. Const DSBCAPS_LOCSOFTWARE=$00000008
  34. Const DSBCAPS_CTRL3D=$00000010
  35. Const DSBCAPS_CTRLFREQUENCY=$00000020
  36. Const DSBCAPS_CTRLPAN=$00000040
  37. Const DSBCAPS_CTRLVOLUME=$00000080
  38. Const DSBCAPS_CTRLPOSITIONNOTIFY=$00000100
  39. Const DSBCAPS_STICKYFOCUS=$00004000
  40. Const DSBCAPS_GLOBALFOCUS=$00008000
  41. Const DSBCAPS_GETCURRENTPOSITION2=$00010000
  42. Const DSBCAPS_MUTE3DATMAXDISTANCE=$00020000
  43. Const DSBCAPS_LOCDEFER=$00040000
  44. Const DSBPLAY_LOOPING=$00000001
  45. Const DSBPLAY_LOCHARDWARE=$00000002
  46. Const DSBPLAY_LOCSOFTWARE=$00000004
  47. Const DSBPLAY_TERMINATEBY_TIME=$00000008
  48. Const DSBPLAY_TERMINATEBY_DISTANCE=$000000010
  49. Const DSBPLAY_TERMINATEBY_PRIORITY=$000000020
  50. Const DSBSTATUS_PLAYING=$00000001
  51. Const DSBSTATUS_BUFFERLOST=$00000002
  52. Const DSBSTATUS_LOOPING=$00000004
  53. Const DSBSTATUS_LOCHARDWARE=$00000008
  54. Const DSBSTATUS_LOCSOFTWARE=$00000010
  55. Const DSBSTATUS_TERMINATED=$00000020
  56. Const DSBLOCK_FROMWRITECURSOR=$00000001
  57. Const DSBLOCK_ENTIREBUFFER=$00000002
  58. ?disabled
  59. Type DSCAPS
  60. Field dwSize
  61. Field dwFlags
  62. Field dwMinSecondarySampleRate
  63. Field dwMaxSecondarySampleRate
  64. Field dwPrimaryBuffers
  65. Field dwMaxHwMixingAllBuffers
  66. Field dwMaxHwMixingStaticBuffers
  67. Field dwMaxHwMixingStreamingBuffers
  68. Field dwFreeHwMixingAllBuffers
  69. Field dwFreeHwMixingStaticBuffers
  70. Field dwFreeHwMixingStreamingBuffers
  71. Field dwMaxHw3DAllBuffers
  72. Field dwMaxHw3DStaticBuffers
  73. Field dwMaxHw3DStreamingBuffers
  74. Field dwFreeHw3DAllBuffers
  75. Field dwFreeHw3DStaticBuffers
  76. Field dwFreeHw3DStreamingBuffers
  77. Field dwTotalHwMemBytes
  78. Field dwFreeHwMemBytes
  79. Field dwMaxContigFreeHwMemBytes
  80. Field dwUnlockTransferRateHwBuffers
  81. Field dwPlayCpuOverheadSwBuffers
  82. Field dwReserved1
  83. Field dwReserved2
  84. End Type
  85. Type DSBCAPS
  86. Field dwSize
  87. Field dwFlags
  88. Field dwBufferBytes
  89. Field dwUnlockTransferRate
  90. Field dwPlayCpuOverhead
  91. End Type
  92. Type WAVEFORMATEX
  93. Field wFormatTag:Short
  94. Field nChannels:Short
  95. Field nSamplesPerSec
  96. Field nAvgBytesPerSec
  97. Field nBlockAlign:Short
  98. Field wBitsPerSample:Short
  99. Field cbSize:Short
  100. End Type
  101. Type DSBUFFERDESC
  102. Field dwSize
  103. Field dwFlags
  104. Field dwBufferBytes
  105. Field dwReserved
  106. Field lpwfxFormat:Byte Ptr
  107. Field guid3DAlgorithm0
  108. Field guid3DAlgorithm1
  109. Field guid3DAlgorithm2
  110. Field guid3DAlgorithm3
  111. End Type
  112. Extern "win32"
  113. Type IDirectSound Extends IUnknown
  114. Method CreateSoundBuffer( desc:Byte Ptr,buf:IDirectSoundBuffer Var,unk:Byte Ptr )
  115. Method GetCaps( caps:Byte Ptr )
  116. Method DuplicateSoundBuffer( in:IDirectSoundBuffer,out:IDirectSoundBuffer Var )
  117. Method SetCooperativeLevel( hwnd,coop )
  118. Method Compact()
  119. Method GetSpeakerConfig( config Var )
  120. Method SetSpeakerConfig( config )
  121. Method Initialize( guid:Byte Ptr )
  122. End Type
  123. Type IDirectSoundBuffer Extends IUnknown
  124. Method GetCaps( caps:Byte Ptr )
  125. Method GetCurrentPosition( pos Var,writePos Var )
  126. Method GetFormat( format:WAVEFORMATEX,sizein,sizeout Var )
  127. Method GetVolume( volume Var )
  128. Method GetPan( pan Var )
  129. Method GetFrequency( freq Var )
  130. Method GetStatus( status Var )
  131. Method Initialize( dsound:IDirectSound,desc:Byte Ptr )
  132. Method Lock( writeCursor,writeBytes,ptr1:Byte Ptr Var,bytes1 Var,ptr2:Byte Ptr Var,bytes2 Var,flags )
  133. Method Play( reserved,priority,flags )
  134. Method SetCurrentPosition( pos )
  135. Method SetFormat( format:WAVEFORMATEX )
  136. Method SetVolume( volume )
  137. Method SetPan( pan )
  138. Method SetFrequency( freq )
  139. Method Stop()
  140. Method Unlock( ptr1:Byte Ptr,bytes1,ptr2:Byte Ptr,bytes2 )
  141. Method Restore()
  142. End Type
  143. End Extern
  144. ?
  145. Extern
  146. Function bmx_directsound_IDirectSound_release:Int(handle:Byte Ptr)
  147. Function bmx_directsound_IDirectSound_create:Int(dsound:Byte Ptr Ptr)
  148. Function bmx_directsound_IDirectSound_setcooperativeLevel:Int(handle:Byte Ptr, hwnd:Byte Ptr, flags:Int)
  149. Function bmx_directsound_IDirectSound_duplicatesoundbuffer:Int(handle:Byte Ptr, buffer:Byte Ptr, buf:Byte Ptr Ptr)
  150. Function bmx_directsound_IDirectSound_createsoundbuffer:Int(handle:Byte Ptr, buf:Byte Ptr Ptr, length:Int, hertz:Int, format:Int, chans:Int, bps:Int, size:Int, flags:Int, _mode:Int)
  151. Function bmx_directsound_IDirectSoundBuffer_release:Int(handle:Byte Ptr)
  152. Function bmx_directsound_IDirectSoundBuffer_stop:Int(handle:Byte Ptr)
  153. Function bmx_directsound_IDirectSoundBuffer_play:Int(handle:Byte Ptr, res:Int, priority:Int, flags:Int)
  154. Function bmx_directsound_IDirectSoundBuffer_setvolume:Int(handle:Byte Ptr, volume:Int)
  155. Function bmx_directsound_IDirectSoundBuffer_setpan:Int(handle:Byte Ptr, pan:Int)
  156. Function bmx_directsound_IDirectSoundBuffer_setfrequency:Int(handle:Byte Ptr, freq:Int)
  157. Function bmx_directsound_IDirectSoundBuffer_setcurrentposition:Int(handle:Byte Ptr, pos:Int)
  158. Function bmx_directsound_IDirectSoundBuffer_lock:Int(handle:Byte Ptr, offset:Int, size:Int, ptr1:Byte Ptr Ptr, bytes1:Int Ptr, ptr2:Byte Ptr Ptr, bytes2:Int Ptr, flags:Int )
  159. Function bmx_directsound_IDirectSoundBuffer_unlock:Int(handle:Byte Ptr, ptr1:Byte Ptr,bytes1:Int,ptr2:Byte Ptr,bytes2:Int)
  160. Function bmx_directsound_IDirectSoundBuffer_getstatus:Int(handle:Byte Ptr, status:Int Ptr)
  161. End Extern
  162. Private
  163. Global _ds:Byte Ptr=LoadLibraryA( "dsound" )
  164. Public
  165. Global DirectSoundCreate( guid:Byte Ptr,dsound:Byte Ptr,unk:Byte Ptr )"win32"=GetProcAddress( _ds,"DirectSoundCreate" )