libretro / hatari

New rebasing of Hatari based on Mercurial upstream. Tries to be a shallow fork for easy upstreaming later on.
25 stars 41 forks source link

Very poor sound quality, 50/60hz bug? #48

Closed bbbradsmith closed 4 years ago

bbbradsmith commented 4 years ago

The sound quality with this core is very poor. There are very bad aliasing artifacts constantly. Adjusting the samplerate in the Hatari options panel to anything but 44100 makes the sound completely broken.

This seems to affect some sounds worse than others. The introduction tune for "Super Cycle" by Epyx sounds particularly bad. I've attached a recording from retroarch:

super_cycle-191229-195515.zip

The sound quality in latetst stand-alone Hatari 2.2.1 seems fine at various samplerates, so it seems like the problem is to do with this libretro integration.

Similarly, Retroarch's auto resampling settings seem to have no effect on the problem.

.

Looking at the attached audio, the audio seems to have a burst of silence at the end of every frame. A 50Hz frame is 882 samples, but we seem to get 735 samples (60Hz frame worth) and then 0s for the rest each frame.

(Atari ST games mostly run in 50Hz mode, but some also run at 60hz. Its monitors were capable of doing both. If this bug only affects 50hz games it might have gone unnoticed depending on which games were tested.)

hizzlekizzle commented 4 years ago

Very possible. I was looking at this core the other day for a possibly-related reason (PAL height wasn't working with crt-switchres) and it doesn't really seem to handle regions like one would expect, though it does declare NTSC region. Dunno why /shrug

So, it's possible it's just a bit of a mess as far as those things go. The guy who originally ported it and did most of the heavy lifting vanished almost a year ago, so we probably won't hear anything from him as to why it works like it does (or doesn't, I guess), unfortunately.

vol-2 commented 4 years ago

I'm using Hatari libretro and I can confirm terrible sound quality. I find that 48000 is as good as 44100, but both are still pretty bad. Anything else is unlistenable. Would be fantastic if this gets addressed. Edit: just realized you said the dev disappeared. that sucks.

retrorepair commented 4 years ago

I had assumed this was down to an inaccurate refresh but seems the ST really does run at exactly 50hz.

@hizzlekizzle I found changing the resolution in libretro.c to 400x274 to look perfect with crt switching (only tested with native res)

vol-2 commented 4 years ago

I had assumed this was down to an inaccurate refresh but seems the ST really does run at exactly 50hz.

@hizzlekizzle I found changing the resolution in libretro.c to 400x274 to look perfect with crt switching (only tested with native res)

Does this help the sound issue?

retrorepair commented 4 years ago

@vol-2 sadly not

vol-2 commented 4 years ago

shoot. that's what is currently making hatari libretro unplayable for me. some things that have zero sound or music are alright, but it's not useful enough to maintain the existence of the core until the sound get fixed. (or someone figures out what setting to tweak) Hatari functions perfectly on a PC, so that's the only real choice right now.

retrorepair commented 4 years ago

To be honest it does sound better having changed that resolution but it's still not perfect. Not unusable though by any means. I'll take a look at the sound, not making any promises.

vol-2 commented 4 years ago

Awesome. FWIW, I was testing with Maniac Mansion when I was trying to get it going. The opening song is very easy to judge because of the tempo and (what should be) very clear wave forms.

I honestly didn't make a lot of progress. However, I found that the sound for lakka (in general) stutters the least when the frame rate is locked closest the actual frame rate. This didn't seem to have too much of an effect so far as I can tell for Hatari, but maybe a little bit.

r-type commented 4 years ago

Ok I've listen your sample.

figure out that you probably use an 60hz tos.img ,using a 50 hz tos.img will give you a sound that is near to be sound you will have using official hatari. that said

first sound obtain with this core is not as perfect as upstream one (have to look at code why).

second, even if it sound good with an 50hz tos it's not an acceptable solution. this core have 44100/50hz options hardcoded in retro_get_system_av_info

we have to change this behavior to change on the fly when a 60hz system is detected using nScreenRefreshRate and/or when nAudioFrequency changing.

r-type commented 4 years ago

https://github.com/libretro/hatari/commit/f8c35958ec1c93c32d41d61fa4903b2f5daec78c should sound a little better with "non 50hz" tos

retrorepair commented 4 years ago

Well with the uk tos it's great, thanks for the tip!

hizzlekizzle commented 4 years ago

@r-type hey! good to see you again! I was worried about you :)

vol-2 commented 4 years ago

Ok. @r-type Thanks for your efforts into this. I will give this a run through when I get a chance. Has the lakka core been updated?

bbbradsmith commented 4 years ago

Tried the nightly build. Thank you! The sound quality is very much improved.

It still seems to have some extra aliasing vs. native Hatari output, and I'm not sure why (maybe some extra samplerate conversion is going on...) but that horrible 50/60hz interruption is gone. Yay!

bbbradsmith commented 4 years ago

There seems to be a remaining issue, every second frame 1 sample is output as 0, which is causing the extra aliasing I mentioned before.

Here is a recording for comparison using 44100Hz for both the nightly build, and native hatari: retroarch_hatari_2020_04_03_comparison.zip

Here is a picture of the problem. Regularly spaced 1470 samples apart (30Hz?) you get a 0 inserted into the stream instead of continuous audio:

zero_sample_error_example

Possibly the same problem as before just much smaller in magnitude of effect (1 sample instead of 245?) Maybe a floating point rounding/conversion issue?

r-type commented 4 years ago

@hizzlekizzle , yeah ,far from here , life event ... but i always take care of this core , as 520 stf was my favorite computer !

@bbbradsmith thanks for your detailed report , i ll try to look at (i was playing to build with last git ver, and it take time :) )

i also noticed that most of time at VBL we have 881 instead of 882 sample/frame maube that the clue

vbl done 881 881 vbl done 881 881 vbl done 881 881 vbl done 881 881 vbl done 881 881 vbl done 881 881 vbl done 881 881 vbl done 881 881 vbl done 881 881 vbl done 881 881 vbl done 881 881 vbl done 881 881 vbl done 882 882

vol-2 commented 4 years ago

Just a heads up. I recently tried Hatari core and it now seems to crash no matter what I try to do. Might be the expected tos.img location, but I think I've tried all possible locations.

metallic77 commented 4 years ago

I compiled this source for Wii, after some trial and error, changing some things in configurations, adding things the compiler lacked blah blah blah... it worked, but had a strange attitude. Every 2-3 or sometimes 5 seconds it freezed for 1 second. When i went to settings, audio, synchronisation and set to off it stopped freezing (very rarely) but then had awful audio. I don't know if this helps. If i switch audio to off it stopped freezing completely. So there is a sound issue definitely.

bbbradsmith commented 4 years ago

The issue I reported is solved with #59. Closing.

There are a few other comments in this thread that seem unrelated and could probably be raised as separate issues?