Skip to content

Dev/vocoder live - #1161

Merged
robotastic merged 43 commits into
masterfrom
dev/vocoder-live
Sep 27, 2026
Merged

robotastic merged 43 commits into
masterfrom
dev/vocoder-live

Conversation

@robotastic

Copy link
Copy Markdown
Collaborator

No description provided.

robotastic and others added 30 commits September 26, 2026 20:15
Six patches to lib/op25_repeater/ targeting audible artifacts under LSM
simulcast and other lossy-RF conditions, primarily by closing gaps in
frame muting/repeat policy on the fixed-point decoder path.

- software_imbe_decoder: enable PhzNz random voiced-phase term per
  TIA-102.BABA-A eq. 142 (rho = pi * Luv / L). Removes mechanical
  timbre on sustained vowels and repeated voiced frames.
- software_imbe_decoder, mbelib: replace exit() on out-of-range input
  with clamping. Bit errors can no longer terminate the recorder.
- p25p1_voice_decode, p25p1_fdma: gate the fixed-point IMBE decoder on
  smoothed ER (>0.0875 mute, 4-frame repeat then mute) so it matches
  what the float decoder already does internally. This is the main
  LSM win: bad simulcast frames now silence instead of screeching.
- rx_sync: same gating applied to the YSF fullrate fixed-point branch
  (DMR halfrate and P25 Phase 2 already had this).
- software_imbe_decoder: replace the period-<=53125 LCG used for
  unvoiced excitation with xorshift32 mod 53125. Same output range,
  vastly longer period; removes audible noise repetition on long
  sibilants/fricatives.

Touches vendored OP25 code; none of these are merged upstream yet.
The PhzNz and exit-removal patches are worth upstreaming to boatbod.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Review of the dev/vocoder-improvements work against an objective
benchmark (PESQ-NB/STOI vs. clean speech through the real P25 FEC with
random and fading bit errors, plus DNSMOS on live dcfd/wmata audio).

Float decoder (software_imbe_decoder):
- decode_fullrate() now shifts u7 itself. imbe_header_decode() returns
  the 7 unprotected bits left-shifted by one; the float decoder was fed
  them unshifted, so b0's LSBs (pitch), b2's LSB (gain) and three
  residual bits were wrong on most frames. Same bug upstream in OP25.
- Formant postfilter off by default: it lowered PESQ/DNSMOS at every
  setting tried; TIA spectral enhancement already acts as a postfilter.
- Repeat only when E0 >= 3 (TIA: 2). Golay(23,12) is perfect, so E0 == 2
  is almost always a correct decode.
- Repeated frames keep advancing psi1/phi instead of freezing phase.
- Muted frames synthesize a zero-amplitude frame so audio fades out/in.
- S_E persists across frames as the TIA recursion requires.
- Random-phase weight uses the current frame's unvoiced count.
- Optional US5701390 kernel (phase_kernel = 1); dead UV->V phase table
  removed.

Fixed-point decoder (imbe_vocoder):
- imbe_decode_checked() implements repeat/mute once for p25p1_fdma,
  p25p1_voice_decode and rx_sync. Repeats re-synthesize the saved
  parameters instead of re-decoding the old bit vector (which applied
  its prediction residual twice); mutes fade out.

IMBE capture: split files on the decoder thread; clear() (main thread)
no longer fcloses a FILE* the decoder thread may be writing.

Add utils/imbe_eval (encode -> channel -> decode) and
utils/score_vocoder.py (PESQ/STOI/DNSMOS) and document results in
docs/Notes/VOCODER-IMPROVEMENTS.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion)

vocoder_monitor writes one JSON line per P25 Phase 1 transmission when
OP25_VOCODER_STATS is set: FEC error histograms (E0, ET), error-burst
lengths, frame repeats/mutes and their causes, pitch and voicing
behaviour, output level and clipping. It also takes over the
OP25_IMBE_CAPTURE_DIR frame capture so each stats line names the .imbe
file that replays the same transmission through utils/imbe_eval.

Both decoders now report what they did with each frame
(ImbeFrameInfo / imbe_decode_checked() status and cause).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spectrograms of the decoder output showed the spectrum changing only
inside the TIA's ~6 ms cross-fade and holding for the rest of each 20 ms
frame; on live speech the harmonics above #8 (cross-faded rather than
interpolated) break into beads.

- Interpolate amplitude/frequency/phase for all harmonics when the pitch
  changes by less than 20% (interp_max_l 57, interp_pitch_tol 0.2).
- New unvoiced synthesis (uv_synth_mode 1): per-frame colored noise with
  exact band energies, cross-faded with power-complementary weights
  across the whole frame.
- onset_ramp_mode option (off; measured worse).

On 80 live dcfd/wmata transmissions: DNSMOS OVRL 2.488 -> 2.560, frame
transition flux 0.66 -> 0.34 dB. Lab corpus PESQ-NB -0.04 (noise path).
score_vocoder.py gains the frame-flux metric.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
robotastic and others added 10 commits September 26, 2026 20:16
Investigating a report of raspy / rapidly fluctuating voiced audio on
wmata tg 2049:

