Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SasAudio: Always reinitialize the VAG decoder on sceSasSetVoice, even if already playing #18076

Merged
merged 4 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions Core/HLE/sceSas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static u32 _sceSasCore(u32 core, u32 outAddr) {

__SasEnqueueMix(outAddr);

return hleLogSuccessI(SCESAS, delaySasResult(0));
return hleLogSuccessVerboseI(SCESAS, delaySasResult(0));
}

// Another way of running the mixer, the inoutAddr should be both input and output
Expand All @@ -315,7 +315,7 @@ static u32 _sceSasCoreWithMix(u32 core, u32 inoutAddr, int leftVolume, int right

__SasEnqueueMix(inoutAddr, inoutAddr, leftVolume, rightVolume);

return hleLogSuccessI(SCESAS, delaySasResult(0));
return hleLogSuccessVerboseI(SCESAS, delaySasResult(0));
}

static u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loop) {
Expand Down Expand Up @@ -363,8 +363,9 @@ static u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loo
v.type = VOICETYPE_VAG;
v.vagAddr = vagAddr; // Real VAG header is 0x30 bytes behind the vagAddr
v.vagSize = size;
v.loop = loop ? true : false;
v.ChangedParams(vagAddr == prevVagAddr);
v.loop = loop != 0;
v.playing = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should still care about on? You can key on or off a voice before or after setting the VAG, I'm pretty sure tests do show that already...

-[Unknown]

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I suppose so. I'll add that in.

v.vag.Start(vagAddr, size, loop != 0);
return 0;
}

Expand Down Expand Up @@ -401,7 +402,6 @@ static u32 sceSasSetVoicePCM(u32 core, int voiceNum, u32 pcmAddr, int size, int
v.pcmLoopPos = loopPos >= 0 ? loopPos : 0;
v.loop = loopPos >= 0 ? true : false;
v.playing = true;
v.ChangedParams(pcmAddr == prevPcmAddr);
return 0;
}

Expand All @@ -424,7 +424,7 @@ static u32 sceSasSetPause(u32 core, u32 voicebit, int pause) {
for (int i = 0; voicebit != 0; i++, voicebit >>= 1) {
if (i < PSP_SAS_VOICES_MAX && i >= 0) {
if ((voicebit & 1) != 0)
sas->voices[i].paused = pause ? true : false;
sas->voices[i].paused = pause != 0;
}
}

Expand Down Expand Up @@ -466,7 +466,6 @@ static u32 sceSasSetPitch(u32 core, int voiceNum, int pitch) {
__SasDrain();
SasVoice &v = sas->voices[voiceNum];
v.pitch = pitch;
v.ChangedParams(false);
return 0;
}

Expand Down Expand Up @@ -523,7 +522,6 @@ static u32 sceSasSetNoise(u32 core, int voiceNum, int freq) {
SasVoice &v = sas->voices[voiceNum];
v.type = VOICETYPE_NOISE;
v.noiseFreq = freq;
v.ChangedParams(true);
return 0;
}

Expand Down
11 changes: 2 additions & 9 deletions Core/HW/SasAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ void VagDecoder::DecodeBlock(const u8 *&read_pointer) {
return;
}

_dbg_assert_(curBlock_ < numBlocks_);

const u8 *readp = read_pointer;
int predict_nr = *readp++;
int shift_factor = predict_nr & 0xf;
Expand Down Expand Up @@ -812,15 +814,6 @@ void SasVoice::KeyOff() {
envelope.KeyOff();
}

void SasVoice::ChangedParams(bool changedVag) {
if (!playing && on) {
playing = true;
if (changedVag)
vag.Start(vagAddr, vagSize, loop);
}
// TODO: restart VAG somehow
}

void SasVoice::DoState(PointerWrap &p) {
auto s = p.Section("SasVoice", 1, 3);
if (!s)
Expand Down
1 change: 0 additions & 1 deletion Core/HW/SasAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ struct SasVoice {
void Reset();
void KeyOn();
void KeyOff();
void ChangedParams(bool changedVag);

void DoState(PointerWrap &p);

Expand Down