v0.77.0: the laser visualizer is the Oscilloscope — screen sliders and rig diagram gone, a graticule dot size, and a sync delay per style
This commit is contained in:
+19
-49
@@ -104,10 +104,10 @@ class TestStylePreference:
|
||||
def test_settings_are_clamped(self, qapp, tmp_path):
|
||||
prefs = Preferences(tmp_path)
|
||||
prefs.set("visualizer_radial_spokes", 100000) # hand-edited
|
||||
prefs.set("visualizer_laser_pitch", "sideways")
|
||||
prefs.set("visualizer_laser_width", "wide")
|
||||
config = vs.settings(prefs)
|
||||
assert config["visualizer_radial_spokes"] == 360
|
||||
assert config["visualizer_laser_pitch"] == 0
|
||||
assert config["visualizer_laser_width"] == 1.5
|
||||
|
||||
def test_every_style_paints_without_error(self, qapp):
|
||||
for style in vs.STYLES:
|
||||
@@ -301,39 +301,11 @@ class TestLaser:
|
||||
s = np.linalg.svd(tilt, compute_uv=False)
|
||||
assert s[1] / s[0] > 0.4
|
||||
|
||||
def test_farther_screen_bigger_figure(self):
|
||||
audio = _sine(vs.MODES[1][0], 1.0)
|
||||
near = _run(vs.LaserRenderer(_config(laser_distance=1.0)), audio)
|
||||
far = _run(vs.LaserRenderer(_config(laser_distance=4.0)), audio)
|
||||
ratio = np.abs(far.paths[0][0]).max() / np.abs(near.paths[0][0]).max()
|
||||
assert 3.5 < ratio < 4.5
|
||||
|
||||
def test_pitch_stretches_vertically_and_roll_spins(self):
|
||||
audio = _sine((vs.MODES[1][0] + vs.MODES[2][0]) / 2, 1.0)
|
||||
|
||||
def spread(**angles):
|
||||
path = _run(vs.LaserRenderer(_config(**angles)), audio).paths[0][0]
|
||||
return np.ptp(path[:, 0]), np.ptp(path[:, 1])
|
||||
|
||||
square_x, square_y = spread()
|
||||
tipped_x, tipped_y = spread(laser_pitch=50)
|
||||
assert tipped_y / square_y > 1.3 * tipped_x / square_x
|
||||
turned_x, turned_y = spread(laser_yaw=50)
|
||||
assert turned_x / square_x > 1.3 * turned_y / square_y
|
||||
spun = _run(vs.LaserRenderer(_config(laser_roll=90)), audio).paths[0][0]
|
||||
flat = _run(vs.LaserRenderer(_config()), audio).paths[0][0]
|
||||
# A quarter turn: x becomes y (up to sign).
|
||||
assert np.allclose(np.abs(spun[:, 0]), np.abs(flat[:, 1]), atol=1e-9)
|
||||
|
||||
@pytest.mark.parametrize("angles", [
|
||||
{}, {"laser_pitch": 60, "laser_yaw": -60},
|
||||
{"laser_pitch": -60, "laser_yaw": 60, "laser_roll": 45},
|
||||
{"laser_distance": 1.0, "laser_pitch": 60}])
|
||||
def test_every_setting_stays_on_screen_and_visible(self, angles):
|
||||
def test_the_figure_stays_on_screen_and_visible(self):
|
||||
rng = np.random.default_rng(0)
|
||||
audio = _sine(90, 2, 0.9) * (1 + rng.standard_normal(2 * RATE) * 0.3)
|
||||
audio = audio + _sine(150, 2, 0.5)
|
||||
r = vs.LaserRenderer(_config(**angles))
|
||||
r = vs.LaserRenderer(_config())
|
||||
rect = QRectF(0, 0, 140, 62)
|
||||
half_w, half_h = 70 - vs.INSET, 31 - vs.INSET
|
||||
biggest = 0.0
|
||||
@@ -632,17 +604,12 @@ class TestPreferencesPage:
|
||||
dialog._head.setChecked(False)
|
||||
dialog._width_box.setValue(dialog._width_box.minimum())
|
||||
dialog._dot_slider.setValue(12)
|
||||
dialog._distance_slider.setValue(15)
|
||||
dialog._angle_sliders["visualizer_laser_pitch"].setValue(30)
|
||||
dialog._grid_dot_slider.setValue(200)
|
||||
assert prefs.get("visualizer_laser_glow") is False
|
||||
assert prefs.get("visualizer_laser_head") is False
|
||||
assert prefs.get("visualizer_laser_width") == 1 # one pixel
|
||||
assert prefs.get("visualizer_laser_dot") == 6
|
||||
assert prefs.get("visualizer_laser_distance") == 1.5
|
||||
assert prefs.get("visualizer_laser_pitch") == 30
|
||||
lo, hi = vs.LIMITS["visualizer_laser_roll"]
|
||||
slider = dialog._angle_sliders["visualizer_laser_roll"]
|
||||
assert (slider.minimum(), slider.maximum()) == (lo, hi)
|
||||
assert prefs.get("visualizer_laser_grid_dot") == 2
|
||||
|
||||
def test_sync_delay_saves_to_config_not_prefs(self, qapp, tmp_path,
|
||||
monkeypatch):
|
||||
@@ -650,10 +617,10 @@ class TestPreferencesPage:
|
||||
monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path / "cfg"))
|
||||
prefs = Preferences(tmp_path)
|
||||
dialog = self._dialog(prefs)
|
||||
dialog._sync_slider.setValue(150)
|
||||
dialog._sync_sliders["laser"].setValue(150)
|
||||
dialog._save_sync_delay()
|
||||
assert load_config()["visualizer_sync_delay_ms"] == 150
|
||||
assert prefs.get("visualizer_sync_delay_ms") is None
|
||||
assert load_config()["visualizer_sync_delays"]["laser"] == 150
|
||||
assert prefs.get("visualizer_sync_delays") is None
|
||||
|
||||
def test_a_swatch_repaints_its_slot(self, qapp, tmp_path):
|
||||
from lintunes import theme
|
||||
@@ -792,7 +759,7 @@ class TestPhosphor:
|
||||
def test_a_setting_change_starts_it_afresh(self, qapp):
|
||||
r = _run(vs.LaserRenderer(_config(laser_afterimage=0.5)), _sine(150, 0.2))
|
||||
_paint(r, 300, 200)
|
||||
r.configure(_config(laser_afterimage=0.5, laser_pitch=30))
|
||||
r.configure(_config(laser_afterimage=0.5, laser_width=3))
|
||||
assert r._phosphor == {}
|
||||
|
||||
|
||||
@@ -902,7 +869,7 @@ class TestPresets:
|
||||
def test_save_and_apply(self, qapp, tmp_path):
|
||||
prefs = Preferences(tmp_path)
|
||||
dialog = self._dialog(prefs)
|
||||
dialog._angle_sliders["visualizer_laser_pitch"].setValue(40)
|
||||
dialog._grid_dot_slider.setValue(40)
|
||||
dialog._grid.setChecked(True)
|
||||
dialog._speaker.setValues(150, 300)
|
||||
dialog._width_box.setValue(3.5)
|
||||
@@ -913,17 +880,17 @@ class TestPresets:
|
||||
|
||||
# Back to Default: every control (and setting) follows.
|
||||
dialog._on_preset_chosen("laser", combo.findData("Default"))
|
||||
assert prefs.get("visualizer_laser_pitch") == 0
|
||||
assert prefs.get("visualizer_laser_grid_dot") == 1
|
||||
assert prefs.get("visualizer_laser_grid") is False
|
||||
assert prefs.get("visualizer_laser_width") == 1.5
|
||||
assert dialog._speaker.values() == (0, 300)
|
||||
assert combo.currentText() == "Default"
|
||||
|
||||
dialog._on_preset_chosen("laser", combo.findData("Big Tilt"))
|
||||
assert prefs.get("visualizer_laser_pitch") == 40
|
||||
assert prefs.get("visualizer_laser_grid_dot") == 0.4
|
||||
assert prefs.get("visualizer_laser_grid") is True
|
||||
assert prefs.get("visualizer_laser_width") == 3.5
|
||||
assert dialog._angle_sliders["visualizer_laser_pitch"].value() == 40
|
||||
assert dialog._grid_dot_slider.value() == 40
|
||||
assert dialog._speaker.values() == (150, 300)
|
||||
assert combo.currentText() == "Big Tilt"
|
||||
|
||||
@@ -966,13 +933,16 @@ class TestPresets:
|
||||
assert set(presets.presets(prefs, "bars")["x"]) == {"visualizer_bars_fade",
|
||||
"visualizer_bars_count"}
|
||||
assert "visualizer_sync_delay_ms" not in presets.STYLE_KEYS["laser"]
|
||||
assert "visualizer_sync_delays" not in presets.STYLE_KEYS["laser"]
|
||||
|
||||
def test_an_old_preset_takes_new_settings_defaults(self, qapp, tmp_path):
|
||||
prefs = Preferences(tmp_path)
|
||||
prefs.set(presets.PRESETS_KEY,
|
||||
{"laser": {"Old": {"visualizer_laser_pitch": 20}}})
|
||||
{"laser": {"Old": {"visualizer_laser_width": 4,
|
||||
"visualizer_laser_pitch": 20}}})
|
||||
values = presets.values_of(prefs, "laser", "Old")
|
||||
assert values["visualizer_laser_pitch"] == 20
|
||||
assert values["visualizer_laser_width"] == 4
|
||||
assert "visualizer_laser_pitch" not in values # retired
|
||||
assert values["visualizer_laser_glow"] is True # default
|
||||
|
||||
def test_every_style_key_has_a_control(self, qapp, tmp_path):
|
||||
|
||||
Reference in New Issue
Block a user