@ -13,14 +13,20 @@ var page_spectrogram = (function () {
dy:1
dy:1
};
};
varopts={
interval:0,
sampCount:0,
binCount:0,
freq:0
};
varinterval=1000;
varinterval=1000;
varrunning=false;
varrunning=false;
varreadTimeout;// timer
varreadTimeout;// timer
varreadoutPending;
varreadoutPending;
varreadXhr;
varreadXhr;
varsampCount=1024;
varlastLoadMs;
varbinCount=sampCount/2;
varcolormap={
varcolormap={
r:[
r:[
@ -83,9 +89,10 @@ var page_spectrogram = (function () {
functiondrawSg(col){
functiondrawSg(col){
shiftSg();
shiftSg();
for(vari=0;i<binCount;i++){
varbc=opts.sampCount/2;
for(vari=0;i<bc;i++){
// resolve color from the value
// resolve color from the value
vary=binCount-i;
vary=bc-i-1;
varclr;
varclr;
if(i>col.length){
if(i>col.length){
@ -109,17 +116,17 @@ var page_spectrogram = (function () {
// display
// display
drawSg(j.samples);
drawSg(j.samples);
}else{
}else{
errorMsg("Sampling failed.");
errorMsg("Sampling failed.",1000);
}
}
}catch(e){
}catch(e){
errorMsg(e);
errorMsg(e);
}
}
}else{
}else{
errorMsg("Request failed.");
errorMsg("Request failed.",1000);
}
}
if(running)
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(){
functionrequestData(){
@ -128,11 +135,13 @@ var page_spectrogram = (function () {