Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'i2s_pop_sample' was not declared in this scope #5

Open
Cristianistrate opened this issue Sep 22, 2021 · 11 comments
Open

'i2s_pop_sample' was not declared in this scope #5

Cristianistrate opened this issue Sep 22, 2021 · 11 comments

Comments

@Cristianistrate
Copy link

I have this issue,
I read somewhere that "i2s_pop_sample" was deprecated.
I use esp 2.0 board from board manager
Thank you.

@tavdog
Copy link

tavdog commented Oct 21, 2021

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.

@s-marley
Copy link
Owner

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!

@tavdog
Copy link

tavdog commented Oct 21, 2021

I'll give it a shot later, but for now I'm reverting to esp32 1.0.3

@s-marley
Copy link
Owner

@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.

@s-marley
Copy link
Owner

@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!

@atuline
Copy link

atuline commented Oct 23, 2021

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

@tavdog
Copy link

tavdog commented Oct 24, 2021

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.

@s-marley
Copy link
Owner

s-marley commented Oct 24, 2021

@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.

@tavdog
Copy link

tavdog commented Oct 25, 2021

The patch mentioned at FastLED/FastLED#1308 fixed the issue for on esp32 2.0.0. I didn't have to change any of the i2s_comm_format options. . . weird.

@atuline
Copy link

atuline commented Oct 27, 2021

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:

atuline/WLED@4560e92

@BlueAndi
Copy link

BlueAndi commented Feb 8, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants