Zeal Ranked Voice v2 -- Windows x86 first
========================================

Integrated with RankedVoice.cpp, the stock party menu, game scoreboard muting,
and ranked_lobby/voice.py. Voice activation is the default; PTT is optional.
See ../../docs/VOICE.txt (from client_native, ../docs) and the integration report
at ../../docs/qa/voice-windows-20261012/REPORT.txt for test scope.

Media path
----------
WASAPI capture -> bounded callback ring -> optional RNNoise -> sensitivity/preroll
-> Opus -> RTP/SRTP -> authenticated relay -> per-speaker SpeexDSP
adaptive jitter -> Opus/PLC -> float mixer/soft clip -> WASAPI playback.
The relay does not decode, transcode, record or log conversations. HTTP/control,
media and game rendering have separate execution paths. Ordinary servers keep
the hardened legacy voice path; no Opus packet reaches its decoder.

Reference profile: mono 48 kHz, 480 samples/10 ms, Opus 1.6.1 APPLICATION_AUDIO,
96 kbit/s constrained VBR, complexity 10. DTX/FEC are off. Measured codec
lookahead is 312 samples (6.5 ms), not total voice latency. Natural processing
is the default; RNNoise 0.2 is optional. No automatic gain or echo cancellation
is claimed. Headphones avoid speaker audio returning through the microphone.

The default gate is -58 dBFS with 4 dB hysteresis, 40 ms preroll and 300 ms
release. Local mute, permission loss and PTT release clear preroll. PTT sends
no pre-press audio. RTP timestamps remain monotonic through mic/device restarts.
Output holds at most three 10 ms frames to tolerate batched device callbacks.
SpeexDSP starts with 30 ms of receive buffering, adapts its packet timing and
uses Opus loss concealment. It is not WebRTC NetEq and does not implement its
time-stretching. Device callbacks allocate nothing and do not encode or lock.

Each activation starts a fresh encoder; its authenticated start marker resets
the decoder when that packet plays. This prevents quiet restart volume spikes.
Speex per-tick delay reduction is disabled because it dropped speech frames
after a preroll burst. Buffering still expands at shortages; talkspurt/stall
and bounded-backlog resets release excess delay. A continuously active stream
with sustained clock mismatch can still need a bounded resynchronization.

Reproducible standalone build
----------------------------
Python 3.12+, CMake 3.21+, MSVC 2022 and a Windows SDK:

  python fetch_dependencies.py
  cmake -S . -B build -G "Visual Studio 17 2022" -A Win32
  cmake --build build --config Release --parallel
  ctest --test-dir build -C Release --output-on-failure

Keep ../LegacyVoiceProtocol.hpp alongside this directory for its parser test.
Dependencies have exact versions/SHA-256 hashes in dependencies.json. Their
complete source archives and licenses are included in the corresponding-source
bundle. THIRD-PARTY-NOTICES.txt accompanies the DLL and installer.

For the game DLL, apply client_native/apply.py to the pinned checkout, then run
this CMake build in that checkout's deps/zeal-voice directory BEFORE premake and
MSBuild. client_native/README.txt gives the full commands. Linux builds use
PulseAudio for portable QA; the actual game is Windows x86, optionally via Wine.

  cmake -S . -B build-linux -DCMAKE_BUILD_TYPE=Release
  cmake --build build-linux --parallel
  ctest --test-dir build-linux --output-on-failure

Diagnostics and fixtures
------------------------
  voice_qa selftest
  voice_qa benchmark
  voice_qa devices
  voice_qa roundtrip input.wav output.wav 96000
  voice_qa quality input.wav output.wav lossPercent jitterMs burstMs denoise01
  voice_qa activation input.wav gated.wav
  voice_qa playback input.wav [output-device-name]
  voice_qa duplex seconds "input-device-name" "output-device-name"
  voice_network_qa

WAV input is mono 48 kHz PCM16. roundtrip aligns codec lookahead for waveform
comparison; its SNR is not a listening score. duplex explicitly opens the chosen
mic for up to 60 seconds and locally monitors the codec without recording.
Use isolated virtual devices/generated fixtures for automated QA. The optional
network endpoint command reads a private config file; never publish its keys.

quality uses file input and a simulated clock/network, with the production
gate, RNNoise, codec, receiver and mixer. It never opens an audio device. The
output preserves startup/silence timing; output.wav.gated.wav records the gate
output. ../../tests/voice_quality.py runs the speech matrix and reports global
alignment and STOI/ESTOI screening metrics (optional numpy/scipy/pystoi tools).
See ../../docs/qa/voice-quality-20261012/REPORT.txt for the latest findings.

Tests cover eight independent speakers, tampering/replay, RTP rollover, bounded
parsing, loss/reordering/bursts and +/-200 ppm clock mismatch. Real game tests
are separately recorded in the integration report. Neither synthetic tests nor
an Opus bitrate establish equality with Discord on people's actual microphones.
