var f = E.openFile("Horse-Angry.raw","r");
var w = new Waveform(2048, {doubleBuffer:true});
// load first bits of sound file
w.buffer.set(f.read(w.buffer.length));
w.buffer2.set(f.read(w.buffer.length));
var fileBuf = f.read(w.buffer.length);
// when one buffer finishes playing, load the next one
w.on("buffer", function(buf) {
buf.set(fileBuf);
fileBuf = f.read(buf.length);
if (fileBuf===undefined) w.stop(); // end of file
});
// start output
analogWrite(A0, 0.5, {freq:40000});
w.startOutput(A0,11025,{repeat:true});
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
First I convert my file in Audacity 3.0.2. from mp3 to 16-bit PCM. Then make it mono, next decrease the rate down to 4000Hz, after that i export it and choose "Other Uncompressed files" then Choose "RAW (header-less)" and "Unsigned 8 bit PCM".
https://drive.google.com/file/d/1aRwviRZEjG6knpzrJkVbDOXAP0abKiZw/view?usp=sharing
https://drive.google.com/file/d/1aNGuXnGg5EVnTYrk8ywcDBUFvIZ2gBli/view?usp=sharing
After that I use this converter
https://www.espruino.com/File+Converter
and choose .raw file I've just created. In converter select window I choose base64, then I save code
converted there to TF card.
https://drive.google.com/file/d/1ekp6Or4iBGBYjUQfUsEeYlxw1mUJGt2U/view?usp=sharing
Next use this code
to play it.