-->
Page 1 of 1

Recording audio at 8KHz and saving to SPI flash

PostPosted: Thu Nov 10, 2016 2:23 pm
by mph070770
I'm preempting problems and seeking prior advice before I start...

I have investigated using the internal ADC on the ESP8266 for audio recording. My requirements are low - 8KHz sampling (ideally at 16b but because of what I say next, that's a moot point). It seems that even with WiFi disabled etc, I can't get analog_adc to run faster than 5KHz. So, i'm moving to an SPI solution, described here: https://github.com/sven337/jeenode/blob ... t/xmit.ino using this chip: http://www.esp8266-projects.com/2015/04 ... p8266.html

I want to record the audio to SPI flash (using SPIFFS) and it can happen when WiFi isn't connected if that helps performance. I've successfully written audio to SPI on other platforms at similar or higher bit rates without an issue.

Will SPIFFS handle a datarate of 8KHz 16 bit along with the simultaneous audio sampling?

Does anyone have any advice on the best way to do it? I'm assuming timer based, with a couple of 1K buffers, writing flip/flop to the SPI. Can the SPI write be DMAed, for example, so that it doesn't impact on the audio sampling?

Thanks!

Re: Recording audio at 8KHz and saving to SPI flash

PostPosted: Sun Nov 20, 2016 3:40 pm
by mph070770
Ok, so no reply to my original post so perhaps there isn't much knowledge out there on this specific goal.

I now have the ADC working but my worries seem to have been realised - I can't sample at 8KHz and write to flash simultaneously. It seems that SPIFFS isn't fast enough. When I am writing, the SPIFFS write activity seems to make the timing of the ADC ISR change.

I've tried turning off caching for the flash (as I believe it writes a 4K page at a time by default) so that my ADC writes are written as they occur but this didn't seem to help. I'm wondering if I can go lower level and use ESP.flashWrite and write my data "raw" (I know I'll have to erase the sectors first). Does anyone know if this will be faster?

Can anyone suggest any solutions?

Re: Recording audio at 8KHz and saving to SPI flash

PostPosted: Wed Apr 03, 2019 6:46 am
by sahil.rke
Hey There.... i also stucked in same problem.
i am unable to record audio and tried many thing provided on google...
please let me know if you are successful in this task...
i have to record a 10-20 second audio using esp8266 and vs1053.

Re: Recording audio at 8KHz and saving to SPI flash

PostPosted: Thu Apr 04, 2019 5:51 pm
by RichardS
I have found the answer is YES and NO.

YES if you start with a formatted SPIFFS filesystem.

NO if you have written and delete files and added files... etc etc.... it can become slow....

Use a ESP32 with 4MB RAM and record into it! :-)

RichardS