diff options
Diffstat (limited to 'tools/mq_editor/viewer.js')
| -rw-r--r-- | tools/mq_editor/viewer.js | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/mq_editor/viewer.js b/tools/mq_editor/viewer.js index d7b5ac1..1bc5fc9 100644 --- a/tools/mq_editor/viewer.js +++ b/tools/mq_editor/viewer.js @@ -109,7 +109,7 @@ class SpectrogramViewer { // DB value -> normalized intensity [0..1], relative to cache maxDB over 80dB range normalizeDB(magDB, maxDB) { - return Math.max(0, Math.min(1, (magDB - (maxDB - 80)) / 80)); + return clamp((magDB - (maxDB - 80)) / 80, 0, 1); } // Partial index -> display color @@ -643,8 +643,8 @@ class SpectrogramViewer { const {x, y} = getCanvasCoords(e, canvas); if (this.dragState) { - const t = Math.max(0, Math.min(this.t_max, this.canvasToTime(x))); - const v = Math.max(this.freqStart, Math.min(this.freqEnd, this.canvasToFreq(y))); + const t = clamp(this.canvasToTime(x), 0, this.t_max); + const v = clamp(this.canvasToFreq(y), this.freqStart, this.freqEnd); const partial = this.partials[this.selectedPartial]; const i = this.dragState.pointIndex; partial.freqCurve['t' + i] = t; |
