class

FVoiceChatSystem

Module
VoiceChat
Header
#include "VoiceChat/FVoiceChatSystem.h"
Namespace
Mowo

Type aliases

AliasDescription
using FPacketSink = std::function<void(uint32_t peerId, const uint8_t* data, size_t len, NetworkChannel channel)>
using FPositionProvider = std::function<bool(uint32_t peerId, Vec3& outPosition)>
using FOcclusionProvider = std::function<FSoundOcclusionResult(const Vec3& from, const Vec3& to)>
using FSpeakingChangedHandler = std::function<void(const FVoiceSpeakerInfo& info)>
using FRadioCarrierProvider = std::function<void(std::vector<FVoiceRadioCarrier>& outCarriers)>
using FRadioNoiseHandler = std::function<void(const Vec3& position, float loudness)>
using FGrainProvider = std::function<float(uint32_t peerId, const Vec3& speaker, const Vec3& listener)>Extra grain for a voice travelling from speaker to listener, 0..1 — the game's own reason a voice breaks up (darkness, interference) on top of distance. The larger of this and the distance grain applies.
using FPlaybackTap = std::function<void(uint32_t peerId, const int16_t* samples, uint32_t sampleCount, bool realFrame)>Every frame handed to a speaker's playback stream, after decode and loss recovery. Tools and tests listen here; it runs whether or not an audio device exists.

Properties

TypeNameDescription
static constexpr uint32_tkSampleRateThe ADPCM format, and the format the system runs at before a codec is chosen. GetSampleRate()/GetFrameSamples() report what is ACTUALLY running; anything sizing a buffer must ask those. Default 16000.
static constexpr uint32_tkFrameSamplesDefault 320.
static constexpr floatkFrameSecondsDefault static_cast<float>(kFrameSamples) / static_cast<float>(kSampleRate).
static constexpr size_tkPacketHeaderBytesDefault 14.
static constexpr uint8_tkPacketMagic0Default 'M'.
static constexpr uint8_tkPacketMagic1Default 'V'.
static constexpr uint8_tkPacketVersionDefault 1.
static constexpr uint32_tkInvalidPeerIdDefault 0xFFFFFFFFu.
static constexpr uint32_tkMaxRadioEmittersA listener hears a transmission from its own radio plus at most this many of the nearest others. Default 4.
static constexpr uint8_tkFlagMimicryConsentHeader byte 5. The talker's own client sets it on every frame, so a change of mind takes effect on the next 20 ms, and the relay copies it through untouched. Default 0x01.

Constructors

SignatureNameDescription
FVoiceChatSystem()FVoiceChatSystemBoth defined out of line: the capture device, the capture ring and the per-speaker playback source are all incomplete here.
~FVoiceChatSystem() override~FVoiceChatSystem
FVoiceChatSystem(const FVoiceChatSystem&) = deleteFVoiceChatSystem

Public functions

