Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CD Audio jumps #379

Closed
ghost opened this issue Feb 11, 2021 · 36 comments
Closed

CD Audio jumps #379

ghost opened this issue Feb 11, 2021 · 36 comments

Comments

@ghost
Copy link

ghost commented Feb 11, 2021

It's been a while since i've been on here, you've made some amazing updates on uae and vice since then, awesome work !

I have a strange problem. I've recently bought a Raspberry Pi 400 and I was very impressed with the performance. It can play everything i've tried so far at full speed, and can even play the majority at full speed (I've only noticed 2 games that don't quite reach 50fps) with the cycle exact option on ! Anyway, back to my issue.

When running CD32 games (PAL) that have audio tracks, the sound stutters when my TV is set to 50Hz. If I set my TV to 60Hz then the stutters go away !? This seems odd because the games are PAL. I'm using CHD's.

@sonninnos
Copy link
Collaborator

sonninnos commented Feb 11, 2021

Cheers! Huh, I have never noticed that on my rig, and of course use 50Hz.

Does it still happen with the CD image uncompressed? And does it only happen when CDA is playing, as in when the CD LED is blinking?

And what about other cores that have CDA?

@ghost
Copy link
Author

ghost commented Feb 11, 2021

I've only tried one other option so far and that's the 'Video Standard' core option. When set to PAL the CD audio randomly stutters, but NTSC makes it play fine.

I'll just have something to eat then i'll try uncompressed and other cores unless you notice anything before I get there !

@ghost
Copy link
Author

ghost commented Feb 11, 2021

It still happens when using ISO-WAV. With PAL50 the CD sound randomly stutters but NTSC60 plays fine.

Something else related to this. Any Amiga game (ADF,WHDLoad etc.) when the screen resolution changes, the sound mutes for that fraction of a second. Very noticeable when TV is at 50Hz. Can hear a slight jump sometimes in 60Hz but nowhere near as much.

Did you say you've not experienced any of this ? Maybe it's just a Retropie thing ?

@sonninnos
Copy link
Collaborator

sonninnos commented Feb 11, 2021

I only have a RPi2 to test with, and have been meaning to do so for a long time, since I have never tried it with this core.

Sounds like something is hindering 50Hz mode in a major way then. Tried every available video and audio driver etc? And is this the only core that behaves like this in synced PAL?

@ghost
Copy link
Author

ghost commented Feb 11, 2021

Having changed my settings that I mentioned in the other 'issue', I think it may have fixed the stuttering 50Hz CD sound. I changed -

Resolution to High 720px
Line Mode to Single Line
Zoom Mode to OFF

I'm not sure which option did it, I'll test some more tomorrow as I haven't got much time at the moment.

@ghost
Copy link
Author

ghost commented Feb 12, 2021

I'll give up with this, I can't seem to find a winning combination. It seems best on Single Line Mode but even then I noticed a audio hiccup. The strange thing is that it stays at a solid 50fps even when the audio jumps. Even stranger is that if I set the TV to 60Hz it doesn't happen at all.

@sonninnos
Copy link
Collaborator

sonninnos commented Feb 12, 2021

Does not sound like there is much to be done on the core then.

So it only skips if core is running at 50 and TV is at 50? All other combinations, as in core and TV running at 60, and either way asynced 50-60 60-50 are fine? Something weird with the hardware..? Frontend audio buffer size makes any difference?

@ghost
Copy link
Author

ghost commented Feb 12, 2021

I tried these variations -

TV 60 Core 60 Audio jumps
TV 60 Core 50 OK
TV 50 Core 50 Audio jumps
TV 50 Core 60 OK

I'll install cough Amiberry and see if it happens there.

@sonninnos
Copy link
Collaborator

Now I'm even more interested in knowing what happens with other cores in the same conditions. SegaCD should be close enough comparison I guess. Though if 60/60 is a problem too, then I'd assume CDA isn't the only sound that should be crackling..

What is/are the problem disc(s)?

@ghost
Copy link
Author

ghost commented Feb 12, 2021

Yeah, I should test other cores like you said before because it's also happening with TV60/Core60. Give me an hour or so to do something then i'll check a SegaCD game.

The audio played fine with Amiberry but my TV was at 60Hz and I couldn't change it to 50Hz for some reason.

A few CD games on PUAE did the Audio hiccups but lately I keep using the title screen (CD audio) on Pinball Fantasies to check.

@ghost
Copy link
Author

ghost commented Feb 12, 2021

I tried Final Fight CD and the music test played the music fine. I also tried Dracula X on PC Engine CD and that played fine too. I don't know what to think. I'll just have to put up with it. I can just use 60Hz for CD32, it's no great loss.

@ghost
Copy link
Author

ghost commented Feb 12, 2021

I'm just going to throw a ridiculously stupid idea out there. I'm under the influence, so I blame Stella. Would it be playing CD's back at an ever so slightly slower (or faster) than correct speed so it has the random micro mutes ?

@ghost
Copy link
Author

ghost commented Feb 13, 2021

So one more test. I downloaded the MegaCD PAL version of Final Fight and at 50Hz there were no audio jumps/silences when playing the music tracks (Uncompressed). I have no idea why PUAE CD32 audio is being affected at 50Hz and is OK at 60Hz.

@ghost
Copy link
Author

ghost commented Feb 14, 2021

I tried my old Amazon Fire Stick at 50Hz. The device is nowhere near powerful enough (dropping down to about 45fps) so the CD audio sounded warbly but didn't hear any random mutes (although it's a completely different operating system). I'm going to put this down to the Raspberry Pi being shit (but perfectly fast enough). Strange how only PUAE is affected though. Sorry for wasting your time.

@ghost ghost closed this as completed Feb 14, 2021
@sonninnos
Copy link
Collaborator

Let's hope then that it is just a configuration issue of some sort..

How periodic is the muting and does it have any relation anymore to the stuff happening on screen? Could you do a small recording?

@ghost
Copy link
Author

ghost commented Feb 14, 2021

Worst recording ever ! I don't have a phone or camera (sad I know) so I had to use an old tablet to just record the audio with a voice recorder ! I had to amplify it a bit but you'll get the gist.

new.zip

@ghost
Copy link
Author

ghost commented Feb 14, 2021

This is even more annoying, I figured out how to record the screen with the Retroarch recorder but when I played the video back the audio was fine ?!

@sonninnos
Copy link
Collaborator

sonninnos commented Feb 14, 2021

Well that is super weird..

For kicks I did some testing while crippling my IO by defragging the same drive, and indeed it was very easy to skip the CDA and only the CDA, as in frametime graph stayed constant during the CD audio skips.

I noticed there is a CDDA_BUFFERS that is currently 12, but WinUAE has 14. We should try increasing it.

Edit: Meh, no matter how much that value is increased it won't remove the random gaps while defragging..

@ghost
Copy link
Author

ghost commented Feb 15, 2021

I figured out how to save logs in Retroarch, should have done this earlier. I set it to 'debug'. Do they reveal anything that could be the cause of these jumps ?

retroarch.log

@sonninnos
Copy link
Collaborator

Indeed it does have a huge bunch of missing sectors..

[libretro INFO] PG missing sector: LBA 2208, trklog 2208
...
[libretro INFO] PG missing sector: LBA 2357, trklog 2208

I don't get any of that and never seen that. Just a bad dump or something interfering with reading..?

And log level "debug" won't give any more useful information from the core than "info".

@ghost
Copy link
Author

ghost commented Feb 15, 2021

