• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

portaudio.h

Go to the documentation of this file.
00001 #ifndef PORTAUDIO_H
00002 #define PORTAUDIO_H
00003 /*
00004  * $Id: portaudio.h 1337 2008-02-15 07:32:09Z rossb $
00005  * PortAudio Portable Real-Time Audio Library
00006  * PortAudio API Header File
00007  * Latest version available at: http://www.portaudio.com/
00008  *
00009  * Copyright (c) 1999-2002 Ross Bencina and Phil Burk
00010  *
00011  * Permission is hereby granted, free of charge, to any person obtaining
00012  * a copy of this software and associated documentation files
00013  * (the "Software"), to deal in the Software without restriction,
00014  * including without limitation the rights to use, copy, modify, merge,
00015  * publish, distribute, sublicense, and/or sell copies of the Software,
00016  * and to permit persons to whom the Software is furnished to do so,
00017  * subject to the following conditions:
00018  *
00019  * The above copyright notice and this permission notice shall be
00020  * included in all copies or substantial portions of the Software.
00021  *
00022  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00023  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00024  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00025  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
00026  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00027  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00028  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00029  */
00030 
00031 /*
00032  * The text above constitutes the entire PortAudio license; however, 
00033  * the PortAudio community also makes the following non-binding requests:
00034  *
00035  * Any person wishing to distribute modifications to the Software is
00036  * requested to send the modifications to the original developer so that
00037  * they can be incorporated into the canonical version. It is also 
00038  * requested that these non-binding requests be included along with the 
00039  * license above.
00040  */
00041 
00048 #ifdef __cplusplus
00049 extern "C"
00050 {
00051 #endif /* __cplusplus */
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 /* Host API enumeration mechanism */
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, /* use while developing support for a new host API */
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 /* Device enumeration and capabilities */
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;  /* this is struct version 2 */
00448     const char *name;
00449     PaHostApiIndex hostApi; /* note this is a host API index, not a type id*/
00450     
00451     int maxInputChannels;
00452     int maxOutputChannels;
00453 
00454     /* Default latency values for interactive performance. */
00455     PaTime defaultLowInputLatency;
00456     PaTime defaultLowOutputLatency;
00457     /* Default latency values for robust non-interactive applications (eg. playing sound files). */
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 /* Streaming types and functions */
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 
01115 PaHostApiTypeId Pa_GetStreamHostApiType( PaStream* stream );
01116 
01117 
01118 /* Miscellaneous utilities */
01119 
01120 
01126 PaError Pa_GetSampleSize( PaSampleFormat format );
01127 
01128 
01136 void Pa_Sleep( long msec );
01137 
01138 
01139 
01140 #ifdef __cplusplus
01141 }
01142 #endif /* __cplusplus */
01143 #endif /* PORTAUDIO_H */

Generated on Tue Aug 3 2010 05:17:30 for PortAudio by  doxygen 1.7.1