ANIPIXELS
Guide

How to add UI sound effects to a Godot 4 game

Updated 29 Oct 2026. Tested in Godot 4.7.2. By Anipixels.

Pack for this guide: Crisp UI (free sampler on itch.io). Also fits: Crisp Cozy, Crisp Cozy Life, Crisp Puzzle, Crisp Cards, Crisp Jingles.

Short answer: Make one autoload script that owns an AudioStreamPlayer per sound, routed to a UI audio bus, and give each player an AudioStreamRandomizer so repeated clicks vary a little in pitch and volume. Then connect to the SceneTree's node_added signal and hook up every BaseButton's mouse_entered, focus_entered and pressed signals, so every button in the game gets sounds without touching any scene.

1. Get short UI sounds

UI sounds should be short (most clicks are under a third of a second), start on the first sample with no silence, and sit at the same loudness, with hovers quieter than clicks because they play constantly. OGG Vorbis files are small and import in Godot as AudioStreamOggVorbis; WAV works too.

Copy them to res://sounds/ui/. The file names in the code below are the ones in the free Crisp UI sampler (hover_soft_01.ogg, click_soft_01.ogg, toggle_on.ogg and so on), so you can drop that sampler in and run it as it is.

2. Add a UI audio bus

Open the Audio panel at the bottom of the editor, click Add Bus and rename the new bus UI. Godot saves it in default_bus_layout.tres. With all interface sounds on one bus, a single settings slider controls them, and you can add effects (a low-pass while paused, for example) to the UI alone.

3. Write the UiSounds autoload

ui_sounds.gd

extends Node
## UiSounds: short UI sounds by name. Add it as an autoload called UiSounds.

const SOUNDS := {
	&"hover": [preload("res://sounds/ui/hover_soft_01.ogg")],
	&"click": [preload("res://sounds/ui/click_soft_01.ogg"), preload("res://sounds/ui/click_wood_01.ogg")],
	&"toggle_on": [preload("res://sounds/ui/toggle_on.ogg")],
	&"toggle_off": [preload("res://sounds/ui/toggle_off.ogg")],
	&"confirm": [preload("res://sounds/ui/confirm_01.ogg")],
	&"error": [preload("res://sounds/ui/error_01.ogg")],
	&"menu_open": [preload("res://sounds/ui/menu_open.ogg")],
	&"menu_close": [preload("res://sounds/ui/menu_close.ogg")],
}

@export var bus: StringName = &"UI"

var _players := {}


func _ready() -> void:
	process_mode = Node.PROCESS_MODE_ALWAYS  # menus still click while the game is paused
	for key in SOUNDS:
		var r := AudioStreamRandomizer.new()
		r.playback_mode = AudioStreamRandomizer.PLAYBACK_RANDOM_NO_REPEATS
		r.random_pitch = 1.05             # each play up to 5% higher or lower
		r.random_volume_offset_db = 1.0   # and up to 1 dB louder or quieter
		for stream in SOUNDS[key]:
			r.add_stream(-1, stream)
		var p := AudioStreamPlayer.new()
		p.stream = r
		p.bus = bus
		p.max_polyphony = 4               # fast clicks overlap instead of cutting off
		add_child(p)
		_players[key] = p
	get_tree().node_added.connect(_on_node_added)


func play(key: StringName) -> void:
	var p: AudioStreamPlayer = _players.get(key)
	if p == null:
		push_warning("UiSounds: no sound called '%s'" % key)
		return
	p.play()


func _on_node_added(node: Node) -> void:
	if node is BaseButton and not node.has_meta(&"ui_sounds"):
		node.set_meta(&"ui_sounds", true)
		node.mouse_entered.connect(_on_hover.bind(node))
		node.focus_entered.connect(_on_focus.bind(node))
		node.pressed.connect(_on_pressed.bind(node))


func _on_hover(button: BaseButton) -> void:
	if not button.disabled:
		play(&"hover")


