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

Distorted mic signal with Inmp441Max98357a device #134

Open
requireiot opened this issue Nov 28, 2023 · 2 comments
Open

Distorted mic signal with Inmp441Max98357a device #134

requireiot opened this issue Nov 28, 2023 · 2 comments

Comments

@requireiot
Copy link

requireiot commented Nov 28, 2023

With the Inmp441Max98357a device, the audio input (microphone signal) is distorted, because each sample is sent twice (apparently, this is what the ESP32 API will do, when 16 bit resolution is requested).

To illustrate, I recorded the streamed signal while playing a loud 440 Hz tone through a PC speaker, the read the resulting WAV file in Audacity. Below are screenshots from Audacity, from the zoomed WAV signal, amplified by 6 dB for clarity.

This was compiled with platform Espressif 32 (4.2.0) for an "Espressif ESP32 Dev Module", framework framework-arduinoespressif32 @ 3.20002.220503 (2.0.2)

With the original code
old-code

With modified code, using 32 bit samples
new-code

The modified code is in my fork of the original code. I'm not a Github expert, I guess I'll have to figure out how to do a pull request ...

@Romkabouter
Copy link
Owner

Nice fix, I will check your fork.
Thank you for the effort!

@requireiot
Copy link
Author

The code in my fork has 2 changes compared to the original, which maybe I shouldn't have checked in together, but too late now:

  1. a functional change to implement the duplicated 16-bit words as described above
  2. a cosmetic change, making the definitions at the top of Inmp441Max98357a.hpp more consistent: all pin numbers etc. pertaining to the microphone I2S port start with MIC_, all pin numbers etc. pertaining to the speaker I2S port start with SPK_, and the config structs in Inmp441Max98357a::init() end with _mic or _spk, resp. -- just made it easier for me to wrap my head about what pertains to what

ProrokWielki added a commit to ProrokWielki/ESP32-Rhasspy-Satellite that referenced this issue Mar 17, 2024
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