I am attempting to write a program to get the ATmega328P to play audio. I first tried to use this library , but I could not get it to work, so I am now attempting to program my own. The problem is that I don't know how to interpret the audio data that I have:
const unsigned char samples[] PROGMEM = {
128, 128, 128, 130, 129, 127, 127, 128,
127, 127, 128, 130, 128, 126, 125, 125, /* ... additional 26 kilobytes of numbers ... */
};
This is the same data used by the library, and it came from an audio file that had a bitrate of 8 kilobits per second. I then used an executable from a tutorial to extract the data from an MP3.
I first tried to see if these were the frequencies that needed to be played each for 1 thousandth of a second (calculated from the bitrate), but it sounded like static and didn't seem to work.
The wiring is pretty simple, just a transistor with the base going to the output pin and the speaker being controlled by this transistor. I know that this part works because I can output a PWM signal on the pin and it sounds as you would expect.
What is this data and how would I write a program to play it?