From d9eab4e4a230b4c593f37f27f19ac9729ce4b9f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 15 Apr 2025 11:44:28 +0200 Subject: [PATCH] sceAudio: Add per-channel mute checkboxes in the debugger --- Core/HLE/__sceAudio.cpp | 8 +++++++- Core/HLE/sceAudio.h | 3 +++ UI/ImDebugger/ImDebugger.cpp | 7 ++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Core/HLE/__sceAudio.cpp b/Core/HLE/__sceAudio.cpp index 124fe330fa..b263af3012 100644 --- a/Core/HLE/__sceAudio.cpp +++ b/Core/HLE/__sceAudio.cpp @@ -338,8 +338,9 @@ void __AudioUpdate(bool resetRecording) { int16_t srcBuffer[srcBufferSize]; for (u32 i = 0; i < PSP_AUDIO_CHANNEL_MAX + 1; i++) { - if (!g_audioChans[i].reserved) + if (!g_audioChans[i].reserved) { continue; + } __AudioWakeThreads(g_audioChans[i], 0, hwBlockSize); @@ -358,6 +359,11 @@ void __AudioUpdate(bool resetRecording) { chanSampleQueues[i].popPointers(sz, &buf1, &sz1, &buf2, &sz2); + // We do this check as the very last thing before mixing, to maximize compatibility. + if (g_audioChans[i].mute) { + continue; + } + if (needsResample) { auto read = [&](size_t i) { if (i < sz1) diff --git a/Core/HLE/sceAudio.h b/Core/HLE/sceAudio.h index d922e5bd39..0fae10d617 100644 --- a/Core/HLE/sceAudio.h +++ b/Core/HLE/sceAudio.h @@ -49,6 +49,9 @@ struct AudioChannel { u32 rightVolume = 0; u32 format = 0; + // For the debugger only. Not saved. + bool mute = false; + std::vector waitingThreads; void DoState(PointerWrap &p); diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 42fa451c30..5f01ef58d7 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -1245,8 +1245,9 @@ void DrawAudioChannels(ImConfig &cfg, ImControl &control) { return; } - if (ImGui::BeginTable("audios", 6, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) { + if (ImGui::BeginTable("audios", 7, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) { ImGui::TableSetupColumn("Index", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("Mute", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("SampleAddr", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("SampleCount", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("Volume", ImGuiTableColumnFlags_WidthFixed); @@ -1262,12 +1263,15 @@ void DrawAudioChannels(ImConfig &cfg, ImControl &control) { } ImGui::TableNextRow(); ImGui::TableNextColumn(); + ImGui::PushID(i); if (i == 8) { ImGui::TextUnformatted("audio2"); } else { ImGui::Text("%d", i); } ImGui::TableNextColumn(); + ImGui::Checkbox("", &g_audioChans[i].mute); + ImGui::TableNextColumn(); char id[2]{}; id[0] = i + 1; ImClickableValue(id, g_audioChans[i].sampleAddress, control, ImCmd::SHOW_IN_MEMORY_VIEWER); @@ -1294,6 +1298,7 @@ void DrawAudioChannels(ImConfig &cfg, ImControl &control) { ImGui::Text("%s: %d", thread->GetName(), t.numSamples); } } + ImGui::PopID(); } ImGui::EndTable();