summaryrefslogtreecommitdiff
path: root/tools/mq_editor/viewer.js
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-17 21:01:56 +0100
committerskal <pascal.massimino@gmail.com>2026-02-17 21:01:56 +0100
commitfbdfa2a7b54894a565fd57d5e27f19d752fe39fa (patch)
tree08c1d0bbb9b57b887ed2adc4c4c4d4eb81bef08e /tools/mq_editor/viewer.js
parent65ed044d4785a3666deb711b9dd964abb28f810c (diff)
clean-up pass mq-partials
Diffstat (limited to 'tools/mq_editor/viewer.js')
-rw-r--r--tools/mq_editor/viewer.js12
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/mq_editor/viewer.js b/tools/mq_editor/viewer.js
index 451421d..c57d693 100644
--- a/tools/mq_editor/viewer.js
+++ b/tools/mq_editor/viewer.js
@@ -157,6 +157,7 @@ class SpectrogramViewer {
// Draw frequency bins
const numBins = fftSize / 2;
const binFreqWidth = sampleRate / fftSize;
+ const freqNorm = 1. / (this.freqEnd - this.freqStart);
for (let bin = 0; bin < numBins; ++bin) {
const freq = bin * binFreqWidth;
@@ -171,16 +172,16 @@ class SpectrogramViewer {
const normalized = (magDB + 80) / 80;
const clamped = Math.max(0, Math.min(1, normalized));
// Power law for better peak visibility
- const intensity = Math.pow(clamped, 0.3);
+ const intensity = Math.pow(clamped, 2.);
- const freqNorm0 = (freq - this.freqStart) / (this.freqEnd - this.freqStart);
- const freqNorm1 = (freqNext - this.freqStart) / (this.freqEnd - this.freqStart);
+ const freqNorm0 = (freq - this.freqStart) * freqNorm;
+ const freqNorm1 = (freqNext - this.freqStart) * freqNorm;
const y0 = Math.floor(height - freqNorm1 * height);
const y1 = Math.floor(height - freqNorm0 * height);
const binHeight = Math.max(1, y1 - y0);
const color = this.getSpectrogramColor(intensity);
- ctx.fillStyle = `rgba(${color.r},${color.g},${color.b},0.5)`;
+ ctx.fillStyle = `rgba(${color.r},${color.g},${color.b}, 0.5)`;
ctx.fillRect(xStart, y0, frameWidth, binHeight);
}
}
@@ -449,8 +450,7 @@ class SpectrogramViewer {
// Normalize to [0, 1]
const normalized = (magDB + 80) / 80;
- const clamped = Math.max(0, Math.min(1, normalized));
- const intensity = Math.pow(clamped, 0.3);
+ const intensity = Math.max(0, Math.min(1, normalized));
const barHeight = intensity * height;
const x = i * barWidth;