From 24a618bf0b975b0c9aae19544ba5fb9d60d309a6 Mon Sep 17 00:00:00 2001 From: jberg Date: Tue, 14 Aug 2018 18:46:03 -0700 Subject: [PATCH] fix oscilloscope amplitude and direction (#629) --- js/components/Visualizer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/components/Visualizer.js b/js/components/Visualizer.js index 67b0d807..33ca70a7 100644 --- a/js/components/Visualizer.js +++ b/js/components/Visualizer.js @@ -226,8 +226,8 @@ class Visualizer extends React.Component { // Iterate over the width of the canvas in "real" pixels. for (let j = 0; j <= this._renderWidth(); j++) { const amplitude = sliceAverage(this.dataArray, sliceWidth, j); - const percentAmplitude = (amplitude - 128) / 128; // dataArray gives us bytes - const y = percentAmplitude * h + h / 2; // center wave at half height + const percentAmplitude = amplitude / 255; // dataArray gives us bytes + const y = (1 - percentAmplitude) * h; // flip y const x = j * PIXEL_DENSITY; // Canvas coordinates are in the middle of the pixel by default.