#ifndef VOIX_DEFINES_H #define VOIX_DEFINES_H #include #include #include #include #include #include #include #include #include using namespace std; #define PrintFilePos() //printf("\nfile:%s, line:%2d---",__FILE__,__LINE__); #define CHUNK_SIZE 512 // 512 samples per frame #define SAMPLE_RATE 16000 // ReSpeaker Mic Array V2.0 support SampleRate from 16kHz to 48kHz #define RECORD_SECONDS 200000 #define ASR_RESULT_LEN 1024 #define WAKE_CHUNK_SIZE 512 #define ASR_CHUNCK_SIZE 8000 #define CHUNK_SIZE 512 // 512 samples per frame #define SAMPLE_RATE 16000 // ReSpeaker Mic Array V2.0 support g_iSampleRate from 16kHz to 48kHz #define RECORD_SECONDS 200000 #define ASR_RESULT_LEN 1024 #define ASR_CHUNCK_SIZE 8000 #define LAST_FRAME_ENERGY_ARRAY_SIZE 15 //-------------------host telemetry defines start -------------------------- #define CMD_CODE_TELEMETRY_LOW_CABIN_TEMPERATURE 0x2F01 #define CMD_TEXT_TELEMETRY_LOW_CABIN_TEMPERATURE "设置低舱温" #define CMD_CODE_TELEMETRY_MODERATE_CABIN_TEMPERATURE 0x2F02 #define CMD_TEXT_TELEMETRY_MODERATE_CABIN_TEMPERATURE "设置舱温适中" #define CMD_CODE_TELEMETRY_HIGH_CABIN_TEMPERATURE 0x2F04 #define CMD_TEXT_TELEMETRY_HIGH_CABIN_TEMPERATURE "设置高舱温" #define CMD_CODE_TURN_OFF_AMBIENT_LIGHT 0x2F07 #define CMD_TEXT_TURN_OFF_AMBIENT_LIGHT "关氛围灯" #define CMD_CODE_TURN_ON_AMBIENT_LIGHT 0x2F08 #define CMD_TEXT_TURN_ON_AMBIENT_LIGHT "开氛围灯" #define CMD_CODE_CONTROL_TOP_LIGHT 0x2F0B #define CMD_TEXT_CONTROL_TOP_LIGHT "控制顶部照明灯" #define CMD_CODE_CONTROL_SHOULDER_LIGHT 0x2F0D #define CMD_TEXT_CONTROL_SHOULDER_LIGHT "控制肩部照明灯" #define CMD_CODE_USE_RESTROOM 0x2F0E #define CMD_TEXT_USE_RESTROOM "使用卫生间" #define CMD_CODE_RESTROOM_USE_FINISHED 0x2F10 #define CMD_TEXT_RESTROOM_USE_FINISHED "卫生间使用结束" extern std::map g_telemetryText2Code; //==============Queue============================================ typedef void* voidPtr; extern void* g_pStatusLog, * g_pProcessLog, * g_pResultLog, * g_pDebugLog; //========================================================== extern void** g_pDataQueue; extern void* g_pRecordQueue; extern volatile bool g_bCloseASR; extern volatile bool g_bCall; extern volatile uint32_t g_iPlayedCallFrameCnt, g_iPlayedCallSampleCnt; extern volatile uint32_t g_iCallRcvFrameCnt;//本次通话接收的帧数量 extern volatile uint32_t g_iInsertSlientSegCnt; extern uint8_t g_iAlarmCode[4]; // 报警码 gejp 2024.10.03 extern uint8_t g_i5cmdNum[5]; // 5 info of cmd in history added by gejp 2024.10.03 extern uint16_t g_i5cmdCode[5]; extern uint8_t g_i5cmdOutcodes[5][6]; extern uint8_t g_i5cmdSendAbsTime[5][5]; extern uint32_t g_iCmdCount; // gejp 2024.10.09 extern uint8_t g_iSysVerHigh; extern uint8_t g_iSysVerLow; extern uint8_t g_iAppVerHigh; extern uint8_t g_iAppVerLow; // gejp 2024.10.10 extern uint8_t g_iEnableAlarmCode; // tangyc 2024.10.25 extern long g_iExternTimeDifference; #define getCodeInfo() getCodeLine(__FILE__, __LINE__) extern bool g_bPrintResultLog; extern int32_t g_outputBaseNum; //int LoadLogQueueModule(char* strModulePath); int32_t openLogAndQueues(char *config_file_path); void ProcQueueFull(int i, bool bClear = true); extern int g_iQueueCnt; extern long g_iRcvNackedPCM; extern bool g_bGPIO_Open; extern int g_iGPIOWakeNum; extern int g_iGPIOVolumeNum; extern int g_iGPIOWakePressTime; extern bool g_bTelemetry_Open; extern bool g_bHostInfoTrans_Open; extern int g_iUseTeleComForTelemetry; extern int g_iUseHostComForTelemetry; extern double g_fSilEnergy; extern long g_iMicDataQueueMB; extern void* g_pLogQueueModuleHandle; extern long g_iPcmBlockBytes; extern long g_iCallBytesPerBlockMS; extern long g_iCallSampleRateMS; extern char g_strPCM_ComPath[128]; extern int g_iPcmCom_tty_id; extern long g_iPCMCom_BaudRate; extern char g_strHostInfo_ComPath[128]; extern int g_iHostCom_tty_id; extern long g_iHostInfoCom_BaudRate; extern char g_strTelemetry_ComPath[128]; extern int g_iTelemetry_Com_tty_id; extern long g_iTelemetryCom_BaudRate; enum QueueIndex { // 数据类型 RECORD_DATA_QUEUE = 0, PCM_QUEUE_FOR_KWS, PCM_QUEUE_FOR_ASR,// TEXT_QUEUE_FOR_TTS,// TEXT_QUEUE_FOR_TTS_URGENT, AUDIO_QUEUE_FOR_PLAY,// AUDIO_QUEUE_FOR_PLAY_URGENT, ORDER_INFO_QUEUE,// to upper host ASSISTANT_INFO_QUEUE,// to upper host HOST_INFO_QUEUE, //from upper host AUDIO_FOR_HOST, // to upper host DATA_QUEUE_COUNT }; //extern void* SystemTimer_old(void* p); extern void* SystemTimer(void* p); extern char g_strCurTime[50], g_strStartTime[50]; //------------ input audio parameters ----------------------- extern long g_iInputType;// 0--com 1--mic 2--udp extern char g_strRcvPCM_UDP_IP[64]; extern long g_iUdpPort4RcvPCM; extern char g_strPCM_ComPath[128]; extern long g_iPCMCom_BaudRate; extern long g_iPCMCom_Proto; extern int g_iPcmCom_tty_id; //------------ upper host parameters ----------------------- extern long g_iHostInfoTransMode; //0--com, 1--udp, 2--unix socket extern char g_strHostInfo_ComPath[128]; extern long g_iHostInfoCom_BaudRate; extern int g_iHostCom_tty_id; extern char g_strSndUnixSocket[500]; extern char g_strRcvUnixSocket[500]; extern char g_strUpperHostIP[64]; extern long g_iSndUdpPort4HostInfo; //port of upper host to receive extern long g_iRcvUdpPort4HostInfo; //port to receive upper host info //--------------------------------------------------------------- extern long g_iWakeWhenStart; extern long g_iStatusLogInterval; //extern volatile long g_iConfirmRemainSeconds;//remain time to finish confirm, seconds //extern volatile long g_iNoEffectiveResultSeconds;// record total time lenght there is no effective result extern volatile uint64_t g_iLastWakeTime; extern volatile uint64_t g_iLastResultTime; extern volatile uint64_t g_iEndPlayTime; //extern volatile uint64_t g_iToSleepTime; extern volatile int g_iWaitType; extern volatile uint64_t g_iWaitTimeMS[5]; extern volatile long g_iSilentSampleCnt, g_iSoundSampleCnt; extern volatile long g_iSilentSampleCnt2FetchResul; extern char g_strSystemLogPath[500]; extern char g_strPCMSavePath[500]; extern struct tm g_tCurLocalTime; extern bool g_bKeepSysRuning; extern long g_iSaveInputAudio; extern long g_iSaveTTSAudio; extern long g_iSaveHostAudio; extern long g_iSavePlaySound; extern long g_iPlaySound; extern uint32_t g_iQueueFullTimes[DATA_QUEUE_COUNT]; extern volatile uint64_t g_iComRcvBytes[2]; extern long g_iUseASR2Wake; extern void set_signal_handler(int n); void setSysSleep(char* pSrc);//pSrc: by whom, kws,asr, button or start void setSysWake(char *pSrc);//pSrc: by whom, kws,asr, button or start void SayHello(char* pNoticeStr); extern std::atomic g_iSysState; extern bool g_bKeepSysRunning; extern unsigned int g_iOrderCnt; extern unsigned int g_iOrderExeSuccCnt; extern unsigned int g_iOrderExeFailCnt; extern unsigned int g_iOrderSndSuccCnt; extern unsigned int g_iOrderSndFailCnt; extern unsigned int g_iOrderResultCnt; extern unsigned int g_iAssistantCnt; extern unsigned int g_iQuerySndSuccCnt; extern unsigned int g_iQuerySndFailCnt; extern unsigned int g_iQueryResultCnt; extern unsigned int g_iRcvResultErr[2]; extern uint16_t volatile g_iTelemetryOrderSndSuccCnt; extern uint8_t volatile g_last_send_command[6]; //extern int64_t g_iPreWakeTime; extern std::atomic g_iOrdinaryPlayStop; extern bool g_bVolumeKeyState; extern bool g_bWakeupKeyState; extern bool g_bVolumeKeyPressed; extern bool g_bWakeupKeyPressed; #endif //AUDIOSERVER_AUDIODATAUNIT_H