Phase 3 (batch 3): route Volume, AGC-top, WfAGC/WfNF through controller

First sliders through the controller, exercising the FSyncingFromController
re-entrancy guard:
- SetVolume/SetAGCTop clamp, apply to the DSP engine, update band cache,
  and fire OnStateChanged. SetAGCTop reuses ApplyAGCToEngine (the unified
  AGC index->enum mapping), fixing the same bad TWDSPAGCMode(index) cast
  that TrkAGCChange/SyncWebAGCTop used when re-applying AGC on level change.
- OnControllerState updates the slider/label/spectrum (rfAGCTop also
  refreshes the FSpecView AGC line, now consistent for web-initiated
  changes too) and the FSpecView waterfall flags (rfWfAGC/rfWfNF).
- TrkVolumeChange/TrkAGCChange (guarded), SyncWebVolume/AGCTop/WfAGC/WfNF,
  and ApplyWfAGCNF all call the commands.

Builds clean (cocoa).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Uladzimir Karpenka
2026-06-04 14:58:03 +03:00
co-authored by Claude Opus 4.8
parent f76533f209
commit b3e4360a5d
2 changed files with 48 additions and 39 deletions
+24 -34
View File
@@ -1439,6 +1439,20 @@ begin
rfANF: UpdateANFButton;
rfAGCMode:
for i := 0 to 4 do StyleButton(BtnAGCMode[i], i = FController.FAGCMode);
rfVolume:
TrkVolume.Position := FController.FVolume;
rfAGCTop:
begin
TrkAGC.Position := FController.FAGCTop;
LblAGCTop.Caption := Format('%ddB', [FController.FAGCTop]);
FSpecView.AGCTop := FController.FAGCTop;
FSpecView.DrawSpectrum;
PbSpectrum.Invalidate;
end;
rfWfAGC:
FSpecView.WfAGCEnabled := FController.FWfAGCEnabled;
rfWfNF:
FSpecView.WfNFEnabled := FController.FWfNFEnabled;
end;
finally
FSyncingFromController := False;
@@ -5945,10 +5959,8 @@ end;
procedure TMainForm.ApplyWfAGCNF(WfAGC, WfNF: Boolean);
begin
FController.FWfAGCEnabled := WfAGC;
FController.FWfNFEnabled := WfNF;
FSpecView.WfAGCEnabled := FController.FWfAGCEnabled;
FSpecView.WfNFEnabled := FController.FWfNFEnabled;
FController.SetWfAGC(WfAGC);
FController.SetWfNF(WfNF);
end;
procedure TMainForm.ApplyADCSettings(Dither, Random: Boolean);
@@ -6301,15 +6313,7 @@ end;
procedure TMainForm.SyncWebAGCTop;
begin
FController.FAGCTop := Max(20, Min(120, FWebSyncInt));
TrkAGC.Position := FController.FAGCTop;
LblAGCTop.Caption := Format('%ddB', [FController.FAGCTop]);
if FController.FWDSPReady then
begin
FController.FDSPEngine.SetAGCTop(FController.FAGCTop);
FController.FDSPEngine.SetAGC(TWDSPAGCMode(FController.FAGCMode), 50.0);
end;
FController.FBandCache[FController.FCurrentBand].AGCTop := FController.FAGCTop;
FController.SetAGCTop(FWebSyncInt); // клампит, применяет, OnControllerState обновит UI
end;
procedure TMainForm.WebOnBand(Idx: Integer);
@@ -6386,9 +6390,7 @@ end;
procedure TMainForm.SyncWebVolume;
begin
FController.FVolume := Max(0, Min(100, FWebSyncInt));
TrkVolume.Position := FController.FVolume;
if FController.FWDSPReady then FController.FDSPEngine.SetVolume(FController.FVolume / 100.0);
FController.SetVolume(FWebSyncInt);
end;
procedure TMainForm.WebOnWfAGC(On_: Boolean);
@@ -6400,8 +6402,7 @@ end;
procedure TMainForm.SyncWebWfAGC;
begin
FController.FWfAGCEnabled := FWebSyncBool;
FSpecView.WfAGCEnabled := FController.FWfAGCEnabled;
FController.SetWfAGC(FWebSyncBool);
end;
procedure TMainForm.WebOnWfNF(On_: Boolean);
@@ -6413,8 +6414,7 @@ end;
procedure TMainForm.SyncWebWfNF;
begin
FController.FWfNFEnabled := FWebSyncBool;
FSpecView.WfNFEnabled := FController.FWfNFEnabled;
FController.SetWfNF(FWebSyncBool);
end;
// ── Run ────────────────────────────────────────────────────────────────────
@@ -7229,9 +7229,8 @@ end;
procedure TMainForm.TrkVolumeChange(Sender: TObject);
begin
FController.FVolume := TrkVolume.Position;
if FController.FWDSPReady then
FController.FDSPEngine.SetVolume(FController.FVolume / 100.0);
if FSyncingFromController then Exit;
FController.SetVolume(TrkVolume.Position);
end;
// ===========================================================================
@@ -7293,17 +7292,8 @@ end;
procedure TMainForm.TrkAGCChange(Sender: TObject);
begin
FController.FAGCTop := TrkAGC.Position;
LblAGCTop.Caption := Format('%ddB', [FController.FAGCTop]);
if FController.FWDSPReady then
begin
FController.FDSPEngine.SetAGCTop(FController.FAGCTop);
FController.FDSPEngine.SetAGC(TWDSPAGCMode(FController.FAGCMode), 50.0);
end;
FController.FBandCache[FController.FCurrentBand].AGCTop := FController.FAGCTop;
FSpecView.AGCTop := FController.FAGCTop;
FSpecView.DrawSpectrum;
PbSpectrum.Invalidate;
if FSyncingFromController then Exit;
FController.SetAGCTop(TrkAGC.Position);
end;
// ===========================================================================