SPU: increase volume display precision in debug window

pull/3745/head
Nagtan 5 months ago committed by Stenzek
parent 70ec9c4915
commit a3f4a086e7
No known key found for this signature in database

@ -50,6 +50,11 @@ ALWAYS_INLINE static constexpr s32 ApplyVolume(s32 sample, s16 volume)
return (sample * s32(volume)) >> 15;
}
ALWAYS_INLINE static constexpr float ApplyVolumeF(float sample, s16 volume)
{
return (sample * static_cast<float>(volume)) / static_cast<float>(0x8000);
}
namespace SPU {
namespace {
@ -2669,9 +2674,9 @@ void SPU::DrawDebugStateWindow(float scale)
ImGui::Text("Volume: ");
ImGui::SameLine(offsets[0]);
ImGui::Text("Left: %d%%", ApplyVolume(100, s_state.main_volume_left.current_level));
ImGui::Text("Left: %.1f%%", ApplyVolumeF(100.0f, s_state.main_volume_left.current_level));
ImGui::SameLine(offsets[1]);
ImGui::Text("Right: %d%%", ApplyVolume(100, s_state.main_volume_right.current_level));
ImGui::Text("Right: %.1f%%", ApplyVolumeF(100.0f, s_state.main_volume_right.current_level));
#ifdef SPU_ENABLE_VU_METER
ImGui::SameLine(offsets[2]);
draw_vu_meter(s_state.output_peaks);
@ -2683,11 +2688,11 @@ void SPU::DrawDebugStateWindow(float scale)
ImGui::TextColored(s_state.SPUCNT.cd_audio_enable ? active_color : inactive_color,
s_state.SPUCNT.cd_audio_enable ? "Enabled" : "Disabled");
ImGui::SameLine(offsets[1]);
ImGui::TextColored(s_state.SPUCNT.cd_audio_enable ? active_color : inactive_color, "Left Volume: %d%%",
ApplyVolume(100, s_state.cd_audio_volume_left));
ImGui::TextColored(s_state.SPUCNT.cd_audio_enable ? active_color : inactive_color, "Left Volume: %.1f%%",
ApplyVolumeF(100.0f, s_state.cd_audio_volume_left));
ImGui::SameLine(offsets[3]);
ImGui::TextColored(s_state.SPUCNT.cd_audio_enable ? active_color : inactive_color, "Right Volume: %d%%",
ApplyVolume(100, s_state.cd_audio_volume_right));
ImGui::TextColored(s_state.SPUCNT.cd_audio_enable ? active_color : inactive_color, "Right Volume: %.1f%%",
ApplyVolumeF(100.0f, s_state.cd_audio_volume_right));
#ifdef SPU_ENABLE_VU_METER
ImGui::SameLine(offsets[5]);
draw_vu_meter(s_state.cd_audio_peaks);
@ -2785,8 +2790,8 @@ void SPU::DrawDebugStateWindow(float scale)
ImGui::Text("Current Amplitude: Input (%d, %d) Output (%d, %d)", s_state.last_reverb_input[0],
s_state.last_reverb_input[1], s_state.last_reverb_output[0], s_state.last_reverb_output[1]);
ImGui::Text("Current Mode: %s", GetReverbModeName(s_state.reverb_registers));
ImGui::Text("Output Volume: Left %d%% Right %d%%", ApplyVolume(100, s_state.reverb_registers.vLOUT),
ApplyVolume(100, s_state.reverb_registers.vROUT));
ImGui::Text("Output Volume: Left %.1f%% Right %.1f%%", ApplyVolumeF(100.0f, s_state.reverb_registers.vLOUT),
ApplyVolumeF(100.0f, s_state.reverb_registers.vROUT));
#ifdef SPU_ENABLE_VU_METER
ImGui::SameLine();
draw_vu_meter(s_state.reverb_peaks);

Loading…
Cancel
Save