I try to play with sounds on my MDBT42Q module. It seems that w.startOutput is not doing anything. Any hint? Furthermore, event 'finish' is never emitted.
My code is below:
(sound.raw is in internal storage and has been generated following the procedure explained here)
BZ=D28;
LS=D29;
var w;
function play() {
var wave = require("Storage").read("sound.raw");
w = new Waveform(wave.length);
w.buffer.set(wave);
analogWrite(BZ, 0.5,{freq:40000} );
w.startOutput(BZ, 4000);
w.on("finish", function(buf) {
BZ.reset();
console.log("done!");
});
}
var inited=false;
function onInit(){
if(!inited)
{
inited=true;
analogWrite(BZ, 0.0,{freq:4000} );
pinMode(LS,'input_pullup');
setWatch("play();", LS, {repeat:true,edge:'rising',debounce:50});
}
}
onInit();
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.
I try to play with sounds on my MDBT42Q module. It seems that
w.startOutput
is not doing anything. Any hint? Furthermore, event 'finish' is never emitted.My code is below:
(sound.raw is in internal storage and has been generated following the procedure explained here)