Skip to content

Commit

Permalink
Merge branch 'daksh4469-main4' of https://github.com/daksh4469/musicb…
Browse files Browse the repository at this point in the history
…locks into daksh4469-daksh4469-main4
  • Loading branch information
walterbender committed Feb 24, 2021
2 parents 84adb74 + 56ce59b commit 4f242db
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions js/widgets/oscilloscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,26 @@
*/

/* global _, SMALLERBUTTON, BIGGERBUTTON, Tone, instruments */

/*
Globals location
- js/artwork.js
SMALLERBUTTON,BIGGERBUTTON
- js/utils/utils.js
_
- js/activity.js
Tone
- js/utils/synthutils.js
instruments
*/
/* exported Oscilloscope */

/**
* @class
* @classdesc pertains to setting up all features of the Oscilloscope Widget.
*/
class Oscilloscope {
static ICONSIZE = 32;
static ICONSIZE = 40;
static analyserSize = 8192;
/**
* @constructor
Expand Down Expand Up @@ -54,27 +65,28 @@ class Oscilloscope {
this.pitchAnalysers = {};
widgetWindow.destroy();
};

document.getElementsByClassName("wfbToolbar")[0].style.backgroundColor = "#e8e8e8";
document.getElementsByClassName("wfbWidget")[0].style.backgroundColor = "#FFFFFF";
const step = 10;
this.zoomFactor = 40.0;
this.verticalOffset = 0;
const zoomInButton = widgetWindow.addButton("", Oscilloscope.ICONSIZE, _("ZOOM IN"));
const zoomInButton = widgetWindow.addButton("", Oscilloscope.ICONSIZE, _("Zoom In"));

zoomInButton.onclick = () => {
this.zoomFactor += step;
};
zoomInButton.children[0].src = `data:image/svg+xml;base64,${window.btoa(
unescape(encodeURIComponent(SMALLERBUTTON))
unescape(encodeURIComponent(BIGGERBUTTON))
)}`;

const zoomOutButton = widgetWindow.addButton("", Oscilloscope.ICONSIZE, _("ZOOM OUT"));
const zoomOutButton = widgetWindow.addButton("", Oscilloscope.ICONSIZE, _("Zoom Out"));

zoomOutButton.onclick = () => {
this.zoomFactor -= step;
};

zoomOutButton.children[0].src = `data:image/svg+xml;base64,${window.btoa(
unescape(encodeURIComponent(BIGGERBUTTON))
unescape(encodeURIComponent(SMALLERBUTTON))
)}`;

widgetWindow.sendToCenter();
Expand Down Expand Up @@ -132,7 +144,7 @@ class Oscilloscope {
this.drawVisualIDs[turtleIdx] = requestAnimationFrame(draw);
if (!turtle.running) return;

canvasCtx.fillStyle = "rgb(200, 200, 200)";
canvasCtx.fillStyle = "#FFFFFF";
const dataArray = this.pitchAnalysers[turtleIdx].getValue();
const bufferLength = dataArray.length;
canvasCtx.fillRect(0, 0, width, height);
Expand Down

0 comments on commit 4f242db

Please sign in to comment.