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

MIC_CONVERT #17

Closed
otger opened this issue Oct 7, 2022 · 9 comments
Closed

MIC_CONVERT #17

otger opened this issue Oct 7, 2022 · 9 comments

Comments

@otger
Copy link

otger commented Oct 7, 2022

Hi,

First of all, let me thank you for this project, which has helped me greatly in my own project. I am adapting your code to a project to check the noise of a street, and I think I've found a problem in your code, although I may be wrong.

When you configure the I2S driver you set the bits_per_sample to 32:

void mic_i2s_init() {
  // Setup I2S to sample mono channel for SAMPLE_RATE * SAMPLE_BITS
  // NOTE: Recent update to Arduino_esp32 (1.0.2 -> 1.0.3)
  //       seems to have swapped ONLY_LEFT and ONLY_RIGHT channels
  const i2s_config_t i2s_config = {
    mode: i2s_mode_t(I2S_MODE_MASTER | I2S_MODE_RX),
    sample_rate: SAMPLE_RATE,
    bits_per_sample: i2s_bits_per_sample_t(SAMPLE_BITS),
    channel_format: I2S_CHANNEL_FMT_ONLY_LEFT,

Where SAMPLE_BITS = 32.

After reading data with i2s, you shift the samples with the MIC_CONVERTmacro:

#define MIC_BITS          24          // valid number of bits in I2S data
#define MIC_CONVERT(s)    (s >> (SAMPLE_BITS - MIC_BITS))
    i2s_read(I2S_PORT, &samples, SAMPLES_SHORT * sizeof(SAMPLE_T), &bytes_read, portMAX_DELAY);

    TickType_t start_tick = xTaskGetTickCount();
    
    // Convert (including shifting) integer microphone values to floats, 
    // using the same buffer (assumed sample size is same as size of float), 
    // to save a bit of memory
    SAMPLE_T* int_samples = (SAMPLE_T*)&samples;
    for(int i=0; i<SAMPLES_SHORT; i++) samples[i] = MIC_CONVERT(int_samples[i]);

The problem is that in my setup (with an INMP441) when I set the sample bits to 32, the values are already right aligned. If I print some samples with #define SAMPLE_BITS 32:

ffa92dfc ffa5ebfc ffa3e9fc ffac6400 ffb067fc ffb4de00 ffc0d3fc ffcf2c00 
ffd65400 ffdb7800 ffe39200 ffead1fc fff199fc fffb6ffc 0003ec00 000e3bfc 
00191200 001d07fc 0025c9fc 0029c9fc 00313c00 00344e00 00370c00 003d5dfc 
003f6800 003c97fc 003821fc 0036b400 0033f800 0037b400 003c4ffc 00439c00 
0047f5fc 00478800 0044b800 00437600 004245fc 003a5e00 00313c00 00315200 
002f5c00 002895fc 002711fc 0023ec00 00225e00 001f2400 002131fc 001bd200 
00114ffc 00052dfc fffdd9fc fff4b9fc ffe841fc ffdb25fc ffd5de00 ffd4b7fc 
ffd139fc ffcae200 ffc695fc ffc36bfc ffbdb800 ffbddffc ffbc5400 ffb78bfc 
ffb5d5fc ffb8a3fc ffbe0800 ffbe59fc ffc30ffc ffc775fc ffcd9a00 ffd58c00 
ffd96000 ffd08c00 ffce3000 ffd155fc ffd23c00 ffd051fc ffd25c00 ffd89a00 
ffdef9fc ffe8cc00 fff11200 fff575fc fff55ffc fff9c5fc fffc9200 fffc0ffc 
fffd7e00 0000fbfc 0009d000 0011ac00 001743fc 0020f600 0024b200 00280e00 
002c8bfc 00297bfc 002b29fc 00266600 00236400 00220400 00228e00 00201800

If I set #define SAMPLE_BITS 24 then values output by the mic are left shifted 8 bits:

ffe97400 ffe97400 fff0c300 fffd5300 000acc00 000acc00 0012fc00 001a5f00 
00225f00 00225f00 00321000 00436b00 0058f700 0058f700 00740400 00930b00 
00b59b00 00b59b00 00d0f000 00e54400 00ef9400 00ef9400 00e7d400 00d56b00 
00ae3300 00ae3300 007fbc00 0049e000 00071000 00071000 ffb95f00 ff691c00 
ff1a2300 ff1a2300 fecbbc00 fe85af00 fe590000 fe590000 fe432800 fe418000 
fe5c7b00 fe5c7b00 fe8c8f00 fed64800 ff2fc000 ff2fc000 ff8ee400 fff0bc00 
004a1800 004a1800 009dd400 00df4700 010b1b00 010b1b00 01223800 01224300 
0108af00 0108af00 00db4b00 00a35000 005c0400 005c0400 001bd300 ffd71400 
ff9e5c00 ff9e5c00 ff73ac00 ff588000 ff51af00 ff51af00 ff655800 ff950300 
ffcb2800 ffcb2800 00169400 00673f00 00c08000 00c08000 01111300 015f2800 
01a0ef00 01a0ef00 01cb1000 01dea400 01d29f00 01d29f00 01a41c00 01579300 
00eccb00 00eccb00 00783f00 fffba800 ff833300 ff833300 ff147300 feb52800 
fe67bf00 fe67bf00 fe30d300 fe16c300 fe163700 fe163700 fe31fc00 fe668700 

So you should shift the samples if you set SAMPLE_BITS to 24 only.

It seems that the LSbits are crappy (either 00 or FC only) when SAMPLE_BITS is set to 32, and might be losing resolution.

The problem is that you might be working with 16 bits samples and not 24 if you set SAMPLE_BITSto 32 and shift the samples by 8 bits. This made me think that the way to calculate short_SPL_dB could be wrong, as you count the reference as 24 bits, not 16 bits:

    // Calculate dB values relative to MIC_REF_AMPL and adjust for microphone reference
    double short_RMS = sqrt(double(q.sum_sqr_SPL) / SAMPLES_SHORT);
    double short_SPL_dB = MIC_OFFSET_DB + MIC_REF_DB + 20 * log10(short_RMS / MIC_REF_AMPL);
// Calculate reference amplitude value at compile time
constexpr double MIC_REF_AMPL = pow(10, double(MIC_SENSITIVITY)/20) * ((1<<(MIC_BITS-1))-1);

In my opinion, at least with an INMP441, the way to operate should be: initialize the driver with #define SAMPLE_BITS 24 and shift samples 8 bits to the right:

for(int i=0; i<ACQ_PACK_SAMPLES; i++) samples[i] = (float) (int_samples[i] >> 8);

This implementation breaks your solution for several MEMS, but as I only have INMP441 sensors I do not know if this happens in all of them or just on the INMP441.

Thank you for your time

@stas-sl
Copy link

stas-sl commented Jan 10, 2023

Hmm. It works just fine for me as is (i.e. using 32 bits).

32 bit:

00002200 fffdebf8 fffea600 ffffde00 ffff1c00 fffd9400 fffdb1f8 fffde1f8 
fffe97f8 fffd7800 fffde600 fffbfbf8 fffec800 fffe5800 fffe7800 fffd17f0 
fffe89f8 ffffbdf8 fffd41f8 ffff4400 ffff99f8 ffff83f8 ffffabf8 00006df8 
000001f8 fffd6c00 fffc1c00 ffff0bf8 fffef000 ffff8400 fffe8e00 fffd5a00 
ffff6800 fffff1f8 fffecc00 ffff7bf8 fffed3f8 fffec1f8 fffea5f8 ffff6c00 
0000fbf8 0001f400 00001200 0000d400 00002a00 ffff0a00 00014bf8 0000f1f8 
0000e000 ffffba00 ffff37f8 ffffebf8 0000b1f8 fffe9200 000005f0 fffd4c00 
fffed400 0000f9f8 ffff5ff8 ffffb800 fffed1f8 fffd89f8 ffffb7f8 ffff3c00 
00017a00 00001a00 fffddbf8 ffff15f8 ffffa000 fffee000 00001df8 ffffec00 
0000c600 ffff5400 ffff1000 ffffe800 00002000 fffc8800 ffff8a00 000039f8 
00011400 ffffc7f8 fffda9f8 fffc8000 fffb9e00 fffcd1f8 fffe67f8 ffff8400 
fffe5df8 00002200 fffea200 fffdedf8 fffeb1f8 ffff0800 ffff2800 000005f0 
000001f8 fffcc600 fff98400 fffb8e00 fffce1f8 fffcb9f8 fffbebf8 fffccdf8 
fffe5600 fffc2df8 fffdea00 fffcfbf8 fffc13f8 fffbd200 fffbda00 fffe29f8 
fffe0000 fffbd3f0 fffaa400 fffa1400 fffada00 fffd1ff8 fffb07f8 fffaa7f8 

Yes, the rightmost byte might contain non-zeros, but it will be shifted anyway.

If I'm trying to use 24 bit sampling, I'm getting quite weird results, which I even don't know how to interpret:

24 bit:

02f40002 00007f00 1c00007f ff34fffe ffffa4ff 6fffffa4 ff04fffe 0000fcff 
380000fc ff230001 ffffbbff 0cffffbb fec30000 ffff23ff 27ffff23 ffcfffff 
fffe9bff d4fffe9b ffa80000 fffc14ff 58fffc14 fd04fffe fffe2fff 38fffe2f 
fd90ffff ffff27ff 6bffff27 fcb3fffd ffff14ff 43ffff14 fdd3fffe fffdf8ff 
8ffffdf8 fef7fffe ffff38ff 5bffff38 fe73ffff 00020bff cb00020b fe54fffa 
fffe4fff 53fffe4f fdfbfffc fffeecff e3fffeec 005cffff fffe9c00 f8fffe9c 
ff3ffffb ffffc8ff 48ffffc8 ffe80000 fffd0bff 74fffd0b 01840001 00028b00 
bc00028b fe1c0000 000213ff 58000213 0148ffff 00019f00 eb00019f 01770001 
ffff9400 04ffff94 03670001 00049300 1b000493 01ac0001 0000f800 c70000f8 
026f0001 0000ff00 4b0000ff 04880001 0003f000 780003f0 022f0000 00036c00 
9b00036c 03130003 0003d300 e40003d3 02bc0002 0003f800 7b0003f8 02f00004 
00033800 bf000338 03e30004 00052800 a4000528 01530001 00041b00 bf00041b 
01f70002 00029000 5f000290 02640003 00020000 34000200 03cc0003 00034b00 
5f00034b 00340002 fffe3f00 bcfffe3f 00a00001 ffff6b00 98ffff6b 023f0000 
0001af00 b70001af 03000002 0001d400 e80001d4 ff4cfffe 000077ff 58000077 
ff70ffff fffec4ff f4fffec4 ff43fffe ffff34ff fbffff34 fcdffffc fffe43ff

I'm using:

  • ESP32 S3
  • INMP 441
  • Arduino 2.0.5
  • ESP-IDF 4.4.2

The only reason I was looking through issues is because I messed up communication format a bit, trying to fix deprecations.

typedef enum {
    I2S_COMM_FORMAT_STAND_I2S        = 0X01, /*!< I2S communication I2S Philips standard, data launch at second BCK*/
    I2S_COMM_FORMAT_STAND_MSB        = 0X02, /*!< I2S communication MSB alignment standard, data launch at first BCK*/
    I2S_COMM_FORMAT_STAND_PCM_SHORT  = 0x04, /*!< PCM Short standard, also known as DSP mode. The period of synchronization signal (WS) is 1 bck cycle.*/
    I2S_COMM_FORMAT_STAND_PCM_LONG   = 0x0C, /*!< PCM Long standard. The period of synchronization signal (WS) is channel_bit*bck cycles.*/
    I2S_COMM_FORMAT_STAND_MAX,               /*!< standard max*/

    //old definition will be removed in the future.
    I2S_COMM_FORMAT_I2S       __attribute__((deprecated)) = 0x01, /*!< I2S communication format I2S, correspond to `I2S_COMM_FORMAT_STAND_I2S`*/
    I2S_COMM_FORMAT_I2S_MSB   __attribute__((deprecated)) = 0x01, /*!< I2S format MSB, (I2S_COMM_FORMAT_I2S |I2S_COMM_FORMAT_I2S_MSB) correspond to `I2S_COMM_FORMAT_STAND_I2S`*/
    I2S_COMM_FORMAT_I2S_LSB   __attribute__((deprecated)) = 0x02, /*!< I2S format LSB, (I2S_COMM_FORMAT_I2S |I2S_COMM_FORMAT_I2S_LSB) correspond to `I2S_COMM_FORMAT_STAND_MSB`*/
    I2S_COMM_FORMAT_PCM       __attribute__((deprecated)) = 0x04, /*!< I2S communication format PCM, correspond to `I2S_COMM_FORMAT_STAND_PCM_SHORT`*/
    I2S_COMM_FORMAT_PCM_SHORT __attribute__((deprecated)) = 0x04, /*!< PCM Short, (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_SHORT) correspond to `I2S_COMM_FORMAT_STAND_PCM_SHORT`*/
    I2S_COMM_FORMAT_PCM_LONG  __attribute__((deprecated)) = 0x08, /*!< PCM Long, (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_LONG) correspond to `I2S_COMM_FORMAT_STAND_PCM_LONG`*/
} i2s_comm_format_t;

Currently in source code format is set as: I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB, so I replaced it with I2S_COMM_FORMAT_STAND_I2S | I2S_COMM_FORMAT_STAND_MSB, whereas it should be just I2S_COMM_FORMAT_STAND_I2S.

@otger
Copy link
Author

otger commented Jan 20, 2023

Hi, I am sorry, but I was wrong. By the time I opened the issue, I was trying to save the data into an SD and playing it on audacity to verify that I was reading the mic correctly, and I was confused because there was no combination that worked fine. Since then I've replaced Arduino and now I am doing my project in the espressif IDF framework directly.

I do not remember which settings I was using when I sent you the issue, but I can tell you that now I am using next settings:

static void i2s_example_init_std_rx(void)
{   

    /* Step 1: Determine the I2S channel configuration and allocate two channels one by one
     * The default configuration can be generated by the helper macro,
     * it only requires the I2S controller id and I2S role
     */
    i2s_chan_config_t rx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
    ESP_ERROR_CHECK(i2s_new_channel(&rx_chan_cfg, NULL, &rx_handle));

    /* Step 2: Setting the configurations of standard mode and initialize each channels one by one
     * The slot configuration and clock configuration can be generated by the macros
     * These two helper macros is defined in 'i2s_std.h' which can only be used in STD mode.
     * They can help to specify the slot and clock configurations for initialization or re-configuring */

    i2s_std_config_t rx_std_cfg = {
        .clk_cfg  = I2S_STD_CLK_DEFAULT_CONFIG(48000),
        .slot_cfg = I2S_STD_PHILIP_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_32BIT, I2S_SLOT_MODE_MONO),
        .gpio_cfg = {
            .mclk = I2S_GPIO_UNUSED,    // some codecs may require mclk signal, this example doesn't need it
            .bclk = CONF_I2S_BCLK,
            .ws   = CONF_I2S_WS,
            .dout = CONF_I2S_DOUT,
            .din  = CONF_I2S_DIN,
            .invert_flags = {
                .mclk_inv = false,
                .bclk_inv = false,
                .ws_inv   = false,
            },
        },
    };

    
    /* Default is only receiving left slot in mono mode,
     * update to right here to show how to change the default configuration */
    // rx_std_cfg.slot_cfg.slot_mask = I2S_STD_SLOT_RIGHT;
    ESP_ERROR_CHECK(i2s_channel_init_std_mode(rx_handle, &rx_std_cfg));
}

and the data I read from the i2s is like this:

I (841) example: 0x00ae8a00 0x00adda00 0x00987e00 0x00701b00 0x006a1400 0x004c8600 0x004bc100 0x00375c00
I (851) example: 0x003e4100 0x00355900 0x0035ef00 0x0027c200 0x00182100 0x00269900 0x00019500 0xffdea600
I (861) example: 0xffdb6b00 0xffe16900 0xffe19400 0xffd14500 0xffeeca00 0x00040f00 0x00016600 0x00006100
I (871) example: 0x00018f00 0xfff4a100 0xffea6200 0xffba2400 0xff9b9d00 0xff87f600 0xff76e900 0xff40f400
I (881) example: 0xff2d7100 0xff17d500 0xfef84c00 0xff0b4300 0xff0ff100 0xff0ec700 0xfef9a300 0xff1d4e00
I (891) example: 0xff1dd100 0xff29e300 0xff3e1400 0xff351000 0xff460900 0xff5edb00 0xff65e500 0xff96db00
I (901) example: 0xff8a9200 0xffa5bc00 0xffc2ac00 0xffcef600 0xfff9ed00 0x0016d400 0x0047fd00 0x005bdb00
I (911) example: 0x0061ad00 0x006bc200 0x006ec200 0x006d0500 0x007c9100 0x00784100 0x00782f00 0x0059ae00
I (921) example: 0x004db500 0x003d5000 0x00483300 0x0054f200 0x00779800 0x00890d00 0x009af400 0x00a37300
I (931) example: 0x00c4be00 0x00b8f900 0x00ba3a00 0x00d1be00 0x00c5c700 0x00c9f300 0x00d36e00 0x00f5a900
I (941) example: 0x010c7800 0x01081000 0x00ee1e00 0x00f29200 0x00e91600 0x00c78c00 0x00c6a100 0x00aef100
I (951) example: 0x0093c300 0x0085a700 0x00811b00 0x0081c200 0x006a4900 0x005aa600 0x004a8500 0x00222900
I (961) example: 0x0000c900 0xffde8700 0xffd9db00 0xffd5c700 0xffb45d00 0xff940400 0xff7a7600 0xff8b9d00
I (971) example: 0xff848a00 0xff7f8300 0xff8a2e00 0xff93a600 0xffa53200 0xffcb8500 0xffc41000 0xffcf4300
I (981) example: 0xfff04d00 0x000e8300 0x00292f00 0x00413e00 0x0044e900 0x006bfb00 0x007b8100 0x009e5500
I (1001) example: 0x00adc000 0x00c0ed00 0x00e0cf00 0x00e72f00 0x00eb4b00 0x00cc1000 0x00c03000 0x00c61500
I (1011) example: 0x00e23100 0x00ec5200 0x00eb4500 0x01097100 0x01023200 0x0117b400 0x011f5f00 0x012c5300
I (1021) example: 0x01550500 0x014d1200 0x0162ee00 0x017d9000 0x01874500 0x018d1f00 0x01786f00 0x017a7f00
I (1031) example: 0x01844700 0x0158bd00 0x0145e100 0x01306800 0x01279900 0x0125ef00 0x0137be00 0x01222500
I (1041) example: 0x01237600 0x0107cc00 0x00fab600 0x00f4c100 0x00e15c00 0x00df8a00 0x00d02300 0x00c49d00
I (1051) example: 0x00bac600 0x00a5af00 0x00a94500 0x008b6a00 0x007e1600 0x0086dd00 0x00707b00 0x006d8600
I (1061) example: 0x007d6c00 0x0087f400 0x007e0b00 0x009dd800 0x0094ac00 0x0091a500 0x00a94000 0x00a56300
I (1071) example: 0x00bae900 0x00b57500 0x00befe00 0x00c0db00 0x00c2a100 0x00b38300 0x00ccb100 0x00cc3a00
I (1081) example: 0x00d57200 0x00d82a00 0x00cf7100 0x00dce400 0x00e03500 0x00cf7700 0x00d25700 0x00cf2200

As you can see, the last byte is always 00 and you are right, it must be shifted 8 bits. I've verified that when I store the data into an SD and then I convert the data to float (dividing by 2**23 - 1), the sound is the one expected.

I've been doing a lot of tests with diferent settings and this is the one that works fine for me.

That you get f8 at some readings should not happen in my opinion.

I am using:

  • IDF 5.1
  • ESP32 (olimex gateway for the sdmmc SD, but same data when using chinese devkitc like boards)
  • No arduino

Again, thank you for your work, it helped me a lot!

@otger otger closed this as completed Jan 20, 2023
@stas-sl
Copy link

stas-sl commented Jan 22, 2023

I've just found a good explanation why last byte could be non-zero. I haven't tried to replace resistor myself, but sound like it should fix the issue.

Interesting that with IDF 5.1 you have always zeros in last byte. Seems like they've changed API/config a bit since 4.x, probably they introduced other changes there as well, like how they handle last byte/tri-state. Probably should check 5.x version as well.

BTW, I'm curious, if you've managed to use it successfully in your project, what were SPL values you've got? I'm a bit confused, because minimal SPL value in complete silence I'm getting is 40 dBA. I understand that the mic has self noise, but according to specs it should be 33 dBA, so I'm not sure where additional noise comes from.

Here is typical "silence" looks like in my case:

image

Have you experienced something similar?

Update:

Ahh... Somehow I missed that by default C-weighting is used, not A-weighting as I was expecting:

#define WEIGHTING         C_weighting // Also available: 'C_weighting' or 'None' (Z_weighting)

With A-weighting I'm getting 36 dBA minimum, which is closer to 33 dBA that I'm expecting, but maybe still missing something...

@otger
Copy link
Author

otger commented Jan 31, 2023

The one INMP441 I have available right now is very noisy, I am waiting to receive more samples. Isolating the mic with a little bit of foam I get values of the order of 20000, 30000. More or less 60dB, with A_Weighting. When I get a new board I will try and let you know.
image

@stas-sl
Copy link

stas-sl commented Jan 31, 2023

20000-30000 values seems like too much even for pretty bad instance. I would double check there is no EM/RF interference. I had similar values with one of my ESP32 boards when streaming audio over WiFi, and I was able to hear how noise changes, moving the mic around the board, closer or farther from it. However for another ESP32 board I didn’t have such issues, even when streaming.

BTW, don’t know if you are finally using 24 or 32 bit sampling, but seems like having bit width less than 32 bits causes folding/aliasing. Although ICS 43434 and 16 bits was mentioned there, I see similar issue with INMP441 and 24 bits sampling (it is even worse):
Pasted Graphic 2

@otger
Copy link
Author

otger commented Feb 1, 2023

Thank you for your feedback, it helped. I've changed the cable for a longer one so I can put the mic away from the electronics and I get results closer to your ones.

RAW as read from mic:
image

Filtering:

    #define WEIGHTING         A_weighting 
    #define MIC_EQUALIZER     INMP441

    res->sum_sqr_SPL = MIC_EQUALIZER.filter(df_buf, df_buf, DATA_BUF_SIZE);                                                                                                                                                                                                                                                                                                                                                                                                                                                             
    res->sum_sqr_weighted = WEIGHTING.filter(df_buf, df_buf, DATA_BUF_SIZE);

The same data becomes:
image

Closer, but still worse than your values.
From your data what I do not understand are the big peaks, specially for f>15KHz. In INMP441 datasheet it states "Flat Frequency Response from 60 Hz to 15 kHz" I did not expect to get anything of value above 15KHz

@stas-sl
Copy link

stas-sl commented Feb 1, 2023

I've changed the cable for a longer one

You could also try lowering wifi power (if you are using it): WiFi.setTxPower(WIFI_POWER_2dBm);

From your data what I do not understand are the big peaks

The last frequency response chart I posted with big peaks was to demonstrate another issue (not related to microphone self noise in silence). To get it I played 5kHz tone on my mobile phone and recorded it with the mic using 24 bit width. You can see there is a correct peak at 5kHz, but you also get multiple other peaks. You can read more explanation by the link I provided in my previous post. However if recording with 32 bit depth there is no such issue. I mentioned this as there was prior conversation wether to use 24/32 bit sampling.

Besides RF/EM interference there seems to be some weird noise variability after device restarts. I described it in more detail here. So if you make multiple recordings separated by device restarts, you might get slightly different results. I've just tested it in absence of external noise, but there more tests needed to see how measurements might differ in presense of some real signal.

@otger
Copy link
Author

otger commented Feb 1, 2023

Cool!

I am using 32 bits data width for the i2s configuration:

i2s_std_config_t rx_std_cfg = {
        .clk_cfg  = I2S_STD_CLK_DEFAULT_CONFIG(48000),
        .slot_cfg = I2S_STD_PHILIP_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_32BIT, I2S_SLOT_MODE_MONO),
        .gpio_cfg = {
            .mclk = I2S_GPIO_UNUSED,    // some codecs may require mclk signal, this example doesn't need it
            .bclk = CONF_I2S_BCLK,
            .ws   = CONF_I2S_WS,
            .dout = CONF_I2S_DOUT,
            .din  = CONF_I2S_DIN,
            .invert_flags = {
                .mclk_inv = false,
                .bclk_inv = false,
                .ws_inv   = false,
            },
        },
    };

I also did a similar test with the long cable, generating 3 tones with my laptop (https://onlinetonegenerator.com/multiple-tone-generator.html) (440 Hz, 600Hz and 1900Hz) and they are correctly resolved:
image

I will try to check if I see those differences on restarts of the mic with my units, will comment on your issue (yep, when reading the issue I realized, you are not the author of the repo, my bad)

@stas-sl
Copy link

stas-sl commented Feb 1, 2023

I am using 32 bits data

they are correctly resolved

Yes, with 32 bits it should be OK

when reading the issue I realized, you are not the author of the repo

Haha, unfortunately not, just trying to learn from it, just like you :)

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