pschatzmann / arduino-audiokit

Arduino ADF/Audiokit HAL (support for ESP32-A1S, AI-Thinker, LyraT for ES7148, ES7210, ES7243, ES8311, ES8347, ES8388, TAS5805M, AC101 audio chips)
GNU General Public License v3.0
157 stars 42 forks source link

Proposed Work around for line in and mic mixed #85

Closed FatherMarco1971 closed 1 year ago

FatherMarco1971 commented 1 year ago

https://www.pschatzmann.ch/home/2021/12/15/the-ai-thinker-audiokit-audio-input-bug/

The Analisys from Mike in the comment is perfectly correct. If the HW patch is not possible this work around make possible using line in Muting microphone.

pschatzmann commented 1 year ago

Can you add some comment into the AudioKitSettings.h how this is supposed to work. What will be AUDIO_HAL_ADC_INPUT_LINE1 and AUDIO_HAL_ADC_INPUT_LINE2 doing exactly when this is active ?

Assuming this is working: shouldn't we activate this automatically for all AudioKits ?

FatherMarco1971 commented 1 year ago

Assuming this is working: shouldn't we activate this automatically for all AudioKits ?

Is it possible but since is a workaround for an HW bug if some revision of the board is correct the SW WO ciould not be needed.

The workaround, when enabled, in case you want enable LINEIN (AUDIO_HAL_ADC_INPUT_LINE1) set AUDIO_HAL_ADC_INPUT_LINE2 and set mic gain to zero, when you enable mic (AUDIO_HAL_ADC_INPUT_LINE2 ) doesn't do nothing...

If you look at this document https://dl.radxa.com/rock2/docs/hw/ds/ES8388%20user%20Guide.pdf caompared to this https://files.seeedstudio.com/wiki/ReSpeaker_6-Mics_Circular_Array_kit_for_Raspberry_Pi/reg/AC101_User_Manual_v1.1.pdf you see that es8388 is missing of linein so ai-thinker to maintain the pintopin compatibility with esp32+ac101 try to emulate it removing a capacitor (the wrong one in case of our boards) This the explanation from a user in your blog maybe clearer and perfectly confirmed by my analisys and the document I linked:

On my board (V2.2 A247 ES8388), LINEINL (pin 22) and MIC1N (pin18) are connected together on the A1S module. Similarly, LINEINR (pin 21) and MIC2N (pin 14) are also connected on the module. These two pairs are routed to LIN2 and RIN2 on the ES8388 respectively. Some capacitors were already removed on the AI Thinker board that I received, but they appear to be the wrong ones. C17 was removed which connects the left microphone to the MIC1P (pin 17 on the A1S, LIN1 on the ES8388) and C19 was removed which connects the right microphone to MIC2P (pin 15 on the A1S). I think the intention was to make the microphones single ended and remove the negative input. However, the effect was to disconnect the microphones from the LIN1 / RIN1 input, and at the same time leave them connected to the LIN2 / RIN2 inputs (which are also connected to the line in circuit). This is why there is no input on Input Line 1 and mixed microphones / line in audio on Input Line 2. I moved capacitor C18 to the C17 position and C20 to the C19 position. This connects the microphones to the left and right channels of Input Line 1 and isolates them from the Input Line 2 / line in path. The fix works well on my board, and I can now use either stereo microphones, stereo line in, or mix both in software. I have a picture of where the caps are on the board if anyone is interested.

I'll add some comment in the AudioKitSettings.h.

pschatzmann commented 1 year ago

I decided to resolve this slightly differently: line1 and line2 have different input gains that can be configured in the AudioKitSettings.h

Thanks a lot for your input. I think this is better then what I had before...

There are many revisions of this board, but unfortunately all of them have this bug...

FatherMarco1971 commented 1 year ago

Happy to have had a Little contribute to your magnific work!