⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 portaudio.h

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 H
📖 第 1 页 / 共 3 页
字号:
#ifndef PORTAUDIO_H#define PORTAUDIO_H/* * $Id: portaudio.h,v 1.2 2004/04/22 04:19:50 mbrubeck Exp $ * PortAudio Portable Real-Time Audio Library * PortAudio API Header File * Latest version available at: http://www.portaudio.com/ * * Copyright (c) 1999-2002 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. *//** @file @brief The PortAudio API.*/#ifdef __cplusplusextern "C"{#endif /* __cplusplus */ /** Retrieve the release number of the currently running PortAudio build, eg 1900.*/int Pa_GetVersion( void );/** Retrieve a textual description of the current PortAudio build, eg "PortAudio V19-devel 13 October 2002".*/const char* Pa_GetVersionText( void );/** Error codes returned by PortAudio functions. Note that with the exception of paNoError, all PaErrorCodes are negative.*/typedef int PaError;typedef enum PaErrorCode{    paNoError = 0,    paNotInitialized = -10000,    paUnanticipatedHostError,    paInvalidChannelCount,    paInvalidSampleRate,    paInvalidDevice,    paInvalidFlag,    paSampleFormatNotSupported,    paBadIODeviceCombination,    paInsufficientMemory,    paBufferTooBig,    paBufferTooSmall,    paNullCallback,    paBadStreamPtr,    paTimedOut,    paInternalError,    paDeviceUnavailable,    paIncompatibleHostApiSpecificStreamInfo,    paStreamIsStopped,    paStreamIsNotStopped,    paInputOverflowed,    paOutputUnderflowed,    paHostApiNotFound,    paInvalidHostApi,    paCanNotReadFromACallbackStream,      /**< @todo review error code name */    paCanNotWriteToACallbackStream,       /**< @todo review error code name */    paCanNotReadFromAnOutputOnlyStream,   /**< @todo review error code name */    paCanNotWriteToAnInputOnlyStream,     /**< @todo review error code name */    paIncompatibleStreamHostApi} PaErrorCode;/** Translate the supplied PortAudio error code into a human readable message.*/const char *Pa_GetErrorText( PaError errorCode );/** Library initialization function - call this before using PortAudio. This function initialises internal data structures and prepares underlying host APIs for use. This function MUST be called before using any other PortAudio API functions. If Pa_Initialize() is called multiple times, each successful  call must be matched with a corresponding call to Pa_Terminate().  Pairs of calls to Pa_Initialize()/Pa_Terminate() may overlap, and are not  required to be fully nested. Note that if Pa_Initialize() returns an error code, Pa_Terminate() should NOT be called. @return paNoError if successful, otherwise an error code indicating the cause of failure. @see Pa_Terminate*/PaError Pa_Initialize( void );/** Library termination function - call this when finished using PortAudio. This function deallocates all resources allocated by PortAudio since it was initializied by a call to Pa_Initialize(). In cases where Pa_Initialise() has been called multiple times, each call must be matched with a corresponding call to Pa_Terminate(). The final matching call to Pa_Terminate() will automatically close any PortAudio streams that are still open. Pa_Terminate() MUST be called before exiting a program which uses PortAudio. Failure to do so may result in serious resource leaks, such as audio devices not being available until the next reboot. @return paNoError if successful, otherwise an error code indicating the cause of failure.  @see Pa_Initialize*/PaError Pa_Terminate( void );/** The type used to refer to audio devices. Values of this type usually range from 0 to (Pa_DeviceCount-1), and may also take on the PaNoDevice and paUseHostApiSpecificDeviceSpecification values. @see Pa_DeviceCount, paNoDevice, paUseHostApiSpecificDeviceSpecification*/typedef int PaDeviceIndex;/** A special PaDeviceIndex value indicating that no device is available, or should be used. @see PaDeviceIndex*/#define paNoDevice ((PaDeviceIndex)-1)/** A special PaDeviceIndex value indicating that the device(s) to be used are specified in the host api specific stream info structure. @see PaDeviceIndex*/#define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)/* Host API enumeration mechanism *//** The type used to enumerate to host APIs at runtime. Values of this type range from 0 to (Pa_GetHostApiCount()-1). @see Pa_GetHostApiCount*/typedef int PaHostApiIndex;/** Retrieve the number of available host APIs. Even if a host API is available it may have no devices available. @return A non-negative value indicating the number of available host APIs or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered. @see PaHostApiIndex*/PaHostApiIndex Pa_GetHostApiCount( void );/** Retrieve the index of the default host API. The default host API will be the lowest common denominator host API on the current platform and is unlikely to provide the best performance. @return A non-negative value ranging from 0 to (Pa_GetHostApiCount()-1) indicating the default host API index or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered.*/PaHostApiIndex Pa_GetDefaultHostApi( void );/** Unchanging unique identifiers for each supported host API. This type is used in the PaHostApiInfo structure. The values are guaranteed to be unique and to never change, thus allowing code to be written that conditionally uses host API specific extensions. New type ids will be allocated when support for a host API reaches "public alpha" status, prior to that developers should use the paInDevelopment type id. @see PaHostApiInfo*/typedef enum PaHostApiTypeId{    paInDevelopment=0, /* use while developing support for a new host API */    paDirectSound=1,    paMME=2,    paASIO=3,    paSoundManager=4,    paCoreAudio=5,    paOSS=7,    paALSA=8,    paAL=9,    paBeOS=10} PaHostApiTypeId;/** A structure containing information about a particular host API. */typedef struct PaHostApiInfo{    /** this is struct version 1 */    int structVersion;    /** The well known unique identifier of this host API @see PaHostApiTypeId */    PaHostApiTypeId type;    /** A textual description of the host API for display on user interfaces. */    const char *name;    /**  The number of devices belonging to this host API. This field may be     used in conjunction with Pa_HostApiDeviceIndexToDeviceIndex() to enumerate     all devices for this host API.     @see Pa_HostApiDeviceIndexToDeviceIndex    */    int deviceCount;    /** The the default input device for this host API. The value will be a     device index ranging from 0 to (Pa_GetDeviceCount()-1), or paNoDevice     if no default input device is available.    */    PaDeviceIndex defaultInputDevice;    /** The the default output device for this host API. The value will be a     device index ranging from 0 to (Pa_GetDeviceCount()-1), or paNoDevice     if no default output device is available.    */    PaDeviceIndex defaultOutputDevice;    } PaHostApiInfo;/** Retrieve a pointer to a structure containing information about a specific host Api. @param hostApi A valid host API index ranging from 0 to (Pa_GetHostApiCount()-1) @return A pointer to an immutable PaHostApiInfo structure describing a specific host API. If the hostApi parameter is out of range or an error is encountered, the function returns NULL. The returned structure is owned by the PortAudio implementation and must not be manipulated or freed. The pointer is only guaranteed to be valid between calls to Pa_Initialize() and Pa_Terminate().*/const PaHostApiInfo * Pa_GetHostApiInfo( PaHostApiIndex hostApi );/** Convert a static host API unique identifier, into a runtime host API index. @param type A unique host API identifier belonging to the PaHostApiTypeId enumeration. @return A valid PaHostApiIndex ranging from 0 to (Pa_GetHostApiCount()-1) or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered.  The paHostApiNotFound error code indicates that the host API specified by the type parameter is not available. @see PaHostApiTypeId*/PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type );/** Convert a host-API-specific device index to standard PortAudio device index. This function may be used in conjunction with the deviceCount field of PaHostApiInfo to enumerate all devices for the specified host API. @param hostApi A valid host API index ranging from 0 to (Pa_GetHostApiCount()-1) @param hostApiDeviceIndex A valid per-host device index in the range 0 to (Pa_GetHostApiInfo(hostApi)->deviceCount-1) @return A non-negative PaDeviceIndex ranging from 0 to (Pa_GetDeviceCount()-1) or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered. A paInvalidHostApi error code indicates that the host API index specified by the hostApi parameter is out of range. A paInvalidDevice error code indicates that the hostApiDeviceIndex parameter is out of range.  @see PaHostApiInfo*/PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex( PaHostApiIndex hostApi,        int hostApiDeviceIndex );/** Structure used to return information about a host error condition.*/typedef struct PaHostErrorInfo{    PaHostApiTypeId hostApiType;    /**< the host API which returned the error code */    long errorCode;                 /**< the error code returned */    const char *errorText;          /**< a textual description of the error if available, otherwise a zero-length string */}PaHostErrorInfo;/** Return information about the last host error encountered. The error information returned by Pa_GetLastHostErrorInfo() will never be modified asyncronously by errors occurring in other PortAudio owned threads (such as the thread that manages the stream callback.) This function is provided as a last resort, primarily to enhance debugging by providing clients with access to all available error information. @return A pointer to an immutable structure constaining information about the host error. The values in this structure will only be valid if a PortAudio function has previously returned the paUnanticipatedHostError error code.*/const PaHostErrorInfo* Pa_GetLastHostErrorInfo( void );/* Device enumeration and capabilities *//** Retrieve the number of available devices. The number of available devices may be zero. @return A non-negative value indicating the number of available devices or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered.*/PaDeviceIndex Pa_GetDeviceCount( void );/** Retrieve the index of the default input device. The result can be used in the inputDevice parameter to Pa_OpenStream(). @return The default input device index for the defualt host API, or paNoDevice if no default input device is available or an error was encountered.*/PaDeviceIndex Pa_GetDefaultInputDevice( void );/** Retrieve the index of the default output device. The result can be used in the outputDevice parameter to Pa_OpenStream(). @return The default output device index for the defualt host API, or paNoDevice if no default output device is available or an error was encountered. @note On the PC, the user can specify a default device by setting an environment variable. For example, to use device #1.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -