Closed T-vK closed 8 months ago
Why don't you modify the code and test? I'm afraid we do not have this HW.
Well, my suggestion would have been software-based and if I understand the quoted comment correctly, the current code sets the ES8288 registers in a way that there is actually a hardware passthrough completely outside of the ESP. But I tested that and it did not work..
I was thinking of doing it that way through software: https://github.com/Aircoookie/WLED/compare/main...T-vK:WLED:feat/add-audio-passthru But now that I know that the ES8388 chip inside the ESP32-A1S might have low-level passthrough capabilities, I'm thinking that it would be way more valuable to get that working properly.
@softhack007 can you help?
Hi, I think you should indeed go for the low-level "hardware" pass-through.
The ES8388 driver was developed by @netmindz and @troyhacks, who had a hard time to read and understand the ES8388 datasheet. Maybe one of them has a clue on how to get pass-tru working on the A1S board.
Modifying the code in getSamples() - as you proposed for a software based solution - would probably not make you happy:
1) we only read samples for the left channel, so it's not possible to "write out" the right channel in software.
2) as i2s_write needs time, this will have negative side-effects on audio processing - fft and other need time, and you're creating a bottleneck by "stealing" time (and buffer ressources) for writing back audio. So I expect that WLED sound processing will start to lag behind audio. Also the "software pass-through" output might stutter and lag behind as a lot of post processing needs to happen in between sampling from I2S.
3) we sample audio at 22khz, which is great for performance but not exactly hi-fi quality.
Btw, just for the sake of completemess, i'd like to mention you also make the same proposal in the MoonModules repository.
https://github.com/MoonModules/WLED/issues/121
In fact I generally prefer to keep discussions together in one place, instead of spreading parts throughout several repos....
The Audiokit A1S board absolutely can do on-chip analog passthru, no need to actually code anything drastic besides maybe a minor I2C init sequence change.
The LyraT uses the same ES8388 codec chip, and analog passthru is enabled for it by default. It's also a much better board as far as audio design. (The AudioKit A1S is a bit of a mess and if you don't already have one, get the LyraT instead. 😁)
This issue highlights the "problem" with these I2C controlled codecs - just because one chipset (like the ES8388) is supported doesn't mean the startup code initializes them for the physical implementation - the A1S is slightly different from the LyraT. Maybe you want to use the mics instead of line-in, or maybe the line-in is on a different input pin, etc.
So I have... no idea. I just dusted off an AudioKit A1S board and flashed it up with current MoonModules mdev (not that it matters, the ES8388 code hasn't changed in some time) and analog passthru is working just fine, even with a hard reset. (It was also working with the old WLED MM release that was on it as well.)
(This config may not be correct for your board, I'm just including it here for reference.)
(You may also notice my AudioKit A1S board is missing a microphone - this is intentional as the line-in and mic share the same signal path. Like I said, it's not a great board.)
Thanks for all the feedback. It turns out that my board has a hardware defect :( Line In in working fine, but the Earphone jack or some component along the way is broken. I managed to get my hands on another Audio Kit board for testing, also flashed it with the current moon modules and that board just worked out of the box. I ended up with a slightly different config though:
Are the dip switches in any way relevant btw? Mine are set to: | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|
ON | ON | ON | OFF | OFF |
Are the dip switches in any way relevant btw? Mine are set to:
1 2 3 4 5 ON ON ON OFF OFF
The DIP switches are kinda poorly detailed on the silkscreen beside the DIPs - basically they set the functionality of GPIO 13 and 15, and sets their use for the SD card or something else -like "KEY2".
DIP 1 = Use GPIO 13 for KEY2 DIP 2 = Use GPIO 13 for SD card "DATA3" DIP 3 = Use GPIO 15 for SD card "CMD" DIP 4 = Use GPIO 13 for JTAG "MTCK" DIP 5 = Use GPIO 15 for JTAG "MTDO"
This also means if you need two more free GPIOs for some reason, you can set DIP 4 and/or DIP 5 to "on" (with everything else "off") and use those pins on the JTAG header - but you lose KEY2 if you need GPIO13 for something else.
For WLED, whatever works for you is fine - but only one of each switch for GPIO 13 (there's 3) and GPIO 15 (there's 2) should be set at a time.
If you want to use the physical buttons/keys, here's the GPIOs:
You can see KEY2 is marked slightly differently as "IO13_KEY" - which means that key is only enabled on GPIO 13 if DIP 1 is set to "on".
Also guessing GPIO 36 is "KEY1", if I'm reading correctly.
Just for extra info, I have also added support for the WM8978 chipset - which is generally similar to the ES8388 used on the AudioKit A1S and the Espressif LyraT - both the WM8978 and the ES8388 are initialized via I2C commands,
The reference board for WM8978 support in WLED is the Puca DSP: https://www.ohmic.net/puca-dsp
The board is similar in function to the AudioKit A1S or the LyraT, but much smaller and without buttons or an SD card slot - and easier to jam into a box, including with its own LiPo battery.
I also enabled analog passthru on the WM8978 as well, and the Puca DSP is currently my go-to for WLED audio sync. The init sequence may be specific the WM8978 hookup on the Puca DSP, but that could be adjusted.
Problem solved. Looks like faulty AudioKit A1S board.
Analog passthru is working as expected with the user's replacement board.
It is great to see that the ESP32 Audio Kit V2.2 is supported. I managed to get it to work by following the pin configuration from the docs of the Moon Modules branch: https://mm.kno.wled.ge/soundreactive/Line-Input/#es8388
It would be nice to get audio pass-trough to work:
I read that it can be achieved with this board with basically zero latency, but it doesn't appear to be enabled by default.
It would be a very valuable feature because this way you wouldn't need a mixer (or Y-adapter and deal with all the impedance issues).
Looks like all it would take is something this:
Looking at this full example: ESP32-LyraT Audio Passthrough
The i2s_read in WLED appears to happen here atm: https://github.com/Aircoookie/WLED/blob/c8c394b4e923d98d37b95e6007509b40b624a8a3/usermods/audioreactive/audio_source.h#L323
Edit: Actually, looking at this: https://github.com/Aircoookie/WLED/blob/c8c394b4e923d98d37b95e6007509b40b624a8a3/usermods/audioreactive/audio_source.h#L458
Shouldn't this already work right now?