dcsteve wrote:Blackaura solved the clicking noise in his port of genesis plus for dreamcast. Here is the source if it provides any information to help you compare sound code.
Somehow I never knew that emulator existed. Huh.
It looks like they took the KOS streaming code and cut it down a bit and used that. I was going to try something like that. It didn't seem to have the issue with requiring a giant minimum latency, so I tried to add it to Gens4All. It took a while, but when I finally got it working correctly... it had the
exact same clicking in PS2 (and some other games) as SDL.
If the software is fine, maybe the problem is hardware? I looked through the hardware setting code, and I noticed that the loop end was set to the length of the loop. That seems odd for the hardware to be designed like that. It should be easier to check that the loop triggers after the current than checking head one sample. I changed the loop end to be buffer_length - 1, and tried it.
The clicking was gone.
So it looks like the AICA doesn't start the loop before hitting the loop end value, it starts the loop after playing sample at the loop end. The clicking on the left channel was from a single sample from the right channel buffer being played.
The non-looping sample end register might also work this way, but I haven't checked.
I noticed there was slightly more CPU usage with Genesis Plus's streamer than when using SDL. The streamer used spu_memload, while SDL didn't. I tried replacing spu_memload with a modified version of SDL's loader, but it didn't improve it. I'm not total sure where the speed difference is from. Maybe it's because of having more buffers to deal with? (With SDL, emu reads stereo two buffers, writes one interleaved stereo for SDL, then SDL reads one. With GP's streams, the emu reads stereo two buffers, writes two separated stereo for the streamer, then the streamer reads those two. So it might be more cache misses?) It's probably worth coming back to sound later to get rid of the intermediate sound buffer and just write samples more directly to the AICA. For now, I'm using the version of SDL that Ian posted with the loop point setting fixed.
I wasn't planning to work on a ROM loader right away, but I changed my mind and added a basic file browser. No settings or sorting. A precompiled ELF is included in the attachment with current source. It can read from /cd and /pc. Loading large directories over BBA is really slow. I don't know about CDs.
I had some trouble getting it to where you could exit one game and load another without the sound stopping or it freezing. I tried going back to the original Gens4All source to see what I had changed that was causing it to have issues with the sound. Oh right, this version didn't have sound originally... I think I was able to get it to switch reliably.
Enter a directory or start a game with A. To go up a directory, press B. To exit the loader, press start. To exit a game and return to the loader, press ABXY+Start.