godotengine / godotengine/godot

Parameter audio/driver/output_latency typed as INT is too restrictive to adjust the buffer size.

Open
#99,423 1 comment 0 reactions 0 assignees View on GitHub
enhancement topic:audio
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

- Reproducible in 4.4 dev4 and previous releases

### System information

Windows 11

### Issue description

I use a lot of audio tools in combination with Godot :
- Audio interfaces like RME Babyface Pro fs or Motu M2
- Qjackctl for Windows
- Voicemeeter
- BiasFx or BYOD
All these tools let me choose the buffer size to reduce the latency in audio input and output.

For my setup, a buffer size of 256 is a good compromise for audio quality and audio latency.
So, when I try to adjust Godot parameter "audio/driver/output_latency" to set a similar buffer size, it is not possible to obtain a buffer size of 256, due to the input value rounded as integer.

Here are the possible values obtained when I modify this parameter :
0 -> Not possible automatically set to 1
1 -> WASAPI: audio buffer frames: 128 calculated latency: 2ms
2 -> WASAPI: audio buffer frames: 128 calculated latency: 2ms
3 -> WASAPI: audio buffer frames: 144 calculated latency: 3ms
4 -> WASAPI: audio buffer frames: 192 calculated latency: 4ms
5 -> WASAPI: audio buffer frames: 240 calculated latency: 5ms
6 -> WASAPI: audio buffer frames: 288 calculated latency: 6ms
7 -> WASAPI: audio buffer frames: 336 calculated latency: 7ms
8 -> WASAPI: audio buffer frames: 384 calculated latency: 8ms
9 -> WASAPI: audio buffer frames: 432 calculated latency: 9ms
10 -> WASAPI: audio buffer frames: 480 calculated latency: 10ms
> 10 -> WASAPI: audio buffer frames: 480 calculated latency: 10ms

It is difficult to set the buffer size in Godot because we have to do a calculation based on the latency in ms and the default sample rate of audio files.

There is no GDScript function to get back the buffer size, and we have to use the verbose mode to obtain this information.
Such a function is necessary, because there can be a difference between the desired latency and the latency restricted by the audio driver.

I can play with the source code for testing purposes during my development process, but if I release the game, the end users won't be able to adjust this kind of setting to reduce the audio latency consistently with their hardware and OS capabilities.

### Steps to reproduce

Change the parameter value and run Godot in verbose mode to display the message that contains the buffer size and the calculated latency :
"WASAPI: audio buffer frames: 480 calculated latency: 10ms"

### Minimal reproduction project (MRP)

Not necessary, running Godot editor in verbose mode is enough.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the audio/driver/output_latency parameter and the WASAPI verbose output that reports audio buffer frames and calculated latency. Review how the setting reaches the audio driver and how its actual buffer size could be exposed to GDScript. Done should allow the requested buffer-size adjustment and provide the resulting driver buffer size to users.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
audio-video-rtc
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.