eq: tweak, smoothing !!

This commit is contained in:
bordun 2020-03-23 19:23:48 +01:00
parent 5372580b0a
commit 987f12bdd0
2 changed files with 15 additions and 7 deletions

View file

@ -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

View file

@ -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)