fix TUN tone frequency sign for LSB/CWL modes

gen1 (TXA PostGen) sits after all modulators and the bandpass filter,
so a positive frequency always produces a tone above the carrier.
For LSB and CWL the tone must appear below the carrier — negate the
frequency for those modes. Also re-apply the tone when mode is switched
while TUN is active.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-10 17:02:43 +03:00
co-authored by Claude Sonnet 4.6
parent 7a0b778114
commit 604fd836ba
2 changed files with 15 additions and 1 deletions
+5
View File
@@ -4352,7 +4352,12 @@ begin
FMode := N; FMode := N;
for i := 0 to MODE_COUNT - 1 do StyleButton(BtnMode[i], i = FMode); for i := 0 to MODE_COUNT - 1 do StyleButton(BtnMode[i], i = FMode);
if FWDSPReady then if FWDSPReady then
begin
FDSPEngine.SetMode(N); FDSPEngine.SetMode(N);
// Если TUN активен — пересчитываем знак частоты под новый режим
if FTuning then
FDSPEngine.SetTXTone(True, FTXSettings.TUNFreq, 1.0);
end;
UpdateFilterButtons; // обновляем подписи и дефолт фильтра под новый режим UpdateFilterButtons; // обновляем подписи и дефолт фильтра под новый режим
ApplyModeFilter; ApplyModeFilter;
SyncSpecViewFreq; // FSpecView.Mode/FilterBW — иначе полоса рисуется под старый режим SyncSpecViewFreq; // FSpecView.Mode/FilterBW — иначе полоса рисуется под старый режим
+10 -1
View File
@@ -1595,12 +1595,21 @@ begin
end; end;
procedure TWDSPEngine.SetTXTone(Enabled: Boolean; FreqHz, Mag: Double); procedure TWDSPEngine.SetTXTone(Enabled: Boolean; FreqHz, Mag: Double);
var
SignedFreq: Double;
begin begin
if not FInitialized then Exit; if not FInitialized then Exit;
if Enabled then if Enabled then
begin begin
// gen1 (PostGen) стоит после всех модуляторов и бандпасса.
// Положительная частота даёт тон ВЫШЕ несущей (USB-сторона).
// Для LSB и CWL нужен тон НИЖЕ несущей — инвертируем знак.
if (FMode = MODE_LSB) or (FMode = MODE_CWL) then
SignedFreq := -Abs(FreqHz)
else
SignedFreq := Abs(FreqHz);
SetTXAPostGenMode(TXA_CHAN, 0); // 0 = tone SetTXAPostGenMode(TXA_CHAN, 0); // 0 = tone
SetTXAPostGenToneFreq(TXA_CHAN, FreqHz); SetTXAPostGenToneFreq(TXA_CHAN, SignedFreq);
SetTXAPostGenToneMag(TXA_CHAN, Max(0.0, Min(1.0, Mag))); SetTXAPostGenToneMag(TXA_CHAN, Max(0.0, Min(1.0, Mag)));
SetTXAPostGenRun(TXA_CHAN, 1); SetTXAPostGenRun(TXA_CHAN, 1);
end else end else