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
00047 #ifdef __cplusplus
00048 extern "C"
00049 {
00050 #endif
00051
00052
00056 int Pa_GetVersion( void );
00057
00058
00062 const char* Pa_GetVersionText( void );
00063
00064
00069 typedef int PaError;
00070 typedef enum PaErrorCode
00071 {
00072 paNoError = 0,
00073
00074 paNotInitialized = -10000,
00075 paUnanticipatedHostError,
00076 paInvalidChannelCount,
00077 paInvalidSampleRate,
00078 paInvalidDevice,
00079 paInvalidFlag,
00080 paSampleFormatNotSupported,
00081 paBadIODeviceCombination,
00082 paInsufficientMemory,
00083 paBufferTooBig,
00084 paBufferTooSmall,
00085 paNullCallback,
00086 paBadStreamPtr,
00087 paTimedOut,
00088 paInternalError,
00089 paDeviceUnavailable,
00090 paIncompatibleHostApiSpecificStreamInfo,
00091 paStreamIsStopped,
00092 paStreamIsNotStopped,
00093 paInputOverflowed,
00094 paOutputUnderflowed,
00095 paHostApiNotFound,
00096 paInvalidHostApi,
00097 paCanNotReadFromACallbackStream,
00098 paCanNotWriteToACallbackStream,
00099 paCanNotReadFromAnOutputOnlyStream,
00100 paCanNotWriteToAnInputOnlyStream,
00101 paIncompatibleStreamHostApi,
00102 paBadBufferPtr
00103 } PaErrorCode;
00104
00105
00109 const char *Pa_GetErrorText( PaError errorCode );
00110
00111
00131 PaError Pa_Initialize( void );
00132
00133
00150 PaError Pa_Terminate( void );
00151
00152
00153
00160 typedef int PaDeviceIndex;
00161
00162
00168 #define paNoDevice ((PaDeviceIndex)-1)
00169
00170
00176 #define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
00177
00178
00179
00180
00186 typedef int PaHostApiIndex;
00187
00188
00198 PaHostApiIndex Pa_GetHostApiCount( void );
00199
00200
00209 PaHostApiIndex Pa_GetDefaultHostApi( void );
00210
00211
00223 typedef enum PaHostApiTypeId
00224 {
00225 paInDevelopment=0,
00226 paDirectSound=1,
00227 paMME=2,
00228 paASIO=3,
00229 paSoundManager=4,
00230 paCoreAudio=5,
00231 paOSS=7,
00232 paALSA=8,
00233 paAL=9,
00234 paBeOS=10,
00235 paWDMKS=11,
00236 paJACK=12,
00237 paWASAPI=13,
00238 paAudioScienceHPI=14
00239 } PaHostApiTypeId;
00240
00241
00244 typedef struct PaHostApiInfo
00245 {
00247 int structVersion;
00249 PaHostApiTypeId type;
00251 const char *name;
00252
00258 int deviceCount;
00259
00264 PaDeviceIndex defaultInputDevice;
00265
00270 PaDeviceIndex defaultOutputDevice;
00271
00272 } PaHostApiInfo;
00273
00274
00288 const PaHostApiInfo * Pa_GetHostApiInfo( PaHostApiIndex hostApi );
00289
00290
00306 PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type );
00307
00308
00330 PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex( PaHostApiIndex hostApi,
00331 int hostApiDeviceIndex );
00332
00333
00334
00337 typedef struct PaHostErrorInfo{
00338 PaHostApiTypeId hostApiType;
00339 long errorCode;
00340 const char *errorText;
00341 }PaHostErrorInfo;
00342
00343
00357 const PaHostErrorInfo* Pa_GetLastHostErrorInfo( void );
00358
00359
00360
00361
00362
00370 PaDeviceIndex Pa_GetDeviceCount( void );
00371
00372
00379 PaDeviceIndex Pa_GetDefaultInputDevice( void );
00380
00381
00397 PaDeviceIndex Pa_GetDefaultOutputDevice( void );
00398
00399
00406 typedef double PaTime;
00407
00408
00428 typedef unsigned long PaSampleFormat;
00429
00430
00431 #define paFloat32 ((PaSampleFormat) 0x00000001)
00432 #define paInt32 ((PaSampleFormat) 0x00000002)
00433 #define paInt24 ((PaSampleFormat) 0x00000004)
00434 #define paInt16 ((PaSampleFormat) 0x00000008)
00435 #define paInt8 ((PaSampleFormat) 0x00000010)
00436 #define paUInt8 ((PaSampleFormat) 0x00000020)
00437 #define paCustomFormat ((PaSampleFormat) 0x00010000)
00439 #define paNonInterleaved ((PaSampleFormat) 0x80000000)
00440
00444 typedef struct PaDeviceInfo
00445 {
00446 int structVersion;
00447 const char *name;
00448 PaHostApiIndex hostApi;
00449
00450 int maxInputChannels;
00451 int maxOutputChannels;
00452
00453
00454 PaTime defaultLowInputLatency;
00455 PaTime defaultLowOutputLatency;
00456
00457 PaTime defaultHighInputLatency;
00458 PaTime defaultHighOutputLatency;
00459
00460 double defaultSampleRate;
00461 } PaDeviceInfo;
00462
00463
00477 const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceIndex device );
00478
00479
00482 typedef struct PaStreamParameters
00483 {
00490 PaDeviceIndex device;
00491
00497 int channelCount;
00498
00503 PaSampleFormat sampleFormat;
00504
00516 PaTime suggestedLatency;
00517
00523 void *hostApiSpecificStreamInfo;
00524
00525 } PaStreamParameters;
00526
00527
00529 #define paFormatIsSupported (0)
00530
00553 PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
00554 const PaStreamParameters *outputParameters,
00555 double sampleRate );
00556
00557
00558
00559
00560
00561
00579 typedef void PaStream;
00580
00581
00586 #define paFramesPerBufferUnspecified (0)
00587
00588
00597 typedef unsigned long PaStreamFlags;
00598
00600 #define paNoFlag ((PaStreamFlags) 0)
00601
00605 #define paClipOff ((PaStreamFlags) 0x00000001)
00606
00610 #define paDitherOff ((PaStreamFlags) 0x00000002)
00611
00621 #define paNeverDropInput ((PaStreamFlags) 0x00000004)
00622
00629 #define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
00630
00634 #define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
00635
00639 typedef struct PaStreamCallbackTimeInfo{
00640 PaTime inputBufferAdcTime;
00641 PaTime currentTime;
00642 PaTime outputBufferDacTime;
00643 } PaStreamCallbackTimeInfo;
00644
00645
00652 typedef unsigned long PaStreamCallbackFlags;
00653
00661 #define paInputUnderflow ((PaStreamCallbackFlags) 0x00000001)
00662
00670 #define paInputOverflow ((PaStreamCallbackFlags) 0x00000002)
00671
00676 #define paOutputUnderflow ((PaStreamCallbackFlags) 0x00000004)
00677
00681 #define paOutputOverflow ((PaStreamCallbackFlags) 0x00000008)
00682
00687 #define paPrimingOutput ((PaStreamCallbackFlags) 0x00000010)
00688
00693 typedef enum PaStreamCallbackResult
00694 {
00695 paContinue=0,
00696 paComplete=1,
00697 paAbort=2
00698 } PaStreamCallbackResult;
00699
00700
00745 typedef int PaStreamCallback(
00746 const void *input, void *output,
00747 unsigned long frameCount,
00748 const PaStreamCallbackTimeInfo* timeInfo,
00749 PaStreamCallbackFlags statusFlags,
00750 void *userData );
00751
00752
00807 PaError Pa_OpenStream( PaStream** stream,
00808 const PaStreamParameters *inputParameters,
00809 const PaStreamParameters *outputParameters,
00810 double sampleRate,
00811 unsigned long framesPerBuffer,
00812 PaStreamFlags streamFlags,
00813 PaStreamCallback *streamCallback,
00814 void *userData );
00815
00816
00847 PaError Pa_OpenDefaultStream( PaStream** stream,
00848 int numInputChannels,
00849 int numOutputChannels,
00850 PaSampleFormat sampleFormat,
00851 double sampleRate,
00852 unsigned long framesPerBuffer,
00853 PaStreamCallback *streamCallback,
00854 void *userData );
00855
00856
00860 PaError Pa_CloseStream( PaStream *stream );
00861
00862
00877 typedef void PaStreamFinishedCallback( void *userData );
00878
00879
00898 PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
00899
00900
00903 PaError Pa_StartStream( PaStream *stream );
00904
00905
00909 PaError Pa_StopStream( PaStream *stream );
00910
00911
00915 PaError Pa_AbortStream( PaStream *stream );
00916
00917
00930 PaError Pa_IsStreamStopped( PaStream *stream );
00931
00932
00946 PaError Pa_IsStreamActive( PaStream *stream );
00947
00948
00949
00954 typedef struct PaStreamInfo
00955 {
00957 int structVersion;
00958
00965 PaTime inputLatency;
00966
00973 PaTime outputLatency;
00974
00982 double sampleRate;
00983
00984 } PaStreamInfo;
00985
00986
01000 const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
01001
01002
01011 PaTime Pa_GetStreamTime( PaStream *stream );
01012
01013
01030 double Pa_GetStreamCpuLoad( PaStream* stream );
01031
01032
01054 PaError Pa_ReadStream( PaStream* stream,
01055 void *buffer,
01056 unsigned long frames );
01057
01058
01081 PaError Pa_WriteStream( PaStream* stream,
01082 const void *buffer,
01083 unsigned long frames );
01084
01085
01094 signed long Pa_GetStreamReadAvailable( PaStream* stream );
01095
01096
01105 signed long Pa_GetStreamWriteAvailable( PaStream* stream );
01106
01107
01108
01109
01110
01116 PaError Pa_GetSampleSize( PaSampleFormat format );
01117
01118
01126 void Pa_Sleep( long msec );
01127
01128
01129
01130 #ifdef __cplusplus
01131 }
01132 #endif
01133 #endif