ReturnsNameDescription
FVoiceChatSystem&operator=
voidInitialize
voidUpdate
voidShutdown
uint32_tGetSampleRateThe active codec's format.
uint32_tGetFrameSamples
floatGetFrameSeconds
std::vector<FVoiceDeviceInfo>EnumerateInputDevicesCapture devices
boolSetInputDevice
const std::string&GetInputDevice
boolStartCapture
voidStopCapture
boolIsCapturing
voidPushCapturedSamplesFeeds captured PCM into the lock-free ring.
voidSetModeTransmission
EVoiceModeGetMode
voidSetPushToTalkHeld
boolIsPushToTalkHeld
voidSetRadioKeyHeld
boolIsRadioKeyHeld
EVoiceTransmitChannelGetActiveTransmitChannel
voidSetEnergyGateOpen-mic energy gate.
floatGetGateOpenRms
floatGetGateCloseRms
boolIsGateOpen
floatGetLastCaptureRms
voidSetInputGainLinear gain applied to captured samples before the gate reads their energy, so raising it opens the gate on a quiet microphone instead of only making an already-transmitting voice louder.
floatGetInputGain
voidSetProcessorSettingsEcho cancellation, noise suppression and automatic gain, run on every captured frame before the gate reads it and before it is encoded — the gate then opens on speech rather than on a fan, and nobody hears themselves come back out of someone's speakers.
const FVoiceProcessorSettings&GetProcessorSettings
const FVoiceProcessor&GetProcessor
voidSetSelfMuted
boolIsSelfMuted
boolIsPlatformMutedMute and deafen mirrored from the player's platform voice client (Discord) while voice.FollowPlatformMute is on.
boolIsPlatformDeafened
voidApplyPlatformVoiceState
voidSetPeerMutedPlayback.
boolIsPeerMuted
voidSetPeerVolume
floatGetPeerVolume
voidSetMasterVoiceVolume
floatGetMasterVoiceVolume
voidSetHearingRangeProximity
floatGetHearingMinDistance
floatGetHearingMaxDistance
voidSetRolloff
floatGetRolloff
voidSetProximityHysteresisFraction of MaxDistance added to the LEAVE threshold.
floatGetProximityHysteresis
floatEvaluateAttenuationGain a listener at distance hears a proximity speaker at, 0..1.
boolIsAudibleToTrue when listenerPeerId is inside the speaker's hearing range, hysteresis included.
voidSetDistanceLowPassThree layers, each a different cue, so a listener can tell a far voice from a walled one: distance takes level and top end (the low-pass slides from nearHz at MinDistance to farHz at MaxDistance, interpolated in log frequency), occlusion takes level and top end by the wall's material, and grain takes fidelity — past startFraction of the hearing range the voice breaks up, reaching maxAmount at its edge.
floatGetDistanceLowPassNear
floatGetDistanceLowPassFar
floatEvaluateDistanceCutoff
voidSetGrainRange
floatGetGrainStart
floatGetGrainMax
floatEvaluateDistanceGrain
voidSetGrainProvider
voidSetOcclusionEnabledOcclusion
boolIsOcclusionEnabled
voidSetRadioCarrierProviderRadio speakers.
voidSetRadioNoiseHandler
voidSetRadioSpeakerRange
floatGetRadioSpeakerRange
voidSetRadioVolume
floatGetRadioVolume
voidSetRadioBandPassEnabled
boolIsRadioBandPassEnabled
std::vector<FVoiceRadioEmitterInfo>GetRadioEmitters
floatEvaluateRadioAttenuationGain a listener at distance hears another carrier's radio at: full out to a metre, the inverse law to the speaker range, silence past it.
voidSetOcclusionSmoothingHow fast a voice glides onto a new occlusion target, per second.
floatGetOcclusionSmoothing
voidSetBytesPerSecondBudgetBandwidth.
uint32_tGetBytesPerSecondBudget
floatGetByteTokens
voidSetLocalPeerIdNetworking
uint32_tGetLocalPeerId
voidSetIsServer
boolIsServer
voidRegisterPeer
voidUnregisterPeer
std::vector<uint32_t>GetPeerIds
voidSetPacketSink
voidClearPacketSink
voidSetPlaybackTap
voidSetPlaybackTapKeyed taps for features that live with the scene (auto-subtitles): one per owner, re-registering replaces, null removes.
voidSetMimicryConsentMimicry.
boolGetMimicryConsent
voidSetFragmentCaptureEnabled
boolIsFragmentCaptureEnabled
boolHasPeerMimicryConsent
FVoiceFragmentBuffer&GetFragmentBuffer
const FVoiceFragmentBuffer&GetFragmentBuffer
voidSetPositionProvider
voidSetOcclusionProvider
uint32_tOcclusionLayerMaskThe layers a voice occlusion ray may stop on — FSoundOcclusion's, so a voice and a world sound stop on the same bodies.
voidSetListenerPosition
boolHandleIncomingPacketDecodes one voice packet.
boolOnIncomingPacketThe NetworkManager data-observer entry point — true means consumed.
boolIsSpeakingSpeaking state
boolIsLocalSpeaking
boolIsAnyoneSpeakingNearby
boolTryGetSpeakerInfo
std::vector<FVoiceSpeakerInfo>GetSpeakers
int32_tAddSpeakingChangedHandler
voidRemoveSpeakingChangedHandler
voidClearSpeakingChangedHandlers
voidSetSpeakingChangedHandlerKeyed registration for scene-lifetime handlers: re-registering the same owner REPLACES its handler instead of appending, so idempotent attach passes (Scene wiring, plugin hooks) never accumulate duplicates and never need a Clear whose ordering could drop another owner's hook — the bug shape that forced WireVoiceChat to run before the modular attach pass.
IVoiceCodec*GetCodecCodec
voidSetCodec
boolSelectCodecInstalls the codec the preference names.
EVoiceCodecPreferenceGetCodecPreference
EVoiceCodecPreferenceParseCodecPreference"auto" / "opus" / "adpcm" — the spelling the voice.Codec cvar and the settings screen both use.
const char*CodecPreferenceName
const FVoiceStats&GetStats
voidResetStats
const FVoiceJitterBuffer*FindJitterBuffer
uint32_tGetQueuedCaptureSamples
voidSetJitterDepthJitter tuning — target lead in frames and the hard queue ceiling.
FVoiceChatSystem*GetActive
voidWritePacketHeaderHeader writer/reader, exposed so a test can build a malformed packet without duplicating the layout.

