Addons documentation
  • 😄Getting Started
  • 🧩Components
    • 👟Godot Essentials Motion Component
      • 🤸Top-Down Movement Component
      • 🤾Platform Movement Component
      • 🔲Grid Movement Component
    • 💓Health Component
    • 🎥Shake Camera Component
    • 🌪️Rotator Component
    • 🚀Projectile component
    • 🔁Finite State Machine
  • ⏳Autoload
    • 🎒Helpers
    • 🎧AudioManager
    • 🎬Scene Transicioner
    • ⚙️Environment variables
    • 🏆Achievements
  • 🎮Examples
    • 🧗‍♂️Alys - Precision platformer
Powered by GitBook
On this page
  • Functional Example:
  • API reference
  • Accessible normal variables
  • change_volume(bus, value: float) -> void
  • get_actual_volume_db_from_bus_name(name: String) -> float
  • get_actual_volume_db_from_bus_index(index: int) -> float
  1. Autoload

AudioManager

Several helper functions for managing the volume levels of various buses in your game.

Functional Example:

Let's demonstrate how these functions can assist us in audio management within our game:

extends Control

@onready var music: HSlider = $Parameters/VBoxContainer/HorizontalContainer/Sliders/Music
@onready var sfx: HSlider = $Parameters/VBoxContainer/HorizontalContainer/Sliders/SFX


func _ready():
	music.value = GodotEssentialsAudio.get_actual_volume_db_from_bus("Music")
	sfx.value = GodotEssentialsAudio.get_actual_volume_db_from_bus("SFX")


func _on_music_value_changed(value):
	GodotEssentialsAudio.change_volume("Music", value)


func _on_sfx_value_changed(value):
	change_volume("SFX", value)

API reference

Accessible normal variables

  • available_buses: Array[String]

Here is an array list of the available buses set up in your project, for example:

GodotEssentialsAudio.available_buses # returns ["Master", "Music", "SFX"]

change_volume(bus, value: float) -> void

Change the volume of selected bus_index if it exists. Can receive the bus parameter as name or index.

GodotEssentialsAudio.change_volume(1, 0.5)
GodotEssentialsAudio.change_volume("Music", 0.5)

get_actual_volume_db_from_bus_name(name: String) -> float

Retrieve the current volume value for the selected bus by its name. If the bus_name does not exist in your project, it will raise an error and return a value of 0.0.

GodotEssentialsAudio.get_actual_volume_db_from_bus("Music")

get_actual_volume_db_from_bus_index(index: int) -> float

Retrieve the current volume value for the selected bus by its index.

GodotEssentialsAudio.get_actual_volume_db_from_index(1)
GodotEssentialsAudio.get_actual_volume_db_from_index(AudioServer.get_bus_index("Music"))

PreviousHelpersNextScene Transicioner

Last updated 1 year ago

The script above is a modification of the following script, incorporating our GodotEssentialAudio class.

⏳
🎧
https://github.com/godotessentials/Veneno/blob/main/scenes/ui/options.gd