Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doubt regarding esp32s3-eye mic input (AIS-1531) #130

Open
PrathamG opened this issue Mar 14, 2024 · 5 comments
Open

Doubt regarding esp32s3-eye mic input (AIS-1531) #130

PrathamG opened this issue Mar 14, 2024 · 5 comments

Comments

@PrathamG
Copy link

Hi! I just had a query regarding the bsp_get_feed_data function for esp32s3-eye board in the hardware driver.

From this line:
tmp_buff[i] = tmp_buff[i] >> 14; // 32:8为有效位, 8:0为低8位, 全为0, AFE的输入为16位语音数据,拿29:13位是为了对语音信号放大。

I can assume that:

  1. Bits ix 0-7 are discarded because they are useless.
  2. Bits ix 8-13 are discarded as noise.
  3. Bits 14-29 remain in the word as our audio reading.
  4. Bits 30-31 remain in the second byte and are considered discarded.

So my query is, assuming that the I2S input is two's complement 24-bit left justified, wouldn't the bit 31 contain the MSB of the audio sample? If we just discard it, wouldn't it affect the sign of the audio sample?
Sorry if I misunderstood something, thanks!

@github-actions github-actions bot changed the title Doubt regarding esp32s3-eye mic input Doubt regarding esp32s3-eye mic input (AIS-1531) Mar 14, 2024
@BlueSkyB
Copy link

Because the data type is int32_t, in the C language, it will be an arithmetic right shift, so the sign bit will not be lost.

@PrathamG
Copy link
Author

Yes, but after the right shift is complete, the MSB of the resulting value still ends up being discarded right?
We have 18 bits of the original 32-bit result after the right shift removes the padding and the noise. From these only the lower 16 bits are used further and the MSB is discarded. Wouldn't this affect the sign of the resulting value?

@BlueSkyB
Copy link

After the right shift, the MSB is not discarded. After the right shift, the result is still assigned to the current variable, which is of type int32_t. You may need to learn more about pointers and right shift operations in C language.

@PrathamG
Copy link
Author

PrathamG commented Mar 18, 2024

Yeah, the result is still stored in the int32_t variable. But the first 2 bits are discarded when it's passed to AFE. For esp-eye, the AFE examples initialize with one mic and one reference channel, which means that only the first 16 bits is used as data for AFE applications and the second half is discarded (or used for aec).

@PrathamG
Copy link
Author

PrathamG commented Mar 20, 2024

Wouldn't this make more sense instead:

buffer[i] = buffer[i] >> 14;  
buffer[i] = (buffer[i] > INT16_MAX) ? INT16_MAX : (buffer[i] < -INT16_MAX) ? -INT16_MAX : buffer[i];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants