Skip to content

Commit a1fcb1a

Browse files
code efficiency improvements
1 parent 87d3028 commit a1fcb1a

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

panel.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,9 @@ class Panel {
226226
for (let i = 1; i <= num_ticks; ++i) {
227227
let tick_amp_pixels = i * pixel_max / num_ticks / this.settings.ampZoom;
228228
// let tick_amp_db = linToDB(tick_amp_pixels, pixel_max);
229-
this.drawHorizontalTick((tick_amp_pixels/pixel_max).toFixed(2), this.halfh - tick_amp_pixels*this.settings.ampZoom,5,"right");
230-
this.drawHorizontalTick((-tick_amp_pixels/pixel_max).toFixed(2), this.halfh + tick_amp_pixels*this.settings.ampZoom,5,"right");
231-
// this.drawHorizontalTick(tick_amp_db.toFixed(1) + 'dBFS', this.halfh - tick_amp_pixels*this.settings.ampZoom,5, "right");
232-
// this.drawHorizontalTick(tick_amp_db.toFixed(1) + 'dBFS', this.halfh + tick_amp_pixels*this.settings.ampZoom,5, "right");
229+
// TODO: bring these back once I figure out why they are so inefficient
230+
// this.drawHorizontalTick((tick_amp_pixels/pixel_max).toFixed(2), this.halfh - tick_amp_pixels*this.settings.ampZoom,5,"right");
231+
// this.drawHorizontalTick((-tick_amp_pixels/pixel_max).toFixed(2), this.halfh + tick_amp_pixels*this.settings.ampZoom,5,"right");
233232
}
234233
// this.drawHorizontalTick('-inf dBFS', this.halfh, 5, "right");
235234
this.drawHorizontalTick('0.00', this.halfh, 5, "right");

slider.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ class Slider {
1414
onEdit() {
1515
this.updateValue();
1616
this.settings.render();
17-
// this.settings.p5.draw();
17+
for (const pObj of this.settings.panelProcessingObjects) {
18+
pObj.redraw();
19+
}
1820
}
1921

2022
resize(x, y, w, p) {

widget.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function getDefaultSettings() {
7171
, render: undefined
7272
, play: playWave
7373
, renderStages : []
74+
, panelProcessingObjects : []
7475
};
7576

7677
settings.render = renderWavesImpl(settings, fft);
@@ -126,13 +127,15 @@ function createWidgets() {
126127
if (id in panelIdLookups) {
127128
const sketch = p => {
128129
p.panelObject = new panelIdLookups[id]();
130+
settings.panelProcessingObjects.push(p);
129131
p.setup = function () {
130132
let canvas = p.createCanvas(450, 300);
131133
p.textAlign(p.CENTER);
132134
canvas.parent(id)
133135
p.panelObject.setup(p, 450, 300, settings);
134136
p.windowResized();
135-
// p.noLoop();
137+
p.noLoop();
138+
p.redraw();
136139
};
137140
p.draw = function () {
138141
p.panelObject.drawPanel();
@@ -162,6 +165,7 @@ function createWidgets() {
162165
p.sliderObject.setup(p, settings);
163166
p.sliderObject.resize(0,0,500,50);
164167
p.sliderObject.onEdit();
168+
p.redraw();
165169
}
166170
}
167171
new p5(sketch, id);

0 commit comments

Comments
 (0)