libretro / fuse-libretro

A port of the Fuse Unix Spectrum Emulator to libretro
GNU General Public License v3.0
39 stars 50 forks source link

AY Stereo Separation option is not working #42

Closed malvert closed 3 years ago

malvert commented 7 years ago

"AY Stereo Separation" in Core Options is not working. There is no noticeable difference between "acb" and "abc" option. And if I set it to "none" the AY sound should be mono, but it's still separated to left and right channel and it sounds exactly the same as if set to "acb" or "abc" option. There is no other option to set AY to mono.

leiradel commented 7 years ago

Hm, maybe you need to reset the emulation so that the changes become current. If this is really the case, I'll add text to this option to make it clear.

If resetting the emulation doesn't work, how does AY Stereo Separation sounds on trhe Fuse emulator? If you set it to "none", does it become mono? Can you tell the difference between "acb" and "abc" modes?

malvert commented 7 years ago

It is set to "none" by default, but you can still hear it is simulated stereo. I tried to set it to other options and reseting emulation, but I didn't notice any changes. If I use fuse128k emulator, the difference between "none" and other options is very noticeable, because "none" option sets sound to mono. But the difference between "acb" and "abc" mode is not very noticeable even in fuse128k. I didn't find any option, how to switch AY sound to mono or to switch off AY separation in lr-fuse.

wermipls commented 3 years ago

I encountered this problem as well and found it incredibly irritating (the stereo separation was ACB no matter the option & it makes tunes written with ABC in mind sound like crap). Seeing that the issue has been open for 4 years (!) and still hasn't been fixed, I decided to investigate on my own. Turns out the sound_stereo_ay value inside fuse/sound.c is set correctly according to the configuration, but gets pretty much immediately overwritten with 1 (which is ACB) inside the sound_lowlevel_init function (from src/compat/sound.c) that gets called right after it. Either moving the init function call (so it happens before the stereo config value gets set) or commenting out/removing the hardcoded stereo value solves the issue. Relevant files:

https://github.com/libretro/fuse-libretro/blob/master/fuse/sound.c https://github.com/libretro/fuse-libretro/blob/master/src/compat/sound.c

Now with that fixed, the only problem now is that mono sounds terribly wrong. With the option selected, audio is 2x the speed and gets choppy (approx. half of the sound is silence), as seen on the waveform screenshot below:

image

I presume the issue is with RetroArch expecting two interleaved channels, while only one is present and every two frames of it get treated as one L/R frame (which would explain the speed increase). It's 4am right now and I'm not quite sure how to fix this properly yet though.