From 7b213bd8b081d3d301b7a0288d030552f36d40df Mon Sep 17 00:00:00 2001 From: "5684185+vsariola@users.noreply.github.com" <5684185+vsariola@users.noreply.github.com> Date: Tue, 15 Oct 2024 23:27:58 +0300 Subject: [PATCH] feat(sointu): display compressor invgain and threshold in dB --- CHANGELOG.md | 1 + patch.go | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbb202b..54da48d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Added +- Compressor displays threshold and invgain in dB - Dragging mouse to select rectangles in the tables - The standalone tracker can open a MIDI port for receiving MIDI notes ([#166][i166]) diff --git a/patch.go b/patch.go index 6b3c79d..a51c0f2 100644 --- a/patch.go +++ b/patch.go @@ -123,8 +123,12 @@ var UnitTypes = map[string]([]UnitParameter){ {Name: "stereo", MinValue: 0, MaxValue: 1, CanSet: true, CanModulate: false}, {Name: "attack", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: compressorTimeDispFunc}, {Name: "release", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: compressorTimeDispFunc}, - {Name: "invgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}, - {Name: "threshold", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true}, + {Name: "invgain", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { + return strconv.FormatFloat(20*math.Log10(128/float64(v)), 'f', 2, 64), "dB" + }}, + {Name: "threshold", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { + return strconv.FormatFloat(20*math.Log10(float64(v)/128), 'f', 2, 64), "dB" + }}, {Name: "ratio", MinValue: 0, MaxValue: 128, CanSet: true, CanModulate: true, DisplayFunc: func(v int) (string, string) { return formatFloat(1 - float64(v)/128), "" }}}, "speed": []UnitParameter{}, "out": []UnitParameter{