Skip to content

Conversation

@Ziemas
Copy link
Contributor

@Ziemas Ziemas commented Nov 4, 2025

Description of Changes

Reintroduces a delay before starting to play keyed on voices, but in a simpler way than before.

Rationale behind Changes

Seems to be needed for Dragon Quest V's streamed music. It uses the SPU IRQ to track playback progress, but starts the voices before enabling it which means the voices will have already moved past its IRQ point and breaking its state machine.

Fixes #13486

Suggested Testing Steps

This needs testing in Battlefield 2: Modern Combat, with the vehicle sounds in online multiplayer. Idk if this can be tested offline?
I was able to test battlefield myelf, still works.

Did you use AI to help find, test, or implement this issue or feature?

No.

@github-actions github-actions bot added the SPU2 label Nov 4, 2025
@Ziemas Ziemas force-pushed the spu-playdelay branch 2 times, most recently from 763205e to 8dd6f4c Compare November 4, 2025 12:56
@Ziemas
Copy link
Contributor Author

Ziemas commented Nov 4, 2025

Hm, I tried testing some stuff on hardware and got even more confused.

The real SPU actually spends even less time in the first ADPCM block than pcsx2 without this patch.

I think I'm going to end up just adding the per-voice sample buffers so I can compare more easily.

The actually correct fix for this is probably to IRQ test the block header address for each voice on every tick.

Might as well If the saveversion is already being bumped.

[SAVEVERSION+]
This makes the timing of NAX advancing more similar to console since it
emulates the decode buffer behaviour of it rushing ahead of playback
until the buffer is full.

It also makes interpolation of the first four samples more correct by
using real data instead of the zero filled previous values.

[SAVEVERSION+]
This seems to match the real HW pretty closely, it probably does a bunch
of different things on each step, but I don't have any current ideas on
how to easily figure out what happens when.
@Ziemas
Copy link
Contributor Author

Ziemas commented Nov 6, 2025

Rebased on top of #13497.

Just for fun I thought I'd see if i could match the timings I see on hardware.

Here is an example of starting a voice on the PS2, after the voice is keyed on it seems like it takes about an audio frame to see a new NAX value. There is then a larger delay before the next one before decoding continues as normal.

ps2:

17.306348: [+8] Keyed on at [2806]
17.306375: [+27] NAX switched to new sample [4002]
17.306429: [+54] NAX switched to new sample [4003]
17.306439: [+10] NAX switched to new sample [4004]
17.306459: [+20] NAX switched to new sample [4005]

By only running the decoding step on odd numbers of the play delay we can see a very similar looking pattern.
pcsx2:

pcsx2
0.182873: [+4] Keyed on at [2803]
0.182899: [+26] NAX switched to new sample [4002]
0.182941: [+42] NAX switched to new sample [4003]
0.182962: [+21] NAX switched to new sample [4004]
0.182983: [+21] NAX switched to new sample [4005]

(the format of those logs is sec.usec: [usec delta from last event])

Idk if this is particularly worthwhile to implement though.

@Ziemas Ziemas closed this Nov 6, 2025
@Ziemas
Copy link
Contributor Author

Ziemas commented Nov 6, 2025

Not bothering with this for now unless we find something that needs it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Dragon Quest V missing BGM.

1 participant