Skip to main content
MKiss.1
Associate II
May 4, 2021
Question

Does SoundSL deliver wrong results? (solved)

  • May 4, 2021
  • 0 replies
  • 615 views

Hello, I cannot get SoundSL working to detect the source of a sound direction correctly. To check how the library performs itself, I wrote a little test script.

I assume a 1kHz sine wave to be sampled by a simulated microphone. At a sampling rate of 16kHz, the buffer for 1ms duration consists of 16 samples (per channel) that describe an entire period. At a sound speed of 350m/s and a distance of 0.1m between the microphones, the phase shift should not exceed approximately +/- 90 degrees (+/- 285us). According to my understanding, a phaseshift of [-90 degrees phase shift; 90 degrees phase shift] should result in about [-90 degree angle; 90 degrees angle] where in-phase would be 0 degrees (same distance to both microphones).

In the test script, I compute the sine wave values for a particular offset and feed the values to the library until the result can be calculated. Once one angle is gathered, I increase the phase shift and redo the whole process. The angles are then stored in an array. The results for a phase shift of [0 degrees; 90 degrees] with a 10 degrees increment are shown in the table. The results are not as expected. What am I doing wrong? I use library version 2.2.0.

Thank you.

Solved! I found out that the variable holding the simulated microphone samples was 32-bit instead of 16-bit.

0693W00000ANMB7QAP.png 

/* USER CODE BEGIN 2 */
 
 float offset = 0.0;
 uint32_t err_type;
 int32_t est_angle;
 AcousticSL_Handler_t h;
 AcousticSL_Config_t c;
 uint8_t gbl_sound2d_internal_mem[30000];
 int32_t glb_test_mic[32]; // 16xL, 16xR
 int32_t angles[11];
 uint32_t angles_cnt = 0;
 
 h.algorithm = ACOUSTIC_SL_ALGORITHM_GCCP;
 h.sampling_frequency = 16000;
 h.channel_number = 2;
 h.ptr_M1_channels = 2;
 h.ptr_M2_channels = 2;
 h.ptr_M3_channels = 2;
 h.ptr_M4_channels = 2;
 h.M12_distance = 100;
 h.M34_distance = 100;	// Dont care
 h.samples_to_process = 512;
 h.pInternalMemory = (uint32_t *)gbl_sound2d_internal_mem;
 
 c.resolution = 5;
 c.threshold = 1;
 
 err_type = AcousticSL_getMemorySize(&h);
 if (err_type)
	 Error_Handler();
 
 if (h.internal_memory_size > 30000)
	Error_Handler();
 
 err_type = AcousticSL_Init(&h);
 if (err_type)
	Error_Handler();
 
 err_type = AcousticSL_setConfig(&h, &c);
 if (err_type)
	Error_Handler();
 
 /* USER CODE END 2 */
 
 /* Infinite loop */
 /* USER CODE BEGIN WHILE */
 while (1)
 {
	for (uint32_t i = 0, j = 0; j < 16; i += 2, j++)
	{
	 glb_test_mic[i] = (int32_t)(1000.0 * cos(2.0 * M_PI / 16 * j));
 glb_test_mic[i+1] = (int32_t)(1000.0 * cos(2.0 * M_PI / 16 * j + offset));
	}
 
	while(!AcousticSL_Data_Input((int16_t*)&glb_test_mic[0], (int16_t*)&glb_test_mic[1], (int16_t*)&glb_test_mic[0], (int16_t*)&glb_test_mic[0], &h))
		;
 
	angles[angles_cnt] = -100;
	if(!AcousticSL_Process(&est_angle, &h))
	{
		 angles[angles_cnt] = est_angle;
		 angles_cnt++;
 
		 if(angles_cnt == 11)
		 {
			 while(1)
			 {
				 asm("nop");
			 }
		 }
	}
	offset += M_PI / (2 * 9);
 /* USER CODE END WHILE */
 /* USER CODE BEGIN 3 */
 }

    This topic has been closed for replies.