From 7194376bc8a73e4ee105b85779e0714f422c52a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=A4dorf?= Date: Sat, 8 Jun 2019 21:20:13 +0200 Subject: [PATCH] Fixed volume lines --- src/index.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/index.js b/src/index.js index ab9a899..5af581d 100644 --- a/src/index.js +++ b/src/index.js @@ -57,7 +57,6 @@ async function main() { // analyser.getByteTimeDomainData(self.spectrum); spectrum.reverse(); - const volume = getRMS(spectrum); const pitch = getPitch(spectrum, volume); @@ -93,17 +92,7 @@ async function main() { sketch.colorMode(sketch.HSL, 255); }; - let shouldDraw = 0; - sketch.draw = () => { - shouldDraw += 1; - if (shouldDraw > 0) { - if (shouldDraw > 3) { - shouldDraw = -1; - } - return; - } - sketch.background(sketch.color(0, 0, 0)); for (let l = 0; l < lines.length; l++) { const lineBaseHeight = baseHeight - (l * LINE_MARGIN); @@ -112,14 +101,16 @@ async function main() { sketch.stroke(((line.pitch - minPitch) / (maxPitch - minPitch)) * 255); sketch.strokeWeight(1); sketch.beginShape(); - sketch.curveVertex(0, lineBaseHeight); + sketch.curveVertex(-10, lineBaseHeight); + sketch.curveVertex(-10, lineBaseHeight); sketch.curveVertex(0, lineBaseHeight); for (let i = 1; i < line.spectrum.length - 1; i++) { const point = line.spectrum[i]; sketch.curveVertex(i * spectrumPointWidth, lineBaseHeight - point); } sketch.curveVertex(window.innerWidth, lineBaseHeight); - sketch.curveVertex(window.innerWidth, lineBaseHeight); + sketch.curveVertex(window.innerWidth + 10, lineBaseHeight); + sketch.curveVertex(window.innerWidth + 10, lineBaseHeight); sketch.endShape(); } };