Prepare audio system and UI for surround

This commit is contained in:
doop
2026-09-02 22:45:43 +00:00
parent 9e05a0a692
commit defeac3fab
12 changed files with 159 additions and 44 deletions
+36 -7
View File
@@ -72,6 +72,13 @@ constexpr std::array kInterpolationModes = {
"Unlimited",
};
constexpr std::array kAudioOutputModeNames = {
"Stereo (Speakers)",
"Stereo (Headphones)",
"5.1 Surround",
"7.1 Surround",
};
constexpr std::array kTouchTargetingLabels = {
"Hybrid",
"Hold",
@@ -1044,6 +1051,35 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
auto& leftPane = add_child<Pane>(content, Pane::Type::Controlled);
auto& rightPane = add_child<Pane>(content, Pane::Type::Uncontrolled);
leftPane.add_section("Output");
leftPane.register_control(
leftPane.add_select_button({
.key = "Output Mode",
.getValue = [] {
const auto idx = static_cast<int>(getSettings().audio.outputMode.getValue());
return Rml::String{kAudioOutputModeNames[idx]};
},
.isModified = [] {
const auto& setting = getSettings().audio.outputMode;
return setting.getValue() != setting.getDefaultValue();
},
}), rightPane, [](Pane& pane) {
for (int i = 0; i < static_cast<int>(kAudioOutputModeNames.size()); ++i) {
pane.add_button({
.text = kAudioOutputModeNames[i],
.isSelected = [i] {
const auto& setting = getSettings().audio.outputMode;
return setting.getValue() == static_cast<AudioOutputMode>(i);
},
}).on_pressed([i] {
mDoAud_seStartMenu(kSoundItemChange);
getSettings().audio.outputMode.setValue(static_cast<AudioOutputMode>(i));
config::save();
audio::Reinitialize();
});
}
});
// TODO: Individual sliders for Main Music, Sub Music, Sound Effects, and Fanfare.
leftPane.add_section("Volume");
leftPane.register_control(
@@ -1076,13 +1112,6 @@ SettingsWindow::SettingsWindow(bool prelaunch) : mPrelaunch(prelaunch) {
.helpText = "Enables the reverb effect in game audio.",
.onChange = [](bool value) { audio::SetEnableReverb(value); },
});
config_bool_select(leftPane, rightPane, getSettings().audio.enableHrtf,
{
.key = "Enable Spatial Sound",
.helpText =
"Emulate surround sound via HRTF. Recommended only for use with headphones!",
.onChange = [](bool value) { audio::EnableHrtf = value; },
});
config_bool_select(leftPane, rightPane, getSettings().audio.menuSounds,
{
.key = "Dusklight Menu Sounds",