2021-09-02 06:56 AM
I'm trying to implement AcousticBF library functions and what I've noticed is that, when I configure it like this for PCM mode, 2 microphones:
void Audio_Libraries_Init(void)
{
volatile uint32_t error_value = 0;
/* Enable CRC peripheral to unlock the library */
__CRC_CLK_ENABLE();
/*Setup Beamforming static parameters*/
error_value = 0;
libBeamforming_Handler_Instance.algorithm_type_init=ACOUSTIC_BF_TYPE_CARDIOID_BASIC;
libBeamforming_Handler_Instance.ref_mic_enable=ACOUSTIC_BF_REF_ENABLE;
libBeamforming_Handler_Instance.ptr_out_channels=2;
libBeamforming_Handler_Instance.data_format=ACOUSTIC_BF_DATA_FORMAT_PCM;
libBeamforming_Handler_Instance.sampling_frequency=16;
libBeamforming_Handler_Instance.ptr_M1_channels=1;
libBeamforming_Handler_Instance.ptr_M2_channels=1;
libBeamforming_Handler_Instance.delay_enable = 0;
(void)AcousticBF_getMemorySize(&libBeamforming_Handler_Instance);
libBeamforming_Handler_Instance.pInternalMemory =(uint32_t *)malloc(libBeamforming_Handler_Instance.internal_memory_size);
error_value = AcousticBF_Init(&libBeamforming_Handler_Instance);
/*Error Management*/
if(error_value != 0U)
{
Error_Handler();
}
/*Malloc Failure*/
if(libBeamforming_Handler_Instance.pInternalMemory == NULL)
{
Error_Handler();
}
/*Setup Beamforming dynamic parameters*/
lib_Beamforming_Config_Instance.algorithm_type = ACOUSTIC_BF_TYPE_CARDIOID_BASIC;
lib_Beamforming_Config_Instance.M2_gain = 0.0f;
lib_Beamforming_Config_Instance.mic_distance = 212;
lib_Beamforming_Config_Instance.volume = 24;
error_value = AcousticBF_setConfig(&libBeamforming_Handler_Instance, &lib_Beamforming_Config_Instance);
/*Error Management*/
if(error_value != 0U)
{
Error_Handler();
}
}
then, AcousticBF_FirstStep function returns 0, so I can't implement AcousticBF_SecondStep() function further:
void AudioProcess(void)
{
if(AcousticBF_FirstStep(&((uint8_t *)(PCM_Buffer))[0],&((uint8_t *)(PCM_Buffer))[1], (int16_t *)Out_Buffer, &libBeamforming_Handler_Instance) == 1U)
{
SW_Task1_Start();
}
/*for L4 PDM to PCM conversion is performed in hardware by DFSDM peripheral*/
Send_Audio_to_USB((int16_t *)Out_Buffer, (AUDIO_IN_SAMPLING_FREQUENCY/1000)*AUDIO_IN_CHANNELS);
}
Is there smth I missed? Or did I configure smth wrong?