mirror of
https://github.com/D-Modem/courier-emu.git
synced 2026-11-28 20:38:07 -08:00
Every sample crossing between the 8 kHz socket line and the AC01 went through a linear interpolator whenever the codec was not at 8 kHz - which in a call is most of the time: the 403 runs its codec at 9600 Hz from V.34 phase 2 on. Measured against the analytic value of a band-limited signal, that path gave 9.4 dB SNR across 300-3800 Hz from 8 kHz to 9600 Hz, and 12.6 dB back: 25 dB for a 1 kHz tone, 13.4 dB at 2 kHz, 5.5 dB at 3.3 kHz, 3.9 dB at 3.7 kHz. The passband droops and every component leaves an image that folds back in band. That is worse than a poor phone line, once in each direction on every call. It is consistent with a 403 pair reaching only CONNECT 12000, and with the x2 client's rate chooser (e2dd) measuring a channel too poor for any PCM rate: 0x2477 against a lowest threshold of 0x2ec0. courier_emu/resample.py replaces it with a Kaiser-windowed sinc interpolator: 64 input samples either side, cutoff at 0.98 of the lower Nyquist, any ratio (7200, 7578.95, 8000, 9600, 10266.67 Hz), 1024 tabulated phases. 8 kHz <-> 9600 Hz is now 73-75 dB at 1 kHz, 63-64 dB at 3.3 kHz, 62-64 dB at 3.7 kHz and 30-39 dB at 3.8 kHz, the filter edge. Physically it stands for the exchange codec's reconstruction and anti-alias filters: the line between the two converters is analogue and band-limited below 4 kHz. Equal rates still pass through untouched. It costs about 0.5 s of CPU per second of audio. bridge.Resampler keeps its name and interface, so _line_to_codec and _codec_to_line are unchanged at their call sites. test_transmit_audio_is_converted_once_from_codec_to_line_rate was already failing at HEAD: its bare bridge had no _line_service. It now has one, and asserts one 800-sample line frame per 720 codec samples, allowing for the first block being one over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>