Skip to content

fix: Interpolate clock stretch factor in log space - #644

Open
realpoke wants to merge 1 commit into
foxssake:mainfrom
realpoke:fix/clock-stretch-factor
Open

fix: Interpolate clock stretch factor in log space#644
realpoke wants to merge 1 commit into
foxssake:mainfrom
realpoke:fix/clock-stretch-factor

Conversation

@realpoke

@realpoke realpoke commented Sep 4, 2026

Copy link
Copy Markdown

Clock stretch was interpolated linearly between 1/max and max, so with a stretch max of 2.0 a zero clock difference still produced a factor of ~1.5 and the simulation ran fast even with synced clocks.

Since stretch factors are speed multipliers they compose geometrically, so this interpolates in log space instead, zero difference now gives exactly 1.0, and +/-1 tick reaches max and its reciprocal symmetrically.

Clock stretch factors are speed multipliers, so they compose
geometrically: the neutral value is 1.0, and slowing down by some
amount is the reciprocal of speeding up by that same amount.

Interpolate in log space so that a clock difference of zero yields
exactly 1.0, and clock_stretch_max and its reciprocal are reached at
+/- one tick of difference. The old linear interpolation produced a
neutral factor of ~1.5 for clock_stretch_max of 2.0, desynchronizing
the simulation even when clocks matched.
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

Successfully merging this pull request may close these issues.

1 participant