I'm new to Arduino and I'm working on a project that record an audio and store it in SD card through a card reader, After that, I want to read the audio from the card and store it in a variable in order to send the audio to a server.
that problem is, while searching on Google/ YouTube an all they use TMRpcm library and try my best to pivot the tutorials to achieve my goal. but the TMRpcm library not supporting MKR boards.
can someone help me in dealing with Audio? how to record it store it in SD and read the audio again to send the audio to a server.
Note that I store it in SD because based on my knowledge the audio size will exceed the Arduino memory capacity. Open for suggestion to improve the work.
If you quickly rid yourself of the idea that audio is stored by your Arduino, the better off you will be.
Your Arduino AD converter will return an integer, 2 bytes, of information every time you ask for an analog read. No Audio! You can do that analog read as often as you can and can write the integer to your SD card. Remember, you get only 10 bit values from the AD read.
The glitch comes in when a 512 byte block of data is ACTUALLY written to the SD card. No other code will be executed during that time, meaning NO audio sampling.
Others will be here soon to tell you that audio is AC and will have to be handled carefully in your Arduino.
I'm new in Arduino world, I'm planning to make an audio recorder using MRK1010 board and store the audio in SD card. And read from the card to be send to a server.
I tried to use TMRpcm as there are many tutorials using it, but it's not compatible with MRK family, only for ARV architecture. I read here that TMRpcm for playing the audio back which is not the goal.
can someone guide me to the correct path? is it feasible to use MRK 1010 in this project or I should change it?
It looks like you’re using some pretty comple libraries which are probably using your your resources.
Maybe a bigger Arduino, or trim back the libraries if you can.
There's some minor stuff you can do - your wait function could be done more simply with millis for example. But the libraries are your real problem and even if you can drop dynamic memory a bit, it will likely crash if there isn't enough stack and heap space.
Your best bet, as suggested is to get a more capable Arduino.
The SD card makes it worse. It allocates a 512 byte buffer when you open a file. So you need to slim down your RAM usage a lot. In the project you're copying, I didn't see any WiFi, nor do you use it (yet) in your code. Does it help if you drop it?
Of course, you can write your own code.
But you will need to dive into register settings as normal analogRead is not fast enough.
Even then, you will never reach great quality. I am not sure, but sampling frequency will be limited to 16 kHz or so. So you need to filter everything above 8 kHz out of your audio.
So basically you will have phone quality sound then. OK for speech, but not to listen to an orchestra.
I am not even sure if you can record and save to SD at the same time...
If not, then you would only be able to record a really short message as memory will fill up quickly with audio files (8 bit sound at 16 kHz will produce 16kByte per second... (and you have only 2 kByte)
So basically: you will need another board (...sorry!).
ESP boards are cheaper and much more capable...