Function details

FVoiceChatSystem

C++
FVoiceChatSystem()

Both defined out of line: the capture device, the capture ring and the per-speaker playback source are all incomplete here.

~FVoiceChatSystem

C++
~FVoiceChatSystem() override

FVoiceChatSystem

C++
FVoiceChatSystem(const FVoiceChatSystem&) = delete

operator=

C++
FVoiceChatSystem& operator=(const FVoiceChatSystem&) = delete

Initialize

C++
void Initialize(World* world) override

Update

C++
void Update(float deltaTime) override

Shutdown

C++
void Shutdown() override

GetSampleRate

C++
uint32_t GetSampleRate() const

The active codec's format. Every frame the system captures, encodes, buffers and plays is this many samples at this rate.

GetFrameSamples

C++
uint32_t GetFrameSamples() const

GetFrameSeconds

C++
float GetFrameSeconds() const

EnumerateInputDevices

C++
static std::vector<FVoiceDeviceInfo> EnumerateInputDevices()

Capture devices

SetInputDevice

C++
bool SetInputDevice(const std::string& deviceId)

GetInputDevice

C++
const std::string& GetInputDevice() const

StartCapture

C++
bool StartCapture()

StopCapture

C++
void StopCapture()

IsCapturing

C++
bool IsCapturing() const

PushCapturedSamples

C++
void PushCapturedSamples(const int16_t* samples, uint32_t count)

Feeds captured PCM into the lock-free ring. Called from the miniaudio capture callback, which is why it neither allocates nor locks; also the injection point for headless drivers and tests.

SetMode

C++
void SetMode(EVoiceMode mode)

Transmission

GetMode

C++
EVoiceMode GetMode() const

SetPushToTalkHeld

C++
void SetPushToTalkHeld(bool held)

IsPushToTalkHeld

C++
bool IsPushToTalkHeld() const

SetRadioKeyHeld

C++
void SetRadioKeyHeld(bool held)

IsRadioKeyHeld

C++
bool IsRadioKeyHeld() const

GetActiveTransmitChannel

C++
EVoiceTransmitChannel GetActiveTransmitChannel() const

SetEnergyGate

C++
void SetEnergyGate(float openRms, float closeRms, float holdSeconds)

Open-mic energy gate. Opens at openRms, closes only below closeRms (hysteresis against a voice sitting on the threshold) and holds open for holdSeconds after the last loud frame so word gaps do not chop.

GetGateOpenRms

C++
float GetGateOpenRms() const

GetGateCloseRms

C++
float GetGateCloseRms() const

IsGateOpen

C++
bool IsGateOpen() const

GetLastCaptureRms

C++
float GetLastCaptureRms() const

SetInputGain

C++
void SetInputGain(float gain)

Linear gain applied to captured samples before the gate reads their energy, so raising it opens the gate on a quiet microphone instead of only making an already-transmitting voice louder.

GetInputGain

C++
float GetInputGain() const

SetProcessorSettings

