diff --git a/acoustic_algorithm/include/esp_mase.h b/acoustic_algorithm/include/esp_mase.h index ef8356b..8ac2562 100644 --- a/acoustic_algorithm/include/esp_mase.h +++ b/acoustic_algorithm/include/esp_mase.h @@ -48,13 +48,13 @@ typedef void* mase_handle_t; * * @param operating_mode '0' for normal mode and '1' for wake-up enhanced mode. * - * @param filter_strength Strengh of the mic-array speech enhancement, must be 0, 1, 2 or 3. + * @param filter_strength Strengh of the mic-array speech enhancement, must be 0 to 6. * * @return * - NULL: Create failed * - Others: An instance of MASE */ -mase_handle_t mase_create(int sample_rate, int frame_size, int array_type, float mic_distance, int operating_mode, int filter_strength); +mase_handle_t mase_create(int fs, int frame_size, int array_type, float mic_distance, int operating_mode, int filter_strength); /** * @brief Performs mic array processing for one frame. @@ -67,9 +67,6 @@ mase_handle_t mase_create(int sample_rate, int frame_size, int array_type, float * * @return None * - * @note Input is a multi-channel signal while the output is single-channel. - * For a 16-ms multi-channel input frame, the i-th point in the c-th channel should be indexed (i + c * 256). - * */ void mase_process(mase_handle_t st, int16_t *in, int16_t *dsp_out); diff --git a/acoustic_algorithm/libesp_audio_processor.a b/acoustic_algorithm/libesp_audio_processor.a index c62ca20..99c1d7f 100644 Binary files a/acoustic_algorithm/libesp_audio_processor.a and b/acoustic_algorithm/libesp_audio_processor.a differ diff --git a/main/audio_process.c b/main/audio_process.c index 053c723..300094c 100644 --- a/main/audio_process.c +++ b/main/audio_process.c @@ -9,6 +9,7 @@ #include "esp_aec.h" #include "esp_agc.h" #include "esp_vad.h" +#include "esp_mase.h" #include "audio_test_file.h" void NSTask(void *arg) @@ -105,6 +106,31 @@ void VADTask(void *arg) vTaskDelete(NULL); } +void MASETask(void *arg) +{ + mase_handle_t mase_st = mase_create(MASE_SAMPLE_RATE, MASE_FRAME_SIZE, THREE_MIC_CIRCLE, MASE_MIC_DISTANCE, WAKE_UP_ENHANCEMENT_MODE, 6); + int chunks = 0; + int nch = 3; + int audio_chunksize = MASE_FRAME_SIZE * MASE_SAMPLE_RATE * nch / 1000; + int16_t *mase_in = malloc(audio_chunksize * sizeof(int16_t)); + int16_t *mase_out = malloc(audio_chunksize / nch * sizeof(int16_t)); + while (1) { + if ((chunks + 1) * audio_chunksize * sizeof(int16_t) <= sizeof(audio_test_file)) { + memcpy(mase_in, audio_test_file + chunks * audio_chunksize * sizeof(int16_t), audio_chunksize * sizeof(int16_t)); + memset(mase_out, 0, audio_chunksize / nch * sizeof(int16_t)); + } else { + break; + } + mase_process(mase_st, mase_in, mase_out); + chunks++; + } + mase_destory(mase_st); + free(mase_in); + free(mase_out); + printf("MASE test successfully\n\n"); + printf("TEST3 FINISHED\n\n"); + vTaskDelete(NULL); +} void audio_process_test() { @@ -115,4 +141,6 @@ void audio_process_test() xTaskCreatePinnedToCore(&AECTask, "acoustic_echo_cancellation", 3 * 1024, NULL, 5, NULL, 0); vTaskDelay(1000 / portTICK_PERIOD_MS); xTaskCreatePinnedToCore(&VADTask, "voice_activity_detection", 3 * 1024, NULL, 5, NULL, 0); + vTaskDelay(1000 / portTICK_PERIOD_MS); + xTaskCreatePinnedToCore(&MASETask, "mic_array_speech_enhancement", 3 * 1024, NULL, 5, NULL, 1); }