I am using the Mega 2560 and am attempting to play a custom mp3 file converted into a bunch of numbers on a speaker attached to Arduino directly using PCM. I loaded up the playback example given with the PCM.h library. When I upload the script, however, I hear nothing. The speaker is attached to the DIGITAL- GND(black wire) and the DIGITAL 11~(red wire). The speaker works with simple tone() script songs. I hear nothing with the default numbers from the example, I have not implemented my own.
Here is the code from the example project, I had to remove over half of the numbers due to the 9000 letter limit per post. Please download the library PCM and open the example project to get the full thing. (when running, it should say a name for 3 seconds)
#include <PCM.h>
const unsigned char sample[] PROGMEM = {
126, 127, 128, 128, 128, 128, 128, 127, 128, 128, 128, 129, 129, 128, 127, 128, 128, 127, 126, 127, 128, 129, 128, 127, 126, 127, 128, 128, 126, 126, 127, 127, 127, 127, 127, 127, 126, 127, 129, 130, 129, 128, 126, 126, 126, 126, 127, 129, 130, 129, 127, 127, 127, 127, 128, 128, 128, 128, 127, 127, 127, 127, 127, 127, 128, 130, 131, 129, 127, 126, 126, 126, 127, 127, 128, 128, 128, 128, 127, 128, 128, 127, 127, 128, 128, 130, 130, 129, 126, 125, 127, 129, 130, 129, 128, 126, 125, 126, 129, 131, 131, 127, 123, 125, 129, 131, 130, 128, 129, 130, 130, 129, 127, 127, 128, 130, 129, 128, 126, 125, 126, 129, 131, 130, 128, 128, 128, 126, 125, 126, 128, 129, 128, 125, 125, 127, 129, 129, 129, 129, 127, 124, 123, 125, 128, 128, 126, 125, 125, 127, 129, 127, 126, 127, 128, 129, 129, 127, 124, 121, 123, 127, 130, 130, 128, 124, 122, 123, 127, 130, 131, 129, 125, 122, 122, 126, 128, 128, 128, 125, 123, 121, 118, 114, 111, 112, 113, 112, 109, 106, 107, 112, 117, 115, 111, 108, 109, 111, 112, 115, 116, 115, 112, 109, 107, 110, 114, 116, 115, 116, 117, 118, 118, 118, 117, 116, 115, 113, 110, 109, 111, 111, 111, 111, 114, 116, 115, 112, 110, 111, 113, 113, 110, 108, 110, 115, 117, 116, 114, 114, 114, 114, 113, 112, 113, 116, 116, 116, 116, 118, 119, 120, 121, 123, 124, 123, 119, 114, 112, 115, 118, 120, 122, 123, 123, 119, 116, 118, 124, 131, 130, 122, 116, 117, 123, 128, 132, 133, 131, 126, 121, 117, 117, 120, 124, 125, 123, 120, 118, 120, 125, 129, 128, 124, 120, 116, 115, 118, 123, 126, 125, 121, 117,
};
void setup()
{
startPlayback(sample, sizeof(sample));
}
void loop()
{
}
Extra Notes: I am following the guide (dev-notes/wavFilesWithoutSdCard.md at master · charliegerard/dev-notes · GitHub)
Conclusion reached: The sound would be extremely low quality and no longer than a couple seconds due to multiple factors(see post 7,8)