C++
void SetProcessorSettings(const FVoiceProcessorSettings& settings)

Echo cancellation, noise suppression and automatic gain, run on every captured frame before the gate reads it and before it is encoded — the gate then opens on speech rather than on a fan, and nobody hears themselves come back out of someone's speakers.

GetProcessorSettings

C++
const FVoiceProcessorSettings& GetProcessorSettings() const

GetProcessor

C++
const FVoiceProcessor& GetProcessor() const

SetSelfMuted

C++
void SetSelfMuted(bool muted)

IsSelfMuted

C++
bool IsSelfMuted() const

IsPlatformMuted

C++
bool IsPlatformMuted() const

Mute and deafen mirrored from the player's platform voice client (Discord) while voice.FollowPlatformMute is on. Kept apart from the in-game mute so unmuting in Discord never unmutes a player who muted here as well.

IsPlatformDeafened

C++
bool IsPlatformDeafened() const

ApplyPlatformVoiceState

C++
void ApplyPlatformVoiceState(bool muted, bool deafened)

SetPeerMuted

C++
void SetPeerMuted(uint32_t peerId, bool muted)

Playback. Muting takes effect on what is already in flight too: the speaker's queued packets and the samples waiting in its playback stream are dropped, its radios close, and anything kept of its voice for mimicry is forgotten.

IsPeerMuted

C++
bool IsPeerMuted(uint32_t peerId) const

SetPeerVolume

C++
void SetPeerVolume(uint32_t peerId, float volume)

GetPeerVolume

C++
float GetPeerVolume(uint32_t peerId) const

SetMasterVoiceVolume

C++
void SetMasterVoiceVolume(float volume)

GetMasterVoiceVolume

C++
float GetMasterVoiceVolume() const

SetHearingRange

C++
void SetHearingRange(float minDistance, float maxDistance)

Proximity

GetHearingMinDistance

C++
float GetHearingMinDistance() const

GetHearingMaxDistance

C++
float GetHearingMaxDistance() const

SetRolloff

C++
void SetRolloff(float rolloff)

GetRolloff

C++
float GetRolloff() const

SetProximityHysteresis

C++
void SetProximityHysteresis(float fraction)

Fraction of MaxDistance added to the LEAVE threshold. 0.15 means a peer enters the relay set at MaxDistance and only leaves past 1.15x it.

GetProximityHysteresis

C++
float GetProximityHysteresis() const

EvaluateAttenuation

C++
float EvaluateAttenuation(float distance) const

Gain a listener at distance hears a proximity speaker at, 0..1. The same inverse-with-rolloff curve miniaudio's default attenuation applies, evaluated on the CPU so the relay decision and the test can agree with what the mixer does.

IsAudibleTo

C++
bool IsAudibleTo(uint32_t speakerPeerId, uint32_t listenerPeerId, EVoiceTransmitChannel channel)

True when listenerPeerId is inside the speaker's hearing range, hysteresis included. Radio always returns true. Unresolvable positions fail OPEN — a missing pawn must not silence a player.

SetDistanceLowPass

C++
void SetDistanceLowPass(float nearHz, float farHz)

Three layers, each a different cue, so a listener can tell a far voice from a walled one: distance takes level and top end (the low-pass slides from nearHz at MinDistance to farHz at MaxDistance, interpolated in log frequency), occlusion takes level and top end by the wall's material, and grain takes fidelity — past startFraction of the hearing range the voice breaks up, reaching maxAmount at its edge. A nearHz at or above 19999 Hz with an equal farHz switches the distance low-pass off; a maxAmount of 0 switches grain off.

GetDistanceLowPassNear

C++
float GetDistanceLowPassNear() const

GetDistanceLowPassFar

C++
float GetDistanceLowPassFar() const

EvaluateDistanceCutoff

C++
float EvaluateDistanceCutoff(float distance) const

SetGrainRange

C++
void SetGrainRange(float startFraction, float maxAmount)

GetGrainStart

C++
float GetGrainStart() const

GetGrainMax

C++
float GetGrainMax() const

EvaluateDistanceGrain

C++
float EvaluateDistanceGrain(float distance) const

