I am working on an audio player project and would like to save the .wav file to the Arduino's EEPROM memory. I have seen other forums that tell me to break it down byte by byte but I'm not sure how to do that in the program, please tell me how!
Hello, do yourself a favour and please read How to get the best out of this forum and provide the necessary documentation for your ask…
What is your sample rate? 1024 bytes of wav? How long should that play?
There's no way you can save anything useful at all. Let's do some math: at 8-bit resolution, you can save 1024 samples (on an UNO or similar). At the very low 8 kHz sampling rate, each second of sound takes 8000 samples, or 8 bytes per millisecond. 1024 / 8 = 128 ms. That's the amount of very low resolution audio that your EEPROM can store. Four times that, or about 1/2 second, if you use a Mega.
Which Arduino model?
Here are a couple of links that might help you with the basics -
Digital Audio Fundamentals
Digital audio is a series of samples, each representing the "height" of the wave at a single instant in-time. (CD audio has 44,100 samples per second).
When the audio is played, the digital-to-analog converter (DAC or D/A) "connects the dots" to re-construct the continuous analog waveform, and there is "smoothing filter". (The regular Arduino does NOT have a DAC.)
A WAV file has a header that tells the software the sample rate, bit-depth, and number of channels, etc., to reconstruct the series of samples from the bytes. After the header it's just a series of sample-values.
8-bit files are pretty-easy because every byte is a sample. But there is a "quirk" in-that 8-bit WAV files use unsigned data (no negative values) so the data is based at 127 or 128 (I can't remember) and silence is a series or 127 or128 samples, instead of a series of zeros. Of course, the DAC (or the driver for the soundcard/DAC) takes-out the bias and the analog goes negative & positive like normal audio.
With 16 or 24-bit files, of course each sample has a high-byte and a low-byte and they have to be in the correct order. And with stereo, the samples alternate with two bytes for the left channel, then two bytes for the right channel, etc.
Now with all of that.... You probably don't need an actual WAV file! The Arduino doesn't have a file system or operating system. And, your software probably "knows" the format details so you shouldn't need the WAV header.
For example, audio CDs don't have WAV files or any kind of "computer files". They don't need a header because they all have the same 16-bit, 44.1kHz, stereo format. (That's why CDs have to be "ripped"... There are no regular files to copy to your hard drive.)
There is an optional Arduino library that will allow you to read/write files to an SD card and that can be useful if you're going to write a file to the SC card with the computer and then read it with the Arduino (or vice-versa).
I don't think we need to add more to this thread
@scientificcrabs seems MIA or got the point