Jack2  1.9.9
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,
94  paIncompatibleStreamHostApi,
95  paBadBufferPtr
96  }
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  }
232 
233 
236  typedef struct PaHostApiInfo {
242  const char *name;
243 
250 
255  PaDeviceIndex defaultInputDevice;
256 
261  PaDeviceIndex defaultOutputDevice;
262 
263  }
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 {
331  long errorCode;
332  const char *errorText;
333  }
335 
336 
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 
490 
495  PaSampleFormat sampleFormat;
496 
509 
516 
517  }
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  }
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 
688  {
689  paContinue = 0,
690  paComplete = 1,
691  paAbort = 2
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 {
951 
958  PaTime inputLatency;
959 
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 */
PaError Pa_Initialize(void)
int structVersion
Definition: portaudio.h:238
struct PaDeviceInfo PaDeviceInfo
int PaHostApiIndex
Definition: portaudio.h:179
PaDeviceIndex Pa_GetDefaultInputDevice(void)
PaDeviceIndex Pa_GetDeviceCount(void)
PaHostApiTypeId type
Definition: portaudio.h:240
PaError Pa_StopStream(PaStream *stream)
void PaStream
Definition: portaudio.h:572
const PaStreamInfo * Pa_GetStreamInfo(PaStream *stream)
PaError Pa_GetSampleSize(PaSampleFormat format)
PaError Pa_OpenStream(PaStream **stream, const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate, unsigned long framesPerBuffer, PaStreamFlags streamFlags, PaStreamCallback *streamCallback, void *userData)
double sampleRate
Definition: portaudio.h:975
PaHostApiIndex Pa_GetDefaultHostApi(void)
const char * name
Definition: portaudio.h:242
struct PaHostApiInfo PaHostApiInfo
int PaStreamCallback(const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
Definition: portaudio.h:739
struct PaHostErrorInfo PaHostErrorInfo
const PaHostErrorInfo * Pa_GetLastHostErrorInfo(void)
PaError Pa_IsFormatSupported(const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate)
struct PaStreamInfo PaStreamInfo
struct PaStreamParameters PaStreamParameters
void PaStreamFinishedCallback(void *userData)
Definition: portaudio.h:871
int PaDeviceIndex
Definition: portaudio.h:153
PaError Pa_SetStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback *streamFinishedCallback)
PaError Pa_StartStream(PaStream *stream)
void * hostApiSpecificStreamInfo
Definition: portaudio.h:515
PaDeviceIndex defaultInputDevice
Definition: portaudio.h:255
PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex(PaHostApiIndex hostApi, int hostApiDeviceIndex)
PaError Pa_IsStreamStopped(PaStream *stream)
PaTime inputLatency
Definition: portaudio.h:958
PaSampleFormat sampleFormat
Definition: portaudio.h:495
const char * errorText
Definition: portaudio.h:332
unsigned long PaStreamFlags
Definition: portaudio.h:590
int PaError
Definition: portaudio.h:63
PaError Pa_IsStreamActive(PaStream *stream)
PaHostApiTypeId
Definition: portaudio.h:216
PaTime suggestedLatency
Definition: portaudio.h:508
int Pa_GetVersion(void)
unsigned long PaStreamCallbackFlags
Definition: portaudio.h:646
PaTime Pa_GetStreamTime(PaStream *stream)
PaError Pa_OpenDefaultStream(PaStream **stream, int numInputChannels, int numOutputChannels, PaSampleFormat sampleFormat, double sampleRate, unsigned long framesPerBuffer, PaStreamCallback *streamCallback, void *userData)
PaDeviceIndex defaultOutputDevice
Definition: portaudio.h:261
int structVersion
Definition: portaudio.h:950
PaError Pa_AbortStream(PaStream *stream)
const PaHostApiInfo * Pa_GetHostApiInfo(PaHostApiIndex hostApi)
unsigned long PaSampleFormat
Definition: portaudio.h:421
signed long Pa_GetStreamReadAvailable(PaStream *stream)
PaHostApiIndex Pa_GetHostApiCount(void)
const PaDeviceInfo * Pa_GetDeviceInfo(PaDeviceIndex device)
PaDeviceIndex Pa_GetDefaultOutputDevice(void)
PaStreamCallbackResult
Definition: portaudio.h:687
PaDeviceIndex device
Definition: portaudio.h:482
PaErrorCode
Definition: portaudio.h:64
void Pa_Sleep(long msec)
PaError Pa_ReadStream(PaStream *stream, void *buffer, unsigned long frames)
PaHostApiTypeId hostApiType
Definition: portaudio.h:330
PaTime outputLatency
Definition: portaudio.h:966
PaError Pa_WriteStream(PaStream *stream, const void *buffer, unsigned long frames)
double PaTime
Definition: portaudio.h:399
const char * Pa_GetErrorText(PaError errorCode)
PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex(PaHostApiTypeId type)
signed long Pa_GetStreamWriteAvailable(PaStream *stream)
struct PaStreamCallbackTimeInfo PaStreamCallbackTimeInfo
PaError Pa_CloseStream(PaStream *stream)
PaError Pa_Terminate(void)
const char * Pa_GetVersionText(void)
double Pa_GetStreamCpuLoad(PaStream *stream)