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 {
101  const char *versionText;
102 } PaVersionInfo;
103 
114 const PaVersionInfo* Pa_GetVersionInfo( void );
115 
116 
121 typedef int PaError;
122 typedef enum PaErrorCode
123 {
125 
155 } PaErrorCode;
156 
157 
161 const char *Pa_GetErrorText( PaError errorCode );
162 
163 
183 PaError Pa_Initialize( void );
184 
185 
202 PaError Pa_Terminate( void );
203 
204 
205 
212 typedef int PaDeviceIndex;
213 
214 
220 #define paNoDevice ((PaDeviceIndex)-1)
221 
222 
228 #define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
229 
230 
231 /* Host API enumeration mechanism */
232 
238 typedef int PaHostApiIndex;
239 
240 
250 PaHostApiIndex Pa_GetHostApiCount( void );
251 
252 
261 PaHostApiIndex Pa_GetDefaultHostApi( void );
262 
263 
275 typedef enum PaHostApiTypeId
276 {
277  paInDevelopment=0, /* use while developing support for a new host API */
279  paMME=2,
283  paOSS=7,
285  paAL=9,
286  paBeOS=10,
288  paJACK=12,
292 
293 
296 typedef struct PaHostApiInfo
297 {
303  const char *name;
304 
311 
316  PaDeviceIndex defaultInputDevice;
317 
322  PaDeviceIndex defaultOutputDevice;
323 
324 } PaHostApiInfo;
325 
326 
340 const PaHostApiInfo * Pa_GetHostApiInfo( PaHostApiIndex hostApi );
341 
342 
358 PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type );
359 
360 
382 PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex( PaHostApiIndex hostApi,
383  int hostApiDeviceIndex );
384 
385 
386 
389 typedef struct PaHostErrorInfo{
391  long errorCode;
392  const char *errorText;
394 
395 
410 
411 
412 
413 /* Device enumeration and capabilities */
414 
422 PaDeviceIndex Pa_GetDeviceCount( void );
423 
424 
431 PaDeviceIndex Pa_GetDefaultInputDevice( void );
432 
433 
449 PaDeviceIndex Pa_GetDefaultOutputDevice( void );
450 
451 
460 typedef double PaTime;
461 
462 
484 typedef unsigned long PaSampleFormat;
485 
486 
487 #define paFloat32 ((PaSampleFormat) 0x00000001)
488 #define paInt32 ((PaSampleFormat) 0x00000002)
489 #define paInt24 ((PaSampleFormat) 0x00000004)
490 #define paInt16 ((PaSampleFormat) 0x00000008)
491 #define paInt8 ((PaSampleFormat) 0x00000010)
492 #define paUInt8 ((PaSampleFormat) 0x00000020)
493 #define paCustomFormat ((PaSampleFormat) 0x00010000)
495 #define paNonInterleaved ((PaSampleFormat) 0x80000000)
500 typedef struct PaDeviceInfo
501 {
502  int structVersion; /* this is struct version 2 */
503  const char *name;
504  PaHostApiIndex hostApi;
508 
515 
517 } PaDeviceInfo;
518 
519 
533 const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceIndex device );
534 
535 
538 typedef struct PaStreamParameters
539 {
546  PaDeviceIndex device;
547 
554 
559  PaSampleFormat sampleFormat;
560 
573 
580 
582 
583 
585 #define paFormatIsSupported (0)
586 
609 PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
610  const PaStreamParameters *outputParameters,
611  double sampleRate );
612 
613 
614 
615 /* Streaming types and functions */
616 
617 
635 typedef void PaStream;
636 
637 
642 #define paFramesPerBufferUnspecified (0)
643 
644 
653 typedef unsigned long PaStreamFlags;
654 
656 #define paNoFlag ((PaStreamFlags) 0)
657 
661 #define paClipOff ((PaStreamFlags) 0x00000001)
662 
666 #define paDitherOff ((PaStreamFlags) 0x00000002)
667 
677 #define paNeverDropInput ((PaStreamFlags) 0x00000004)
678 
685 #define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
686 
690 #define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
691 
701  PaTime currentTime;
704 
705 
712 typedef unsigned long PaStreamCallbackFlags;
713 
721 #define paInputUnderflow ((PaStreamCallbackFlags) 0x00000001)
722 
730 #define paInputOverflow ((PaStreamCallbackFlags) 0x00000002)
731 
736 #define paOutputUnderflow ((PaStreamCallbackFlags) 0x00000004)
737 
741 #define paOutputOverflow ((PaStreamCallbackFlags) 0x00000008)
742 
747 #define paPrimingOutput ((PaStreamCallbackFlags) 0x00000010)
748 
754 {
759 
760 
830 typedef int PaStreamCallback(
831  const void *input, void *output,
832  unsigned long frameCount,
833  const PaStreamCallbackTimeInfo* timeInfo,
834  PaStreamCallbackFlags statusFlags,
835  void *userData );
836 
837 
892 PaError Pa_OpenStream( PaStream** stream,
893  const PaStreamParameters *inputParameters,
894  const PaStreamParameters *outputParameters,
895  double sampleRate,
896  unsigned long framesPerBuffer,
897  PaStreamFlags streamFlags,
898  PaStreamCallback *streamCallback,
899  void *userData );
900 
901 
932 PaError Pa_OpenDefaultStream( PaStream** stream,
933  int numInputChannels,
934  int numOutputChannels,
935  PaSampleFormat sampleFormat,
936  double sampleRate,
937  unsigned long framesPerBuffer,
938  PaStreamCallback *streamCallback,
939  void *userData );
940 
941 
945 PaError Pa_CloseStream( PaStream *stream );
946 
947 
962 typedef void PaStreamFinishedCallback( void *userData );
963 
964 
983 PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
984 
985 
988 PaError Pa_StartStream( PaStream *stream );
989 
990 
994 PaError Pa_StopStream( PaStream *stream );
995 
996 
1000 PaError Pa_AbortStream( PaStream *stream );
1001 
1002 
1015 PaError Pa_IsStreamStopped( PaStream *stream );
1016 
1017 
1031 PaError Pa_IsStreamActive( PaStream *stream );
1032 
1033 
1034 
1039 typedef struct PaStreamInfo
1040 {
1043 
1051 
1059 
1067  double sampleRate;
1068 
1069 } PaStreamInfo;
1070 
1071 
1085 const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
1086 
1087 
1103 PaTime Pa_GetStreamTime( PaStream *stream );
1104 
1105 
1122 double Pa_GetStreamCpuLoad( PaStream* stream );
1123 
1124 
1146 PaError Pa_ReadStream( PaStream* stream,
1147  void *buffer,
1148  unsigned long frames );
1149 
1150 
1173 PaError Pa_WriteStream( PaStream* stream,
1174  const void *buffer,
1175  unsigned long frames );
1176 
1177 
1186 signed long Pa_GetStreamReadAvailable( PaStream* stream );
1187 
1188 
1197 signed long Pa_GetStreamWriteAvailable( PaStream* stream );
1198 
1199 
1200 /* Miscellaneous utilities */
1201 
1202 
1208 PaError Pa_GetSampleSize( PaSampleFormat format );
1209 
1210 
1218 void Pa_Sleep( long msec );
1219 
1220 
1221 
1222 #ifdef __cplusplus
1223 }
1224 #endif /* __cplusplus */
1225 #endif /* PORTAUDIO_H */
PaError Pa_Initialize(void)
Definition: pa_front.c:355
Definition: portaudio.h:281
Definition: portaudio.h:146
double defaultSampleRate
Definition: portaudio.h:516
Definition: portaudio.h:131
struct PaDeviceInfo PaDeviceInfo
Definition: portaudio.h:136
Definition: portaudio.h:283
int structVersion
Definition: portaudio.h:299
PaTime defaultHighInputLatency
Definition: portaudio.h:513
Definition: portaudio.h:147
int PaHostApiIndex
Definition: portaudio.h:238
PaDeviceIndex Pa_GetDefaultInputDevice(void)
Definition: pa_front.c:703
int maxInputChannels
Definition: portaudio.h:506
PaDeviceIndex Pa_GetDeviceCount(void)
Definition: pa_front.c:682
PaHostApiTypeId type
Definition: portaudio.h:301
struct PaStreamInfo PaStreamInfo
PaError Pa_StopStream(PaStream *stream)
Definition: pa_front.c:1457
struct PaHostErrorInfo PaHostErrorInfo
void PaStream
Definition: portaudio.h:635
Definition: portaudio.h:1039
Definition: portaudio.h:290
Definition: portaudio.h:133
int versionSubMinor
Definition: portaudio.h:93
int structVersion
Definition: portaudio.h:502
const PaStreamInfo * Pa_GetStreamInfo(PaStream *stream)
Definition: pa_front.c:1542
Definition: portaudio.h:500
long errorCode
Definition: portaudio.h:391
Definition: portaudio.h:755
Definition: portaudio.h:149
Definition: portaudio.h:278
Definition: portaudio.h:145
PaError Pa_GetSampleSize(PaSampleFormat format)
Definition: pa_front.c:1774
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:1138
double sampleRate
Definition: portaudio.h:1067
PaHostApiIndex Pa_GetDefaultHostApi(void)
Definition: pa_front.c:574
const char * name
Definition: portaudio.h:503
Definition: portaudio.h:148
const char * name
Definition: portaudio.h:303
Definition: portaudio.h:127
int PaStreamCallback(const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
Definition: portaudio.h:830
Definition: portaudio.h:296
Definition: portaudio.h:90
Definition: portaudio.h:288
const PaHostErrorInfo * Pa_GetLastHostErrorInfo(void)
Definition: pa_front.c:416
PaError Pa_IsFormatSupported(const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate)
Definition: pa_front.c:1034
Definition: portaudio.h:132
void PaStreamFinishedCallback(void *userData)
Definition: portaudio.h:962
int PaDeviceIndex
Definition: portaudio.h:212
PaError Pa_SetStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback *streamFinishedCallback)
Definition: pa_front.c:1402
PaTime defaultLowInputLatency
Definition: portaudio.h:510
PaError Pa_StartStream(PaStream *stream)
Definition: pa_front.c:1431
Definition: portaudio.h:124
Definition: portaudio.h:128
void * hostApiSpecificStreamInfo
Definition: portaudio.h:579
struct PaHostApiInfo PaHostApiInfo
const char * versionControlRevision
Definition: portaudio.h:99
Definition: portaudio.h:139
PaDeviceIndex defaultInputDevice
Definition: portaudio.h:316
int deviceCount
Definition: portaudio.h:310
Definition: portaudio.h:130
Definition: portaudio.h:757
Definition: portaudio.h:143
Definition: portaudio.h:284
Definition: portaudio.h:151
PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex(PaHostApiIndex hostApi, int hostApiDeviceIndex)
Definition: pa_front.c:644
PaError Pa_IsStreamStopped(PaStream *stream)
Definition: pa_front.c:1509
PaTime inputLatency
Definition: portaudio.h:1050
PaSampleFormat sampleFormat
Definition: portaudio.h:559
const char * versionText
Definition: portaudio.h:101
const char * errorText
Definition: portaudio.h:392
unsigned long PaStreamFlags
Definition: portaudio.h:653
int PaError
Definition: portaudio.h:121
PaError Pa_IsStreamActive(PaStream *stream)
Definition: pa_front.c:1525
Definition: portaudio.h:282
PaHostApiTypeId
Definition: portaudio.h:275
Definition: portaudio.h:286
PaTime suggestedLatency
Definition: portaudio.h:572
struct PaVersionInfo PaVersionInfo
int Pa_GetVersion(void)
Definition: pa_front.c:115
Definition: portaudio.h:538
unsigned long PaStreamCallbackFlags
Definition: portaudio.h:712
PaTime Pa_GetStreamTime(PaStream *stream)
Definition: pa_front.c:1578
struct PaStreamParameters PaStreamParameters
Definition: portaudio.h:289
PaError Pa_OpenDefaultStream(PaStream **stream, int numInputChannels, int numOutputChannels, PaSampleFormat sampleFormat, double sampleRate, unsigned long framesPerBuffer, PaStreamCallback *streamCallback, void *userData)
Definition: pa_front.c:1272
PaDeviceIndex defaultOutputDevice
Definition: portaudio.h:322
Definition: portaudio.h:280
Definition: portaudio.h:279
int structVersion
Definition: portaudio.h:1042
PaError Pa_AbortStream(PaStream *stream)
Definition: pa_front.c:1483
Definition: portaudio.h:389
Definition: portaudio.h:154
const PaHostApiInfo * Pa_GetHostApiInfo(PaHostApiIndex hostApi)
Definition: pa_front.c:603
unsigned long PaSampleFormat
Definition: portaudio.h:484
PaHostApiIndex hostApi
Definition: portaudio.h:504
signed long Pa_GetStreamReadAvailable(PaStream *stream)
Definition: pa_front.c:1716
PaTime inputBufferAdcTime
Definition: portaudio.h:700
Definition: portaudio.h:144
Definition: portaudio.h:142
Definition: portaudio.h:756
Definition: portaudio.h:135
PaHostApiIndex Pa_GetHostApiCount(void)
Definition: pa_front.c:553
const PaDeviceInfo * Pa_GetDeviceInfo(PaDeviceIndex device)
Definition: pa_front.c:749
PaDeviceIndex Pa_GetDefaultOutputDevice(void)
Definition: pa_front.c:726
Definition: portaudio.h:150
PaStreamCallbackResult
Definition: portaudio.h:753
Definition: portaudio.h:129
PaDeviceIndex device
Definition: portaudio.h:546
struct PaStreamCallbackTimeInfo PaStreamCallbackTimeInfo
int versionMinor
Definition: portaudio.h:92
PaErrorCode
Definition: portaudio.h:122
void Pa_Sleep(long msec)
Definition: pa_unix_util.c:108
Definition: portaudio.h:287
PaError Pa_ReadStream(PaStream *stream, void *buffer, unsigned long frames)
Definition: pa_front.c:1637
Definition: portaudio.h:153
PaTime defaultLowOutputLatency
Definition: portaudio.h:511
char buffer[NUM_BYTES]
Definition: recplay.c:26
PaHostApiTypeId hostApiType
Definition: portaudio.h:390
PaTime outputLatency
Definition: portaudio.h:1058
Definition: portaudio.h:277
Definition: portaudio.h:140
PaError Pa_WriteStream(PaStream *stream, const void *buffer, unsigned long frames)
Definition: pa_front.c:1677
double PaTime
Definition: portaudio.h:460
PaTime outputBufferDacTime
Definition: portaudio.h:702
const char * Pa_GetErrorText(PaError errorCode)
Definition: pa_front.c:422
Definition: portaudio.h:141
Definition: portaudio.h:137
int maxOutputChannels
Definition: portaudio.h:507
int channelCount
Definition: portaudio.h:553
const PaVersionInfo * Pa_GetVersionInfo(void)
Definition: pa_front.c:133
PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex(PaHostApiTypeId type)
Definition: pa_front.c:470
signed long Pa_GetStreamWriteAvailable(PaStream *stream)
Definition: pa_front.c:1745
PaTime currentTime
Definition: portaudio.h:701
PaError Pa_CloseStream(PaStream *stream)
Definition: pa_front.c:1368
PaTime defaultHighOutputLatency
Definition: portaudio.h:514
PaError Pa_Terminate(void)
Definition: pa_front.c:385
const char * Pa_GetVersionText(void)
Definition: pa_front.c:120
int versionMajor
Definition: portaudio.h:91
Definition: portaudio.h:138
Definition: portaudio.h:134
Definition: portaudio.h:152
Definition: portaudio.h:699
double Pa_GetStreamCpuLoad(PaStream *stream)
Definition: pa_front.c:1607
Definition: portaudio.h:285
Definition: portaudio.h:126