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
49 extern "C"
50 {
51 #endif /* __cplusplus */
52 
58 int Pa_GetVersion( void );
59 
67 const char* Pa_GetVersionText( void );
68 
81 #define paMakeVersionNumber(major, minor, subminor) \
82  (((major)&0xFF)<<16 | ((minor)&0xFF)<<8 | ((subminor)&0xFF))
83 
84 
90 typedef struct PaVersionInfo {
102  const char *versionText;
103 } PaVersionInfo;
104 
115 const PaVersionInfo* Pa_GetVersionInfo( void );
116 
117 
122 typedef int PaError;
123 typedef enum PaErrorCode
124 {
126 
157 } PaErrorCode;
158 
159 
163 const char *Pa_GetErrorText( PaError errorCode );
164 
165 
185 PaError Pa_Initialize( void );
186 
187 
204 PaError Pa_Terminate( void );
205 
206 
207 
214 typedef int PaDeviceIndex;
215 
216 
222 #define paNoDevice ((PaDeviceIndex)-1)
223 
224 
230 #define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
231 
232 
233 /* Host API enumeration mechanism */
234 
240 typedef int PaHostApiIndex;
241 
242 
252 PaHostApiIndex Pa_GetHostApiCount( void );
253 
254 
263 PaHostApiIndex Pa_GetDefaultHostApi( void );
264 
265 
277 typedef enum PaHostApiTypeId
278 {
279  paInDevelopment=0, /* use while developing support for a new host API */
281  paMME=2,
285  paOSS=7,
287  paAL=9,
288  paBeOS=10,
290  paJACK=12,
297 
298 
301 typedef struct PaHostApiInfo
302 {
308  const char *name;
309 
316 
321  PaDeviceIndex defaultInputDevice;
322 
327  PaDeviceIndex defaultOutputDevice;
328 
329 } PaHostApiInfo;
330 
331 
345 const PaHostApiInfo * Pa_GetHostApiInfo( PaHostApiIndex hostApi );
346 
347 
363 PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type );
364 
365 
387 PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex( PaHostApiIndex hostApi,
388  int hostApiDeviceIndex );
389 
390 
391 
394 typedef struct PaHostErrorInfo{
396  long errorCode;
397  const char *errorText;
399 
400 
415 
416 
417 
418 /* Device enumeration and capabilities */
419 
427 PaDeviceIndex Pa_GetDeviceCount( void );
428 
429 
436 PaDeviceIndex Pa_GetDefaultInputDevice( void );
437 
438 
454 PaDeviceIndex Pa_GetDefaultOutputDevice( void );
455 
456 
465 typedef double PaTime;
466 
467 
489 typedef 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)
505 typedef struct PaDeviceInfo
506 {
510  const char *name;
511 
513  PaHostApiIndex hostApi;
514 
517 
524 
526 } PaDeviceInfo;
527 
528 
542 const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceIndex device );
543 
544 
547 typedef struct PaStreamParameters
548 {
555  PaDeviceIndex device;
556 
563 
568  PaSampleFormat sampleFormat;
569 
582 
589 
591 
592 
594 #define paFormatIsSupported (0)
595 
618 PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
619  const PaStreamParameters *outputParameters,
620  double sampleRate );
621 
622 
623 
624 /* Streaming types and functions */
625 
626 
644 typedef void PaStream;
645 
646 
651 #define paFramesPerBufferUnspecified (0)
652 
653 
662 typedef 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 
710  PaTime currentTime;
713 
714 
721 typedef 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 
763 {
768 
769 
839 typedef int PaStreamCallback(
840  const void *input, void *output,
841  unsigned long frameCount,
842  const PaStreamCallbackTimeInfo* timeInfo,
843  PaStreamCallbackFlags statusFlags,
844  void *userData );
845 
846 
904 PaError Pa_OpenStream( PaStream** stream,
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 
944 PaError Pa_OpenDefaultStream( PaStream** stream,
945  int numInputChannels,
946  int numOutputChannels,
947  PaSampleFormat sampleFormat,
948  double sampleRate,
949  unsigned long framesPerBuffer,
950  PaStreamCallback *streamCallback,
951  void *userData );
952 
953 
957 PaError Pa_CloseStream( PaStream *stream );
958 
959 
974 typedef void PaStreamFinishedCallback( void *userData );
975 
976 
995 PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
996 
997 
1000 PaError Pa_StartStream( PaStream *stream );
1001 
1002 
1006 PaError Pa_StopStream( PaStream *stream );
1007 
1008 
1012 PaError Pa_AbortStream( PaStream *stream );
1013 
1014 
1027 PaError Pa_IsStreamStopped( PaStream *stream );
1028 
1029 
1043 PaError Pa_IsStreamActive( PaStream *stream );
1044 
1045 
1046 
1051 typedef struct PaStreamInfo
1052 {
1055 
1063 
1071 
1079  double sampleRate;
1080 
1081 } PaStreamInfo;
1082 
1083 
1097 const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
1098 
1099 
1115 PaTime Pa_GetStreamTime( PaStream *stream );
1116 
1117 
1134 double Pa_GetStreamCpuLoad( PaStream* stream );
1135 
1136 
1162 PaError Pa_ReadStream( PaStream* stream,
1163  void *buffer,
1164  unsigned long frames );
1165 
1166 
1193 PaError Pa_WriteStream( PaStream* stream,
1194  const void *buffer,
1195  unsigned long frames );
1196 
1197 
1209 signed long Pa_GetStreamReadAvailable( PaStream* stream );
1210 
1211 
1223 signed long Pa_GetStreamWriteAvailable( PaStream* stream );
1224 
1225 
1226 /* Miscellaneous utilities */
1227 
1228 
1234 PaError Pa_GetSampleSize( PaSampleFormat format );
1235 
1236 
1244 void Pa_Sleep( long msec );
1245 
1246 
1247 
1248 #ifdef __cplusplus
1249 }
1250 #endif /* __cplusplus */
1251 #endif /* PORTAUDIO_H */
PaError Pa_Initialize(void)
Definition: pa_front.c:353
Definition: portaudio.h:283
Definition: portaudio.h:147
double defaultSampleRate
Definition: portaudio.h:525
Definition: portaudio.h:132
struct PaDeviceInfo PaDeviceInfo
Definition: portaudio.h:137
Definition: portaudio.h:285
int structVersion
Definition: portaudio.h:304
PaTime defaultHighInputLatency
Definition: portaudio.h:522
Definition: portaudio.h:148
int PaHostApiIndex
Definition: portaudio.h:240
PaDeviceIndex Pa_GetDefaultInputDevice(void)
Definition: pa_front.c:717
int maxInputChannels
Definition: portaudio.h:515
PaDeviceIndex Pa_GetDeviceCount(void)
Definition: pa_front.c:696
PaHostApiTypeId type
Definition: portaudio.h:306
struct PaStreamInfo PaStreamInfo
PaError Pa_StopStream(PaStream *stream)
Definition: pa_front.c:1471
struct PaHostErrorInfo PaHostErrorInfo
void PaStream
Definition: portaudio.h:644
Definition: portaudio.h:1051
Definition: portaudio.h:292
Definition: portaudio.h:134
int versionSubMinor
Definition: portaudio.h:93
int structVersion
Definition: portaudio.h:507
const PaStreamInfo * Pa_GetStreamInfo(PaStream *stream)
Definition: pa_front.c:1556
Definition: portaudio.h:505
long errorCode
Definition: portaudio.h:396
Definition: portaudio.h:764
Definition: portaudio.h:150
Definition: portaudio.h:280
Definition: portaudio.h:146
PaError Pa_GetSampleSize(PaSampleFormat format)
Definition: pa_front.c:1788
PaError Pa_OpenStream(PaStream **stream, const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate, unsigned long framesPerBuffer, PaStreamFlags streamFlags, PaStreamCallback *streamCallback, void *userData)
Definition: pa_front.c:1152
double sampleRate
Definition: portaudio.h:1079
PaHostApiIndex Pa_GetDefaultHostApi(void)
Definition: pa_front.c:588
const char * name
Definition: portaudio.h:510
Definition: portaudio.h:149
const char * name
Definition: portaudio.h:308
Definition: portaudio.h:128
int PaStreamCallback(const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
Definition: portaudio.h:839
Definition: portaudio.h:301
Definition: portaudio.h:293
Definition: portaudio.h:90
Definition: portaudio.h:290
const PaHostErrorInfo * Pa_GetLastHostErrorInfo(void)
Definition: pa_front.c:429
PaError Pa_IsFormatSupported(const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate)
Definition: pa_front.c:1048
Definition: portaudio.h:133
void PaStreamFinishedCallback(void *userData)
Definition: portaudio.h:974
int PaDeviceIndex
Definition: portaudio.h:214
PaError Pa_SetStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback *streamFinishedCallback)
Definition: pa_front.c:1416
PaTime defaultLowInputLatency
Definition: portaudio.h:519
PaError Pa_StartStream(PaStream *stream)
Definition: pa_front.c:1445
Definition: portaudio.h:125
Definition: portaudio.h:129
void * hostApiSpecificStreamInfo
Definition: portaudio.h:588
struct PaHostApiInfo PaHostApiInfo
const char * versionControlRevision
Definition: portaudio.h:100
Definition: portaudio.h:140
Definition: portaudio.h:295
PaDeviceIndex defaultInputDevice
Definition: portaudio.h:321
int deviceCount
Definition: portaudio.h:315
Definition: portaudio.h:131
Definition: portaudio.h:766
Definition: portaudio.h:144
Definition: portaudio.h:286
Definition: portaudio.h:152
PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex(PaHostApiIndex hostApi, int hostApiDeviceIndex)
Definition: pa_front.c:658
PaError Pa_IsStreamStopped(PaStream *stream)
Definition: pa_front.c:1523
PaTime inputLatency
Definition: portaudio.h:1062
PaSampleFormat sampleFormat
Definition: portaudio.h:568
const char * versionText
Definition: portaudio.h:102
const char * errorText
Definition: portaudio.h:397
unsigned long PaStreamFlags
Definition: portaudio.h:662
int PaError
Definition: portaudio.h:122
PaError Pa_IsStreamActive(PaStream *stream)
Definition: pa_front.c:1539
Definition: portaudio.h:284
PaHostApiTypeId
Definition: portaudio.h:277
Definition: portaudio.h:288
PaTime suggestedLatency
Definition: portaudio.h:581
struct PaVersionInfo PaVersionInfo
int Pa_GetVersion(void)
Definition: pa_front.c:112
Definition: portaudio.h:547
unsigned long PaStreamCallbackFlags
Definition: portaudio.h:721
PaTime Pa_GetStreamTime(PaStream *stream)
Definition: pa_front.c:1592
struct PaStreamParameters PaStreamParameters
Definition: portaudio.h:291
PaError Pa_OpenDefaultStream(PaStream **stream, int numInputChannels, int numOutputChannels, PaSampleFormat sampleFormat, double sampleRate, unsigned long framesPerBuffer, PaStreamCallback *streamCallback, void *userData)
Definition: pa_front.c:1286
PaDeviceIndex defaultOutputDevice
Definition: portaudio.h:327
Definition: portaudio.h:282
Definition: portaudio.h:281
int structVersion
Definition: portaudio.h:1054
PaError Pa_AbortStream(PaStream *stream)
Definition: pa_front.c:1497
Definition: portaudio.h:394
Definition: portaudio.h:155
const PaHostApiInfo * Pa_GetHostApiInfo(PaHostApiIndex hostApi)
Definition: pa_front.c:617
unsigned long PaSampleFormat
Definition: portaudio.h:489
PaHostApiIndex hostApi
Definition: portaudio.h:513
signed long Pa_GetStreamReadAvailable(PaStream *stream)
Definition: pa_front.c:1730
PaTime inputBufferAdcTime
Definition: portaudio.h:709
Definition: portaudio.h:145
Definition: portaudio.h:143
Definition: portaudio.h:765
Definition: portaudio.h:136
Definition: portaudio.h:294
PaHostApiIndex Pa_GetHostApiCount(void)
Definition: pa_front.c:567
const PaDeviceInfo * Pa_GetDeviceInfo(PaDeviceIndex device)
Definition: pa_front.c:763
PaDeviceIndex Pa_GetDefaultOutputDevice(void)
Definition: pa_front.c:740
Definition: portaudio.h:151
PaStreamCallbackResult
Definition: portaudio.h:762
Definition: portaudio.h:130
PaDeviceIndex device
Definition: portaudio.h:555
struct PaStreamCallbackTimeInfo PaStreamCallbackTimeInfo
int versionMinor
Definition: portaudio.h:92
PaErrorCode
Definition: portaudio.h:123
void Pa_Sleep(long msec)
Definition: pa_unix_util.c:112
Definition: portaudio.h:289
PaError Pa_ReadStream(PaStream *stream, void *buffer, unsigned long frames)
Definition: pa_front.c:1651
Definition: portaudio.h:154
PaTime defaultLowOutputLatency
Definition: portaudio.h:520
char buffer[NUM_BYTES]
Definition: recplay.c:26
PaHostApiTypeId hostApiType
Definition: portaudio.h:395
PaTime outputLatency
Definition: portaudio.h:1070
Definition: portaudio.h:279
Definition: portaudio.h:141
PaError Pa_WriteStream(PaStream *stream, const void *buffer, unsigned long frames)
Definition: pa_front.c:1691
double PaTime
Definition: portaudio.h:465
PaTime outputBufferDacTime
Definition: portaudio.h:711
Definition: portaudio.h:156
const char * Pa_GetErrorText(PaError errorCode)
Definition: pa_front.c:435
Definition: portaudio.h:142
Definition: portaudio.h:138
int maxOutputChannels
Definition: portaudio.h:516
int channelCount
Definition: portaudio.h:562
const PaVersionInfo * Pa_GetVersionInfo(void)
Definition: pa_front.c:130
PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex(PaHostApiTypeId type)
Definition: pa_front.c:484
signed long Pa_GetStreamWriteAvailable(PaStream *stream)
Definition: pa_front.c:1759
PaTime currentTime
Definition: portaudio.h:710
PaError Pa_CloseStream(PaStream *stream)
Definition: pa_front.c:1382
PaTime defaultHighOutputLatency
Definition: portaudio.h:523
PaError Pa_Terminate(void)
Definition: pa_front.c:398
const char * Pa_GetVersionText(void)
Definition: pa_front.c:117
int versionMajor
Definition: portaudio.h:91
Definition: portaudio.h:139
Definition: portaudio.h:135
Definition: portaudio.h:153
Definition: portaudio.h:708
double Pa_GetStreamCpuLoad(PaStream *stream)
Definition: pa_front.c:1621
Definition: portaudio.h:287
Definition: portaudio.h:127