@ -13,14 +13,20 @@ var page_spectrogram = (function () {
dy:1
};
varopts={
interval:0,
sampCount:0,
binCount:0,
freq:0
};
varinterval=1000;
varrunning=false;
varreadTimeout;// timer
varreadoutPending;
varreadXhr;
varsampCount=1024;
varbinCount=sampCount/2;
varlastLoadMs;
varcolormap={
r:[
@ -83,9 +89,10 @@ var page_spectrogram = (function () {
functiondrawSg(col){
shiftSg();
for(vari=0;i<binCount;i++){
varbc=opts.sampCount/2;
for(vari=0;i<bc;i++){
// resolve color from the value
vary=binCount-i;
vary=bc-i-1;
varclr;
if(i>col.length){
@ -109,17 +116,17 @@ var page_spectrogram = (function () {
// display
drawSg(j.samples);
}else{
errorMsg("Sampling failed.");
errorMsg("Sampling failed.",1000);
}
}catch(e){
errorMsg(e);
}
}else{
errorMsg("Request failed.");
errorMsg("Request failed.",1000);
}
if(running)
readTimeout=setTimeout(requestData,interval);// TODO should actually compute time remaining, this adds interval to the request time.
readTimeout=setTimeout(requestData,Math.max(0,opts.interval-msElapsed(lastLoadMs)));// TODO should actually compute time remaining, this adds interval to the request time.
}
functionrequestData(){
@ -128,11 +135,13 @@ var page_spectrogram = (function () {