The finish stuff seems to work for me? I just tried this:
var BUZZER = B4;
var s = atob("f4GBgoODh5GtnmgkE1m435g/MobgzYJbd41YHkHD/7UoEZPysyscl/K5PSqLy5tLToqdfHGdrXI1V7vUeiVIqceEUG2kmWVfj6qIWFuKpZFpXXiXknNthZB9cH6LgG5vgJKSdWF7oZVoXHuRioJ8c3iJjHtweomLf3JygpCHdHOCiYJ8fYCBg4ODgn53d4CGiIZ8cHGAjo1+dn6Jh3pzeoWHfXd8hYd8d3+Gg3t1e4F9d36KiHp0fYZ+cneLlol3cnyEgXt8g4WBeXV8hoqDdnOCjoNxc4aRhnd3f4J6cXmNlIJxd4mKeXJ5iI2Denh9fX1/f4B/g4N2bnuSlYJzdoOIgXp7g4V+dnmDhoF9gIF+eHqDioJyb3+Oi3xzeIOHgXp7gIB+fH+DgHt8hIh/cnOEjoVzb32Mi3pxeYeLf3N2hIqBdXaBhoB7fYSGfXZ7hYeAeXl9goJ9e36BgYGCgoF8e4GDgHp6f4ODgHo=");
var w = new Waveform(s.length);
w.buffer.set(s);
analogWrite(BUZZER, 0.5, {freq:20000});
w.on('finish', function() {
print("Finished!");
});
w.startOutput(BUZZER,2000);
And it prints Finished! when done. There shouldn't be any difference between that and loading from a file though, as the Waveform is exactly the same.
I'm afraid it's not possible to play directly from flash, but you could use double-buffering and read it in chunks very easily.
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.
The finish stuff seems to work for me? I just tried this:
And it prints
Finished!
when done. There shouldn't be any difference between that and loading from a file though, as the Waveform is exactly the same.I'm afraid it's not possible to play directly from flash, but you could use double-buffering and read it in chunks very easily.