Input Lag Compensation to compensate for game's internal lag?

Do you manage to have the sound right with your patch?
It’s always skipping here.

I notice some button actions are getting ignored sometimes jumping repeatedly in smb fceumm.

Fba has sound problems with stuck notes, Mame goes too fast.

It’s up to the emulator cores to have seamless audio after loading state, and most of them simply don’t.

What are your current plans? Will you attempt to implement this as a new feature and try to also fix some common cores?

Don’t know what my exact plans are, but I now have an idea of what’s going on in Snes9x, it is missing samples in the output.

Okay, sounds good. If you provide an x64 Windows build when you think you’ve found and fixed the issue, I’ll be happy to test it and perhaps also do a camera test.

glad to see work being done this, this is the same method i described in the input lag thread on this forum a few years back:

i toyed with the idea as well since i wrote that post with results and issues similar to this. however, i gave up before coming up with a way to implement the idea cleanly and/or efficiently, let alone address the problems. what really discouraged me, other than a severe lack of time in general, was the fights i knew i was going to have in order to get anything relating to the hack merged anywhere.

with that said let me offer you this advice, if you’re going to pursue this make sure you implemented it as cleanly as possible. while people like us may think this is a cool idea it’s still kind of a nasty hack, and judging by past arguments i’ve had with various emulator authors/maintainers, most are going to be reluctant to merge any changes having to do with it. the less code you touch and the nicer it is the better the odds will be that various maintainers will adopt it. i think your best bet would be to focus solely on libretro curated/downstream projects to start with, as the libretro devs are the ones most open to these kinds of enhancements.

anyway, good luck! wish i could offer more than just words of encouragement, but if you ever need someone to back you up on the merits of this when trying to convince maintainers to adopt your changes let me know.

on a fast enough, well supported, and properly configured machine it can accomplish just that. (not by much though… but still cool to brag about to the “purists” :wink: )

Snes9x core is excluding two things from savestates it needs to restore audio properly:

  • Leftover samples in the main audio buffer
  • The state and contents of the audio resampler, including buffer contents

If these can be corrected, Snes9x will gain the ability to have steady sound even after loading state 60 times per second.

As for why there’s even a resampler in the first place, I don’t know.

Edit: Got Snes9x working!

Fixed QuickNES and Snes9X cores for testing (Windows 64-bit)

4 Likes

That’s so fast…

How comes snes9x isn’t showing pause/next frame like quicknes?
Pretty sure the lag reduction works while pushing “K” tells otherwise.

(it’s spamming msu search in the log too)

Just tested both cores. QuickNES was tested with Mega Man 2 and SMB. Both worked without any glitches what so ever and pause + frame advance confirmed next frame response.

EDIT: Oh, and playing Mega Man 2 emulated at ~2 frames of total input lag is a pretty cool feeling. :sunglasses:

However, while Snes9x runs without glitches, it also responds the same as without the fix, i.e. SMW responds on the third frame instead of the second. The regular Snes9x build, but with your modified retroarch.exe responds on the second frame (but with audio glitches).

Just to make be sure: You did build Snes9x with LAG_FIX=1 defined, right? It is the default, but it’s worth checking.

It’s not too early to start thinking about what term to call this. People are going to need to know how to refer to this feature when they start blogging and making youtube videos about it. Which will probably be very soon from what I can see.

I’d like to suggest something with just a tiny amount of snazinnes.

My best idea so far is Libretro Unlag. Used like this “Go to the Options, Activate Unlag, and set it to 3 frames.” etc.

Other terminology that’s been used includes:

  • Input Lag Compensation (or just Lag Compensation)
  • Lag Reduction
  • Latency Adjustment

Well, you get the picture. Just a thought from the peanut gallery. Exciting work, whatever you call it!

It was built using the MSVC 2010 project file, then I added in msu1.cpp, which was missing from the project.

I see no references to LAG_FIX anywhere in the code, so I don’t think defining LAG_FIX would do anything.

I also notice that Pausing with the P key blanks the screen until you hit the frame advance K button.

LAGFIX in the makefile.

Activates that here, and more bellow.

Sorry, it’s LAGFIX, as @Tatsuya79 correctly wrote.

Also, the changes I made now appear to be live on Core Updater, so you could try that build too.

I can confirm that the build of Snes9x on the Core Updater behaves correctly in terms of input lag, i.e. it responds on frame two in SMW. So, please use that for testing.

Spent some 20 minutes testing:

Super Mario World: Just some quick tests of the first couple of levels. No issues. Responds on frame number 2 (frame number 3 before fix).

Mega Man X: Played the intro stage and half of Armored Armadillo’s stage. No issues. Responds on frame number 2 (frame number 3 before fix).

Cool, looks like I should try adding a number to adjust the setting.

1 Like

I can also confirm no issues with Snes9X from the buildbot and the patched retroarch.exe. Music and video seem perfect. Pause + K method shows one less frame of lag.

Note this is on an Atom Windows 10 device, so it’s pretty astounding to have a full frame of lag shaved off. I was quite surprised to see it work this well, since this device can only achieve a frame_delay value of 5 with Snes9X before audio starts to crackle… :smiley:

@Brunnis Hope you find some time these days to do a camera test

A few friends emulate SNES via an HDMI projector which seems to add the equivalent of a couple of frames of lag. I’m looking forward to finding out if an adjustable setting would make that feel as snappy as a CRT.