From 9b6138b7dc3813cee33ede577f56540ddf11d902 Mon Sep 17 00:00:00 2001 From: bordun Date: Mon, 23 Mar 2020 19:23:48 +0100 Subject: [PATCH] eq: tweak, smoothing !! --- src/client/widgets/graphs/eq.js | 13 ++++++++++--- src/client/widgets/graphs/plot.js | 9 +++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/client/widgets/graphs/eq.js b/src/client/widgets/graphs/eq.js index 330a89ae..bee346f9 100644 --- a/src/client/widgets/graphs/eq.js +++ b/src/client/widgets/graphs/eq.js @@ -3,7 +3,7 @@ var {mapToScale} = require('../utils'), Widget = require('../common/widget'), StaticProperties = require('../mixins/static_properties') -class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false}) { +class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smooth:true}) { static description() { @@ -19,7 +19,7 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false}) { filters: {type: 'array', value: '', help: [ 'Each item must be an object with the following properties', - '- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peaking", "bandpass" or "notch")', + '- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch")', '- `freq`: number (filter\'s resonant frequency)', '- `q`: number (Q factor)', '- `gain`: number', @@ -76,6 +76,13 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false}) { setValue() {} + resizeHandle(event){ + + super.resizeHandle(event) + if (this.width !== this.value.length) this.calcResponse() + + } + onPropChanged(propName, options, oldPropValue) { super.onPropChanged(...arguments) @@ -147,7 +154,7 @@ function biquadResponse(options, frequencyHz, filterResponse) { b2 = (1 - K / q + K * K) * norm break - case 'peaking': + case 'peak': if (gain >= 0) { norm = 1 / (1 + 1/q * K + K * K) a0 = (1 + V/q * K + K * K) * norm diff --git a/src/client/widgets/graphs/plot.js b/src/client/widgets/graphs/plot.js index a2c195ff..2e69c818 100644 --- a/src/client/widgets/graphs/plot.js +++ b/src/client/widgets/graphs/plot.js @@ -115,16 +115,17 @@ module.exports = class Plot extends StaticProperties(Canvas, {bypass: true, inte var points = [], padding = this.cssVars.padding + PXSCALE, + decimals = this.getProp('smooth') ? 1 : 0, x, y, i for (i in this.value) { if (this.value[i].length) { - points.push(mapToScale(this.value[i][0], [this.rangeX.min, this.rangeX.max], [padding, this.width - padding], 0, this.logScaleX, true)) - points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], 0, this.logScaleY, true)) + points.push(mapToScale(this.value[i][0], [this.rangeX.min, this.rangeX.max], [padding, this.width - padding], decimals, this.logScaleX, true)) + points.push(mapToScale(this.value[i][1], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], decimals, this.logScaleY, true)) } else { - let nx = mapToScale(i, [0, this.value.length - 1], [padding, this.width - padding], 0, this.logScaleX, true), - ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], 0, this.logScaleY, true) + let nx = mapToScale(i, [0, this.value.length - 1], [padding, this.width - padding], decimals, this.logScaleX, true), + ny = mapToScale(this.value[i], [this.rangeY.min, this.rangeY.max], [this.height - 2 * PXSCALE - padding, 2 * PXSCALE + padding], decimals, this.logScaleY, true) if (x !== nx || y !== ny) { points.push(nx) points.push(ny)