diff --git a/core/src/audio/audio_engine.h b/core/src/audio/audio_engine.h index 41bf5b1..9fe2051 100644 --- a/core/src/audio/audio_engine.h +++ b/core/src/audio/audio_engine.h @@ -478,12 +478,12 @@ class AudioEngine { uint32_t user_id = 0; uint32_t stream_id = 0; - // Talk-indicator edge detection (docs/voice.md §7) — updated by push_recv_frame + // Talk-indicator edge detection updated by push_recv_frame // (already off the real-time audio thread), polled by poll_talk_transitions(). std::atomic last_voice_ms{0}; bool talking = false; - // ── Decode/playback decoupling ring ───────────────────────────────────── + // Decode/playback decoupling ring // opus_decode() must be called with max_samples == the encoder's fixed frame size // (decoder.frame_samples(), e.g. 960 @ 20ms/48kHz) — that's a property of the bitstream, // not a choice. miniaudio's playback callback period is a *separate*, independently diff --git a/core/src/codec/opus_codec.cpp b/core/src/codec/opus_codec.cpp index cbf5b80..c5fd673 100644 --- a/core/src/codec/opus_codec.cpp +++ b/core/src/codec/opus_codec.cpp @@ -3,7 +3,7 @@ namespace voicecat::codec { // Map an intended channel/capture sample rate (Hz) to the Opus max-bandwidth constant. The -// codec always runs at 48 kHz internally (docs/voice.md §3); this caps the bandwidth the +// codec always runs at 48 kHz internally. this caps the bandwidth the // encoder will select so a channel can request narrowband/wideband audio for low-bitrate rooms. // 0 (unset) and >= 48000 map to FULLBAND, which is the encoder default (i.e. a no-op cap). static opus_int32 opus_max_bandwidth_for(uint32_t rate_hz) { @@ -15,7 +15,7 @@ static opus_int32 opus_max_bandwidth_for(uint32_t rate_hz) { return OPUS_BANDWIDTH_FULLBAND; // ~20 kHz } -// ── OpusEncoder ────────────────────────────────────────────────────────────── +// OpusEncoder bool OpusEncoder::init(const OpusParams& p) { destroy(); @@ -65,7 +65,7 @@ void OpusEncoder::destroy() { if (enc_) { opus_encoder_destroy(enc_); enc_ = nullptr; } } -// ── OpusDecoder ────────────────────────────────────────────────────────────── +// OpusDecoder bool OpusDecoder::init(const OpusParams& p) { destroy(); diff --git a/core/src/codec/opus_codec.h b/core/src/codec/opus_codec.h index 9f297c9..ac274c8 100644 --- a/core/src/codec/opus_codec.h +++ b/core/src/codec/opus_codec.h @@ -1,7 +1,7 @@ /* - * codec/opus_codec.h — Opus encode/decode (libopus 1.6). + * codec/opus_codec.h: Opus encode/decode (libopus 1.6). * - * Design: docs/voice.md §3–4. Per-channel AudioConfig (mono/stereo, bitrate, frame size, + * Per-channel AudioConfig (mono/stereo, bitrate, frame size, * FEC, DTX, complexity). The server relays Opus payloads unmodified (no transcode). */ #ifndef VOICECAT_CODEC_OPUS_CODEC_H @@ -25,9 +25,8 @@ enum class OpusApplication { struct OpusParams { uint32_t sample_rate = 48000; // Intended channel/capture sample rate (Hz), used ONLY to cap the encoder's audio bandwidth - // (narrowband/wideband/…) via OPUS_SET_MAX_BANDWIDTH. The codec always runs at 48 kHz - // internally (docs/voice.md §3); this lets a low-bitrate channel constrain encoded bandwidth - // without changing the PCM clock. 0 = unset → full band. Decoder ignores it. + // (narrowband/wideband/…) via OPUS_SET_MAX_BANDWIDTH. this lets a low-bitrate channel constrain encoded bandwidth + // without changing the PCM clock. 0 = unset full band. Decoder ignores it. uint32_t max_bandwidth_hz = 0; uint32_t bitrate_bps = 24000; uint32_t frame_ms = 20; @@ -89,7 +88,7 @@ class OpusDecoder { bool init(const OpusParams& p); // Decode one Opus packet into out_pcm (frame_samples * channels int16 samples). - // opus_data=nullptr, len=0 → PLC (free, always enabled by libopus). + // opus_data=nullptr, len=0 PLC (free, always enabled by libopus). // fec=true, next valid packet in opus_data → FEC recovery from previous loss. // Returns number of samples decoded (= frame_samples), or -1 on error. int decode(const uint8_t* opus_data, int len, int16_t* out_pcm, int max_samples,