dsound.bmx 4.5 KB

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