Pre-roll bug: when MIC_PREROLL_SAMP is an exact multiple of OPUS_FRAME_SAMP
(1920/960=2), the N<=Want branch filled the buffer but never flushed it,
losing the first 40ms of audio and leaving the ring empty long enough for
silence blocks to be injected into WDSP.
StallCount threshold raised from 2 to 4 (~43ms) to cover OS scheduler
jitter of up to 22ms, preventing false silence injection when an Opus
frame arrives slightly late relative to the DSP tick.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Opus decodes 960 samples per frame; the TX DSP thread consumes
512-sample blocks. 960 mod 512 = 448, so the ring always kept a
sub-threshold tail, causing TTXDSPThread to skip ticks and starve
the DUC hardware every ~20 ms.
FlushMicToCallback accumulates samples in FMicStageBuf and calls
FOnWebMic only when a full 512-sample block is ready. The remainder
stays in the buffer until the next Opus frame arrives. This ensures
FTXMicRing always receives data in multiples of 512, eliminating
the 0 < Avail < 512 dead-zone entirely.
FMicStageLen is reset together with FMicPreRollPos on new TX session
to prevent stale samples from a previous session mixing in.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WebOnMic: drop intermediate Singles[] array, read PSingle directly.
PushAudio: replace per-frame SetLength/array of Byte with pre-allocated
FWsAudioBuf field — eliminates heap allocation from the DSP thread.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove manual "Mic Source" (Radio/SoundCard) setting from UI and storage;
source is now determined automatically in ApplyMOX: HW PTT → txmsRadio,
MOX button/CAT → txmsSoundCard if audio device configured, else txmsRadio
- Replace "Line in" checkbox with "Mic jack" combo (Mic In / Line In);
when Line In is selected, Mic Boost is hidden and Line In Gain (-34.5..+12 dB,
step 1.5 dB) is shown and sent as DUC Specific byte 51
- Add Tip/Ring connector selector (Orion/OrionMkII boards 4/5 only, byte 50 bit 3);
control is hidden for other board types
- Fix byte 50 bit 1 (Mic Boost) suppressed when Line In is active
- Fix byte 51 comment polarity (was reversed: 0=+12dB; correct: 0=-34.5dB)
- New JSON fields: mic_line_in, mic_tip_ring, line_in_gain_db; mic_source removed
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
WebPageHtml.pas:
- Add MIC gain slider (0..300%) with localStorage persistence; inserts
Web Audio GainNode between MediaStreamSource and Opus encoder.
- Disable autoGainControl in getUserMedia so the manual gain actually works.
- Pre-create+resume AudioContext synchronously inside the MOX click handler
(before any await) so user-gesture context isn't lost during getUserMedia
on macOS/Android.
- Call startTXMic() from the click handler too — the call from applyState
runs in a WS-message context which mobile browsers reject.
- Re-resume txMicACtx on every MOX→TX (Android can suspend it between
cycles) and reuse the existing context instead of recreating per session.
- stopTXMic now a no-op: the previous flag reset created a race that spun
up duplicate pipelines on rapid RX→TX toggles.
WebServer.pas:
- Pre-roll cushion: hold first 40ms of decoded mic samples before flushing
to FTXMicRing, raising steady-state ring depth from ~9ms to ~50ms so
WiFi jitter no longer drains the buffer into silence ("robotic" voice).
- Wall-clock-based Opus PLC: synthesize up to 5 frames via
opus_decode_float(NULL) when packet gap exceeds expected 20ms cadence.
- A gap > 200ms is treated as a new TX session: pre-roll resets, PLC
is skipped (no useful decoder state).
- Local (non-web) mic paths are untouched — they bypass WebOnMic entirely.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
UserADC1 (bytes 55-56) carries current sensor data on the ANAN-8000DLE.
Formula from Thetis: amps = ((adc/4095 * 5000) - 360) / 120 (Voff=360mV,
Sens=120mV/A). Status bar now shows "Supply: 13.8V / 2.3A | PLL OK"
when current is available.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PA calibration per band (HF and VHF):
- Add VHFBandCal[0..7] in TGlobalSettings (saved as vhf_cal_0..7 in JSON)
- Default HF cal updated to Thetis HERMES defaults (38.8-41.3 dB per band)
- Default VHF cal = 56.2 dB (Thetis HERMES XVTR default)
- SettingsForm: second group in PA tab "VHF Calibration (Transverters)" with
8 spinboxes VHF0..VHF7; labels dynamically show XVTR slot ButtonText
when LoadXvtrSettings is called (e.g. "VHF0 (2m):")
TX drive formula (CalcDriveByte) rewritten to match Thetis exactly:
drive_byte = min(sqrt(10^((10*log10(pwr_W*1000) - Cal)/10) * 0.05) / 0.8, 1.0) * 1.02 * 255
Cal = PA gain in dB (not a percentage); matches Thetis verified output
(Cal=63.1 + slider=100% + PAMax=100W → drive_byte=16, verified against Thetis)
Old formula Pos/100*Cal/100*255 was wrong: treated dB gain as linear percent
Fix stale FDriveLevel not updated on band/XVTR switch:
- Startup: FCurrentBand must be set before CalcDriveByte (was reversed)
- RestoreBand: recalculate FDriveLevel before ApplyVfoA network update
- ActivateXvtrBand: recalculate after FCurrentXvtr changes
- ApplyVfoA: recalculate when VFO crosses HF band boundary
- FreqDispBChanged: same for VFO-B band changes
- ApplyMOX(True): safety recalculate at PTT engage time
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Web UI: stepSel.onchange now sends fm_step command to server when in FM
mode; option values stay in Hz so tuneStep works unchanged.
WebServer: add fm_step command handler and OnFMStep callback.
MainForm: wire WebOnFMStep -> SyncWebFMStep -> SetFMStep + SaveCurrentBand.
Web spectrum/ruler: vertical FM-step grid lines in drawSpec; FM-aligned
ticks and labels in drawRuler with auto label-density (short ticks between
labeled lines, measureText-based labelMult to prevent overlap).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When FM mode is active, vertical grid lines and frequency labels snap to
FM channel boundaries (FM_STEP_HZ) instead of the fixed 8-division layout.
Grid and label density auto-adapt: lines thinner than 4px are thinned,
labels are spaced so they never overlap (short tick shown between labeled
lines). Grid cache invalidates on center-freq, step, or span changes.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add LastCTun, LastAGCMode, LastAGCTop to TXvtrEntry; SaveCurrentBand
now captures all three in the XVTR branch; ActivateXvtrBand restores
them on slot switch/startup (previously CTun was always reset to False
and AGC was never saved/restored for XVTR)
- WebServer: expose fmstep_idx in state JSON so web clients sync the
FM step from desktop state
- WebPageHtml: swap stepSel options to FM steps (6.25k/12.5k/20k/25k)
when mode=FM, restore HF steps when leaving FM; syncs fmstep_idx
from server on connect and mode change
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix web spectrum scroll resetting freq to XVTR minimum (same root
cause as desktop: hardcoded 60 MHz clamp; now delegates to server)
- Save/restore FM mode, NFM/WFM filter, squelch, CTCSS per XVTR slot
and per HF band (CTCSSOn/ToneIdx added to TBandSettings; full state
added to TXvtrEntry; ActivateXvtrBand restores all on slot switch)
- Fix UpdateFilterButtons always resetting NFM/WFM to default on
mode restore; now preserves saved filter index
- Add FM Step tuning: panel with STEP toggle + 6.25/12.5/20/25 kHz
selector (popup); mouse wheel uses selected step in FM mode;
state saved per band and XVTR slot
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- LSB/USB: 5.0k–1.0k (unchanged)
- DSB: split into own group 16k–2.4k (was sharing AM filters)
- CWL/CWU: 1.0k 800 600 500 400 250 150 100 50 25 (removed 750, added 150)
- AM/SAM: 20k–5.0k (new wider range)
- Web FNP FM: now shows NFM/FM only (11k/16k), matching desktop
- Fix SyncWebFilter: FM array out-of-bounds; FFMDeviation now set on web filter select
- VfoOverlay: DSB separated from SSB with own quick-select values
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
FM modulation:
- Replace 10 generic FM filter buttons with NFM (2.5kHz dev/11kHz BW) and FM
(5.0kHz dev/16kHz BW); deviation applied to both RX and TX via WDSP
- Add FM squelch panel (SQL toggle + slider 0..100, per-band save/restore)
with WDSP SetRXAFMSQRun/SetRXAFMSQThreshold (threshold = level/200.0)
- Add CTCSS panel with on/off toggle and custom flat-button tone picker popup
(38 standard tones 67.0..250.3 Hz, default 67.0); tone selection and enable
state saved per band via SetTXACTCSS*
- FM panels (SQL, CTCSS) shown only in FM mode, layout via RelayoutBelowBands
- PanelFilter height shrinks in FM mode so panels sit tight below filters
- FlatButton: handle CMTextChanged to invalidate on Caption change
ADC settings (Dither/Random):
- Add DitherEnabled/RandomEnabled to TGlobalSettings (default true)
- Pass as bitmask to ConfigureDDCs DDC Specific packet bytes 5/6
- Exposed in Settings → Advanced tab with live apply via ApplyADCSettings
Web server settings:
- Add TWebSettings (enabled, port, bind_addr, user, pass) stored globally
- WebServer: configurable port/bind IP via ParseIPv4; Reconfigure method
- Exposed in Settings → Advanced tab with live apply via ApplyWebSettings
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
XVTR RF (xvtr_rf in Thetis) is dead code — GetXVTRRF() is never called.
Remove the field, UI column, save/load from TXvtrEntry. UseDDCIn is now
always True when in XVTR mode (previous default behaviour, XVTRRF=False).
Byte 1400 bit 0 (XVTR Enable / VHF T/R relay output) now follows Thetis:
- XVTR mode: set only when DisablePA=True (external T/R relay needed)
- HF mode: set when Alex.EnableXvtrHf is checked (Antenna tab)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CalcAlex0: Alex.RxOnly[band]=3 (XVTR checkbox in Antenna tab) now sets
XVTR DDC In only when XvtrActive=True (FXvtrEnable). Matches Thetis
Alex.cs behaviour: "do not use XVTR ant port if not using transverter".
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Separate FPTTActive from FIsTransmitting so PTT bit in HP packet
can be sent as a second packet after Alex bit27 (T/R relay) is set,
matching Thetis behaviour: relay switches first, then PTT=1
- On TX stop: PTT=0 first, then Alex switches back to RX
- Add SendPTT(Active) method to THPSDRNetwork
- Reset FSeqHP to 0 in SetRunAndFreq(Run=True) to eliminate HP SEQ
ERROR caused by intermediate SendFullHP calls before Run=1 packet
- RebuildXvtrButtons: use dynamic BtnH/RowH/MaxBottom instead of
hardcoded px values so XVTR buttons scale correctly on HiDPI
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Was 72px, causing VFO to disappear while there was still visible space
between it and the S-meter. Now 8px — just enough visual breathing room.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- RelayoutBelowBands: replace hardcoded Inc(Y,76) with actual panel
heights so Mode/Filter/RX panels don't overlap at scaled DPI
- ResizeSpectrumPanels, SplitterMouseMove/Up: make RULER_H dynamic
via MulDiv(18, Screen.PixelsPerInch, 96) so frequency ruler is tall
enough to fit text at 125%/150% DPI
- LayoutTopVfoBlock: use BtnTopVfoASelect.Width / BtnTopVfoBSelect.Width
instead of constant VFO_BTN_W so FreqDisp doesn't clip the A/TX buttons
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaced the WF AGC and WF NF toggle buttons in the main panel with
"Waterfall AGC" and "Waterfall NF" checkboxes in the Settings form
Waterfall tab (AGC & Noise Floor group). Settings are global, defaults
remain AGC=on, NF=off.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Power bar: minor ticks every 5% (between 0/25/50/75/100% main marks)
SWR bar: minor ticks at integer values 2,3,4,6,7,8,9 (between 1/2.5/5/10)
Applied to both desktop (SpectrumView) and web (paintTXMeter JS)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- WebServer: add fwd_w, swr, pa_max_power to state JSON and PushSpectrum
- MainForm: pass FLastFwdW, FLastSWR, FPAMaxPower to PushSpectrum
- Web UI: paintSM switches to paintTXMeter when transmitting/tuning;
same layout as desktop — two sub-bars at 44-58% height, power ticks
above, SWR ticks below, SWR>2.5 turns red with "SWR High" label
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- S-meter panel switches to TX mode when transmitting: single bar splits
into two sub-bars (power top, SWR bottom) at the same position/size
- Power bar: 0..PAMaxPower W, green; SWR bar: 1..10, amber/red past 2.5
- SWR > 2.5: red border, red label, "SWR High" warning text
- Remove PWR/SWR bars and labels from TX panel (left column)
- Remove FWD/SWR from status bar; remove frequency from RUNNING status
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Settings > Display: new "VFO Display" control to select max frequency
range (999 MHz / 9.999 GHz / 99.999 GHz), persisted as freq_mhz_digits
- FreqDisplay: extend digit map [0..10] to support up to 11 digit positions;
keyboard navigation adapts to MinMhzDigits dynamically
- MainForm/LayoutTopVfoBlock: VFO panel width scales automatically with
selected digit count using dynamic text measurement
- Web VFO: fix broken HTML (class attr not closed before data-s — wheel and
hover were completely non-functional); rewrite fmtVfo to use variable MHz
digit count synced from server state; fix missing </span> for .vfo-hz
- WebServer: publish freq_mhz_digits in state JSON; updated from
ApplyFreqMhzDigits so desktop and web stay in sync
- Fix Int32 overflow on frequencies above ~2.15 GHz: CATEngine.Pad V param
Int64, FormatFreq/FormatFreqSV Mhz var Int64 (Mhz*1000000 overflowed)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
Format() used the system locale decimal separator, so on Russian/Eastern
European Windows smeter_dbm and float fields got commas ("−87,5"), producing
invalid JSON that JS silently dropped — breaking S-meter and frequency display.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Browser: AudioWorklet accumulates 960-sample frames, AudioEncoder encodes
to Opus, sends binary WS frame 'M' + raw Opus packet
- Server: opcode $02 handler decodes Opus via libopus, calls OnWebMic callback
- MainForm: WebOnMic converts PSingle→Double, pushes to PushTXMicSamplesD;
ApplyMOX switches mic source to txmsWeb when web client active, restores on TX-off
- WDSPEngine: added txmsWeb to TTXMicSource enum
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deadlock: BroadcastBinary held FClientLock during blocking SockSend;
slow/stalled client caused Stop() to wait forever. Fix: set SO_SNDTIMEO=1s
on each accepted socket so SockSend returns error instead of hanging,
mark client wsClosed on send failure so subsequent ticks skip it.
Mobile: move TONE/TX-slider/MOX to front of toolbar via CSS order so
they are immediately visible without horizontal scroll on phones.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Change filter passband fill from blue/white to semi-transparent red
on both spectrum and waterfall when transmitting or tuning, matching
the desktop behaviour.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add 'dup' field to state JSON (FDisplayDuplex). In CTUN+non-DUP TX,
use vfo_a_hz as spectrum center so the TX signal renders at the VFO
position instead of the display center. In CTUN+DUP TX, keep center_hz
so the RX spectrum stays correctly positioned at the filter.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Track wheelActiveTs on each wheel tick; suppress server center_hz
overwrites for 300ms after last wheel event so localCenter stays at
the current VFO position instead of snapping back to screen center.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Click on spectrum/waterfall no longer sets localCenter immediately.
The filter passband now appears exactly at the clicked pixel instead of
jumping to screen center. Server's center_hz (arrives ~200ms later)
naturally re-centers the display once fresh spectrum data is ready.
VFO display wheel (vDispA/vDispB) now updates localCenter when tuning
the active VFO. Previously localCenter lagged behind, causing applyState
to teleport the filter back to center every 200ms (the "passes through
center" oscillation).
Spectrum canvas wheel (doWheel) is unchanged: user expects the spectrum
to scroll when wheel-scrolling over it, filter stays at center — correct.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add freq_a command: sets VFO A regardless of active VFO; fixes A=B and
SWAP when VFO B is active (prev. sent freq_b which overwrote wrong VFO)
- Add pend("freq") to B=A / A=B / SWAP to guard local display during round-trip
- RX step attenuator: HPSDRNetwork.SetStepAtten → bytes 1442/1443 in HP packet;
WebServer attn command; MainForm FAtten + SyncWebAttn; attSel.onchange in JS
- TUN mode: set_tun WebSocket command wired to ApplyTUN(); toneBtn toggles
with on/off highlight and pending protection; tuning field in state JSON
- FNP button opens semi-transparent filter overlay (10 buttons, 5×2 grid)
with mode-appropriate widths (SSB/CW/AM/FM); active filter highlighted;
cur.filter_bw updated immediately on click so passband redraws within 50ms
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
В non-DUP при MOX/TUN на возврате слышен и виден на водопаде хвост
своего сигнала. Во время TX RX-IQ оседал в RXA pipeline / FFT-истории
RX-анализатора и «выстреливал» при открытии гейта.
- WDSPEngine: KeepRXDuringTX (DUP-флаг). В non-DUP TX PushIQItemToDSP
дропает пакеты на входе DSP-потока — RXA и анализатор не кормятся.
- Windows-only post-TX hold (250 мс): дропаем И входящие RX-IQ, И аудио
в окне после MOX-off, чтобы скрыть «хвост» от FPGA TX-buffer/PA
slew-down радио. На Linux код-путь не активируется (буфер OS мелкий).
- Network: ClearDUCIQQueue + IsTransmitting guard в DUC sender thread,
чтобы недопереданные TX-IQ пакеты не уходили после MOX-off.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>