Skip to content

Commit

Permalink
Adding audio buffer size to preferences, with reasonable default limi…
Browse files Browse the repository at this point in the history
…ts (128-4096). 512 should be a good default for most systems. This will allow users to customize how much audio buffer must be filled prior to audio playback for their systems. Updating docs also, with a description of this setting.
  • Loading branch information
jonoomph committed Dec 9, 2024
1 parent 341978b commit 9057b39
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/preferences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ real-time preview audio settings, for example, which audio device and sample rat
================================ ================== ===========
Setting Default Description
================================ ================== ===========
Default Video Profile HD 720P 30 fps Select the profile for Preview and Export defaults
Default Video Profile HD 720P 30 fps Select the profile for Preview and Export defaults
Playback Audio Buffer Size 512 Adjust how many audio samples must be buffered before audio playback begins. Allowed range of values is 128 to 4096. NOTE: If you are experiencing a large drift or delay in audio playback, try setting this value lower.
Playback Audio Device Default
Default Audio Sample Rate 44100
Default Audio Channels Stereo (2 Channel)
Expand Down
10 changes: 10 additions & 0 deletions src/settings/_default.settings
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@
"values": [],
"restart": true
},
{
"min": 128,
"max": 4096,
"value": 512,
"title": "Playback Audio Buffer Size",
"category": "Preview",
"setting": "playback-buffer-size",
"type": "spinner-int",
"restart": true
},
{
"value": "",
"title": "Playback Audio Device",
Expand Down
2 changes: 2 additions & 0 deletions src/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -3675,6 +3675,7 @@ def __init__(self, *args):
# - OLD settings only includes device name (i.e. "PulseAudio Sound Server")
# - NEW settings include both device name and type (double pipe delimited)
# (i.e. "PulseAudio Sound Server||ALSA")
playback_buffer_size = s.get("playback-buffer-size") or 512
playback_device_value = s.get("playback-audio-device") or ""
playback_device_parts = playback_device_value.split("||")
playback_device_name = playback_device_parts[0]
Expand All @@ -3685,6 +3686,7 @@ def __init__(self, *args):
# Set libopenshot settings
lib_settings.PLAYBACK_AUDIO_DEVICE_NAME = playback_device_name
lib_settings.PLAYBACK_AUDIO_DEVICE_TYPE = playback_device_type
lib_settings.PLAYBACK_AUDIO_BUFFER_SIZE = playback_buffer_size

# Set scaling mode to lower quality scaling (for faster previews)
lib_settings.HIGH_QUALITY_SCALING = False
Expand Down

0 comments on commit 9057b39

Please sign in to comment.