PortAudio 2.0
portaudio.h
Go to the documentation of this file.
1#ifndef PORTAUDIO_H
2#define PORTAUDIO_H
3/*
4 * $Id$
5 * PortAudio Portable Real-Time Audio Library
6 * PortAudio API Header File
7 * Latest version available at: http://www.portaudio.com/
8 *
9 * Copyright (c) 1999-2002 Ross Bencina and Phil Burk
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining
12 * a copy of this software and associated documentation files
13 * (the "Software"), to deal in the Software without restriction,
14 * including without limitation the rights to use, copy, modify, merge,
15 * publish, distribute, sublicense, and/or sell copies of the Software,
16 * and to permit persons to whom the Software is furnished to do so,
17 * subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be
20 * included in all copies or substantial portions of the Software.
21 *
22 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 */
30
31/*
32 * The text above constitutes the entire PortAudio license; however,
33 * the PortAudio community also makes the following non-binding requests:
34 *
35 * Any person wishing to distribute modifications to the Software is
36 * requested to send the modifications to the original developer so that
37 * they can be incorporated into the canonical version. It is also
38 * requested that these non-binding requests be included along with the
39 * license above.
40 */
41
48#ifdef __cplusplus
49extern "C"
50{
51#endif /* __cplusplus */
52
58int Pa_GetVersion( void );
59
67const char* Pa_GetVersionText( void );
68
81#define paMakeVersionNumber(major, minor, subminor) \
82 (((major)&0xFF)<<16 | ((minor)&0xFF)<<8 | ((subminor)&0xFF))
83
84
90typedef struct PaVersionInfo {
91 int versionMajor;
92 int versionMinor;
93 int versionSubMinor;
102 const char *versionText;
104
116
117
122typedef int PaError;
123typedef enum PaErrorCode
124{
125 paNoError = 0,
126
127 paNotInitialized = -10000,
128 paUnanticipatedHostError,
129 paInvalidChannelCount,
130 paInvalidSampleRate,
131 paInvalidDevice,
132 paInvalidFlag,
133 paSampleFormatNotSupported,
134 paBadIODeviceCombination,
135 paInsufficientMemory,
136 paBufferTooBig,
137 paBufferTooSmall,
138 paNullCallback,
139 paBadStreamPtr,
140 paTimedOut,
141 paInternalError,
142 paDeviceUnavailable,
143 paIncompatibleHostApiSpecificStreamInfo,
144 paStreamIsStopped,
145 paStreamIsNotStopped,
146 paInputOverflowed,
147 paOutputUnderflowed,
148 paHostApiNotFound,
149 paInvalidHostApi,
150 paCanNotReadFromACallbackStream,
151 paCanNotWriteToACallbackStream,
152 paCanNotReadFromAnOutputOnlyStream,
153 paCanNotWriteToAnInputOnlyStream,
154 paIncompatibleStreamHostApi,
155 paBadBufferPtr,
156 paCanNotInitializeRecursively
157} PaErrorCode;
158
159
163const char *Pa_GetErrorText( PaError errorCode );
164
165
186
187
205
206
207
214typedef int PaDeviceIndex;
215
216
222#define paNoDevice ((PaDeviceIndex)-1)
223
224
230#define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
231
232
233/* Host API enumeration mechanism */
234
240typedef int PaHostApiIndex;
241
242
253
254
264
265
277typedef enum PaHostApiTypeId
278{
279 paInDevelopment=0, /* use while developing support for a new host API */
280 paDirectSound=1,
281 paMME=2,
282 paASIO=3,
283 paSoundManager=4,
284 paCoreAudio=5,
285 paOSS=7,
286 paALSA=8,
287 paAL=9,
288 paBeOS=10,
289 paWDMKS=11,
290 paJACK=12,
291 paWASAPI=13,
292 paAudioScienceHPI=14,
293 paAudioIO=15,
294 paPulseAudio=16,
295 paSndio=17
297
298
330
331
346
347
364
365
388 int hostApiDeviceIndex );
389
390
391
399
400
415
416
417
418/* Device enumeration and capabilities */
419
428
429
437
438
455
456
465typedef double PaTime;
466
467
489typedef unsigned long PaSampleFormat;
490
491
492#define paFloat32 ((PaSampleFormat) 0x00000001)
493#define paInt32 ((PaSampleFormat) 0x00000002)
494#define paInt24 ((PaSampleFormat) 0x00000004)
495#define paInt16 ((PaSampleFormat) 0x00000008)
496#define paInt8 ((PaSampleFormat) 0x00000010)
497#define paUInt8 ((PaSampleFormat) 0x00000020)
498#define paCustomFormat ((PaSampleFormat) 0x00010000)
500#define paNonInterleaved ((PaSampleFormat) 0x80000000)
505typedef struct PaDeviceInfo
506{
510 const char *name;
511
514
515 int maxInputChannels;
516 int maxOutputChannels;
517
520 PaTime defaultLowOutputLatency;
523 PaTime defaultHighOutputLatency;
524
525 double defaultSampleRate;
527
528
543
544
591
592
594#define paFormatIsSupported (0)
595
619 const PaStreamParameters *outputParameters,
620 double sampleRate );
621
622
623
624/* Streaming types and functions */
625
626
644typedef void PaStream;
645
646
651#define paFramesPerBufferUnspecified (0)
652
653
662typedef unsigned long PaStreamFlags;
663
665#define paNoFlag ((PaStreamFlags) 0)
666
670#define paClipOff ((PaStreamFlags) 0x00000001)
671
675#define paDitherOff ((PaStreamFlags) 0x00000002)
676
686#define paNeverDropInput ((PaStreamFlags) 0x00000004)
687
694#define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
695
699#define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
700
713
714
721typedef unsigned long PaStreamCallbackFlags;
722
730#define paInputUnderflow ((PaStreamCallbackFlags) 0x00000001)
731
739#define paInputOverflow ((PaStreamCallbackFlags) 0x00000002)
740
745#define paOutputUnderflow ((PaStreamCallbackFlags) 0x00000004)
746
750#define paOutputOverflow ((PaStreamCallbackFlags) 0x00000008)
751
756#define paPrimingOutput ((PaStreamCallbackFlags) 0x00000010)
757
768
769
840 const void *input, void *output,
841 unsigned long frameCount,
842 const PaStreamCallbackTimeInfo* timeInfo,
843 PaStreamCallbackFlags statusFlags,
844 void *userData );
845
846
905 const PaStreamParameters *inputParameters,
906 const PaStreamParameters *outputParameters,
907 double sampleRate,
908 unsigned long framesPerBuffer,
909 PaStreamFlags streamFlags,
910 PaStreamCallback *streamCallback,
911 void *userData );
912
913
945 int numInputChannels,
946 int numOutputChannels,
947 PaSampleFormat sampleFormat,
948 double sampleRate,
949 unsigned long framesPerBuffer,
950 PaStreamCallback *streamCallback,
951 void *userData );
952
953
958
959
974typedef void PaStreamFinishedCallback( void *userData );
975
976
996
997
1001
1002
1007
1008
1013
1014
1028
1029
1044
1045
1046
1082
1083
1098
1099
1116
1117
1135
1136
1163 void *buffer,
1164 unsigned long frames );
1165
1166
1194 const void *buffer,
1195 unsigned long frames );
1196
1197
1210
1211
1224
1225
1226/* Miscellaneous utilities */
1227
1228
1235
1236
1244void Pa_Sleep( long msec );
1245
1246
1247
1248#ifdef __cplusplus
1249}
1250#endif /* __cplusplus */
1251#endif /* PORTAUDIO_H */
PaError Pa_WriteStream(PaStream *stream, const void *buffer, unsigned long frames)
PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex(PaHostApiTypeId type)
PaError Pa_OpenDefaultStream(PaStream **stream, int numInputChannels, int numOutputChannels, PaSampleFormat sampleFormat, double sampleRate, unsigned long framesPerBuffer, PaStreamCallback *streamCallback, void *userData)
PaError Pa_ReadStream(PaStream *stream, void *buffer, unsigned long frames)
PaError Pa_Terminate(void)
PaError Pa_AbortStream(PaStream *stream)
struct PaStreamCallbackTimeInfo PaStreamCallbackTimeInfo
void PaStream
Definition portaudio.h:644
PaHostApiIndex Pa_GetHostApiCount(void)
void Pa_Sleep(long msec)
const PaHostErrorInfo * Pa_GetLastHostErrorInfo(void)
PaError Pa_IsStreamActive(PaStream *stream)
signed long Pa_GetStreamWriteAvailable(PaStream *stream)
PaTime Pa_GetStreamTime(PaStream *stream)
unsigned long PaStreamFlags
Definition portaudio.h:662
struct PaVersionInfo PaVersionInfo
PaError Pa_OpenStream(PaStream **stream, const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate, unsigned long framesPerBuffer, PaStreamFlags streamFlags, PaStreamCallback *streamCallback, void *userData)
unsigned long PaSampleFormat
Definition portaudio.h:489
int PaError
Definition portaudio.h:122
PaError Pa_IsStreamStopped(PaStream *stream)
PaError Pa_GetSampleSize(PaSampleFormat format)
PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex(PaHostApiIndex hostApi, int hostApiDeviceIndex)
unsigned long PaStreamCallbackFlags
Definition portaudio.h:721
const char * Pa_GetVersionText(void)
struct PaStreamInfo PaStreamInfo
int Pa_GetVersion(void)
struct PaDeviceInfo PaDeviceInfo
PaError Pa_StartStream(PaStream *stream)
double Pa_GetStreamCpuLoad(PaStream *stream)
int PaStreamCallback(const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
Definition portaudio.h:839
PaHostApiTypeId
Definition portaudio.h:278
PaError Pa_CloseStream(PaStream *stream)
const PaVersionInfo * Pa_GetVersionInfo(void)
struct PaStreamParameters PaStreamParameters
PaError Pa_SetStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback *streamFinishedCallback)
struct PaHostErrorInfo PaHostErrorInfo
void PaStreamFinishedCallback(void *userData)
Definition portaudio.h:974
const PaDeviceInfo * Pa_GetDeviceInfo(PaDeviceIndex device)
const PaStreamInfo * Pa_GetStreamInfo(PaStream *stream)
PaError Pa_IsFormatSupported(const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate)
PaError Pa_Initialize(void)
PaDeviceIndex Pa_GetDefaultInputDevice(void)
PaDeviceIndex Pa_GetDeviceCount(void)
signed long Pa_GetStreamReadAvailable(PaStream *stream)
int PaDeviceIndex
Definition portaudio.h:214
PaDeviceIndex Pa_GetDefaultOutputDevice(void)
struct PaHostApiInfo PaHostApiInfo
PaHostApiIndex Pa_GetDefaultHostApi(void)
const char * Pa_GetErrorText(PaError errorCode)
PaStreamCallbackResult
Definition portaudio.h:763
@ paComplete
Definition portaudio.h:765
@ paAbort
Definition portaudio.h:766
@ paContinue
Definition portaudio.h:764
int PaHostApiIndex
Definition portaudio.h:240
double PaTime
Definition portaudio.h:465
PaError Pa_StopStream(PaStream *stream)
const PaHostApiInfo * Pa_GetHostApiInfo(PaHostApiIndex hostApi)
const char * name
Definition portaudio.h:510
int structVersion
Definition portaudio.h:507
PaTime defaultHighInputLatency
Definition portaudio.h:522
PaTime defaultLowInputLatency
Definition portaudio.h:519
PaHostApiIndex hostApi
Definition portaudio.h:513
PaHostApiTypeId type
Definition portaudio.h:306
PaDeviceIndex defaultOutputDevice
Definition portaudio.h:327
const char * name
Definition portaudio.h:308
PaDeviceIndex defaultInputDevice
Definition portaudio.h:321
const char * errorText
Definition portaudio.h:397
PaHostApiTypeId hostApiType
Definition portaudio.h:395
PaTime inputLatency
Definition portaudio.h:1062
PaTime outputLatency
Definition portaudio.h:1070
double sampleRate
Definition portaudio.h:1079
PaTime suggestedLatency
Definition portaudio.h:581
PaSampleFormat sampleFormat
Definition portaudio.h:568
PaDeviceIndex device
Definition portaudio.h:555
void * hostApiSpecificStreamInfo
Definition portaudio.h:588
const char * versionControlRevision
Definition portaudio.h:100
const char * versionText
Definition portaudio.h:102