SetGrainProvider

C++
void SetGrainProvider(FGrainProvider provider)

SetOcclusionEnabled

C++
void SetOcclusionEnabled(bool enabled)

Occlusion

IsOcclusionEnabled

C++
bool IsOcclusionEnabled() const

SetRadioCarrierProvider

C++
void SetRadioCarrierProvider(FRadioCarrierProvider provider)

Radio speakers. The provider lists every carrier and where their radio hangs; without one the only radio is the listener's own, at the listener. Another carrier's radio is audible out to the speaker range.

SetRadioNoiseHandler

C++
void SetRadioNoiseHandler(FRadioNoiseHandler handler)

SetRadioSpeakerRange

C++
void SetRadioSpeakerRange(float meters)

GetRadioSpeakerRange

C++
float GetRadioSpeakerRange() const

SetRadioVolume

C++
void SetRadioVolume(float volume)

GetRadioVolume

C++
float GetRadioVolume() const

SetRadioBandPassEnabled

C++
void SetRadioBandPassEnabled(bool enabled)

IsRadioBandPassEnabled

C++
bool IsRadioBandPassEnabled() const

GetRadioEmitters

C++
std::vector<FVoiceRadioEmitterInfo> GetRadioEmitters(uint32_t speakerPeerId) const

EvaluateRadioAttenuation

C++
float EvaluateRadioAttenuation(float distance) const

Gain a listener at distance hears another carrier's radio at: full out to a metre, the inverse law to the speaker range, silence past it.

SetOcclusionSmoothing

C++
void SetOcclusionSmoothing(float ratePerSecond)

How fast a voice glides onto a new occlusion target, per second. Zero or less means the shared rate from the occlusion table.

GetOcclusionSmoothing

C++
float GetOcclusionSmoothing() const

SetBytesPerSecondBudget

C++
void SetBytesPerSecondBudget(uint32_t bytesPerSecond)

Bandwidth. A hard per-client cap in bytes/second over the outgoing voice stream; frames over budget are DROPPED, never queued — a queued voice frame is a stale voice frame.

GetBytesPerSecondBudget

C++
uint32_t GetBytesPerSecondBudget() const

GetByteTokens

C++
float GetByteTokens() const

SetLocalPeerId

C++
void SetLocalPeerId(uint32_t peerId)

Networking

GetLocalPeerId

C++
uint32_t GetLocalPeerId() const

SetIsServer

C++
void SetIsServer(bool isServer)

IsServer

C++
bool IsServer() const

RegisterPeer

C++
void RegisterPeer(uint32_t peerId)

UnregisterPeer

C++
void UnregisterPeer(uint32_t peerId)

GetPeerIds

C++
std::vector<uint32_t> GetPeerIds() const

SetPacketSink

C++
void SetPacketSink(FPacketSink sink)

ClearPacketSink

C++
void ClearPacketSink()

SetPlaybackTap

C++
void SetPlaybackTap(FPlaybackTap tap)

SetPlaybackTap

C++
void SetPlaybackTap(const char* owner, FPlaybackTap tap)

Keyed taps for features that live with the scene (auto-subtitles): one per owner, re-registering replaces, null removes. They hear what the player hears — a muted or deafened speaker is silence here too.

SetMimicryConsent

C++
void SetMimicryConsent(bool consent)

Mimicry. The local player's consent to have their voice kept as short fragments by whoever hosts the creature (voice.MimicryConsent, on by default — the opt-out lives on the player's settings screen), stamped on every frame this client sends. Capture is the receiving side's choice (voice.MimicryCapture, off by default): only a host that runs a mimic turns it on, and it keeps only consenting, unmuted talkers.

GetMimicryConsent

C++
bool GetMimicryConsent() const

SetFragmentCaptureEnabled

C++
void SetFragmentCaptureEnabled(bool enabled)

IsFragmentCaptureEnabled

C++
bool IsFragmentCaptureEnabled() const

HasPeerMimicryConsent

C++
bool HasPeerMimicryConsent(uint32_t peerId) const

GetFragmentBuffer

C++
FVoiceFragmentBuffer& GetFragmentBuffer()

GetFragmentBuffer

C++
const FVoiceFragmentBuffer& GetFragmentBuffer() const

SetPositionProvider

C++
void SetPositionProvider(FPositionProvider provider)

SetOcclusionProvider

C++
void SetOcclusionProvider(FOcclusionProvider provider)

OcclusionLayerMask

C++
static uint32_t OcclusionLayerMask()

The layers a voice occlusion ray may stop on — FSoundOcclusion's, so a voice and a world sound stop on the same bodies.

SetListenerPosition

C++
void SetListenerPosition(const Vec3& position)

HandleIncomingPacket

C++
bool HandleIncomingPacket(uint32_t senderPeerId, const uint8_t* data, size_t len)

Decodes one voice packet. On a server it also relays the frame to the peers that can hear it. Returns false when the packet was refused.

OnIncomingPacket

C++
bool OnIncomingPacket(const NetworkEvent& evt)

The NetworkManager data-observer entry point — true means consumed.

IsSpeaking

C++
bool IsSpeaking(uint32_t peerId) const

Speaking state

IsLocalSpeaking

C++
bool IsLocalSpeaking() const

IsAnyoneSpeakingNearby

C++
bool IsAnyoneSpeakingNearby() const

TryGetSpeakerInfo

C++
bool TryGetSpeakerInfo(uint32_t peerId, FVoiceSpeakerInfo& out) const

GetSpeakers

C++
std::vector<FVoiceSpeakerInfo> GetSpeakers() const

AddSpeakingChangedHandler

C++
int32_t AddSpeakingChangedHandler(FSpeakingChangedHandler handler)

RemoveSpeakingChangedHandler

C++
void RemoveSpeakingChangedHandler(int32_t handle)

ClearSpeakingChangedHandlers

C++
void ClearSpeakingChangedHandlers()

SetSpeakingChangedHandler

C++
void SetSpeakingChangedHandler(const char* owner, FSpeakingChangedHandler handler)

Keyed registration for scene-lifetime handlers: re-registering the same owner REPLACES its handler instead of appending, so idempotent attach passes (Scene wiring, plugin hooks) never accumulate duplicates and never need a Clear whose ordering could drop another owner's hook — the bug shape that forced WireVoiceChat to run before the modular attach pass.

GetCodec

C++
IVoiceCodec* GetCodec() const

Codec

SetCodec

C++
void SetCodec(std::unique_ptr<IVoiceCodec> codec)

SelectCodec

C++
bool SelectCodec(EVoiceCodecPreference preference)

Installs the codec the preference names. False when the preference named Opus and this build has no Opus — the caller learns the request was refused instead of finding out from the pitch of the session.

GetCodecPreference

C++
EVoiceCodecPreference GetCodecPreference() const

ParseCodecPreference

C++
static EVoiceCodecPreference ParseCodecPreference(const std::string& name)

"auto" / "opus" / "adpcm" — the spelling the voice.Codec cvar and the settings screen both use. Anything else reads as Auto.

CodecPreferenceName

C++
static const char* CodecPreferenceName(EVoiceCodecPreference preference)

GetStats

C++
const FVoiceStats& GetStats() const

ResetStats

C++
void ResetStats()

FindJitterBuffer

C++
const FVoiceJitterBuffer* FindJitterBuffer(uint32_t peerId) const

GetQueuedCaptureSamples

C++
uint32_t GetQueuedCaptureSamples() const

SetJitterDepth

C++
void SetJitterDepth(uint32_t targetFrames, uint32_t maxFrames)

Jitter tuning — target lead in frames and the hard queue ceiling.

GetActive

C++
static FVoiceChatSystem* GetActive()

WritePacketHeader

C++
static void WritePacketHeader(uint8_t* out, EVoiceCodecId codec, EVoiceTransmitChannel channel, uint32_t speakerPeerId, uint16_t sequence, uint16_t payloadLen, uint8_t flags = 0)

Header writer/reader, exposed so a test can build a malformed packet without duplicating the layout.

Generated from VoiceChat/FVoiceChatSystem.h via voicechat.json · Oct 26, 2026Version 1.0.0