Julius 4.2
msvc/portaudio/portaudio.h
説明を見る。
00001 #ifndef PORTAUDIO_H
00002 #define PORTAUDIO_H
00003 /*
00004  * $Id: portaudio.h,v 1.1 2009/10/21 16:47:20 sumomo Exp $
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 
00047 #ifdef __cplusplus
00048 extern "C"
00049 {
00050 #endif /* __cplusplus */
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 /* Host API enumeration mechanism */
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, /* use while developing support for a new host API */
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 /* Device enumeration and capabilities */
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;  /* this is struct version 2 */
00447     const char *name;
00448     PaHostApiIndex hostApi; /* note this is a host API index, not a type id*/
00449     
00450     int maxInputChannels;
00451     int maxOutputChannels;
00452 
00453     /* Default latency values for interactive performance. */
00454     PaTime defaultLowInputLatency;
00455     PaTime defaultLowOutputLatency;
00456     /* Default latency values for robust non-interactive applications (eg. playing sound files). */
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 /* Streaming types and functions */
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 /* Miscellaneous utilities */
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 /* __cplusplus */
01133 #endif /* PORTAUDIO_H */