Sample Rate on EOS_RTCAudio_AddNotifyAudioBeforeRender callback

Hi,

We’re working on rerouting the voice chat audio from EOS to a different audio engine.

Currently we’re grabbing the samples from EOS_RTCAudio_AddNotifyAudioBeforeRender callback and sending them to the audio engine ( also setting them to zero, so EOS won’t render them ). This is working great.

But, something we haven’t figure it out, is the expected Sample Rate the Audio Before Render callback will use. On our tests Win64 will always use a 48k sample rate in this callback, but I wasn’t able to find any documentation in this regards.

Some questions:

  • Is there a way to know in advance the Sample Rate that EOS_RTCAudio_AddNotifyAudioBeforeRender callback will use ?
  • Is the Sample Rate the same even in different platforms ?
  • Does EOS Voice Chat pre render callback uses a variable Sample Rate ( in case the connection quality drops ) ?
  • Is there some documentation for the Sample Rate used in EOS_RTCAudio_AddNotifyAudioBeforeRender callback ?

Thanks in advance,

Alvaro

Hey,

Don’t assume a fixed rate, you should read it from the buffer every callback.

The EOS_RTCAudio_AudioBufferstruct you receive in the AddNotifyAudioBeforeRender callback carries everything you need to interpret the samples:

- SampleRate : sample rate of the Frames in this buffer

- FramesCount : number of frames available

- Channels : number of channels

- Frames : interleaved signed 16-bit PCM

Always use Buffer->SampleRate, Buffer->Channels and Buffer->FramesCount to drive your audio engine rather than hardcoding a value. These describe each buffer authoritatively.

Your specific questions:

  1. There is no API to query the rate before the first callback. Read Buffer->SampleRate from the callback itself.
  2. Don’t rely on it. The render rate is derived from the actual output audio device, so it can differ across devices and platforms. On Win64 the output device is typically 48k, which is why you see a consistent 48000, but you should treat it as device-dependent rather than a guaranteed constant. The SampleRate is also currently clamped to a max value of 48k via a hardcoded config in the EOS SDK. This value could change.
  3. The rate is not affected by network/connection quality. It can change at runtime only if the output audio device changes (e.g. the user switches output device), in which case subsequent buffers report the new rate. So treat SampleRate (and Channels) as values that can change between callbacks, and re-check them rather than caching once.
  4. No documentation on the sample rate as the design is to read the value from the callback every time.

Thanks,

Seb

Hi Alvaro,

The audio processing controls (noise suppression, auto gain control, echo cancellation) are applied locally on the sending client, on the capture path, before the audio goes over the wire. So the audio you receive in AddNotifyAudioBeforeRender is already filtered. Each remote participant’s voice was cleaned by their own client before it was sent. You don’t need to re-implement those filters for the incoming audio. It is also filtered before EOS_RTCAudio_AddNotifyAudioBeforeSend fires.

For reference, the two interception points are:

- EOS_RTCAudio_AddNotifyAudioBeforeSend: outgoing (your captured mic audio, before send)

- EOS_RTCAudio_AddNotifyAudioBeforeRender: incoming (decoded remote audio, before playback)

One thing to keep in mind: echo cancellation normally uses the EOS playback output as its reference. Since you’re zeroing the render buffer and playing through your own engine, EOS AEC loses that reference, so if echo becomes an issue, handle it in your own engine using your actual playback as the reference.

Thanks,

Seb

Hi Alavaro,

It uses WebRTC AEC3.

Thanks,

Seb

Hi [Content removed] Bergeron​ ,

We were able to implement this based on your suggestions and it’s working as expected. Thanks !

I would like to do a follow up question related to the audio processing settings mentioned in here: https://dev.epicgames.com/docs/epic-online-services/multiplayer/voice-and-rtc-interface/voice-interface/using-voice\#change-audio-processing-settings ( echo cancelling, noise suppression, etc ) .

When is that processing done ?

Is it before or after EOS_RTCAudio_AddNotifyAudioBeforeRender ?

I’m asking because since we’re redirecting the audio samples to an audio engine is not clear if we should try to have similar filters.

Thanks in advance,

Alvaro

Hi [Content removed] Bergeron​ ,

Thanks for sharing all the details, this is going to be super useful for our implementation.

Out of curiosity, is EOS using an in house solution for echo cancellation or is it using something like WebRTC AEC3.

Best regards,

Alvaro