📄 portaudio.h
字号:
#ifndef PORT_AUDIO_H#define PORT_AUDIO_H#ifdef __cplusplusextern "C"{#endif /* __cplusplus *//* * PortAudio Portable Real-Time Audio Library * PortAudio API Header File * Latest version available at: http://www.audiomulch.com/portaudio/ * * Copyright (c) 1999-2000 Ross Bencina and Phil Burk * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files * (the "Software"), to deal in the Software without restriction, * including without limitation the rights to use, copy, modify, merge, * publish, distribute, sublicense, and/or sell copies of the Software, * and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * Any person wishing to distribute modifications to the Software is * requested to send the modifications to the original developer so that * they can be incorporated into the canonical version. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */// added by zplane.developement in order to generate a DLL#if defined(PA_MME_EXPORTS) || defined(PA_DX_EXPORTS)#define DLL_API __declspec( dllexport )#elif defined(_LIB) || defined(_STATIC_LINK) || defined(_STATIC_APP)#define DLL_API#else#define DLL_API __declspec(dllexport)#endiftypedef int PaError;typedef enum { paNoError = 0, paHostError = -10000, paInvalidChannelCount, paInvalidSampleRate, paInvalidDeviceId, paInvalidFlag, paSampleFormatNotSupported, paBadIODeviceCombination, paInsufficientMemory, paBufferTooBig, paBufferTooSmall, paNullCallback, paBadStreamPtr, paTimedOut, paInternalError} PaErrorNum;/* Pa_Initialize() is the library initialisation function - call this before using the library.*/DLL_API PaError Pa_Initialize( void );/* Pa_Terminate() is the library termination function - call this after using the library.*/DLL_API PaError Pa_Terminate( void );/* Return host specific error. This can be called after receiving a paHostError.*/DLL_API long Pa_GetHostError( void );/* Translate the error number into a human readable message.*/DLL_API const char *Pa_GetErrorText( PaError errnum );/* Sample formats These are formats used to pass sound data between the callback and the stream. Each device has a "native" format which may be used when optimum efficiency or control over conversion is required. Formats marked "always available" are supported (emulated) by all devices. The floating point representation uses +1.0 and -1.0 as the respective maximum and minimum. */typedef unsigned long PaSampleFormat;#define paFloat32 ((PaSampleFormat) (1<<0)) /*always available*/#define paInt16 ((PaSampleFormat) (1<<1)) /*always available*/#define paInt32 ((PaSampleFormat) (1<<2)) /*always available*/#define paInt24 ((PaSampleFormat) (1<<3))#define paPackedInt24 ((PaSampleFormat) (1<<4))#define paInt8 ((PaSampleFormat) (1<<5))#define paUInt8 ((PaSampleFormat) (1<<6)) /* unsigned 8 bit, 128 is "ground" */#define paCustomFormat ((PaSampleFormat) (1<<16))/* Device enumeration mechanism. Device ids range from 0 to Pa_CountDevices()-1. Devices may support input, output or both. Device 0 is always the "default" device and should support at least stereo in and out if that is available on the taget platform _even_ if this involves kludging an input/output device on platforms that usually separate input from output. Other platform specific devices are specified by positive device ids.*/typedef int PaDeviceID;#define paNoDevice -1typedef struct{ int structVersion; const char *name; int maxInputChannels; int maxOutputChannels; /* Number of discrete rates, or -1 if range supported. */ int numSampleRates; /* Array of supported sample rates, or {min,max} if range supported. */ const double *sampleRates; PaSampleFormat nativeSampleFormats;}PaDeviceInfo;DLL_API int Pa_CountDevices();/* Pa_GetDefaultInputDeviceID(), Pa_GetDefaultOutputDeviceID() Return the default device ID or paNoDevice if there is no devices. The result can be passed to Pa_OpenStream(). On the PC, the user can specify a default device by setting an environment variable. For example, to use device #1. set PA_RECOMMENDED_OUTPUT_DEVICE=1 The user should first determine the available device ID by using the supplied application "pa_devs".*/DLL_API PaDeviceID Pa_GetDefaultInputDeviceID( void );DLL_API PaDeviceID Pa_GetDefaultOutputDeviceID( void );/* PaTimestamp is used to represent a continuous sample clock with arbitrary start time useful for syncronisation. The type is used in the outTime argument to the callback function and the result of Pa_StreamTime()*/typedef double PaTimestamp;/* Pa_GetDeviceInfo() returns a pointer to an immutable PaDeviceInfo structure referring to the device specified by id. If id is out of range the function returns NULL. The returned structure is owned by the PortAudio implementation and must not be manipulated or freed. The pointer is guaranteed to be valid until between calls to Pa_Initialize() and Pa_Terminate().*/DLL_API const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceID id );/* PortAudioCallback is implemented by clients of the portable audio api. inputBuffer and outputBuffer are arrays of interleaved samples, the format, packing and number of channels used by the buffers are determined by parameters to Pa_OpenStream() (see below). framesPerBuffer is the number of sample frames to be processed by the callback. outTime is the time in samples when the buffer(s) processed by this callback will begin being played at the audio output. See also Pa_StreamTime() userData is the value of a user supplied pointer passed to Pa_OpenStream() intended for storing synthesis data etc. return value: The callback can return a nonzero value to stop the stream. This may be useful in applications such as soundfile players where a specific duration of output is required. However, it is not necessary to utilise this mechanism as StopStream() will also terminate the stream. A callback returning a nonzero value must fill the entire outputBuffer. NOTE: None of the other stream functions may be called from within the callback function except for Pa_GetCPULoad(). */typedef int (PortAudioCallback)( void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, PaTimestamp outTime, void *userData );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -