Open Cristianistrate opened 3 years ago
apparently need to use i2s_read instead of i2s_pop_sample as in this post : https://www.esp32.com/viewtopic.php?t=20835
It needs some tweaking though. I haven't gotten it to work either.
Looks like this function was deprecated at some point. I don't have access to my electronics at the moment due to a house move. If anyone would like to try and fix this it would be appreciated!
I'll give it a shot later, but for now I'm reverting to esp32 1.0.3
@tavdog thank you. The code was 'borrowed' from the sound reactive fork of wled https://github.com/atuline/WLED/blob/master/wled00/audio_reactive.h Looking at their code, they haven't managed to fix the problem yet either.
@atuline as I used some of your audio reactive code in here, have you guys made any progress on this issue? I have no idea where to start!
Hi Scott,
I2S is the way to go on the ESP32's. That's with either the INMP441 or the ICS-43434. We implemented a deprecated version of a driver (unfortunately). Other references are atomic14 on YouTube and most recently Dave Plummer's Nightdriver at:
https://github.com/PlummersSoftwareLLC/NightDriverStrip
I highly recommend going through his software, especially include/soundanalyzer.h.
Am not too good on object oriented, so I'll have to work extra hard to try and get a handle on it.
Cheers,
Andrew
I figured out the new format of i2s_read. To fix the read code i did the following
for(int i=0; i<samples; i++) { int32_t digitalSample = 0; size_t bytes_read = 0; esp_err_t result = i2s_read(I2S_PORT, &digitalSample, sizeof(digitalSample), &bytes_read, /*portMAX_DELAY*/ 10); // no timeout //bytes_read = i2s_pop_sample(I2S_PORT, (char *)&digitalSample, portMAX_DELAY); // no timeout if (bytes_read > 0) { micData = abs(digitalSample >> 16); }
and to fix the mic test portion i did this
// Test to see if we have a digital microphone installed or not. float mean = 0.0; int32_t samples[BLOCK_SIZE]; size_t num_bytes_read = 0; esp_err_t result = i2s_read(I2S_PORT, &samples, BLOCK_SIZE, // the doc says bytes, but its elements. &num_bytes_read, portMAX_DELAY); // no timeout
Esp32 2.0.0 is unreliable. Half the time it boots up and just shines bright white. This code also works for the 1.0.6 version which I'm again reverting to for it to be more stable.
I can submit a PR later if you'd like but it's such a small change I'm not sure its worth the trouble.
@tavdog Thanks for your help on this, I've updated the code, and now it works as intended on 1.0.6.
To get anywhere on 2.0.0 I also had to change (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB)
to (I2S_COMM_FORMAT_STAND_I2S)
. However with 2.0.0 I'm not getting anything on the display (well I do occasionally and seemingly at random). I'm wondering if this is a FastLED issue at this point? Possibly related to this? I know the system is working as it connects to the network and I can see that it's responding to web control by plugging it into the serial monitor. It just doesn't display anything. This is also the case if I use the github version of FastLED rather than the 3.4.0 library manager version.
So for now, I guess its ESP32 core 1.0.6 only. Thanks again for your help.
The patch mentioned at https://github.com/FastLED/FastLED/pull/1308 fixed the issue for on esp32 2.0.0. I didn't have to change any of the i2s_comm_format options. . . weird.
OK, I finally understand (have been pre-occupied). . . Thanks for your work on this guys. I've updated our SR WLED dev branch with your updates. MUCH appreciated!! That update is at:
https://github.com/atuline/WLED/commit/4560e92424617f124ada301975f7591b848a3e2d
fyi, you find the deprecated info with the proposed replacement in the espressif documentation too: https://docs.espressif.com/projects/esp-idf/en/v3.3.6/api-reference/peripherals/i2s.html#_CPPv414i2s_pop_sample10i2s_port_tPv10TickType_t
I have this issue, I read somewhere that "i2s_pop_sample" was deprecated. I use esp 2.0 board from board manager Thank you.