eventsTrack = colors.on('track', function(event) {
if(recording) {
var context = document.getElementById("canvas").getContext("2d");
context.globalCompositeOperation = "source-over" ;
event.data.forEach(function(rect) {
if( rect.height > (context.canvas.height/6)) {
context.beginPath();
context.fillStyle = "#00000033";
context.strokeStyle = "#00000033";
context.lineWidth = "12";
const pad = 0;
context.moveTo(rect.x - pad, rect.y + (rect.height/2));
const maxRadius = (pad/2) +(rect.height/2 + rect.width/2)/2;
context.arcTo(rect.x -pad, rect.y -pad, rect.x + (rect.width/2), rect.y -pad, maxRadius);
context.arcTo(rect.x + rect.width +pad, rect.y -pad, rect.x + rect.width +pad, rect.y + (rect.height/2), maxRadius);
context.arcTo(rect.x + rect.width +pad, rect.y + rect.height +pad, rect.x + (rect.width/2), rect.y + rect.height +pad, maxRadius);
context.arcTo(rect.x - pad, rect.y + rect.height +pad, rect.x -pad, rect.y + (rect.height/2), maxRadius);
context.lineTo(rect.x - pad, rect.y + (rect.height/2));
}
});
context.globalCompositeOperation = "lighten";
event.data.forEach(function(rect) {
if( rect.height > (context.canvas.height/6)) context.drawImage(spectrogram, rect.x +(rect.width/2) - (rect.height/6), rect.y +(rect.height/2) - (rect.width * 1), rect.height/3, rect.width * 2);
});
}
});