?? lcylib.h
字號:
/*聲卡音頻實時函數(shù)庫的應(yīng)用程序接口頭文件*/
#ifndef PORT_AUDIO_H
#define PORT_AUDIO_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef enum {
paNoError = 0,
paHostError = -10000,
paInvalidChannelCount,
paInvalidSampleRate,
paInvalidDeviceId,
paInvalidFlag,
paSampleFormatNotSupported,
paBadIODeviceCombination,
paInsufficientMemory,
paBufferTooBig,
paBufferTooSmall,
paNullCallback,
paBadStreamPtr,
paTimedOut,
paInternalError
} PaErrorNum;
/*1.函數(shù)庫的初始化函數(shù),使用庫之前,要先調(diào)用該函數(shù)。*/
int Pa_Initialize( void );
/*2.函數(shù)庫的中止函數(shù),使用庫之后,要調(diào)用該函數(shù)。*/
int Pa_Terminate( void );
/*3.返回錯誤代碼函數(shù)*/
long Pa_GetHostError( void );
/*4.翻譯錯誤代碼為人可讀懂信息函數(shù)*/
const char *Pa_GetErrorText( int errnum );
/*(1)采樣所得數(shù)據(jù)的格式定義*/
#define paFloat32 ((unsigned long) (1<<0))
#define paInt16 ((unsigned long) (1<<1))
#define paInt32 ((unsigned long) (1<<2))
#define paInt24 ((unsigned long) (1<<3))
#define paPackedInt24 ((unsigned long) (1<<4))
#define paInt8 ((unsigned long) (1<<5))
#define paUInt8 ((unsigned long) (1<<6))
#define paCustomFormat ((unsigned long) (1<<16))
#define paNoDevice -1
/*(2)聲卡信息定義*/
typedef struct{
int structVersion;
const char *name;
int maxInputChannels;
int maxOutputChannels;
int numSampleRates;
const double *sampleRates;
unsigned long nativeSampleFormats;
} PaDeviceInfo;
/*5.獲得聲卡數(shù)量函數(shù)*/
int Pa_CountDevices();
/*6.獲得聲卡默認(rèn)的輸入端數(shù)量函數(shù)*/
int Pa_GetDefaultInputDeviceID( void );
/*7.獲得聲卡默認(rèn)的輸出端數(shù)量函數(shù)*/
int Pa_GetDefaultOutputDeviceID( void );
/*8.獲得存儲聲卡信息地址函數(shù)*/
const PaDeviceInfo* Pa_GetDeviceInfo( int devID );
/*9.回調(diào)函數(shù)及參數(shù)說明:
inputBuffer and outputBuffer:采樣的數(shù)據(jù)、格式、存儲和通道數(shù)量。
framesPerBuffer:采樣數(shù)據(jù)幀的數(shù)量。
outTime():數(shù)據(jù)流時間。
userData:向數(shù)據(jù)流傳送的數(shù)據(jù)。
*/
typedef int (PortAudioCallback)(
void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
double outTime, void *userData );
/*(3)數(shù)據(jù)流屬性定義*/
#define paNoFlag (0)
#define paClipOff (1<<0)
#define paDitherOff (1<<1)
#define paPlatformSpecificFlags (0x00010000)
/*10.打開輸入或輸出端的數(shù)據(jù)流,或兩者同時打開函數(shù)。*/
int Pa_OpenStream( void** stream,
int inputDevice,
int numInputChannels,
unsigned long inputSampleFormat,
void *inputDriverInfo,
int outputDevice,
int numOutputChannels,
unsigned long outputSampleFormat,
void *outputDriverInfo,
double sampleRate,
unsigned long framesPerBuffer,
unsigned long numberOfBuffers,
unsigned long streamFlags,
PortAudioCallback *callback,
void *userData );
/*11.打開聲卡默認(rèn)的輸入或輸出端,或兩者同時打開函數(shù)。*/
int Pa_OpenDefaultStream( void** stream,
int numInputChannels,
int numOutputChannels,
unsigned long sampleFormat,
double sampleRate,
unsigned long framesPerBuffer,
unsigned long numberOfBuffers,
PortAudioCallback *callback,
void *userData );
/*12.關(guān)閉數(shù)據(jù)流并清空緩沖區(qū)函數(shù)*/
int Pa_CloseStream( void* );
/*13.開始數(shù)據(jù)流函數(shù)*/
int Pa_StartStream( void *stream );
/*14.中止數(shù)據(jù)流函數(shù),但要等緩沖區(qū)的數(shù)據(jù)空后。*/
int Pa_StopStream( void *stream );
/*15.立即中止數(shù)據(jù)流函數(shù),不等緩沖區(qū)的數(shù)據(jù)空后。*/
int Pa_AbortStream( void *stream );
/* 16.數(shù)據(jù)流處理狀況函數(shù):返回1值,數(shù)據(jù)流正在進(jìn)行;0值數(shù)據(jù)流沒在進(jìn)行;
負(fù)值:數(shù)據(jù)流無效。*/
int Pa_StreamActive( void *stream );
/*17.返回數(shù)據(jù)流要用的時間函數(shù)*/
double Pa_StreamTime( void *stream );
/*18.返回數(shù)據(jù)流占用CPU百分比函數(shù),0.5表示占用50%。*/
double Pa_GetCPULoad( void* stream );
/*18.獲得所需最小緩沖區(qū)函數(shù)*/
int Pa_GetMinNumBuffers( int framesPerBuffer, double sampleRate );
/*19.暫停函數(shù),以微秒(msec)單位。*/
void Pa_Sleep( long msec );
/*20.返回bytes表示的采樣數(shù)據(jù)大小函數(shù)*/
int Pa_GetSampleSize( unsigned long format );
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PORT_AUDIO_H */
#include <math.h>
//#ifndef M_PI
//#define M_PI (2*asin(1))
//#endif
const double M_PI=2*asin(1.0);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -