AliveTeam / alive_reversing

Re-implementation of Oddworld: Abe's Exoddus and Oddworld: Abe's Oddysee
345 stars 44 forks source link

Audio SPU emulation (duckstation) #1601

Open sean-horton opened 1 year ago

sean-horton commented 1 year ago

This is an attempt at replacing sound with Duckstation's SPU. It is a non-ABI breaking change and can be turned off and on using options.cmake value AUDIO_SPU_EMULATION.

I have not hooked up FMV audio to the SPU emulator, but it should be trivial. I'll wait to see if this PR is even something that would be wanted.

The SPU runs at 44100hz which is executing in the SDL callback. The emulator should probably run in its own thread as running calculations in the SDL callback is probably bad practice. Unsure if this will cause clipping on slower CPU's. CPU usage seems comparable to master branch, however if many sounds are playing (slig constantly shooting), my CPU usage is slightly higher than master.

Interestingly the PC vag attributes differ from PSX. This can be seen by disabling the vag attribute fixes by commenting out mSoundSampleParser.applyFix(...) in MidiPlayer. With it commented it will sound like pc, with it uncommented it will sound like psx. One obvious example is Abe's "Hello". He has a deeper voice in pc, whereas psx is slightly higher pitch.

R6 is even more messed up and fixes can not be applied without more inspection, right now it uses all pc sounds, so Abe will have pc's lower pitch voice.

Further, I believe a lot of the volumes are incorrect in the sound definitions within things like slig.cpp.

  1. When a slig stops shooting it plays eHitBottomOfDDeathPit at full volume. This should almost certainly be played at a lower volume. SND_SEQ_SetVol()
  2. The sequence played for doves in, for example, paramonia, play at full volume, and should have SND_SEQ_SetVol()
  3. And; Leaves shooting out of wells seem to have too low of volume
  4. Probably others...

I have not applied fixes for AE, so that could probably be improved. However, I know greeters wheeling around make no noise, but it's because their volume is too low, increasing it the sound will play.

In short; I'm pretty sure the pc port introduced more sound issues than just the player, most likely to cover for the incorrect player.