AutoAnalogAudio icon indicating copy to clipboard operation
AutoAnalogAudio copied to clipboard

Useing AAAudio for rec sound's from mic with esp32

Open FoxEast2021 opened this issue 3 years ago • 8 comments

Hi Mr I want to use this library to record a wav file with a microphone connected to esp 32 dev kit, but my problem is when recording the file because it starts working by pressing the 9 key first, but after pressing the 0 button for a few seconds To stop recording, this message is displayed File contains no data, exiting , and nothing is actually recorded I used an onboard ADC 34 pin and also had another problem with this library at first and it was in the sd.h library because this library did not match esp 32 and it showed the error Failed to open file that I changed the sd.h library I fixed this error with mySD.h What do you think is the problem for recording? please...

FoxEast2021 avatar Apr 29 '21 09:04 FoxEast2021

There is an issue with the current recording example and ESP32. On Arduino boards like Uno, Nano, Due etc, the SD library behaviour is to append to file, where ESP32 will truncate the file. Essentially, it is probably recording correctly, but the data is being deleted by ESP32 SD library when the file is opened for finalization. Either that behaviour needs to be modified or the example sketch needs to be modified to fix this issue. ( the file needs to be left open for finalization after recording )

TMRh20 avatar Apr 29 '21 12:04 TMRh20

I took a quick look at the recording example, and it looks like a few more modifications are needed to work with ESP32, so I'll see about that...

TMRh20 avatar Apr 29 '21 13:04 TMRh20

Ok, I fixed it. The examples can be updated from https://github.com/TMRh20/AutoAnalogAudio/tree/master/examples/SDAudio/SdAudioRecording or if you reinstall the library manually it will work as well.

TMRh20 avatar Apr 29 '21 14:04 TMRh20

Thank you very much Mr. TMRh20 for this great favor

FoxEast2021 avatar Apr 29 '21 21:04 FoxEast2021

Thank you very much for your answers Now it records the wav file on the sdcard, but my only problem is the sound is recorded because the sound inside the wav file is very fast, which means that we have doubled the playback speed of the wav file while playing it! This is the case. Do you think there is a problem with my esp32? If you want, I can upload a sample of the recorded file for you, of course, if needed, sir!

FoxEast2021 avatar Apr 29 '21 22:04 FoxEast2021

Hmm, I'm not sure why it would be speeding up on playback like that. It could have something to do with the SD write speed. What if you try a lower sample rate. ( Call startRecording(newWavFile, 11000); and stopRecording(newWavFile, 11000); )

It should also show the Samples per Second: while recording so you can see if there are buffer underruns.

TMRh20 avatar Apr 29 '21 23:04 TMRh20

thank you very much (Great Sir)

FoxEast2021 avatar May 01 '21 10:05 FoxEast2021

Excuse me, Mr. TMRh, for my many questions from you I wanted to use this library and your library to send the recorded audio to the mqtt server through the mqtt server I set up on my computer, and then save it using node-red, but a small problem I have about how to configure node-red; To store audio sent from esp32. I wanted you to give me a reference or guidance on this if possible. (Ie for example the node-red side, should a buffer be created to receive it?) Thanks for your great answers

FoxEast2021 avatar May 01 '21 10:05 FoxEast2021

Sorry about the late reply, but looks like you're on your own on this one anyway as I don't know the answer. I can't really help much more with this issue.

TMRh20 avatar Apr 26 '23 11:04 TMRh20