I have the 1.4 Espruino now and have tried to stream a converted raw file from the sdcard, but all I'm getting is a high pitched whine. I used the code here: http://www.espruino.com/Waveform
var f = E.openFile("1.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);
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.
Hey Gordon,
I have the 1.4 Espruino now and have tried to stream a converted raw file from the sdcard, but all I'm getting is a high pitched whine. I used the code here: http://www.espruino.com/Waveform
var f = E.openFile("1.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);
w.startOutput(A0,11025,{repeat:true});
Any help would be appreciated.
Thanks.