0
|
1 module dynamin.c.portaudio;
|
|
2
|
|
3 /*
|
|
4 * A complete binding to the core of the PortAudio library v19.
|
|
5 */
|
|
6
|
|
7 version(build) { pragma(link, portaudio); }
|
|
8
|
|
9 extern(C):
|
|
10
|
|
11 int Pa_GetVersion();
|
|
12
|
|
13 char* Pa_GetVersionText();
|
|
14
|
|
15 alias int PaError;
|
|
16
|
|
17 alias int PaErrorCode;
|
|
18 enum : PaErrorCode {
|
|
19 paNoError = 0,
|
|
20
|
|
21 paNotInitialized = -10000,
|
|
22 paUnanticipatedHostError,
|
|
23 paInvalidChannelCount,
|
|
24 paInvalidSampleRate,
|
|
25 paInvalidDevice,
|
|
26 paInvalidFlag,
|
|
27 paSampleFormatNotSupported,
|
|
28 paBadIODeviceCombination,
|
|
29 paInsufficientMemory,
|
|
30 paBufferTooBig,
|
|
31 paBufferTooSmall,
|
|
32 paNullCallback,
|
|
33 paBadStreamPtr,
|
|
34 paTimedOut,
|
|
35 paInternalError,
|
|
36 paDeviceUnavailable,
|
|
37 paIncompatibleHostApiSpecificStreamInfo,
|
|
38 paStreamIsStopped,
|
|
39 paStreamIsNotStopped,
|
|
40 paInputOverflowed,
|
|
41 paOutputUnderflowed,
|
|
42 paHostApiNotFound,
|
|
43 paInvalidHostApi,
|
|
44 paCanNotReadFromACallbackStream,
|
|
45 paCanNotWriteToACallbackStream,
|
|
46 paCanNotReadFromAnOutputOnlyStream,
|
|
47 paCanNotWriteToAnInputOnlyStream,
|
|
48 paIncompatibleStreamHostApi,
|
|
49 paBadBufferPtr
|
|
50 }
|
|
51
|
|
52 char* Pa_GetErrorText(PaError errorCode);
|
|
53
|
|
54 PaError Pa_Initialize();
|
|
55
|
|
56 PaError Pa_Terminate();
|
|
57
|
|
58 alias int PaDeviceIndex;
|
|
59
|
|
60 enum : PaDeviceIndex {
|
|
61 paNoDevice = -1,
|
|
62 paUseHostApiSpecificDeviceSpecification = -2
|
|
63 }
|
|
64
|
|
65 alias int PaHostApiIndex;
|
|
66
|
|
67 PaHostApiIndex Pa_GetHostApiCount();
|
|
68
|
|
69 PaHostApiIndex Pa_GetDefaultHostApi();
|
|
70
|
|
71 alias int PaHostApiTypeId;
|
|
72 enum : PaHostApiTypeId {
|
|
73 paInDevelopment = 0,
|
|
74 paDirectSound = 1,
|
|
75 paMME = 2,
|
|
76 paASIO = 3,
|
|
77 paSoundManager = 4,
|
|
78 paCoreAudio = 5,
|
|
79 paOSS = 7,
|
|
80 paALSA = 8,
|
|
81 paAL = 9,
|
|
82 paBeOS = 10,
|
|
83 paWDMKS = 11,
|
|
84 paJACK = 12,
|
|
85 paWASAPI = 13,
|
|
86 paAudioScienceHPI = 14
|
|
87 }
|
|
88
|
|
89 struct PaHostApiInfo {
|
|
90 int structVersion;
|
|
91 PaHostApiTypeId type;
|
|
92 char* name;
|
|
93
|
|
94 int deviceCount;
|
|
95
|
|
96 PaDeviceIndex defaultInputDevice;
|
|
97
|
|
98 PaDeviceIndex defaultOutputDevice;
|
|
99
|
|
100 }
|
|
101
|
|
102 PaHostApiInfo* Pa_GetHostApiInfo(PaHostApiIndex hostApi);
|
|
103
|
|
104 PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex(PaHostApiTypeId type);
|
|
105
|
|
106 PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex(
|
|
107 PaHostApiIndex hostApi,
|
|
108 int hostApiDeviceIndex);
|
|
109
|
|
110 struct PaHostErrorInfo {
|
|
111 PaHostApiTypeId hostApiType;
|
|
112 int errorCode;
|
|
113 char* errorText;
|
|
114 }
|
|
115
|
|
116
|
|
117 PaHostErrorInfo* Pa_GetLastHostErrorInfo();
|
|
118
|
|
119 PaDeviceIndex Pa_GetDeviceCount();
|
|
120
|
|
121 PaDeviceIndex Pa_GetDefaultInputDevice();
|
|
122
|
|
123 PaDeviceIndex Pa_GetDefaultOutputDevice();
|
|
124
|
|
125 alias double PaTime;
|
|
126
|
|
127 alias uint PaSampleFormat;
|
|
128
|
|
129 enum : PaSampleFormat {
|
|
130 paFloat32 = 0x00000001,
|
|
131 paInt32 = 0x00000002,
|
|
132 paInt24 = 0x00000004,
|
|
133 paInt16 = 0x00000008,
|
|
134 paInt8 = 0x00000010,
|
|
135 paUInt8 = 0x00000020,
|
|
136 paCustomFormat = 0x00010000,
|
|
137
|
|
138 paNonInterleaved = 0x80000000
|
|
139 }
|
|
140
|
|
141 struct PaDeviceInfo {
|
|
142 int structVersion;
|
|
143 char* name;
|
|
144 PaHostApiIndex hostApi;
|
|
145
|
|
146 int maxInputChannels;
|
|
147 int maxOutputChannels;
|
|
148
|
|
149 PaTime defaultLowInputLatency;
|
|
150 PaTime defaultLowOutputLatency;
|
|
151 PaTime defaultHighInputLatency;
|
|
152 PaTime defaultHighOutputLatency;
|
|
153
|
|
154 double defaultSampleRate;
|
|
155 }
|
|
156
|
|
157 PaDeviceInfo* Pa_GetDeviceInfo(PaDeviceIndex device);
|
|
158
|
|
159 struct PaStreamParameters {
|
|
160 PaDeviceIndex device;
|
|
161
|
|
162 int channelCount;
|
|
163
|
|
164 PaSampleFormat sampleFormat;
|
|
165
|
|
166 PaTime suggestedLatency;
|
|
167
|
|
168 void* hostApiSpecificStreamInfo;
|
|
169 }
|
|
170
|
|
171 const paFormatIsSupported = 0;
|
|
172
|
|
173 PaError Pa_IsFormatSupported(
|
|
174 PaStreamParameters* inputParameters,
|
|
175 PaStreamParameters* outputParameters,
|
|
176 double sampleRate);
|
|
177
|
|
178 alias void PaStream;
|
|
179
|
|
180 const paFramesPerBufferUnspecified = 0;
|
|
181
|
|
182 alias uint PaStreamFlags;
|
|
183 enum : PaStreamFlags {
|
|
184 paNoFlag = 0,
|
|
185 paClipOff = 0x00000001,
|
|
186 paDitherOff = 0x00000002,
|
|
187 paNeverDropInput = 0x00000004,
|
|
188 paPrimeOutputBuffersUsingStreamCallback = 0x00000008,
|
|
189 paPlatformSpecificFlags = 0xFFFF0000
|
|
190 }
|
|
191
|
|
192 struct PaStreamCallbackTimeInfo {
|
|
193 PaTime inputBufferAdcTime;
|
|
194 PaTime currentTime;
|
|
195 PaTime outputBufferDacTime;
|
|
196 }
|
|
197
|
|
198 alias uint PaStreamCallbackFlags;
|
|
199 enum : PaStreamCallbackFlags {
|
|
200 paInputUnderflow = 0x00000001,
|
|
201 paInputOverflow = 0x00000002,
|
|
202 paOutputUnderflow = 0x00000004,
|
|
203 paOutputOverflow = 0x00000008,
|
|
204 paPrimingOutput = 0x00000010
|
|
205 }
|
|
206
|
|
207 alias uint PaStreamCallbackResult;
|
|
208 enum : PaStreamCallbackResult {
|
|
209 paContinue = 0,
|
|
210 paComplete = 1,
|
|
211 paAbort = 2
|
|
212 }
|
|
213
|
|
214 alias int function(
|
|
215 void* input, void* output,
|
|
216 uint frameCount,
|
|
217 PaStreamCallbackTimeInfo* timeInfo,
|
|
218 PaStreamCallbackFlags statusFlags,
|
|
219 void* userData) PaStreamCallback;
|
|
220
|
|
221 PaError Pa_OpenStream(
|
|
222 PaStream** stream,
|
|
223 PaStreamParameters* inputParameters,
|
|
224 PaStreamParameters* outputParameters,
|
|
225 double sampleRate,
|
|
226 uint framesPerBuffer,
|
|
227 PaStreamFlags streamFlags,
|
|
228 PaStreamCallback streamCallback,
|
|
229 void* userData);
|
|
230
|
|
231 PaError Pa_OpenDefaultStream(
|
|
232 PaStream** stream,
|
|
233 int numInputChannels,
|
|
234 int numOutputChannels,
|
|
235 PaSampleFormat sampleFormat,
|
|
236 double sampleRate,
|
|
237 uint framesPerBuffer,
|
|
238 PaStreamCallback streamCallback,
|
|
239 void* userData);
|
|
240
|
|
241 PaError Pa_CloseStream(PaStream* stream);
|
|
242
|
|
243 alias void function(void* userData) PaStreamFinishedCallback;
|
|
244
|
|
245 PaError Pa_SetStreamFinishedCallback(
|
|
246 PaStream* stream, PaStreamFinishedCallback streamFinishedCallback);
|
|
247
|
|
248 PaError Pa_StartStream(PaStream* stream);
|
|
249
|
|
250 PaError Pa_StopStream(PaStream* stream);
|
|
251
|
|
252 PaError Pa_AbortStream(PaStream* stream);
|
|
253
|
|
254 PaError Pa_IsStreamStopped(PaStream* stream);
|
|
255
|
|
256 PaError Pa_IsStreamActive(PaStream* stream);
|
|
257
|
|
258 struct PaStreamInfo {
|
|
259 int structVersion;
|
|
260
|
|
261 PaTime inputLatency;
|
|
262
|
|
263 PaTime outputLatency;
|
|
264
|
|
265 double sampleRate;
|
|
266 }
|
|
267
|
|
268 PaStreamInfo* Pa_GetStreamInfo(PaStream* stream);
|
|
269
|
|
270 PaTime Pa_GetStreamTime(PaStream* stream);
|
|
271
|
|
272 double Pa_GetStreamCpuLoad(PaStream* stream);
|
|
273
|
|
274 PaError Pa_ReadStream(
|
|
275 PaStream* stream,
|
|
276 void* buffer,
|
|
277 uint frames);
|
|
278
|
|
279
|
|
280 PaError Pa_WriteStream(
|
|
281 PaStream* stream,
|
|
282 void* buffer,
|
|
283 uint frames);
|
|
284
|
|
285 int Pa_GetStreamReadAvailable(PaStream* stream);
|
|
286
|
|
287 int Pa_GetStreamWriteAvailable(PaStream* stream);
|
|
288
|
|
289 PaError Pa_GetSampleSize(PaSampleFormat format);
|
|
290
|
|
291 void Pa_Sleep(long msec);
|
|
292
|