Files
summit/engine/tests/test_multiplier.py
ZebraticandClaude Opus 5.5 2eec6b324d Frame generation for 60 fps games, output resolution, and a regrouped overlay
60 fps games
- A game at a steady 60 fps (found after a second at 57+, or Game frame rate
  set to the new 60 fps) goes on the frame timeline, which draws in-between
  frames at any rate; the 60 Hz beat alone only ever showed its own frames
- The frame multiplier works from the game's rate: 2x makes 30 fps 60 and
  60 fps 120 (labels are now just "2x", "3x"...)
- --sim60 plays a 60 fps file as a 60 fps game, for testing

Output resolution
- The upscaler makes the picture at a chosen size (720p .. 4K, or any WxH),
  then it's fitted to the screen: lighter below the screen's size,
  supersampling above it. --output-res, the overlay, Summit's profile editor
  (with a custom size), `summit profile set --output-res`

In-game overlay
- Tabs regrouped with headings: Home, Frame generation (Basics, AI model,
  Smoothing), Upscaling (Upscaler, Output), Display (Window, Colour and look),
  Overlay (Stats, Graphs, This menu, Branding), Clips, Sources; one table
  (settings.LAYOUT) says where each setting goes
- Bigger: 1100 px wide, 11 rows; headings are skipped by keys and the mouse
- Home adds Game frame rate and Output resolution

Summit: Game frame rate and Output resolution per game (profile, editor, CLI)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-25 03:22:53 +01:00

59 lines
2.4 KiB
Python

"""Frame multiplier: N generated-frame positions per real frame of a 30 fps game (pipeline.cadence_steps), and the
settings that take any multiple of 30 fps from 60 to 300 (2x to 10x)."""
import pathlib
import sys
from fractions import Fraction
import pytest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from framegen.settings import BY_KEY, Settings, valid_hz
pipeline = pytest.importorskip("framegen.pipeline")
def test_the_old_rates_keep_their_cadence():
assert pipeline.cadence_steps(60) == ([0.5], [])
assert pipeline.cadence_steps(90) == ([1 / 3, 2 / 3], [])
assert pipeline.cadence_steps(120) == ([0.25, 0.5], [0.75])
@pytest.mark.parametrize("n", range(2, 11))
def test_every_multiplier_shows_n_evenly_spaced_frames_per_real_one(n):
first, second = pipeline.cadence_steps(30 * n)
shown = first + second + [1.0] # the real frame closes the pair
assert [Fraction(t).limit_denominator(100) for t in shown] == [Fraction(j, n) for j in range(1, n + 1)]
# the real frame's tick carries half of them (one more for an odd N): the next tick never has more to show
assert len(first) - (len(second) + 1) in (0, 1)
def test_settings_take_any_multiple_of_30_from_2x_to_10x():
assert all(valid_hz(h) for h in (60, 90, 210, 300))
assert not any(valid_hz(h) for h in (30, 100, 330, True, "120", 120.0))
s = Settings()
s.override("hz", 210) # 7x, not a menu choice
assert s.hz == 210 and BY_KEY["hz"].name(210) == "7x"
with pytest.raises(ValueError):
s.override("hz", 100)
assert s.step("hz", 1) == 240 and s.step("hz", -1) == 180 # from a custom value, to the menu's neighbours
assert BY_KEY["hz"].name(120) == "4x"
def test_a_steady_60_fps_game_is_found_and_left_again():
from framegen.cadence import UNEVEN_DWELL, FrameTimeline
t = FrameTimeline()
for _ in range(60 + UNEVEN_DWELL + 1): # a second to count, then a second there
t.tick(True)
assert t.full and t.delay <= 1.1 # at most about a frame of delay (steady frames need next to none)
for k in range(60 + UNEVEN_DWELL + 1): # 30 fps: new every other tick
t.tick(k % 2 == 0)
assert not t.full
def test_a_short_60_fps_burst_isnt_a_60_fps_game():
from framegen.cadence import FrameTimeline
t = FrameTimeline()
for n in range(240): # a 30 fps game with a 60 fps menu for half a second
t.tick(n % 2 == 0 or 100 <= n < 130)
assert not t.full