- phase_track: fraction of the way interpolated harmonics are steered to
  each frame's target phase. Frame-to-frame jitter in the envelope phase
  moves the pitch pulse within the period (live traffic: 5.6% period
  jitter vs 2.2% with linear phase).
- amp_smooth: pull each harmonic's log amplitude toward the previous
  frame's envelope at the same frequency (skipped at onsets). Live
  DNSMOS OVRL +0.07 at 0.2, +0.11 at 0.35; lab PESQ-NB -0.04 / -0.10.

Defaults unchanged pending listening tests; phase_c_env 0.7 cuts live
jitter to 3.8% with small gains on every score.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… by default)

Moves a rising share of each voiced harmonic's power above aper_f1 into
band noise (power preserving). Live DVSI-encoded traffic decodes with
2-3.7 kHz periodicity of 0.54-0.58 vs 0.34 for natural speech (buzz);
aper_max 0.5 brings it to 0.45-0.49 with PESQ unchanged, DNSMOS -0.03.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
phase_c_env 0.7 was preferred in listening tests on live dcfd/wmata
traffic (vs 1.3, and vs JMBE, mbelib, mbelib-neo, GopherTrunk and a
DVSI-derived reference decoder) and lowers pulse-timing jitter from 5.6%
to 3.8%. hf_lift_db adds a presence lift above hf_lift_f1 (the DVSI-
derived decoder carries ~+1 to +3 dB above 2.5 kHz); off pending
listening.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Chosen in listening tests on live dcfd/wmata traffic against 0/+2 dB and
the DVSI-derived reference decoder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drops the utils/ scripts and tools added during vocoder work
(imbe_tune, imbe_eval, sweep configs, analyze/compare/rank/score/report
scripts, VOCODER-TUNING.md), their CMake targets and the __pycache__
ignore rule, and the doc sections that described them. Decoder code and
the OP25_DEBUG_VOCODER / OP25_VOCODER_STATS / OP25_IMBE_CAPTURE_DIR
hooks are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The 60 s stderr telemetry aggregator and the get_decoded_voicing /
set_voicing_override hooks (used only by the removed imbe_tune utility)
are no longer needed. No change to decoded audio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drops the per-transmission stats and IMBE frame capture
(OP25_VOCODER_STATS, OP25_IMBE_CAPTURE_DIR) and the per-frame status
reporting that fed it (ImbeFrameInfo, last_frame_info(), and
imbe_vocoder::last_cause()/last_er(); imbe_decode_checked() returns
void again). No change to decoded audio.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The note had accumulated per-round history whose defaults, mechanisms
and tooling no longer matched the code. Rewritten as one description of
what the branch changes and why, the synthesis pipeline, every
VocoderParams field with its current default, the lab and live
measurements, the comparison with other IMBE decoders, findings from
live traffic, what was tried and not adopted, and follow-ups.

Also replaces the stale tuning comment block at the top of
software_imbe_decoder.cc with a pointer to VocoderParams, corrects
several field comments, and drops a stray blank line in p25p1_fdma.h.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
robotastic and others added 3 commits September 26, 2026 20:30
Rewrites VOCODER-IMPROVEMENTS.md as a reference of how the vendored
IMBE decoders differ from stock OP25 (decoding fixes, error concealment,
float-decoder synthesis, parameters with stock equivalents, files
touched) instead of a record of the tuning work, and drops everything
about tools and instrumentation that are no longer in the tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- p25p2_tdma::clear() resets the half-rate error-rate tracker, repeat
  counter, previous-frame parameters and both decoders; the frame
  assembler calls it between calls with the Phase 1 reset. Without it a
  call that ended on a bad signal muted the start of the next call and
  burst ~20 dB too loud on its first frames.
- Muted Phase 2 frames are synthesized as zero-amplitude frames
  (decode_tap_mute() / imbe_mute()) instead of hard silence.
- decode_tap() uses the persistent S_E.
- decode_tap() scales mbelib's half-rate amplitudes by tap_gain (0.3):
  at 1.0 the float decoder ran ~8 dB hotter than full rate and clipped
  2-2.5% of samples. Float now matches fixed-point on Phase 2 (PESQ-NB
  2.98 vs 2.99, was 2.56); also applies to DMR/D-STAR via rx_sync.

Tested offline with OP25's ambe_encoder through the Phase 2 FEC on
random and fading channels. Phase 1 output is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the vocoder changes on this branch the floating-point decoder
matches or beats the fixed-point decoder on Phase 1 and Phase 2, and was
preferred in listening tests on live traffic. Existing configs that set
softVocoder explicitly are unaffected; set it to false to keep the
fixed-point decoder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robotastic
robotastic merged commit 1aac86c into master Sep 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant