From 22f71f1e9aa98f702a5fe6bed3e936f7dfa82e46 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 28 Oct 2015 21:20:20 +0100 Subject: [PATCH] Show simple info about currently playing audio in on-screen Debug Statistics --- Core/HLE/sceSas.cpp | 8 ++++++++ Core/HLE/sceSas.h | 2 ++ Core/HW/SasAudio.cpp | 23 +++++++++++++++++++++-- Core/HW/SasAudio.h | 2 ++ UI/EmuScreen.cpp | 5 +++++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceSas.cpp b/Core/HLE/sceSas.cpp index 99b3a82cc3..7fa1703d3a 100644 --- a/Core/HLE/sceSas.cpp +++ b/Core/HLE/sceSas.cpp @@ -577,6 +577,14 @@ static u32 __sceSasUnsetATRAC3(u32 core, int voiceNum) { return 0; } +void __SasGetDebugStats(char *stats, size_t bufsize) { + if (sas) { + sas->GetDebugText(stats, bufsize); + } else { + snprintf(stats, bufsize, "Sas not initialized"); + } +} + const HLEFunction sceSasCore[] = { {0X42778A9F, &WrapU_UUUUU, "__sceSasInit", 'x', "xxxxx" }, diff --git a/Core/HLE/sceSas.h b/Core/HLE/sceSas.h index bf798dee45..a957f3d475 100644 --- a/Core/HLE/sceSas.h +++ b/Core/HLE/sceSas.h @@ -21,4 +21,6 @@ void __SasInit(); void __SasDoState(PointerWrap &p); void __SasShutdown(); +void __SasGetDebugStats(char *stats, size_t bufsize); + void Register_sceSasCore(); diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index 13a8aebf26..837c2ca1f3 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -345,6 +345,26 @@ SasInstance::~SasInstance() { ClearGrainSize(); } +void SasInstance::GetDebugText(char *text, size_t bufsize) { + char voiceBuf[4096]; + voiceBuf[0] = '\0'; + char *p = voiceBuf; + for (int i = 0; i < maxVoices; i++) { + if (voices[i].playing) { + p += snprintf(p, sizeof(voiceBuf) - (p - voiceBuf), " %d: Pitch: %d L/R: %d,%d FX-L/R: %d,%d VAG: %08x:%d Height:%d\n", i, voices[i].pitch, voices[i].volumeLeft, voices[i].volumeRight, voices[i].effectLeft, voices[i].effectRight, voices[i].vagAddr, voices[i].vagSize, voices[i].envelope.GetHeight()); + } + } + + snprintf(text, bufsize, + "SR: %d Mode: %s Grain: %d\n" + "Effect: Type: %d Dry: %d Wet: %d L: %d R: %d Delay: %d Feedback: %d\n" + "\n%s\n", + sampleRate, outputMode == PSP_SAS_OUTPUTMODE_RAW ? "Raw" : "Mixed", grainSize, + waveformEffect.type, waveformEffect.isDryOn, waveformEffect.isWetOn, waveformEffect.leftVol, waveformEffect.rightVol, waveformEffect.delay, waveformEffect.feedback, + voiceBuf); + +} + void SasInstance::ClearGrainSize() { delete[] mixBuffer; delete[] sendBuffer; @@ -500,7 +520,6 @@ void SasInstance::MixVoice(SasVoice &voice) { // TODO: Special case no-resample case (and 2x and 0.5x) for speed, it's not uncommon u32 sampleFrac = voice.sampleFrac; - // We need to shift by 12 anyway, so combine that with the volume shift. for (int i = 0; i < grainSize; i++) { // For now: nearest neighbour, not even using the resample history at all. int sample = resampleBuffer[sampleFrac / PSP_SAS_PITCH_BASE + 2]; @@ -562,7 +581,7 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) { if (outputMode == PSP_SAS_OUTPUTMODE_MIXED) { // Okay, apply effects processing to the Send buffer. // TODO: Is this only done in PSP_SAS_OUTPUTMODE_MIXED? - if (waveformEffect.type != PSP_SAS_EFFECT_TYPE_OFF) { + if (waveformEffect.type != PSP_SAS_EFFECT_TYPE_OFF && waveformEffect.isWetOn) { ApplyWaveformEffect(); // TODO: Mix send when it has proper values, probably based on dry/wet? if (inp) { diff --git a/Core/HW/SasAudio.h b/Core/HW/SasAudio.h index 70c0d51d3f..761f80faec 100644 --- a/Core/HW/SasAudio.h +++ b/Core/HW/SasAudio.h @@ -292,6 +292,8 @@ public: void ApplyWaveformEffect(); void SetWaveformEffectType(int type); + void GetDebugText(char *text, size_t bufsize); + void DoState(PointerWrap &p); SasVoice voices[PSP_SAS_VOICES_MAX]; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index bdc57b3adb..d2277d99b1 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -46,6 +46,7 @@ #include "GPU/GLES/Framebuffer.h" #include "Core/HLE/sceCtrl.h" #include "Core/HLE/sceDisplay.h" +#include "Core/HLE/sceSas.h" #include "Core/Debugger/SymbolMap.h" #include "Core/SaveState.h" #include "Core/MIPS/MIPS.h" @@ -794,6 +795,10 @@ static void DrawDebugStats(DrawBuffer *draw2d) { draw2d->SetFontScale(.7f, .7f); draw2d->DrawText(UBUNTU24, statbuf, 11, 31, 0xc0000000, FLAG_DYNAMIC_ASCII); draw2d->DrawText(UBUNTU24, statbuf, 10, 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); + + __SasGetDebugStats(statbuf, sizeof(statbuf)); + draw2d->DrawText(UBUNTU24, statbuf, PSP_CoreParameter().pixelWidth / 2 + 11, 31, 0xc0000000, FLAG_DYNAMIC_ASCII); + draw2d->DrawText(UBUNTU24, statbuf, PSP_CoreParameter().pixelWidth / 2 + 10, 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); draw2d->SetFontScale(1.0f, 1.0f); }