Adding the two results for one seconds works better for me with 200Hz test.
var p=0, sBuff=new Uint8Array(2), sN=new Uint8Array(2);
function soundTest() {
var w = new Waveform(512,{doubleBuffer:true,bits:16});
var a = new Uint16Array(512);
w.on("buffer", function(buf) {
a.set(buf);
E.FFT(a);
var m=0,n=-1;
for (var i=50;i<250;i++)if(a[i]>n)n=a[m=i];
sBuff[p]=m;
sN[p]=n;
if(p==1){
var avgF=E.sum(sBuff);
var nAvg=E.sum(sN);
console.log(avgF+"Hz @ "+nAvg);
p=0;
} else {
p=1;
}
});
w.startInput(D2,1024,{repeat:true});
}
Do you know what is the accuracy loss on doubling the input sound compared to the buffer we have for processing ?
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.
Hi @Gordon,
Adding the two results for one seconds works better for me with 200Hz test.
Do you know what is the accuracy loss on doubling the input sound compared to the buffer we have for processing ?