DatabaseAudio ​
Inherits: RefCounted
The audio library of the project, read from the folders under res://src/data/audio/.
Description ​
SFX_CATEGORIES lists the categories (music, ambience, UI, voices, voicelines, footsteps, casting, impact, loops, environmental, interactables ...) with their folder, how the folder is organised and the file types. The folders are scanned once on first use. The albums (collections of tracks) are not here: they are the Music Albums of the project (SoundAlbum, Audio > Music Albums).
Methods ​
Array[String] | get_ui_sound_names() static |
Array[String] | get_missing_ui_sounds() static |
Dictionary | get_addable_sections() static |
void | initialize() static |
void | ensure_initialized() static |
void | ensure_category_directories() static |
Array[String] | get_sfx_categories() static |
Dictionary | get_category_info( category: String ) static |
Dictionary | import_files( category: String, type_name: String, file_paths: PackedStringArray ) static |
String | get_category_display_name( category: String ) static |
Array[String] | get_available_types( category: String ) static |
Array[String] | get_available_files( category: String, type: String = "" ) static |
AudioStream | get_random_sfx_audio( category: String, type: String ) static |
AudioStream | get_specific_sfx_audio( category: String, type: String, file_name: String ) static |
AudioStream | get_random_footsteps_audio( entity_type: String, surface: String, movement: String ) static |
AudioStream | get_random_voice_audio( entity_type: String, voice_variant: String, action: String ) static |
Array[String] | get_available_footstep_entities() static |
Array[String] | get_available_surfaces( entity_type: String ) static |
Array[String] | get_available_movements( entity_type: String, surface: String ) static |
Array[String] | get_available_voice_entities() static |
Array[String] | get_available_voice_variants( entity_type: String ) static |
bool | is_valid_voice_name( folder_name: String ) static |
Array[String] | get_voice_files( entity_type: String, voice_variant: String, call_name: String ) static |
Dictionary | get_voice_report( entity_type: String, voice_variant: String ) static |
String | create_voice_type( entity_type: String ) static |
String | create_voice_variant( entity_type: String, voice_variant: String ) static |
Dictionary | rename_voice_variant( entity_type: String, old_name: String, new_name: String ) static |
String | copy_voice_variant( entity_type: String, source_name: String, new_name: String ) static |
String | create_voice_call_folder( entity_type: String, voice_variant: String, call_name: String ) static |
Dictionary | import_voice_files( entity_type: String, voice_variant: String, call_name: String, file_paths: PackedStringArray ) static |
Array[String] | get_voice_usage( entity_type: String, voice_variant: String ) static |
Array[String] | get_available_voice_actions( entity_type: String, voice_variant: String ) static |
AudioStream | get_random_voiceline_audio( character_name: String, language: String = "" ) static |
AudioStream | get_voiceline_audio( character_name: String, file_name: String, language: String = "" ) static |
String | get_voiceline_path( character_name: String, file_name: String, language: String = "" ) static |
String | get_voiceline_language_path( character_name: String, file_name: String, language: String ) static |
Array[String] | get_voiceline_language_folders( character_name: String ) static |
Array[String] | get_available_voiceline_characters() static |
Array | get_all_voiceline_files_for_character( character_name: String ) static |
Array | get_all_voice_files( entity_type: String, voice_variant: String, action: String ) static |
Array[String] | get_available_file_names( category: String, type: String ) static |
Array[String] | get_available_voice_actions_for_ui( entity_type: String, voice_variant: String ) static |
Array[String] | get_all_footstep_files( entity_type: String, surface: String, movement: String ) static |
void | refresh_database() static |
Dictionary | get_database_stats() static |
Constants ​
StringAUDIO_RESOURCES_PATH ="res://src/data/audio/"- ========== PATHS ==========DictionarySFX_CATEGORIES ={- ========== Audio CATEGORY DEFINITIONS ========== Organized by source/origin: Tracks, UI, Character Audio, Ability Audio, World AudioDictionaryFOLDER_HELP ={- What the folder name of each category is for, in plain words (the Audio tab shows it when you add a folder)DictionarySECTIONS ={- The words of the sections of the Audio tab, and which categories belong to eachStringVOICES_PATH ="res://src/data/audio/entity_voices/"- The folder of the voices
Method descriptions ​
Array[String] get_ui_sound_names() ​
The names of the interface sounds the game knows: the folders of ui_sfx that it looks for (AudioManager.UISound)
Array[String] get_missing_ui_sounds() ​
The interface sounds the game knows that the library has no folder for yet
Dictionary get_addable_sections() ​
The categories you can add a folder to (the ones whose folders are free names), by section: {section: [categories]}
void initialize() ​
Initialize the SFX database by scanning all categories
void ensure_initialized() ​
Ensure database is initialized before any operation (private)
void ensure_category_directories() ​
Ensure category directories exist
Array[String] get_sfx_categories() ​
Get all available SFX categories
Dictionary get_category_info( category: String ) ​
Get category info
Dictionary import_files( category: String, type_name: String, file_paths: PackedStringArray ) ​
Copies sound files from anywhere on the computer (or from the project) into a folder of the library. Files that are not sound files of the category, and files the folder has already, are not copied. Returns {imported: the paths in the library, skipped: [name and why], error: "" or why nothing was done}
String get_category_display_name( category: String ) ​
Get category display name
Array[String] get_available_types( category: String ) ​
Get available types for a category
Array[String] get_available_files( category: String, type: String = "" ) ​
Get available files for a category and type
AudioStream get_random_sfx_audio( category: String, type: String ) ​
Get random audio from SFX category
AudioStream get_specific_sfx_audio( category: String, type: String, file_name: String ) ​
Get specific audio file by name from SFX category
AudioStream get_random_footsteps_audio( entity_type: String, surface: String, movement: String ) ​
Get random footsteps audio
AudioStream get_random_voice_audio( entity_type: String, voice_variant: String, action: String ) ​
Get random voice audio
Array[String] get_available_footstep_entities() ​
Get all discovered entity types for footsteps
Array[String] get_available_surfaces( entity_type: String ) ​
Get all available surfaces for a specific entity
Array[String] get_available_movements( entity_type: String, surface: String ) ​
Get all available movements for an entity and surface
Array[String] get_available_voice_entities() ​
Get all discovered entity types for voices
Array[String] get_available_voice_variants( entity_type: String ) ​
Get all available voice variants for a specific entity
bool is_valid_voice_name( folder_name: String ) ​
Is this a name a voice folder can have (letters, numbers, underscores, hyphens; not empty)?
Array[String] get_voice_files( entity_type: String, voice_variant: String, call_name: String ) ​
The files of a call of a voice (the folder called exactly that), empty when there are none
Dictionary get_voice_report( entity_type: String, voice_variant: String ) ​
What a voice has, against the voice calls: {calls: {name: {files, folder, via}}, custom: [folder names that are no call], missing_required: [names], missing: [names]}. folder is the folder that has the files of the call (the call or an older name), via the call that stands in for it when it has none ("" when it has its own or nothing stands in)
String create_voice_type( entity_type: String ) ​
Makes the folder of a new kind of creature (an entity type with voices). The error in words, "" when it was made
String create_voice_variant( entity_type: String, voice_variant: String ) ​
Makes the folder of a new voice of an entity type
Dictionary rename_voice_variant( entity_type: String, old_name: String, new_name: String ) ​
Renames a voice (the folder of a voice of an entity type) and gives every NPC, character and player class that has it the new name, so none of them is left with a voice that is gone. Returns {error, updated}: the error in words ("" when it was renamed) and how many definitions were changed
String copy_voice_variant( entity_type: String, source_name: String, new_name: String ) ​
Copies a voice (all its folders and files) as the start of another voice of the same kind of creature. The error in words, "" when it was copied
String create_voice_call_folder( entity_type: String, voice_variant: String, call_name: String ) ​
Makes the folder of a call of a voice (an empty folder to put the files in)
Dictionary import_voice_files( entity_type: String, voice_variant: String, call_name: String, file_paths: PackedStringArray ) ​
Copies sound files from anywhere into the folder of a call of a voice (the folder is made when it is not there). Returns {imported, skipped, error} as import_files does
Array[String] get_voice_usage( entity_type: String, voice_variant: String ) ​
Who uses a voice: the NPCs, characters and player classes whose voice is entity_type/voice_variant, as "NPC: Goblin"
Array[String] get_available_voice_actions( entity_type: String, voice_variant: String ) ​
Get all available actions for an entity and voice variant
AudioStream get_random_voiceline_audio( character_name: String, language: String = "" ) ​
Get random voiceline audio for a character, in the voice language of the player (the file of the same name in the language folder when there is one)
AudioStream get_voiceline_audio( character_name: String, file_name: String, language: String = "" ) ​
Get specific voiceline audio by character and filename, in the voice language of the player (the file of the same name in the language folder when there is one, else the default file)
String get_voiceline_path( character_name: String, file_name: String, language: String = "" ) ​
The path of a voice line: the file in the language folder of the voice language ("" language = the voice language of the player) when the language is not the source language and the file exists there, else the default file. "" when the line does not exist.
String get_voiceline_language_path( character_name: String, file_name: String, language: String ) ​
The path of a voice line in the language folder of a language ("" when that language has no such file).
Array[String] get_voiceline_language_folders( character_name: String ) ​
The names of the language folders a character has (any folder inside its folder; the editor shows the ones that are languages of the game).
Array[String] get_available_voiceline_characters() ​
Get all discovered characters for voicelines
Array get_all_voiceline_files_for_character( character_name: String ) ​
Get all files for a voiceline character (for editor)
Array get_all_voice_files( entity_type: String, voice_variant: String, action: String ) ​
Get all files for a voice entity/variant/action (for editor)
Array[String] get_available_file_names( category: String, type: String ) ​
Get available file names for a specific SFX category and type
Array[String] get_available_voice_actions_for_ui( entity_type: String, voice_variant: String ) ​
Get available voice actions for specific entity_type and voice_variant (for UI dropdowns)
Array[String] get_all_footstep_files( entity_type: String, surface: String, movement: String ) ​
Get all footstep files for specific parameters
void refresh_database() ​
Refresh database (rescan filesystem)
Dictionary get_database_stats() ​
Get database statistics