Save a binary
This does NOT work, because you need to encode the wave file.
But there's a lib that does that:
https://github.com/mattdiamond/Recorderjs
HTML
<a id="a1" download="test.wav" type="audio/wav">file</a>
JavaScript
var
buffer = new ArrayBuffer(8) // allocates 8 bytes
, data = new DataView(buffer)
;
// You can write uint8/16/32s and float32/64s to dataviews
data.setUint8 (0, 0x01);
data.setUint16(1, 0x2345);
data.setUint32(3, 0x6789ABCD);
data.setUint8 (7, 0xEF);
saveAs(new Blob([buffer], {type: "example/binary"}), "data.dat");
var aaa = btoa(data);
console.log(aaa);
var a = document.getElementById('a1');
console.log(a)
a.href = "data:audio/wav;base64,"+btoa(data)
console.log(a.href)