Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ESP32 INMP441 I2S sound recorder spectrogram shows strange artefacts

butty_bach

New Member
I've built a sound recorder based on ESP32 with an I2S INMP441 microphone. The code needed a lot of massaging to get it to work using lots of hints and tips from samples etc on the web. It appears to work OK, and I created a spectrogram using Audacity to get an idea of frequency response etc. But the spectrogram has strange features in it that I don't understand, and I could do with some idea of what could be causing them.

The sound recorded is a generated linear tone from 100Hz to 20kHz over 30 secs. The most obvious weird thing is the "anti" signal descending from on high and crossing the "real" signal at about the point where the microphone is beginning to hit its frequency limit. There is also a dark band, faint in this sample but more pronounced at lower sampling rates, where the two obvious signals cross. I feel this must be related. There's also faint arcing signals, perhaps harmonics?

The other obvious thing is the banding that appears when there's (relative) silence.

I've played with the I2S config and buffering parameters without fundamentally changing anything. Changing the sampling rate does move things around a bit but all the artefacts remain.

I'm hoping someone knowledgeable in audio may have some idea what this is showing!
inmp441 50kHz sampling.png
 
This is my I2S config:

const i2s_driver_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)BITS_PER_SAMPLE,
.channel_format = I2S_CHANNEL_FMT_ONLY_LEFT, // ALL_LEFT or RIGHT_LEFT gives loud mush
.communication_format = (i2s_comm_format_t)(I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB),
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 4,
.dma_buf_len = 1024
};

BITS_PER_SAMPLE is 16
I've tried many sample rates, which give basically the same result, although the dark band where the two arcs cross becomes more pronounced at lower rates.

I've spent a fair amount of time looking at examples on the web and this is the result. There are more parameters available that I have no idea what they do :confused:
 
I've tried a different microphone where everything except the two clear signal is not present, so that I think can be put down to individual microphone characteristics. But the two strong signals remain.

From further tests I can see that the second signal is sample_rate/2 - f (f being the real signal frequency). Clearly it's an artefact, probably caused by something wrong in the config parameters. Any ideas?
 
It's "Aliasing"; signal (or harmonics), especially above half the sample rate. Anything above that is in effect frequency mirrored, and higher input frequencies produce lower frequency artefacts.

You need to add a low-pass filter with a fairly sharp cut-off below the sample frequency before digitising; it's a basic requirement for digitising audio.

Or, increase the sample rate so a simpler filter can be use and still have a fairly flat response up to 20 KHz.
 

Latest threads

New Articles From Microcontroller Tips

Back
Top