just leaving it as is, gives amplification by 256.
Why do you say that? Shifting the 24 bit value doesn't change it. Agreed, the signal is quite loud, my code has the ability to attenuate the value if necessary (configurable):
Code: Select all
// first, shift out the lower empty byte
int32_t val32 = input_buffer[i] >> 8; // shift out the empty byte - this is a signed int, the shift will preserve the sign
// we now need to reduce this to a 16 bit integer value, ensuring values are between -32,768 and 32,767
// but if we just reduce the high values we'll be clipping the sound, better to attenuate it (by experience)
// apply an attenuation factor if it sounds too high
val32 = val32 / ATTENUATION_FACTOR; // reduce the overall signal strength if requested
however, inspecting the data, i do see, that the low-byte is not always 00, but sometimes C0 , so some artifacts going on.
If the low order byte is unused, I don't see what it contains is unimportant. It could just be random data.
We would like it the other way, that mono mode results in reading only the one active mono channel, thus halfing the datarate to the correct value of a mono channel.
Surely if configured as mono, it only samples from the configured microphone.
Code: Select all
i2s_std_config_t std_cfg = {
... .slot_cfg = {
.data_bit_width = I2S_DATA_BIT_WIDTH_32BIT, // INMP441 provides 24 bits of data, we have to use 32 bit and discard a byte
.slot_mode = I2S_SLOT_MODE_MONO,
.slot_mask = I2S_STD_SLOT_LEFT, // L/R pin is connected to GND
etc
I've not played with stereo recording, but my limited understanding is that in stereo mode, samples alternate from left/right, whereas in mono mode all the samples are from the single configured mic.