Did you try re-opening the raw file in Audacity?
For testing purposes, try an 8-bit WAV file. Since a WAV file has a header, you can check it with [u]MediaInfo[/u] to check the sample rate and bit-depth, etc. (MediaInfo won’t work with raw data.)
If your ATmega player is working and the bit-depth & sample rate are correct, it should play the WAV file. Since your player is reading raw data it will read the bytes in the WAV header and convert them to audio and you’ll hear a noise-glitch at the beginning before the recorded sound plays, but it should play.
=raw audio file (8kS, 8 bit)
Your linked instructions say to use a sample rate of 62,500 (62.5 kHz). Since you’re at 8-bits (one byte per sample), one second should be 62,500 bytes.
Otherwise reading the raw file with a hex editor, the output do not look like 32 bit numbers, so I do not know how to convert this.
4 lines as example:
}}|||||{{{{{{{zz
zzzzzzyyyyyyyyyy
yyyxxxxxxxxxxxxx
xxxyyyyyyyyyyyzz
zzzzz{{{{{{||||}
The ASCII character conversions are meaningless since this isn’t a text file. (The hex editor doesn’t know that so it will show the ASCII conversion for any value that can be converted to ASCII.)
The hex data (00-FF hex) for an audio file should “look random” since you’re looking a sampled waveform at one byte at a time. You can’t determine the bit-depth by looking at the bytes. (That information is contained in a WAV file header, but raw files don’t have a header.)
Try making a silent file. There are no standards for “raw” files but 8-bit WAV files are normally unsigned so silence gives you a file full of ‘80’ hex bytes (128 decimal) following the header. I tried a raw file and I got the same thing (without the header, of course) 16-bit WAV files use signed integers so silence gives you a file full of zeros.
Because I could not load my MP3 wav file
You can load anything you want but it’s a question of what your firmware can read. You’d need an MP3 decoder and the ATmega chip isn’t fast enough to decode MP3 in real time.
Raw PCM data is a lot “simpler” but the format is strict because the firmware has to know the exact format in advance. It’s the same if you open a raw file in Audacity… You have to enter the correct parameters.
…It would be pretty simple for the firmware to read a WAV header and make sure the format is correct (or acceptable) but whoever wrote the library didn’t bother with that. Of course on a computer or other any “normal” audio player, the file header is read and any necessary conversion is done so that a variety of formats can be played.
\
…The tricky thing with the ATmega chip is that it doesn’t have a DAC so these libraries use PWM to “fake” the analog. (With an 8-bit DAC, you’d just write-out the raw 8-bit data at the correct sample rate and you’d be done!
BTW - Don’t connect the unfiltered PWM to your stereo system or to a “good amplifier” that you care about! PWM is a “loud” high-frequency/ultrasonic signal (usually 5V from the ATmega chip) and “bad things” can happen.