1 module win32.directx.dsound8;
2 version(Windows):
3 
4 //import tango.sys.win32.Types;
5 import win32.windows;
6 
7 alias GUID* LPCGUID;
8 
9 interface IUnknown
10 {
11 	HRESULT QueryInterface(IID* riid, void** pvObject);
12 	ULONG AddRef();
13 	ULONG Release();
14 }
15 
16 alias IUnknown LPUNKNOWN;
17 
18 interface IDirectSound : IUnknown
19 {
20 	extern(Windows):
21 
22     // IDirectSound methods
23     HRESULT CreateSoundBuffer    (LPCDSBUFFERDESC pcDSBufferDesc, LPDIRECTSOUNDBUFFER *ppDSBuffer, LPUNKNOWN pUnkOuter);
24     HRESULT GetCaps              (LPDSCAPS pDSCaps);
25     HRESULT DuplicateSoundBuffer (LPDIRECTSOUNDBUFFER pDSBufferOriginal, LPDIRECTSOUNDBUFFER *ppDSBufferDuplicate);
26     HRESULT SetCooperativeLevel  (HWND hwnd, DWORD dwLevel);
27     HRESULT Compact              ();
28     HRESULT GetSpeakerConfig     (LPDWORD pdwSpeakerConfig);
29     HRESULT SetSpeakerConfig     (DWORD dwSpeakerConfig);
30     HRESULT Initialize           (LPCGUID pcGuidDevice);
31 }
32 
33 alias IDirectSound LPDIRECTSOUND;
34 
35 interface IDirectSound8 : IDirectSound
36 {
37 	extern(Windows):
38 
39     // IDirectSound8 methods
40     HRESULT VerifyCertification  (LPDWORD pdwCertified);
41 }
42 
43 alias IDirectSound8 LPDIRECTSOUND8;
44 
45 interface IDirectSoundBuffer : IUnknown
46 {
47 	extern(Windows):
48 
49     // IDirectSoundBuffer methods
50     HRESULT GetCaps              (LPDSBCAPS pDSBufferCaps);
51     HRESULT GetCurrentPosition   (LPDWORD pdwCurrentPlayCursor, LPDWORD pdwCurrentWriteCursor);
52     HRESULT GetFormat            (LPWAVEFORMATEX pwfxFormat, DWORD dwSizeAllocated, LPDWORD pdwSizeWritten);
53     HRESULT GetVolume            (LPLONG plVolume);
54     HRESULT GetPan               (LPLONG plPan);
55     HRESULT GetFrequency         (LPDWORD pdwFrequency);
56     HRESULT GetStatus            (LPDWORD pdwStatus);
57     HRESULT Initialize           (LPDIRECTSOUND pDirectSound, LPCDSBUFFERDESC pcDSBufferDesc);
58     HRESULT Lock                 (DWORD dwOffset, DWORD dwBytes, LPVOID *ppvAudioPtr1, LPDWORD pdwAudioBytes1,
59                                            LPVOID *ppvAudioPtr2, LPDWORD pdwAudioBytes2, DWORD dwFlags);
60     HRESULT Play                 (DWORD dwReserved1, DWORD dwPriority, DWORD dwFlags);
61     HRESULT SetCurrentPosition   (DWORD dwNewPosition);
62     HRESULT SetFormat            (LPCWAVEFORMATEX pcfxFormat);
63     HRESULT SetVolume            (LONG lVolume);
64     HRESULT SetPan               (LONG lPan);
65     HRESULT SetFrequency         (DWORD dwFrequency);
66     HRESULT Stop                 ();
67     HRESULT Unlock               (LPVOID pvAudioPtr1, DWORD dwAudioBytes1, LPVOID pvAudioPtr2, DWORD dwAudioBytes2);
68     HRESULT Restore              ();
69 }
70 
71 alias IDirectSoundBuffer LPDIRECTSOUNDBUFFER;
72 
73 interface IDirectSound3DListener : IUnknown
74 {
75 	extern(Windows):
76 
77     // IDirectSound3DListener methods
78     HRESULT GetAllParameters         (LPDS3DLISTENER pListener);
79     HRESULT GetDistanceFactor        (D3DVALUE* pflDistanceFactor);
80     HRESULT GetDopplerFactor         (D3DVALUE* pflDopplerFactor);
81     HRESULT GetOrientation           (D3DVECTOR* pvOrientFront, D3DVECTOR* pvOrientTop);
82     HRESULT GetPosition              (D3DVECTOR* pvPosition);
83     HRESULT GetRolloffFactor         (D3DVALUE* pflRolloffFactor);
84     HRESULT GetVelocity              (D3DVECTOR* pvVelocity);
85     HRESULT SetAllParameters         (LPCDS3DLISTENER pcListener, DWORD dwApply);
86     HRESULT SetDistanceFactor        (D3DVALUE flDistanceFactor, DWORD dwApply);
87     HRESULT SetDopplerFactor         (D3DVALUE flDopplerFactor, DWORD dwApply);
88     HRESULT SetOrientation           (D3DVALUE xFront, D3DVALUE yFront, D3DVALUE zFront,
89                                                D3DVALUE xTop, D3DVALUE yTop, D3DVALUE zTop, DWORD dwApply);
90     HRESULT SetPosition              (D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply);
91     HRESULT SetRolloffFactor         (D3DVALUE flRolloffFactor, DWORD dwApply);
92     HRESULT SetVelocity              (D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply);
93     HRESULT CommitDeferredSettings   ();
94 }
95 
96 struct WAVEFORMATEX
97 {
98 	ushort wFormatTag;
99 	ushort nChannels;
100 	uint nSamplesPerSec;
101 	uint nAvgBytesPerSec;
102 	ushort nBlockAlign;
103 	ushort wBitsPerSample;
104 	ushort cbSize;
105 }
106 
107 alias WAVEFORMATEX* LPWAVEFORMATEX, LPCWAVEFORMATEX;
108 
109 enum : uint
110 {
111 	WAVE_FORMAT_PCM = 1
112 }
113 
114 struct DSCBUFFERDESC
115 {
116     DWORD           dwSize;
117     DWORD           dwFlags;
118     DWORD           dwBufferBytes;
119     DWORD           dwReserved;
120     LPWAVEFORMATEX  lpwfxFormat;
121     DWORD           dwFXCount;
122     LPDSCEFFECTDESC lpDSCFXDesc;
123 }
124 
125 alias DSCBUFFERDESC* LPDSCBUFFERDESC;
126 
127 struct DSBUFFERDESC
128 {
129     DWORD           dwSize;
130     DWORD           dwFlags;
131     DWORD           dwBufferBytes;
132     DWORD           dwReserved;
133     LPWAVEFORMATEX  lpwfxFormat;
134     GUID            guid3DAlgorithm;
135 }
136 
137 alias DSBUFFERDESC* LPCDSBUFFERDESC;
138 
139 struct DSCAPS
140 {
141     DWORD           dwSize;
142     DWORD           dwFlags;
143     DWORD           dwMinSecondarySampleRate;
144     DWORD           dwMaxSecondarySampleRate;
145     DWORD           dwPrimaryBuffers;
146     DWORD           dwMaxHwMixingAllBuffers;
147     DWORD           dwMaxHwMixingStaticBuffers;
148     DWORD           dwMaxHwMixingStreamingBuffers;
149     DWORD           dwFreeHwMixingAllBuffers;
150     DWORD           dwFreeHwMixingStaticBuffers;
151     DWORD           dwFreeHwMixingStreamingBuffers;
152     DWORD           dwMaxHw3DAllBuffers;
153     DWORD           dwMaxHw3DStaticBuffers;
154     DWORD           dwMaxHw3DStreamingBuffers;
155     DWORD           dwFreeHw3DAllBuffers;
156     DWORD           dwFreeHw3DStaticBuffers;
157     DWORD           dwFreeHw3DStreamingBuffers;
158     DWORD           dwTotalHwMemBytes;
159     DWORD           dwFreeHwMemBytes;
160     DWORD           dwMaxContigFreeHwMemBytes;
161     DWORD           dwUnlockTransferRateHwBuffers;
162     DWORD           dwPlayCpuOverheadSwBuffers;
163     DWORD           dwReserved1;
164     DWORD           dwReserved2;
165 }
166 
167 alias DSCAPS* LPDSCAPS;
168 
169 struct DSBCAPS
170 {
171     DWORD           dwSize;
172     DWORD           dwFlags;
173     DWORD           dwBufferBytes;
174     DWORD           dwUnlockTransferRate;
175     DWORD           dwPlayCpuOverhead;
176 }
177 
178 alias DSBCAPS *LPDSBCAPS;
179 
180 struct DSCEFFECTDESC
181 {
182     DWORD       dwSize;
183     DWORD       dwFlags;
184     GUID        guidDSCFXClass;
185     GUID        guidDSCFXInstance;
186     DWORD       dwReserved1;
187     DWORD       dwReserved2;
188 }
189 
190 alias DSCEFFECTDESC *LPDSCEFFECTDESC;
191 
192 struct DS3DLISTENER
193 {
194     DWORD           dwSize;
195     D3DVECTOR       vPosition;
196     D3DVECTOR       vVelocity;
197     D3DVECTOR       vOrientFront;
198     D3DVECTOR       vOrientTop;
199     D3DVALUE        flDistanceFactor;
200     D3DVALUE        flRolloffFactor;
201     D3DVALUE        flDopplerFactor;
202 }
203 
204 alias DS3DLISTENER *LPDS3DLISTENER, LPCDS3DLISTENER;
205 
206 alias float D3DVALUE;
207 
208 struct D3DVECTOR
209 {
210     float x;
211     float y;
212     float z;
213 }
214 
215 extern(Windows) export HRESULT DirectSoundCreate8(LPCGUID pcGuidDevice, LPDIRECTSOUND8 *ppDS8, LPUNKNOWN pUnkOuter);
216 
217 const DSSCL_PRIORITY = 0x00000002;
218 const DSBCAPS_PRIMARYBUFFER = 0x00000001;
219 const DSBCAPS_CTRL3D = 0x00000010;
220 const DSBCAPS_GETCURRENTPOSITION2 = 0x00010000;
221 const DSBCAPS_LOCDEFER = 0x00040000;
222 const DSBPLAY_LOOPING = 0x00000001;
223 const DSBSTATUS_PLAYING = 0x00000001;
224 const DSBCAPS_CTRLFREQUENCY = 0x00000020;
225 const DSBCAPS_CTRLPAN = 0x00000040;
226 const DSBCAPS_CTRLVOLUME = 0x00000080;
227 const DSBLOCK_ENTIREBUFFER = 0x00000002;
228 
229 const GUID IID_IDirectSound3DListener8 = {0x279AFA84,0x4981,0x11CE,[0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60]};