00001 #ifndef PORTAUDIO_H
00002 #define PORTAUDIO_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00048 #ifdef __cplusplus
00049 extern "C"
00050 {
00051 #endif
00052
00053
00057 int Pa_GetVersion( void );
00058
00059
00063 const char* Pa_GetVersionText( void );
00064
00065
00070 typedef int PaError;
00071 typedef enum PaErrorCode
00072 {
00073 paNoError = 0,
00074
00075 paNotInitialized = -10000,
00076 paUnanticipatedHostError,
00077 paInvalidChannelCount,
00078 paInvalidSampleRate,
00079 paInvalidDevice,
00080 paInvalidFlag,
00081 paSampleFormatNotSupported,
00082 paBadIODeviceCombination,
00083 paInsufficientMemory,
00084 paBufferTooBig,
00085 paBufferTooSmall,
00086 paNullCallback,
00087 paBadStreamPtr,
00088 paTimedOut,
00089 paInternalError,
00090 paDeviceUnavailable,
00091 paIncompatibleHostApiSpecificStreamInfo,
00092 paStreamIsStopped,
00093 paStreamIsNotStopped,
00094 paInputOverflowed,
00095 paOutputUnderflowed,
00096 paHostApiNotFound,
00097 paInvalidHostApi,
00098 paCanNotReadFromACallbackStream,
00099 paCanNotWriteToACallbackStream,
00100 paCanNotReadFromAnOutputOnlyStream,
00101 paCanNotWriteToAnInputOnlyStream,
00102 paIncompatibleStreamHostApi,
00103 paBadBufferPtr
00104 } PaErrorCode;
00105
00106
00110 const char *Pa_GetErrorText( PaError errorCode );
00111
00112
00132 PaError Pa_Initialize( void );
00133
00134
00151 PaError Pa_Terminate( void );
00152
00153
00154
00161 typedef int PaDeviceIndex;
00162
00163
00169 #define paNoDevice ((PaDeviceIndex)-1)
00170
00171
00177 #define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
00178
00179
00180
00181
00187 typedef int PaHostApiIndex;
00188
00189
00199 PaHostApiIndex Pa_GetHostApiCount( void );
00200
00201
00210 PaHostApiIndex Pa_GetDefaultHostApi( void );
00211
00212
00224 typedef enum PaHostApiTypeId
00225 {
00226 paInDevelopment=0,
00227 paDirectSound=1,
00228 paMME=2,
00229 paASIO=3,
00230 paSoundManager=4,
00231 paCoreAudio=5,
00232 paOSS=7,
00233 paALSA=8,
00234 paAL=9,
00235 paBeOS=10,
00236 paWDMKS=11,
00237 paJACK=12,
00238 paWASAPI=13,
00239 paAudioScienceHPI=14
00240 } PaHostApiTypeId;
00241
00242
00245 typedef struct PaHostApiInfo
00246 {
00248 int structVersion;
00250 PaHostApiTypeId type;
00252 const char *name;
00253
00259 int deviceCount;
00260
00265 PaDeviceIndex defaultInputDevice;
00266
00271 PaDeviceIndex defaultOutputDevice;
00272
00273 } PaHostApiInfo;
00274
00275
00289 const PaHostApiInfo * Pa_GetHostApiInfo( PaHostApiIndex hostApi );
00290
00291
00307 PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type );
00308
00309
00331 PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex( PaHostApiIndex hostApi,
00332 int hostApiDeviceIndex );
00333
00334
00335
00338 typedef struct PaHostErrorInfo{
00339 PaHostApiTypeId hostApiType;
00340 long errorCode;
00341 const char *errorText;
00342 }PaHostErrorInfo;
00343
00344
00358 const PaHostErrorInfo* Pa_GetLastHostErrorInfo( void );
00359
00360
00361
00362
00363
00371 PaDeviceIndex Pa_GetDeviceCount( void );
00372
00373
00380 PaDeviceIndex Pa_GetDefaultInputDevice( void );
00381
00382
00398 PaDeviceIndex Pa_GetDefaultOutputDevice( void );
00399
00400
00407 typedef double PaTime;
00408
00409
00429 typedef unsigned long PaSampleFormat;
00430
00431
00432 #define paFloat32 ((PaSampleFormat) 0x00000001)
00433 #define paInt32 ((PaSampleFormat) 0x00000002)
00434 #define paInt24 ((PaSampleFormat) 0x00000004)
00435 #define paInt16 ((PaSampleFormat) 0x00000008)
00436 #define paInt8 ((PaSampleFormat) 0x00000010)
00437 #define paUInt8 ((PaSampleFormat) 0x00000020)
00438 #define paCustomFormat ((PaSampleFormat) 0x00010000)
00440 #define paNonInterleaved ((PaSampleFormat) 0x80000000)
00441
00445 typedef struct PaDeviceInfo
00446 {
00447 int structVersion;
00448 const char *name;
00449 PaHostApiIndex hostApi;
00450
00451 int maxInputChannels;
00452 int maxOutputChannels;
00453
00454
00455 PaTime defaultLowInputLatency;
00456 PaTime defaultLowOutputLatency;
00457
00458 PaTime defaultHighInputLatency;
00459 PaTime defaultHighOutputLatency;
00460
00461 double defaultSampleRate;
00462 } PaDeviceInfo;
00463
00464
00478 const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceIndex device );
00479
00480
00483 typedef struct PaStreamParameters
00484 {
00491 PaDeviceIndex device;
00492
00498 int channelCount;
00499
00504 PaSampleFormat sampleFormat;
00505
00517 PaTime suggestedLatency;
00518
00524 void *hostApiSpecificStreamInfo;
00525
00526 } PaStreamParameters;
00527
00528
00530 #define paFormatIsSupported (0)
00531
00554 PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
00555 const PaStreamParameters *outputParameters,
00556 double sampleRate );
00557
00558
00559
00560
00561
00562
00580 typedef void PaStream;
00581
00582
00587 #define paFramesPerBufferUnspecified (0)
00588
00589
00598 typedef unsigned long PaStreamFlags;
00599
00601 #define paNoFlag ((PaStreamFlags) 0)
00602
00606 #define paClipOff ((PaStreamFlags) 0x00000001)
00607
00611 #define paDitherOff ((PaStreamFlags) 0x00000002)
00612
00622 #define paNeverDropInput ((PaStreamFlags) 0x00000004)
00623
00630 #define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
00631
00635 #define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
00636
00640 typedef struct PaStreamCallbackTimeInfo{
00641 PaTime inputBufferAdcTime;
00642 PaTime currentTime;
00643 PaTime outputBufferDacTime;
00644 } PaStreamCallbackTimeInfo;
00645
00646
00653 typedef unsigned long PaStreamCallbackFlags;
00654
00662 #define paInputUnderflow ((PaStreamCallbackFlags) 0x00000001)
00663
00671 #define paInputOverflow ((PaStreamCallbackFlags) 0x00000002)
00672
00677 #define paOutputUnderflow ((PaStreamCallbackFlags) 0x00000004)
00678
00682 #define paOutputOverflow ((PaStreamCallbackFlags) 0x00000008)
00683
00688 #define paPrimingOutput ((PaStreamCallbackFlags) 0x00000010)
00689
00694 typedef enum PaStreamCallbackResult
00695 {
00696 paContinue=0,
00697 paComplete=1,
00698 paAbort=2
00699 } PaStreamCallbackResult;
00700
00701
00746 typedef int PaStreamCallback(
00747 const void *input, void *output,
00748 unsigned long frameCount,
00749 const PaStreamCallbackTimeInfo* timeInfo,
00750 PaStreamCallbackFlags statusFlags,
00751 void *userData );
00752
00753
00808 PaError Pa_OpenStream( PaStream** stream,
00809 const PaStreamParameters *inputParameters,
00810 const PaStreamParameters *outputParameters,
00811 double sampleRate,
00812 unsigned long framesPerBuffer,
00813 PaStreamFlags streamFlags,
00814 PaStreamCallback *streamCallback,
00815 void *userData );
00816
00817
00848 PaError Pa_OpenDefaultStream( PaStream** stream,
00849 int numInputChannels,
00850 int numOutputChannels,
00851 PaSampleFormat sampleFormat,
00852 double sampleRate,
00853 unsigned long framesPerBuffer,
00854 PaStreamCallback *streamCallback,
00855 void *userData );
00856
00857
00861 PaError Pa_CloseStream( PaStream *stream );
00862
00863
00878 typedef void PaStreamFinishedCallback( void *userData );
00879
00880
00899 PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
00900
00901
00904 PaError Pa_StartStream( PaStream *stream );
00905
00906
00910 PaError Pa_StopStream( PaStream *stream );
00911
00912
00916 PaError Pa_AbortStream( PaStream *stream );
00917
00918
00931 PaError Pa_IsStreamStopped( PaStream *stream );
00932
00933
00947 PaError Pa_IsStreamActive( PaStream *stream );
00948
00949
00950
00955 typedef struct PaStreamInfo
00956 {
00958 int structVersion;
00959
00966 PaTime inputLatency;
00967
00974 PaTime outputLatency;
00975
00983 double sampleRate;
00984
00985 } PaStreamInfo;
00986
00987
01001 const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
01002
01003
01012 PaTime Pa_GetStreamTime( PaStream *stream );
01013
01014
01031 double Pa_GetStreamCpuLoad( PaStream* stream );
01032
01033
01055 PaError Pa_ReadStream( PaStream* stream,
01056 void *buffer,
01057 unsigned long frames );
01058
01059
01082 PaError Pa_WriteStream( PaStream* stream,
01083 const void *buffer,
01084 unsigned long frames );
01085
01086
01095 signed long Pa_GetStreamReadAvailable( PaStream* stream );
01096
01097
01106 signed long Pa_GetStreamWriteAvailable( PaStream* stream );
01107
01108
01109
01110
01111
01117 PaError Pa_GetSampleSize( PaSampleFormat format );
01118
01119
01127 void Pa_Sleep( long msec );
01128
01129
01130
01131 #ifdef __cplusplus
01132 }
01133 #endif
01134 #endif