context = {
const context = canvas.getContext('2d')
const drawOscilloscope = () => {
context.clearRect(0, 0, canvas.width, canvas.height)
context.beginPath()
for (let x = 0; x < waveform.length; x++) {
const y = (0.5 + waveform[x] / 2) * canvas.height;
if (x === 0) {
context.moveTo(x, y)
} else {
context.lineTo(x, y)
}
}
context.stroke()
requestAnimationFrame(drawOscilloscope)
}
requestAnimationFrame(drawOscilloscope)
return context
}