The dump is fine (i think, and i've experienced the skipping with other games). It plays fine on my laptop (60Hz) and also plays fine on the Pi400 when the TV is set to 60Hz. It's just really weird that i'm only experiencing this on PUAE. It's not like it could be much different either because all the cores use Retroarch.

@ghost
Copy link
Author

ghost commented Feb 15, 2021

I just checked a log file on my laptop and it has those same [libretro INFO] PG missing sector: LBA 2208, trklog 2208 errors. (But it sounds fine because of 60Hz I suppose). Could you check one of your logs and see if you also get that 'missing sector' thing ?

The other thread I opened a while ago about the Resolution changing, that also skipped the audio (on any game format) when the resolution changed. Probably related but don't know and if its a RPi thing.

Edit: Here is a log from Pinball Illusions, same thing
retroarch.log

@sonninnos
Copy link
Collaborator

sonninnos commented Feb 15, 2021

Like I said I'm not seeing that and never have. It is a CHD related warning regarding pregaps, so might be nothing to worry about, since the same hiccups happen with raw images.

Edit: Ah, found some images that do warn, but no symptoms.

@ghost
Copy link
Author

ghost commented Feb 15, 2021

So I was trying to compare the Android version with the Pi version, setting the same options between the two. I was only testing on the Android version but I think I found a bug but don't know if this will affect the CD skipping. If I turn on the 'CD Delay Start' option, when it got to the table selection on 'Pinball Fantasies' it slowed down to an absolute crawl. If I turn it off and reload content it's fine again. Now I know I have this option on on my Pi but I have to go out now so no time to test !! I'm hoping this will fix it.

@ghost
Copy link
Author

ghost commented Feb 15, 2021

Well it may be a bug in the CD Delay Start but it doesn't help with the Pi400 50Hz CD Audio skipping. Damn it! The audio doesn't even sound right when playing, like its warbling.

@sonninnos
Copy link
Collaborator

Please test if these new changes have any effect.

@ghost
Copy link
Author

ghost commented Feb 18, 2021

Unfortunately not, it's still the same. I think we should just put it down to a Raspberry Pi 4/400 thing. No great loss as there isn't anything worth having on CD32 anyway, just CD audio (which is sometimes worse than the original MODs) and the extras that some games have are in the WHDLoad CD32 versions anyway. It's a shame nobody else can confirm this, they're all obsessed with Amiberry for some reason.

@sonninnos
Copy link
Collaborator

Darn. It has something to do with threads since CDA play creates one. Windows part of the threading code seems to give high priorities for all threads it creates, but no idea what is happening with other platforms and their semaphores..

Sure there are no other ninja processes running then that could make any difference, such as my defrag testings..? Though maybe it and IO speed in general should affect other cores too, but then again the same rules may not apply when stuff is done differently. For example I'm not seeing any semaphore stuff in GenPlusGx.

@ghost
Copy link
Author

ghost commented Feb 18, 2021

No idea, it's weird that it works OK at 60Hz. GenesisPlusGX works OK at 50Hz using a PAL MegaCD game. I bet it's something to do with just Pi 4's and 400's and on their side of the code because I think they do it differently to the earlier Pi versions. Shame it only affects PUAE. Feel free to move onto other things, maybe they'll fix it without realising someday.

@ghost
Copy link
Author

ghost commented Feb 22, 2021

I had another mess about with this and got mixed results. I tried the different Retroarch video drivers but nothing made a difference (for the ones that worked). The default audio driver on my Retroarch is 'alsa'. I made a core override and changed it to 'sdl2'. It stopped the CD audio skipping/muting but sounds warbly. Again, this is weird that this only happens on PUAE at 50Hz. Is there anything in there that relates to audio drivers or is it all handled by Retroarch ? No special makefile needed for Pi 4/400 ?

@sonninnos
Copy link
Collaborator

Frontend of course handles the audio. It must have something to do with CDA playing in its own thread, but I have no idea how.

Is the frontend audio rate at 44100 like the core is, or is the default at 48000? Maybe the hardware does not like the resampler/rate combo, or something..

@ghost
Copy link
Author

ghost commented Feb 22, 2021

Retroarch is at the default 48000, I tried setting it to 44100 but it didn't make any difference. So would anything be missing in the makefile that could cause this ? The Pi 400 has a ARM Cortex-A72 but didn't see any mention of it, maybe something else needs defining? I have no clue what i'm talking about! I just looked at the lr-GenesisPlusGX makefile and saw some platform defines for different Raspberry Pi's (although the Pi 4 Cortex-A72 wasn't there either).

Amiberry seems to have a RPi4 define -

# Raspberry Pi 4 CPU flags
ifneq (,$(findstring rpi4,$(PLATFORM)))
    CPUFLAGS = -mcpu=cortex-a72 -mfpu=neon-fp-armv8
endif

Where is -fp-armv8 ?

@ghost
Copy link
Author

ghost commented Feb 23, 2021

What do you think about this, what would it default to if there is no Platform defined (Cortex-A72) ? I looked at some other cores (lr-fceumm, lr-genplusgx and Amiberry although not a libretro core) and they have the flag -fp-armv8 at least for Pi3, which isn't present in the PUAE makefile.

Would any of this make the difference ?

@sonninnos
Copy link
Collaborator

sonninnos commented Feb 23, 2021

Since buildbot isn't building Linux ARM builds, what is the recipe used in the build that you are using and what builds it? Shouldn't the platform=armv versions work too instead of platform=rpi..? Edit: Oh right that is the only place where any cortex-stuff is. And in those "classic" platforms.

And since you have the hardware, please try building with the different flags.

@ghost
Copy link
Author

ghost commented Feb 23, 2021

I'm using RetroPie. It can build straight from the source github. This is the script it uses https://github.com/RetroPie/RetroPie-Setup/blob/master/scriptmodules/libretrocores/lr-puae.sh . I'll have to clone this repo and figure out how to make it build from the cloned repo. Not something i've ever done before ! I may just stick with my sdl2 audio driver core override. It's good enough for now. Thanks anyway.

@sonninnos
Copy link
Collaborator

Please try if these recent changes make any difference.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant