Commit Graph

148 Commits (main)

Author SHA1 Message Date
Steve Pinkham f522b46fa8 fix(audio): re-block captured RX audio into whole DSP blocks
With blocksize=0 PortAudio picks the capture block size per device. On
the devices measured for the previous commit it happened to deliver
multiple-of-6 block sizes, but other hardware returns 512/1024-class
blocks. codec2's resample48_to_8 asserts len(input) % 6 == 0
(FDMDV_OS_48), so on such a device every captured block raised
AssertionError, the DSP chain never ran, and RX was completely deaf.

The fix decouples the capture block size from the DSP block size
instead of pinning the stream back to blocksize=4800, which is the
configuration that negotiates a two-period ring on snd-aloop and drops
audio continuously (the deaf-on-loopback case the previous commit
fixed). Captured audio is appended to a carry buffer and the DSP chain
runs once per whole RX_DSP_BLOCK_48K (4800 samples, 100 ms) available;
the remainder carries into the next captured block, so the sample
stream handed to the resampler stays gapless (its filter memory spans
blocks) and always has a valid length, whatever the device delivers.

Running the DSP only on whole 4800-sample blocks also fixes three
silent degradations that short blocks caused:

- calculate_fft pads its input to 800 samples at 8 kHz, so short
  blocks fed the waterfall, channel-busy detection and audio_dbfs
  mostly zeros
- enqueue_streaming_audio_chunks zero-pads every block up to 2400
  samples and emits one chunk per block regardless of size, so short
  blocks streamed mostly silence and flooded the RX audio queue
- normalize_audio (rx_auto_audio_level, on by default) normalizes per
  block, so shorter blocks made the auto level faster and jumpier

Tests: the old test captured 4800-frame blocks, a multiple of 6, which
is exactly why this was never caught. The capture size is now 512 and
TestRxAudioReblocking covers odd sizes never reaching the resampler,
exact block accounting including the carried remainder, sample-stream
preservation (nothing dropped, duplicated or reordered), and every
re-blocked block being accepted end to end by the real codec2
resampler. Against the pre-fix code 5 of the 6 tests fail; with the
fix all pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 21:34:19 -04:00
Steve Pinkham 16052308b5 test(audio): cover the real-time-safe RX audio callback / worker split
Exercise the callback/worker split from the previous commit:

- the worker drains rx_audio_in_queue and runs the relocated RX DSP
  (resample 48->8 kHz, FFT, demod-buffer push) on an enqueued block, and
- the callback drops (and counts via rx_audio_dropped_blocks) instead of
  blocking when the queue is full -- the real-time-safety property the
  change exists to provide.

Both feed synthetic int16 blocks straight to the callback, so they need no
audio hardware and run under the existing `unittest discover tests` suite.
The live ARQ transfer test uses an in-memory queue and never touches the
sounddevice path, so this is new coverage rather than a changed test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 07:20:19 -04:00
Steve Pinkham f19c775a3a fix: emit arq-session-finished on IRS success again (lost April 2024)
The IRS success branch set ENDED and returned without the
session-finished event, while abort, failure and the ISS success path
all send one. A successful inbound raw transfer was invisible to every
websocket/REST consumer, and the received payload was dropped with it
(handle_raw returns the data into a call chain that discards it).

c2388a65 emitted exactly this event, data= included; it vanished by
ef18f4cc without that commit's IRS diff touching the lines, so this
looks like a merge casualty rather than a decision. Restore the event
and add a regression test: one finished event with success=True,
payload round-trips through the base64 data field.

The original also pushed session statistics gated on enable_stats, but
that key is no longer in the config schema (config.py STATION), so the
strict lookup raises KeyError; the two existing stats sites in the
failure and abort paths have the same latent problem. Restoring just
the event here; the stats question is worth its own look.

No setARQ(False) here: dispatch() already clears busy on this path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-22 18:30:05 -04:00
as3ii e2b2c73f1a
Fixed other module's paths 2026-01-10 20:27:19 +01:00
as3ii 646174b75d
Fixed ruff F811 and F401 2026-01-10 19:11:47 +01:00
as3ii ed4c79cd2a
Fixed ruff F541 2026-01-10 19:11:47 +01:00
as3ii f88f5fe2a3
Increased max line length to 120, reformatted everything
In practice, in this commit I've increased from 100 to 120 the maximum
allowed line length for python files and re-run ruff's formatter.
2026-01-10 19:11:26 +01:00
DJ2LS 04366b0cb6
Merge branch 'develop' into ls-norm 2026-01-08 16:28:45 +01:00
as3ii 191c94c942
Executed `ruff format --preview`, small update to CONTRIBUTING.md 2025-11-13 23:48:17 +01:00
as3ii 444c0d37cf
Removed f-strings without placeholders (ruff F541) 2025-11-13 22:45:07 +01:00
as3ii 4a458730ea
Removed unused imports
Ruff's rule F401
2025-11-13 20:12:55 +01:00
as3ii 0deef898ff
Fixed ruff rule E401 and E402
See https://peps.python.org/pep-0008/#imports
2025-11-13 19:55:53 +01:00
as3ii 6f7288335f
Switched from editing `sys.path` to proper PEP8 imports
See: https://peps.python.org/pep-0008/#imports

Here absolute imports have been used to avoid the error
`ImportError: attempted relative import with no known parent package`.
2025-11-13 19:49:38 +01:00
as3ii 66b2c6bf4e
Run `ruff format`
This applies mostly the same rules that `black` used.

This commit should not have introduced any logical or functional
changes, only fixing style consistency
2025-11-13 15:53:43 +01:00
DJ2LS 76518ca9c4 save data to database 2025-06-23 10:04:42 +02:00
DJ2LS 5433a001b4 first basic work on NORM implementation 2025-06-22 21:49:36 +02:00
DJ2LS de13c807ec first success with test 2025-05-25 12:46:43 +02:00
DJ2LS 448be61e8d first success with test 2025-05-25 12:41:37 +02:00
DJ2LS b32de53f7c first success with test 2025-05-25 12:39:12 +02:00
DJ2LS 708ed22c0a first success with test 2025-05-25 12:01:49 +02:00
DJ2LS e5208cffff adjustments to modem tests - still not working yet. but we have first benefits of new modem structure 2025-05-19 08:54:24 +02:00
DJ2LS bebf3e491b first adjustments to tests 2025-04-29 21:13:42 +02:00
DJ2LS 65ba983737 first adjustments to tests 2025-04-29 14:03:49 +02:00
DJ2LS 8ca0783cd0 fixing tests and merging problems 2025-03-18 08:22:11 +01:00
DJ2LS 78eb1913c3 disabled tests until work continues 2025-03-17 11:39:19 +01:00
DJ2LS 89868dcea5
Merge branch 'develop' into dev-connected-mode 2025-03-12 10:41:43 +01:00
DJ2LS bdb9af2c90 fixing tests 2025-03-11 11:00:24 +01:00
DJ2LS d78aed93cc
Merge branch 'develop' into dev-connected-mode 2025-02-24 13:18:38 +01:00
DJ2LS a88539dca7 organized api endpoints into subfolders 2025-02-19 09:51:19 +01:00
DJ2LS e1bfd97e25 test related work in progress - still improving automated testing. Whats working for now is catching command socket for IRS and ISS. Pushing data on ISS side to data socket is working as well. But we are still trying to get data on IRS. 2025-02-12 10:57:59 +01:00
DJ2LS 351e5f8408 test related work in progress - still improving automated testing. Whats working for now is catching command socket for IRS and ISS. Pushing data on ISS side to data socket is working as well. But we are still trying to get data on IRS. 2025-02-12 10:38:38 +01:00
DJ2LS fdd3be4b56 some work in progress regarding automated testing 2025-02-02 17:39:50 +01:00
DJ2LS ebc5088679 fixing test 2025-01-22 09:35:51 +01:00
DJ2LS 4c84391fd4 fixing test 2025-01-22 09:34:08 +01:00
DJ2LS 0ec07ff2f3 fixing some tests 2025-01-22 09:16:28 +01:00
DJ2LS a59250d8b3 fixing some tests 2025-01-21 19:22:20 +01:00
modernham d50735fc49 Merge branch 'develop' into dev-connected-mode 2025-01-20 14:24:37 -05:00
DJ2LS dbcbd74628 move respond to cq to STATION 2024-09-05 14:57:53 +02:00
DJ2LS 672e9f3413 improved speed level in relation to channel busy 2024-08-03 12:53:21 +02:00
DJ2LS 8732aad4b0 fixed tests 2024-07-31 19:25:15 +02:00
DJ2LS 29b5b8aa4b tests - wait for server before running them 2024-07-23 11:13:23 +02:00
DJ2LS cb105afb6f some small work on socket interface 2024-06-04 15:12:26 +02:00
DJ2LS c3c93d9956 adjusted server api version 2024-05-27 10:17:21 +02:00
DJ2LS 317ca302ee adjusted api for retransmitting and upating 2024-05-25 10:45:56 +02:00
DJ2LS 3a6e001bdb fixed tests 2024-05-19 13:38:48 +02:00
DJ2LS 80c8dc1685 work on packet collision avoidance 2024-05-19 10:46:59 +02:00
DJ2LS ca1da47cae give server more time to start for fixing tests 2024-05-08 08:17:35 +02:00
DJ2LS d5097b8b94 another folder renaming 2024-04-18 11:04:25 +02:00
DJ2LS 6309c5363f fixing some tests 2024-04-17 23:37:28 +02:00
DJ2LS efe8bb3aec renamed "modem" to "freedata-server" 2024-04-17 22:49:08 +02:00