feat(audio): 添加音频数据库支持及XML解析功能

实现音频数据库系统,支持从XML文件加载音频配置
添加RapidXML库用于XML解析
提供统一的音频查询接口,支持音效、音乐和随机音效组
This commit is contained in:
2026-03-21 02:44:29 +08:00
parent 46ca534a19
commit 4870627b4d
8 changed files with 23258 additions and 0 deletions

19186
Game/assets/audio.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,7 @@
#include <frostbite2D/audio/sound.h>
#include <frostbite2D/resource/npk_archive.h>
#include <frostbite2D/resource/audio_database.h>
#include <frostbite2D/resource/sound_pack_archive.h>
using namespace frostbite2D;
@@ -143,6 +144,16 @@ int main(int argc, char **argv) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to load music!");
}
auto &audioDB = AudioDatabase::get();
audioDB.loadFromFile("assets/audio.xml");
// ========== 方式 1: 最简单的 API推荐 ==========
std::string path = audioDB.filePath("P_ICECANNON_SHOT");
if (!path.empty()) {
SDL_Log("=== 方式 1: 直接获取文件路径 ===");
SDL_Log("File: %s", path.c_str());
}
app.run();
app.shutdown();