Jack2 1.9.12

portaudio.h
Go to the documentation of this file.
1
2 #ifndef PORTAUDIO_H
3 #define PORTAUDIO_H
4 /*
5 * $Id: portaudio.h,v 1.1.2.2 2006/06/20 14:44:48 letz Exp $
6 * PortAudio Portable Real-Time Audio Library
7 * PortAudio API Header File
8 * Latest version available at: http://www.portaudio.com/
9 *
10 * Copyright (c) 1999-2002 Ross Bencina and Phil Burk
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining
13 * a copy of this software and associated documentation files
14 * (the "Software"), to deal in the Software without restriction,
15 * including without limitation the rights to use, copy, modify, merge,
16 * publish, distribute, sublicense, and/or sell copies of the Software,
17 * and to permit persons to whom the Software is furnished to do so,
18 * subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be
21 * included in all copies or substantial portions of the Software.
22 *
23 * Any person wishing to distribute modifications to the Software is
24 * requested to send the modifications to the original developer so that
25 * they can be incorporated into the canonical version.
26 *
27 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
30 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
31 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
32 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 */
35
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif /* __cplusplus */
45
46
50 int Pa_GetVersion( void );
51
52
56 const char* Pa_GetVersionText( void );
57
58
63 typedef int PaError;
64 typedef enum PaErrorCode {
65 paNoError = 0,
66
67 paNotInitialized = -10000,
68 paUnanticipatedHostError,
69 paInvalidChannelCount,
70 paInvalidSampleRate,
71 paInvalidDevice,
72 paInvalidFlag,
73 paSampleFormatNotSupported,
74 paBadIODeviceCombination,
75 paInsufficientMemory,
76 paBufferTooBig,
77 paBufferTooSmall,
78 paNullCallback,
79 paBadStreamPtr,
80 paTimedOut,
81 paInternalError,
82 paDeviceUnavailable,
83 paIncompatibleHostApiSpecificStreamInfo,
84 paStreamIsStopped,
85 paStreamIsNotStopped,
86 paInputOverflowed,
87 paOutputUnderflowed,
88 paHostApiNotFound,
89 paInvalidHostApi,
90 paCanNotReadFromACallbackStream,
91 paCanNotWriteToACallbackStream,
92 paCanNotReadFromAnOutputOnlyStream,
93 paCanNotWriteToAnInputOnlyStream,
94 paIncompatibleStreamHostApi,
95 paBadBufferPtr
96 }
97 PaErrorCode;
98
99
103 const char *Pa_GetErrorText( PaError errorCode );
104
105
124 PaError Pa_Initialize( void );
125
126
143 PaError Pa_Terminate( void );
144
145
146
153 typedef int PaDeviceIndex;
154
155
161 #define paNoDevice ((PaDeviceIndex)-1)
162
163
169 #define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
170
171
172 /* Host API enumeration mechanism */
173
179 typedef int PaHostApiIndex;
180
181
191 PaHostApiIndex Pa_GetHostApiCount( void );
192
193
202 PaHostApiIndex Pa_GetDefaultHostApi( void );
203
204
216 typedef enum PaHostApiTypeId {
217 paInDevelopment = 0, /* use while developing support for a new host API */
218 paDirectSound = 1,
219 paMME = 2,
220 paASIO = 3,
221 paSoundManager = 4,
222 paCoreAudio = 5,
223 paOSS = 7,
224 paALSA = 8,
225 paAL = 9,
226 paBeOS = 10,
227 paWDMKS = 11,
228 paJACK = 12,
229 paWASAPI = 13
230 }
231 PaHostApiTypeId;
232
233
236 typedef struct PaHostApiInfo {
238 int structVersion;
240 PaHostApiTypeId type;
242 const char *name;
243
249 int deviceCount;
250
255 PaDeviceIndex defaultInputDevice;
256
261 PaDeviceIndex defaultOutputDevice;
262
263 }
264 PaHostApiInfo;
265
266
280 const PaHostApiInfo * Pa_GetHostApiInfo( PaHostApiIndex hostApi );
281
282
298 PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type );
299
300
322 PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex( PaHostApiIndex hostApi,
323 int hostApiDeviceIndex );
324
325
326
329 typedef struct PaHostErrorInfo {
330 PaHostApiTypeId hostApiType;
331 long errorCode;
332 const char *errorText;
333 }
334 PaHostErrorInfo;
335
336
350 const PaHostErrorInfo* Pa_GetLastHostErrorInfo( void );
351
352
353
354 /* Device enumeration and capabilities */
355
363 PaDeviceIndex Pa_GetDeviceCount( void );
364
365
372 PaDeviceIndex Pa_GetDefaultInputDevice( void );
373
374
390 PaDeviceIndex Pa_GetDefaultOutputDevice( void );
391
392
399 typedef double PaTime;
400
401
421 typedef unsigned long PaSampleFormat;
422
423
424 #define paFloat32 ((PaSampleFormat) 0x00000001)
425 #define paInt32 ((PaSampleFormat) 0x00000002)
426 #define paInt24 ((PaSampleFormat) 0x00000004)
427 #define paInt16 ((PaSampleFormat) 0x00000008)
428 #define paInt8 ((PaSampleFormat) 0x00000010)
429 #define paUInt8 ((PaSampleFormat) 0x00000020)
430 #define paCustomFormat ((PaSampleFormat) 0x00010000)
432 #define paNonInterleaved ((PaSampleFormat) 0x80000000)
433
437 typedef struct PaDeviceInfo {
438 int structVersion; /* this is struct version 2 */
439 const char *name;
440 PaHostApiIndex hostApi; /* note this is a host API index, not a type id*/
441
442 int maxInputChannels;
443 int maxOutputChannels;
444
445 /* Default latency values for interactive performance. */
446 PaTime defaultLowInputLatency;
447 PaTime defaultLowOutputLatency;
448 /* Default latency values for robust non-interactive applications (eg. playing sound files). */
449 PaTime defaultHighInputLatency;
450 PaTime defaultHighOutputLatency;
451
452 double defaultSampleRate;
453 }
454 PaDeviceInfo;
455
456
470 const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceIndex device );
471
472
475 typedef struct PaStreamParameters {
482 PaDeviceIndex device;
483
489 int channelCount;
490
495 PaSampleFormat sampleFormat;
496
508 PaTime suggestedLatency;
509
515 void *hostApiSpecificStreamInfo;
516
517 }
518 PaStreamParameters;
519
520
522 #define paFormatIsSupported (0)
523
546 PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
547 const PaStreamParameters *outputParameters,
548 double sampleRate );
549
550
551
552 /* Streaming types and functions */
553
554
572 typedef void PaStream;
573
574
579 #define paFramesPerBufferUnspecified (0)
580
581
590 typedef unsigned long PaStreamFlags;
591
593 #define paNoFlag ((PaStreamFlags) 0)
594
598 #define paClipOff ((PaStreamFlags) 0x00000001)
599
603 #define paDitherOff ((PaStreamFlags) 0x00000002)
604
614 #define paNeverDropInput ((PaStreamFlags) 0x00000004)
615
622 #define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
623
627 #define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
628
632 typedef struct PaStreamCallbackTimeInfo {
633 PaTime inputBufferAdcTime;
634 PaTime currentTime;
635 PaTime outputBufferDacTime;
636 }
637 PaStreamCallbackTimeInfo;
638
639
646 typedef unsigned long PaStreamCallbackFlags;
647
655 #define paInputUnderflow ((PaStreamCallbackFlags) 0x00000001)
656
664 #define paInputOverflow ((PaStreamCallbackFlags) 0x00000002)
665
670 #define paOutputUnderflow ((PaStreamCallbackFlags) 0x00000004)
671
675 #define paOutputOverflow ((PaStreamCallbackFlags) 0x00000008)
676
681 #define paPrimingOutput ((PaStreamCallbackFlags) 0x00000010)
682
687 typedef enum PaStreamCallbackResult
688 {
689 paContinue = 0,
690 paComplete = 1,
691 paAbort = 2
692 } PaStreamCallbackResult;
693
694
739 typedef int PaStreamCallback(
740 const void *input, void *output,
741 unsigned long frameCount,
742 const PaStreamCallbackTimeInfo* timeInfo,
743 PaStreamCallbackFlags statusFlags,
744 void *userData );
745
746
801 PaError Pa_OpenStream( PaStream** stream,
802 const PaStreamParameters *inputParameters,
803 const PaStreamParameters *outputParameters,
804 double sampleRate,
805 unsigned long framesPerBuffer,
806 PaStreamFlags streamFlags,
807 PaStreamCallback *streamCallback,
808 void *userData );
809
810
841 PaError Pa_OpenDefaultStream( PaStream** stream,
842 int numInputChannels,
843 int numOutputChannels,
844 PaSampleFormat sampleFormat,
845 double sampleRate,
846 unsigned long framesPerBuffer,
847 PaStreamCallback *streamCallback,
848 void *userData );
849
850
854 PaError Pa_CloseStream( PaStream *stream );
855
856
871 typedef void PaStreamFinishedCallback( void *userData );
872
873
892 PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
893
894
897 PaError Pa_StartStream( PaStream *stream );
898
899
903 PaError Pa_StopStream( PaStream *stream );
904
905
909 PaError Pa_AbortStream( PaStream *stream );
910
911
924 PaError Pa_IsStreamStopped( PaStream *stream );
925
926
940 PaError Pa_IsStreamActive( PaStream *stream );
941
942
943
948 typedef struct PaStreamInfo {
950 int structVersion;
951
958 PaTime inputLatency;
959
966 PaTime outputLatency;
967
975 double sampleRate;
976
977 }
978 PaStreamInfo;
979
980
994 const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
995
996
1005 PaTime Pa_GetStreamTime( PaStream *stream );
1006
1007
1024 double Pa_GetStreamCpuLoad( PaStream* stream );
1025
1026
1048 PaError Pa_ReadStream( PaStream* stream,
1049 void *buffer,
1050 unsigned long frames );
1051
1052
1075 PaError Pa_WriteStream( PaStream* stream,
1076 const void *buffer,
1077 unsigned long frames );
1078
1079
1088 signed long Pa_GetStreamReadAvailable( PaStream* stream );
1089
1090
1099 signed long Pa_GetStreamWriteAvailable( PaStream* stream );
1100
1101
1102 /* Miscellaneous utilities */
1103
1104
1110 PaError Pa_GetSampleSize( PaSampleFormat format );
1111
1112
1120 void Pa_Sleep( long msec );
1121
1122
1123
1124 #ifdef __cplusplus
1125 }
1126 #endif /* __cplusplus */
1127 #endif /* PORTAUDIO_H */
Pa_Initialize
PaError Pa_Initialize(void)
PaHostApiInfo::structVersion
int structVersion
Definition: portaudio.h:238
PaDeviceInfo
struct PaDeviceInfo PaDeviceInfo
PaHostApiIndex
int PaHostApiIndex
Definition: portaudio.h:179
Pa_GetDefaultInputDevice
PaDeviceIndex Pa_GetDefaultInputDevice(void)
Pa_GetDeviceCount
PaDeviceIndex Pa_GetDeviceCount(void)
PaHostApiInfo::type
PaHostApiTypeId type
Definition: portaudio.h:240
Pa_StopStream
PaError Pa_StopStream(PaStream *stream)
PaStream
void PaStream
Definition: portaudio.h:572
PaStreamInfo
Definition: portaudio.h:948
Pa_GetStreamInfo
const PaStreamInfo * Pa_GetStreamInfo(PaStream *stream)
PaDeviceInfo
Definition: portaudio.h:437
PaHostErrorInfo::errorCode
long errorCode
Definition: portaudio.h:331
paCanNotReadFromACallbackStream
Definition: portaudio.h:90
Pa_GetSampleSize
PaError Pa_GetSampleSize(PaSampleFormat format)
Pa_OpenStream
PaError Pa_OpenStream(PaStream **stream, const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate, unsigned long framesPerBuffer, PaStreamFlags streamFlags, PaStreamCallback *streamCallback, void *userData)
PaStreamInfo::sampleRate
double sampleRate
Definition: portaudio.h:975
Pa_GetDefaultHostApi
PaHostApiIndex Pa_GetDefaultHostApi(void)
PaHostApiInfo::name
const char * name
Definition: portaudio.h:242
PaHostApiInfo
struct PaHostApiInfo PaHostApiInfo
PaStreamCallback
int PaStreamCallback(const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
Definition: portaudio.h:739
PaHostApiInfo
Definition: portaudio.h:236
PaHostErrorInfo
struct PaHostErrorInfo PaHostErrorInfo
Pa_GetLastHostErrorInfo
const PaHostErrorInfo * Pa_GetLastHostErrorInfo(void)
Pa_IsFormatSupported
PaError Pa_IsFormatSupported(const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate)
PaStreamInfo
struct PaStreamInfo PaStreamInfo
PaStreamParameters
struct PaStreamParameters PaStreamParameters
PaStreamFinishedCallback
void PaStreamFinishedCallback(void *userData)
Definition: portaudio.h:871
PaDeviceIndex
int PaDeviceIndex
Definition: portaudio.h:153
Pa_SetStreamFinishedCallback
PaError Pa_SetStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback *streamFinishedCallback)
Pa_StartStream
PaError Pa_StartStream(PaStream *stream)
PaStreamParameters::hostApiSpecificStreamInfo
void * hostApiSpecificStreamInfo
Definition: portaudio.h:515
PaHostApiInfo::defaultInputDevice
PaDeviceIndex defaultInputDevice
Definition: portaudio.h:255
PaHostApiInfo::deviceCount
int deviceCount
Definition: portaudio.h:249
paCanNotReadFromAnOutputOnlyStream
Definition: portaudio.h:92
Pa_HostApiDeviceIndexToDeviceIndex
PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex(PaHostApiIndex hostApi, int hostApiDeviceIndex)
Pa_IsStreamStopped
PaError Pa_IsStreamStopped(PaStream *stream)
PaStreamInfo::inputLatency
PaTime inputLatency
Definition: portaudio.h:958
PaStreamParameters::sampleFormat
PaSampleFormat sampleFormat
Definition: portaudio.h:495
PaHostErrorInfo::errorText
const char * errorText
Definition: portaudio.h:332
PaStreamFlags
unsigned long PaStreamFlags
Definition: portaudio.h:590
PaError
int PaError
Definition: portaudio.h:63
Pa_IsStreamActive
PaError Pa_IsStreamActive(PaStream *stream)
PaHostApiTypeId
PaHostApiTypeId
Definition: portaudio.h:216
PaStreamParameters::suggestedLatency
PaTime suggestedLatency
Definition: portaudio.h:508
Pa_GetVersion
int Pa_GetVersion(void)
PaStreamParameters
Definition: portaudio.h:475
PaStreamCallbackFlags
unsigned long PaStreamCallbackFlags
Definition: portaudio.h:646
Pa_GetStreamTime
PaTime Pa_GetStreamTime(PaStream *stream)
Pa_OpenDefaultStream
PaError Pa_OpenDefaultStream(PaStream **stream, int numInputChannels, int numOutputChannels, PaSampleFormat sampleFormat, double sampleRate, unsigned long framesPerBuffer, PaStreamCallback *streamCallback, void *userData)
PaHostApiInfo::defaultOutputDevice
PaDeviceIndex defaultOutputDevice
Definition: portaudio.h:261
PaStreamInfo::structVersion
int structVersion
Definition: portaudio.h:950
Pa_AbortStream
PaError Pa_AbortStream(PaStream *stream)
PaHostErrorInfo
Definition: portaudio.h:329
Pa_GetHostApiInfo
const PaHostApiInfo * Pa_GetHostApiInfo(PaHostApiIndex hostApi)
PaSampleFormat
unsigned long PaSampleFormat
Definition: portaudio.h:421
Pa_GetStreamReadAvailable
signed long Pa_GetStreamReadAvailable(PaStream *stream)
Pa_GetHostApiCount
PaHostApiIndex Pa_GetHostApiCount(void)
Pa_GetDeviceInfo
const PaDeviceInfo * Pa_GetDeviceInfo(PaDeviceIndex device)
Pa_GetDefaultOutputDevice
PaDeviceIndex Pa_GetDefaultOutputDevice(void)
paCanNotWriteToACallbackStream
Definition: portaudio.h:91
PaStreamCallbackResult
PaStreamCallbackResult
Definition: portaudio.h:687
PaStreamParameters::device
PaDeviceIndex device
Definition: portaudio.h:482
PaErrorCode
PaErrorCode
Definition: portaudio.h:64
Pa_Sleep
void Pa_Sleep(long msec)
Pa_ReadStream
PaError Pa_ReadStream(PaStream *stream, void *buffer, unsigned long frames)
PaHostErrorInfo::hostApiType
PaHostApiTypeId hostApiType
Definition: portaudio.h:330
PaStreamInfo::outputLatency
PaTime outputLatency
Definition: portaudio.h:966
Pa_WriteStream
PaError Pa_WriteStream(PaStream *stream, const void *buffer, unsigned long frames)
PaTime
double PaTime
Definition: portaudio.h:399
Pa_GetErrorText
const char * Pa_GetErrorText(PaError errorCode)
PaStreamParameters::channelCount
int channelCount
Definition: portaudio.h:489
Pa_HostApiTypeIdToHostApiIndex
PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex(PaHostApiTypeId type)
Pa_GetStreamWriteAvailable
signed long Pa_GetStreamWriteAvailable(PaStream *stream)
PaStreamCallbackTimeInfo
struct PaStreamCallbackTimeInfo PaStreamCallbackTimeInfo
Pa_CloseStream
PaError Pa_CloseStream(PaStream *stream)
Pa_Terminate
PaError Pa_Terminate(void)
Pa_GetVersionText
const char * Pa_GetVersionText(void)
paCanNotWriteToAnInputOnlyStream
Definition: portaudio.h:93
PaStreamCallbackTimeInfo
Definition: portaudio.h:632
Pa_GetStreamCpuLoad
double Pa_GetStreamCpuLoad(PaStream *stream)