-
Notifications
You must be signed in to change notification settings - Fork 44
ESP32-S2-Kaluga-1 v1.2 + ESP-LyraT-8311a v1.2 - Doesn't work #94
Comments
Since I don't have any of this board, I can't really test. |
Thank you for your quick reply, indeed MCLK must be 35, and now I have sinewave audio output, but it is skipping and sounds distorted... it seems like an I2S fifo's buffer overrun... I'm digging on it now, I will report when I catch where it comes from. Then I will do full tests with microphone input as well. Best Regards |
If I override default config's sample rate with |
Did you change the log level ? This would explain the reduced sample rate. |
Info: bool audiokit::AudioKit::begin(audiokit::AudioKitConfig) |
Yes, I did..same results, ADC reads samples full of harsh white noise, pumping up and down... Today I will dig deeper with an oscilloscope and Logic Analyzer to check I2S integrity. As I was able to trace the code flow of initialization all I2C registers were loaded properly as intended. I will make the same log for a LyraT v4.3 board which is working normally, to see are there some skipped sections of the init sequence. |
I think the mic is connected as diff input: did you try cfg.adc_input =AUDIO_HAL_ADC_INPUT_DIFFERENCE |
I did try with LINE1 and LINE2, now with DIFFERENCE... it's the same pumping noise up and down, but now i think there is a "difference" - the microphone is picking at least something, because when the noise is going down, I can hear something - if knock on the board or whistling straight into the mic. It looks that it comes from some kind of Auto Leveling Gain control which is out of lock. |
This codec supports digital mics too (Digital Data goes like single ended mic into the chip, while mic's clock is sourced from I2S) |
Not sure if this helps, but I wondered about the following line: |
I've tested that already and it didn't help, but I'm about to nail it. There is ALC control which needs to be constrained in gain, and there is muting threshold levels to suppress background noise in idle.. These registers don't have proper factory defaults, so I fiddled randomly with values, and now it is recoding clean an undistorted audio. I will test thoroughly to see which are vital for proper initialization for recording, so you can add some extra functionality to HAL and the codec chip driver. I think some conditional #ifdefs must be used as well, so the problem with missing I2S_NUM1 on S2-Wrover modules shall be sorted. I will make a full report of other tests and will give you necessary stuff you wish to change the code base. Best regards |
I'm still chasing the sampleRate issue, it is working good only with 8k. On all other possible rates it does skipping and clicking but sound pitch is unchanged - so it's not like sampling frequency mismatch, but more like I2S buffer overrun. Now I will connect the codec board LyraT to another MCU which is not S2, but WROVER-E, to check the possibility that bug comes from ESP core libs. |
Higher samplerates than 8k, consumes buffer qiucker, so if i increase buffer to 16000, and use 16k as sample rate, it sounds 1/2 of the time, if i make buffer 32k and sample rate also 32k, it sounds 1/4 of the second... I thought it is related with that this codec is mono, and SineGenerator feeds two 16bit integers for a sample into the buffer... but it is not that... I will dig more, so far I achieved good recording/playback audio @8k samplerate, after settled mic gain and ALC min/max levels... |
Maybe it helps to compare the actual 8311.c from ADF with my (old) copy. I noticed that the coeff_div has changed. |
Hmm, I never tried - but maybe it helps to have the ESP32 in slave mode and use the 8311 as master ? |
That's good idea I will try tonight, meanwhile I have de-soldered 4 x 22p caps C101,C32,C33,C34... now measuring with scope shows the edges became a little bit more steep, and it started to work with 11K sample rate, however a strange click is heard from time to time on random basis... could be errors from shifted clock or a jitter accumulation... it's still working perfect with 8k sr. |
AudioKitHAL.h @line 640 |
Actually I am not using this I2S output any more. |
Then I have to check how it is performing with AudioTools, so far with AudioKit it is working at 8k, and after I de-soldered few caps started to work @11k too. But it is not clean and sharp like 8388, sounds like de-tuned and with random clicks of an old vinyl record :) |
I will remove the parameter for the setupI2S() method since this is not used and is confusing... |
okay... which example of AudioTools should I use for testing output and changing sample rate ? |
I usually test the output with a sine generator: https://github.com/pschatzmann/arduino-audio-tools/tree/main/examples/examples-audiokit/streams-generator-audiokit Or for intput and output: https://github.com/pschatzmann/arduino-audio-tools/tree/main/examples/examples-audiokit/streams-audiokit-audiokit |
the Generator is sounding good... |
Confirmed, stream-input->output forwarding with AudioTools do work on 8311, but it still does need patching mic_gain and ALC max/min registers. Still digging on I2S issues with AudioKit, I'm looking now how it is done in AudioTools, and what could be the problem... |
I found this: d9cfb28 |
I have already set interrupt flags prio to 0, also added these lines at the bottom of the section. |
It seems like buffering issue, overrun at fifo buffers, or DMA... interrupt nesting... I will not stop until it is sorted, it's good to have the more simple AudioKit usable on all platforms, with supported boards and codecs... Please consider splitting board profile for Kaluga + ESP-LyraT-8311A v1.2 in two setups, one for ES8311 and another for ES7243... so different pin mapping can be switched easy with the board selection choice... |
I would like to have this resolved as well, but currently I don't see any difference. The idea is to use the I2SESP-New.h as soon Arduino supports the new API... |
This afternoon I will try to isolate what is causing these strange effects, for now its 100% that it has nothing to do with codec initialization, however some corrections would be necessary to setup the proper INPUT_LINE and mic gain + alc. |
You won't believe it, but the cause of noises clicks and sounding de-tuned in pitch, was caused by the SineWaveGenerator.h included in the output.ino test... it is from the "float", I've changed angle and deltaTime to double, and noises and clicks did stop immediately, however there is de-tune effect, but when i changed all floats to double, it sounds clean and nice at all sampleRates... because deltaTime is precomputed at setSampleRate... it lacks of resolution, and later when angle is accumulated, because it's not wrapped around at a full cycle, floats do cause these distortion, and clicks at higher sampleRates... Unbelievable... |
i propose that as a replacement for readSample() in the SineWaveGenerator class which is bundled with output.ino example int16_t readSample() { |
Strange: why would this not be noticeable on the regular ESP32. |
Probably it is because of a different compiler options, and/or versions/implementations of the pulled-in libraries into the Arduino core. It could be from configs for specific CPU/Boards or can be caused by a any pragma statement somewhere in all included source code for a given core variant. I could hunt it down, but it's better first to make code in the example - to be as portable as possible. |
output.zip |
Hmm, if you want to submit this, I suggest that you create a new directory in the examples instead of changing the existing one. |
okay. i will put this example in a separate folder, you can just fix generator of the existing one. |
If your ESP32-S2-Kaluga-1 v1.2 changes are working, I propose to submit it. It is much easier to review some individual changes than many different things |
The text was updated successfully, but these errors were encountered: