Voice Core Intro

Overview

Voice Core adds real-time voice chat to Realtime Core. Each player in a room sends an audio stream that all other players in the room receive.

Voice builds on RealtimeClient. Connecting, matchmaking and rooms work as described in the rest of this manual. A VoiceClient attaches to an existing RealtimeClient and follows it in and out of rooms.

The SDK encodes the audio with Opus, sends it through the room, decodes it and buffers it against network jitter. The application only supplies captured samples and plays the decoded ones.

The SDK does not access audio devices. The application captures and plays audio with any audio library, engine audio system or platform API.

Voice Core uses the same wire protocol as the other Photon Voice SDKs. Clients built with those can share a room with Voice Core clients.

Where to Go Next

Feature Overview

Feature Area Description Manual Page
Outgoing streams Send captured audio to the room, with format, transmit and delivery options. Local Voices
Incoming streams Receive the streams of other players and read them through a jitter buffer. Remote Voices
Audio devices and threading Connect any audio library and share voices with the audio thread. Audio Integration
Targeting Limit a stream to chosen players or an interest group, or echo it back for testing. Targeting and Interest Groups
Statistics Count sent, received and lost frames. Voice Client
Existing projects Keep using the previous Photon Voice C++ API on the Realtime Core binaries. Legacy Voice API

Key Concepts

The API has four main types. VoiceClient connects voice to a room, LocalVoice sends a stream, RemoteVoice receives one and PlaybackBuffer sits between a remote voice and the audio output.

The figure shows the path of one stream from sender to receiver and the thread each step runs on.

Voice Core data flow.
Voice Core data flow.

VoiceClient

One VoiceClient belongs to one RealtimeClient. Its Service() is called every tick together with RealtimeClient::Service(). It creates local voices and reports remote voices as they are added and removed.

Local Voice

A LocalVoice is one outgoing stream, owned by the application as a std::unique_ptr<LocalVoice>. It receives float samples through PushAudio(). Its settings define the stream format, who receives the stream and whether it transmits.

Remote Voice

A RemoteVoice is one incoming stream, identified by the sender's player number and a voice id. It arrives as a std::shared_ptr<RemoteVoice> through OnRemoteVoiceAdded and leaves through OnRemoteVoiceRemoved. It provides the stream format and the sender's user data.

Playback Buffer

Each remote voice owns a PlaybackBuffer, a jitter buffer between the decoder and the audio callback. It smooths out uneven network timing at the cost of a configurable delay. A higher delay plays more smoothly on a jittery network but adds latency, while a lower one risks gaps in the playback.

Legacy Photon Voice C++ API

Voice Core is built on PhotonVoice-cpp, the library of the previous Photon Voice C++ SDK. The PhotonVoice-cpp binaries ship in the Realtime Core SDK.

Existing projects keep their code by installing the legacy headers, while new projects use Voice Core. Legacy Voice API describes the setup.

Supported Platforms

Voice Core runs on Windows, macOS, Linux, iOS and Android. The toolchains are the same as for Realtime Core and are listed on SDK Download.

PlayStation 4, PlayStation 5, Xbox One, Xbox Series X|S, Nintendo Switch and Nintendo Switch 2 are supported through separate voice add-on downloads, listed in Voice Setup. Console access is covered in Consoles Overview.

Requirements

Like Realtime Core, Voice Core requires a C++20 compiler and, for the CMake package, CMake 3.20 or newer.

Connecting requires a Voice App Id, created in the Photon Dashboard.

Capture and playback need an audio library of the application's choice. The Voice Quick Start uses PortAudio.

Known Limitations

Voice Core is available from C++ only. Bindings for other languages will follow.

Voice Core does not support the Web yet. Voice on the Web is available through the legacy Photon Voice native SDK in the meantime.

Voice detection uses a fixed volume threshold and does not adapt to background noise. An improved detector is in development.

Acoustic echo cancellation and noise suppression are not included yet. Until they are, headphones or the platform's own voice processing keep the speaker output out of the microphone.

Only Opus streams are received. Streams that other Photon Voice clients send with another codec are ignored.

Last updated on

Back to top