Archive for December, 2008

PS2Doom – Time for updates

December 29, 2008

Both Lukasz and Janson’s ports of Doom uses SDL for graphics and sound. And I realised that the PS2 port of SDL (at least the SDL_mixer) is buggy. An example of this is clear if you look at the sources of PS2Pang: Before any call to SDL_mixer’s Mix_PlayChannel() function which actuallys pumps the samples to the mixer there is a misterious ‘printf(“”)’ which seems to do a lot more than nothing – without it, there is only silence, so no sound is ever played… (I suspect it could be a thread issue).

So, actually, it’s quite normal to have silence in this PS2 ports of Doom instead of any sound.

So, lets all go home and live happy with a silent Doom and I’m going to start working over another project.

 

Just kidding.

 

So, I could take two paths:

  1 – debug SDL_mixer
  2 – forget about SDL_mixer and use an alternative for sound

Sincerely, option 1 is not appealing to me, without any decent debugging tools. I’ll take path 2 instead.

Currently I’m exploring the well known and tested sjPCM library. It’s a low-level lib (well, it’s more a middle-level actually) so I’ve been looking at other projects that uses it like PGEN emulator to see how it works. I should also need to make a sound mixer by myself, since sjPCM only pumps sound samples to the PS2 dual SPU cores. I never did any sound mixer before, but it seems quite easy (i’ll probabily post a sketch of it later).
The question is: Where to do the mixing? At the IOP or at the EE? Doing in the IOP would be optimal since it would be synchronized with the sound pumping (I would only need to do the mixing just before the pumping to the SPU core) but I wonder if that’s too much work for the 36Mhz IOP… Doing the mixer on the EE may not be much simple since I would need to call it periodically and as you may know, the PS2 only have cooperative multitasking. Anyway, this all should be doable.
 
I’ve also chatting with jbit (helpful dude, he is) since his ps2snd library is able to send sound samples to the PS2 hardware as long as those are previously ADPCM encoded. This makes a lot of sense, since the PS2 already does sound mixing as long the audio streams are ADPCM encoded (the Doom sounds are the usual PCM signed words but there are examples on the ps2sdk for ADPCM encoding). He gave me some snippets of his yet unrealised ps2kit library regarding audio and I’m still messing with it (sucessful compiling but yet unsucessful playing).

I might also try to see why the heck the implanted Jason’s audio functions doesn’t work over Lukasz port… Those should work (I wonder how Jason’s was able to use sucessfully SDL_mixer considering the odd behaviour of it…) just because the time Jason must had over these.