till213 / SkyDolly

Sky Dolly connects with Flight Simulator 2020 and records the flight path and basic instruments for replay.
MIT License
77 stars 9 forks source link

Can you increase the recording rate beyond 60fps #105

Open varrri opened 1 year ago

varrri commented 1 year ago

I notice that the stuttering during formation playback stops if the recording rate is set to values beyond 60(100-300) on other tools.

If possible could you add a field where we can set a custom, unlimited, number value for the recording rate?

Thank you for the work!

till213 commented 1 year ago

Hello,

Thank you for raising this issue: yes, the "aircraft jitter" specifically for "AI aircraft" ("formation flight") is a known problem. In fact, apparently since FSX (where the underlying SimConnect API made its first appearance).

For the following discussion we need to distinguish between two sample rates:

Currently in Sky Dolly only the recording sample rate can be selected (in earlier versions also the replay sample rate could be adjusted - more on that later).

Let's focus on the recoding sample rate first:

The short answer to your question: you can already request a higher sample rate than the 60 Hz (that is selectable in the sample rate selection combo box). How? Simply keep it at its default "auto" value.

So what does "auto" really do? It asks MSFS to notify us (Sky Dolly) about each "simulated frame". MSFS does all its physic calculations per "simulated frame" (that is, update the aircraft position based on the current forces acting upon the aircraft, update all forces, calculate / update engine performance etc.).

In theory the "simulated frame rate" is higher than the "displayed frames rates" (better known as "frames per second", or simply FPS) - on my (very average) system the "simulated frame rate" is about the same as the "displayed frames rate", that is around 30 Hz (only).

It doesn't make sense to ask MSFS for updated position (and other "simulation variables") data more frequently than MSFS is able to calculate them: you would simply get the same value multiple times, and hence simply be wasting storage space.

In fact, the current recording sample rate selection was always meant that you could lower the rate, in order to save storage space, by selecting a sample rate like 20, 10 or even only 5 Hz.

In the early days of Sky Dolly I made a comparison video with different recording sample rates. The conclusion: unless you choose very low sample rates like 5 Hz or below (or you do very wild acrobatic maneuvres) you won't be able to tell the difference:

https://youtu.be/bfgkY0eXL4w

In any case, the movement will be smooth (more on that later when we talk about the replay sample rate).

In fact, I intend to remove the recording sample rate selection altogether: Sky Dolly already has techniques to reduce the data storage, by organising the simulation variables into "groups": the effect is that unless a variable in a given group is changing nothing is recorded at all, and no disk storage is wasted (with repetitive values, e.g. "flaps" that are retracted for the most part of the flight).

And I probably will go even further and "hard-code" the position sample rate to as low as 1 Hz. "But why?!" you probably ask. And rightly so, it sounds absurd, initially: but my idea is to "smoothen out" the recorded data: a natural "low pass filter" that only records the lowest frequencies of the flight path, so to speak. Because I believe that currently also "micro-stutters" will be recorded and hence also replayed. But by only recording the position data every second or so (I will have to experiment with the final value) the recorded position data will be "smooth", or in other words: "micro-stutters" won't be recorded.

Now let's talk about replay and the replay sample rate:

The recorded data is, in fact, also "re-sampled" all the time, but this time with the "highest possible sample rate". Again we are talking about the "simulated frame rate", as notified by MSFS. According to various older FSX discussions (in various FSX developer forums) the "AI aircraft jitter" is a known problem (and to some extend it probably also applies to the "user aircraft" itself = the one being followed by the camera in MSFS). Someone wrote that even "supersampling" the recorded data with 120 Hz doesn't make the "jitter" go away, and that is congruent with my own experiments (and yes, I also tried to supersample with 120 Hz, even before I read that particular post).

The simple reason seems to be: MSFS doesn't update the AI aircraft position - as sent via SimConnect, that is - as often as we would like. So sending more data than MSFS could process doesn't help.

(The exact reason why we do see this "jitter" is not exactly known to me).

So I do have some ideas how I could improve this: essentially by letting MSFS do its own "interpolation" between the points in time when it (is able to) processes SimConnect requests. Whether that'll work (based on some suggestion in the FSX days) still with MSFS remains to be seen.

I also plan to try to make replay of the "user aircraft" a bit smoother, by:

And finally the new method of having MSFS itself interpolate the aircraft movement. But again, whether that last point will (still) work I only know once impleented ;)

I'll keep this issue open and link it to the above new features.