Fix heat map scaling, add per-channel amplifier

- Add per-channel amplifier (0-100, 1.0x to 10.0x) applied to intensity
  before limiter gates strength
- Fix heat map scaling: use LimitScaleA/B (valA/DesiredA ratio) instead
  of valA/200 — was capping colors at green, never reaching orange
- Scale heat map intensity by limiter ratio so colors reflect actual
  output after limiter
- Remove dead LastIntensityA/B field (replaced by heat map scaling)
- Amp trackbars: 0=1.0x, 100=10.0x, integer value labels
- Close button quits app instead of hiding to tray
This commit is contained in:
2026-08-09 11:55:16 +00:00
parent 4ad85f57ec
commit 4e36580b22
2 changed files with 119 additions and 10 deletions
+37 -6
View File
@@ -17,7 +17,7 @@ public class State
public int ActualA, ActualB;
public int LastSentA, LastSentB;
public int LastIntensityA, LastIntensityB;
public double LimitScaleA, LimitScaleB;
public byte[]? LastFreqA, LastIntA, LastFreqB, LastIntB;
public bool LastActiveA, LastActiveB;
@@ -26,6 +26,8 @@ public class State
public LimitMode LimitModeA = LimitMode.Clamp;
public LimitMode LimitModeB = LimitMode.Clamp;
public bool SwapChannels;
public double AmpA = 1.0;
public double AmpB = 1.0;
public void SetLimitA(int max, LimitMode mode)
{
@@ -47,6 +49,24 @@ public class State
}
}
public void SetAmpA(double amp)
{
lock (Lock)
{
AmpA = Math.Clamp(amp, 0.1, 10.0);
DirtyA = true;
}
}
public void SetAmpB(double amp)
{
lock (Lock)
{
AmpB = Math.Clamp(amp, 0.1, 10.0);
DirtyB = true;
}
}
public bool IsSignaling
{
get
@@ -115,20 +135,31 @@ public class State
var valB = ApplyLimit(DesiredB, MaxB, LimitModeB);
LastSentA = valA;
LastSentB = valB;
LimitScaleA = DesiredA > 0 ? (double)valA / DesiredA : 0;
LimitScaleB = DesiredB > 0 ? (double)valB / DesiredB : 0;
DirtyA = false;
DirtyB = false;
bool hasA = !StreamA.IsEmpty || (LoopFreqA != null && LoopIntA != null);
bool hasB = !StreamB.IsEmpty || (LoopFreqB != null && LoopIntB != null);
var (freqA, intA) = PopWave(StreamA, LoopFreqA, LoopIntA);
var (freqB, intB) = PopWave(StreamB, LoopFreqB, LoopIntB);
var (freqA, intARaw) = PopWave(StreamA, LoopFreqA, LoopIntA);
var (freqB, intBRaw) = PopWave(StreamB, LoopFreqB, LoopIntB);
// Apply amplifier to intensity, clamp to 0-100
var ampA = AmpA;
var ampB = AmpB;
var intA = new byte[4];
var intB = new byte[4];
for (int i = 0; i < 4; i++)
{
intA[i] = (byte)Math.Clamp((int)Math.Round(intARaw[i] * ampA), 0, 100);
intB[i] = (byte)Math.Clamp((int)Math.Round(intBRaw[i] * ampB), 0, 100);
}
LastActiveA = hasA;
LastActiveB = hasB;
LastFreqA = freqA; LastIntA = intA;
LastFreqB = freqB; LastIntB = intB;
LastIntensityA = hasA ? (intA[0] + intA[1] + intA[2] + intA[3]) / 4 : 0;
LastIntensityB = hasB ? (intB[0] + intB[1] + intB[2] + intB[3]) / 4 : 0;
if (SwapChannels)
{
@@ -140,7 +171,7 @@ public class State
(LastFreqA, LastFreqB) = (LastFreqB, LastFreqA);
(LastIntA, LastIntB) = (LastIntB, LastIntA);
(LastActiveA, LastActiveB) = (LastActiveB, LastActiveA);
(LastIntensityA, LastIntensityB) = (LastIntensityB, LastIntensityA);
(LimitScaleA, LimitScaleB) = (LimitScaleB, LimitScaleA);
}
return (modeA, valA, modeB, valB, freqA, intA, freqB, intB);