1 #ifndef SPEECH_FIR_CALIBRATION_H 2 #define SPEECH_FIR_CALIBRATION_H 3 4 #include "fftfilt.h" 5 6 // i.e. only support 4 channels 7 #define SPEECH_FIR_CALIB_MAX_NUM (3) 8 9 typedef struct 10 { 11 float *filter; 12 int filter_length; 13 } CalibChannelConfig; 14 15 typedef struct 16 { 17 int bypass; 18 int mic_num; 19 float delay; // fraction delay for main mic 20 CalibChannelConfig calib[SPEECH_FIR_CALIB_MAX_NUM]; 21 } SpeechFirCalibConfig; 22 23 typedef struct SpeechFirCalibState_ SpeechFirCalibState; 24 25 #define CONSTRUCT_FUNC_NAME_A(p, c, m) p ## _ ## c ## _ ## m 26 #define CONSTRUCT_FUNC_NAME(p, c, m) CONSTRUCT_FUNC_NAME_A(p, c, m) 27 28 #ifndef FIR_CALIB_IMPL 29 #if defined(VQE_SIMULATE) 30 #define FIR_CALIB_IMPL fir 31 #else 32 #define FIR_CALIB_IMPL hwfir 33 #endif 34 #endif 35 36 #define speech_fir_calib_init CONSTRUCT_FUNC_NAME(speech, FIR_CALIB_IMPL, calib_init) 37 #define speech_fir_calib_destroy CONSTRUCT_FUNC_NAME(speech, FIR_CALIB_IMPL, calib_destroy) 38 #define speech_fir_calib_process CONSTRUCT_FUNC_NAME(speech, FIR_CALIB_IMPL, calib_process) 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 SpeechFirCalibState *speech_fir_calib_init(int32_t sample_rate, int32_t frame_size, const SpeechFirCalibConfig *config); 45 46 void speech_fir_calib_destroy(SpeechFirCalibState *st); 47 48 void speech_fir_calib_process(SpeechFirCalibState *st, int16_t *buf, int32_t frame_size); 49 50 #ifdef __cplusplus 51 } 52 #endif 53 54 #endif