Analog mic + pwm out behaves weird? #1480
-
Hello, I am putting this into Q and A, since I am not sure if it's a bug or if I am just doing something wrong. Thank you so much for this awesome library. I tried reading the analog input and streaming it as PWM, but that doesn't work as expected. I made sure I am using the correct pin for the analog input by running the base_adc_average_mono_serial example, which works. I made sure I am using the correct pin for the analog output by running the streams_generator_pwm example, which works. In order to have repeatable data, instead of microphone I am using a signal generator with a DC offset. I verified that the adc sees the data correctly with the base_adc_average_mono_serial. There is low volume noise coming from the speaker. The oscilloscope shows a waveform with a roughly similar shape to the one I am putting in, extremely noisy, low amplitude, chopped up (discontinuities in the waveform, as if you cut pieces of it and stitched them back together) and at a much lower frequency, suggesting a sampling issue. Am I just doing something really dumb? Or is this combination not supported? Or is it a bug? I just need a combination of an analog input and "analog-compatible" (i.e. lm386 with an aliasing filter compatible) output. As far as I remember, the ESP32 does not support ADC DMA with I2S PDM, since ADC DMA uses the I2S0 memory and furthermore PDM is only supported by I2S0 - that's why I tried my luck with the PWM instead. I tried enabling "auto_center_read", didnt help. Thank you very much!! If you need me to do some more tests, just let me know HW+SW: Arduino 1.8.19, ESP32 2.0.9, NodeMCU32S Sketch:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 15 replies
-
I am not sure what the issue is, but maybe there is a difference between the input and output speed which leads to a buffer over or underflow.
|
Beta Was this translation helpful? Give feedback.
-
Okay... thank you. So the code looks good? I will try to measure the input and output sample rates later today, I will also upgrade to the newest ESP IDF and also try to change the buffer size config. Thank you very much! |
Beta Was this translation helpful? Give feedback.
I am not sure what the issue is, but maybe there is a difference between the input and output speed which leads to a buffer over or underflow.