func _on_focus(button: BaseButton) -> void:
	# Keyboard and gamepad focus moves. A mouse click also gives focus, so stay quiet then.
	if not button.disabled and not Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
		play(&"hover")


func _on_pressed(button: BaseButton) -> void:
	if button.toggle_mode:
		play(&"toggle_on" if button.button_pressed else &"toggle_off")
	else:
		play(&"click")

Add it under Project > Project Settings > Globals > Autoload with the name UiSounds.

What the settings do:

  • PLAYBACK_RANDOM_NO_REPEATS never plays the same variation twice in a row when a sound has two or more files.
  • random_pitch = 1.05 varies the pitch by up to 5% each time (1.0 means no change), and random_volume_offset_db varies the volume. Small amounts stop fast clicks sounding robotic.
  • max_polyphony = 4 lets a quick double-click overlap instead of cutting itself off.
  • PROCESS_MODE_ALWAYS keeps the menu sounds working while the game is paused.

4. Connect every button automatically

Autoloads enter the tree before the main scene, so node_added sees every button of every scene, including ones you create from code later. The script plays:

  • hover when the mouse enters a button, unless the button is disabled;
  • hover again when keyboard or gamepad focus moves to a button. A mouse click also gives a button focus, so the script stays quiet while the left mouse button is held;
  • toggle_on or toggle_off for CheckBox, CheckButton and any button in toggle mode, and click for everything else.

The ui_sounds meta flag stops a button being connected twice when it leaves the tree and comes back. It also works as an opt-out: to keep a button silent, or give it its own sound, add a metadata entry named ui_sounds to it in the Inspector (Add Metadata, at the bottom), or set it in code before the button enters the tree:

button.set_meta(&"ui_sounds", true)   # before add_child(button)

5. Play sounds from code

UiSounds.play(&"menu_open")      # when a panel slides in
UiSounds.play(&"error")          # not enough coins
UiSounds.play(&"confirm")        # purchase done

Keep the sound names in one place (the SOUNDS table) so swapping a sound later is a one-line change.

6. Add a UI volume slider

func _on_ui_volume_value_changed(value: float) -> void:   # HSlider, min 0, max 1, step 0.01
	var bus := AudioServer.get_bus_index("UI")
	AudioServer.set_bus_volume_db(bus, linear_to_db(value))
	AudioServer.set_bus_mute(bus, value < 0.01)

Sliders feel natural on a linear 0 to 1 scale, while buses work in decibels: linear_to_db(0.5) is about -6 dB. Muting at the bottom avoids linear_to_db(0), which is minus infinity.

How this was tested

The script above was run headless in Godot 4.7.2 with the Crisp UI free sampler sounds: buttons were connected automatically, a mouse click played click, a check box played toggle_on and toggle_off, a disabled button stayed silent and keyboard focus played hover.

Free assets to try

Crisp UI Free: 20 UI sounds (clicks, hovers, toggles, confirm, error, menu open and close, coins, level up) as WAV and OGG, free for commercial games. The code on this page uses its file names. Download Crisp UI Free - or get the same 20 sounds as a Godot 4 add-on with a play-by-name autoload: crisp-ui-sounds-free on GitHub.

Crisp Cozy Free: 20 softer, warmer sounds (wooden taps, bubble pops, a page turn, planting and watering) for cozy games. Download Crisp Cozy Free.

Listen to all the free sampler sounds first in the UI sound board.

The full Crisp UI pack has 583 UI sounds, many of them in numbered variations ready for the randomizer ($4.99). Crisp Cozy has 1,363 cozy sounds and ships a Godot 4 sound bank with one AudioStreamRandomizer per sound and a one-line play() autoload ($4.99). About Crisp UI: Claude (an AI assistant) designed everything in this pack; every sound is synthesised by code, with no recordings. All 19 Crisp packs are also in the Crisp Everything Bundle for $17.99.

More guides

All guides