Issues in Configuration of the 'ST acoustic libraries' for audio sampling from default value 16k to 96k in the X-CUBE-MEMSMIC1 example
I have been going through the X-CUBE-MEMSMIC examples on the STWINKt development board. There are two examples 'AMicArray_Acoustic_SL' and 'AMicArray_Microphones_Streaming' are given.
AMicArray_Acoustic_SL - is sampling audio at 16k and providing the sound direction using a compiled library.
Also, AMicArray_Microphones_Streaming - is sampling audio at 96k and streaming it to USB audio.
Now I am trying to integrate both programs i.e. to get the audio samples --> Stream them to USB and also get the sound localization using the same samples.
However, when I am using 96k samples to the SoundLocalization API it is always throwing a sample_frequency_error. I have tried different configurations for sound localization API but nothing works.
My question is to integrate both functionalities in one, what sampling configuration is required to change or how to remove sample_frequency_error?
here is the code snapshot I am trying to configure for 96k samples.
void Audio_Libraries_Init(void)
{
volatile uint32_t error_value = 0;
/* Enable CRC peripheral to unlock the library */
__CRC_CLK_ENABLE();
/*Setup Source Localization static parameters*/
libSoundSourceLoc_Handler_Instance.channel_number = 4;
libSoundSourceLoc_Handler_Instance.M12_distance =DIAGONAL;
libSoundSourceLoc_Handler_Instance.M34_distance =DIAGONAL;
libSoundSourceLoc_Handler_Instance.sampling_frequency = AUDIO_IN_SAMPLING_FREQUENCY;
libSoundSourceLoc_Handler_Instance.algorithm = ACOUSTIC_SL_ALGORITHM_BMPH;
libSoundSourceLoc_Handler_Instance.ptr_M1_channels = 4;
libSoundSourceLoc_Handler_Instance.ptr_M2_channels = 4;
libSoundSourceLoc_Handler_Instance.ptr_M3_channels = 4;
libSoundSourceLoc_Handler_Instance.ptr_M4_channels = 4;
libSoundSourceLoc_Handler_Instance.samples_to_process = 4096; //Initial - 512;
AcousticSL_getMemorySize( &libSoundSourceLoc_Handler_Instance);
libSoundSourceLoc_Handler_Instance.pInternalMemory=(uint32_t *)malloc(libSoundSourceLoc_Handler_Instance.internal_memory_size);
error_value += AcousticSL_Init( &libSoundSourceLoc_Handler_Instance);
/*Setup Source Localization dynamic parameters*/
libSoundSourceLoc_Config_Instance.resolution =10;
libSoundSourceLoc_Config_Instance.threshold =15;
error_value += AcousticSL_setConfig(&libSoundSourceLoc_Handler_Instance, &libSoundSourceLoc_Config_Instance);
/*Error Management*/
if(error_value != 0U)
{
Error_Handler();
}
/*Malloc Failure*/
if(libSoundSourceLoc_Handler_Instance.pInternalMemory == NULL)
{
Error_Handler();
}
}