v0.66.0: DJ mode's djay layout, loops, a sync that sets once, a real horn, a smooth slide

- Records in the top corners, each deck's controls beside them facing the
  middle, the zoomed A-over-B waveforms in the centre, and a whole-song
  overview per deck below (click to jump, drag to move) with the
  crossfader between them.
- Loops per deck: Loop plus a 1/32 to 8 beat stepper; a loop starts on
  the next beat and shows on both waveforms.
- Sync sets this deck to the other's tempo once, and stays lit only while
  that still holds.
- The air horn plays like a real one: every press a fresh blast, held it
  carries the note, let go it stops.
- Opening and closing DJ mode slides a picture over the final layout
  instead of re-laying-out the window every frame (the flicker).
- Tests: garbage is collected on the main thread after each test, which
  stops a rare segfault in the full run.
This commit is contained in:
2026-10-17 22:19:59 -07:00
parent e00aafefba
commit 279f51fba9
9 changed files with 734 additions and 191 deletions
+8 -37
View File
@@ -57,13 +57,10 @@ class TestSync:
_loaded(shelf, b, shelf.tracks[1], _clicks(118, 0.05, 20), 118.0, 0.05)
return a, b
def test_sync_sticks_glows_and_follows(self, shelf):
def test_sync_glows_while_it_holds(self, shelf):
a, b = self._pair(shelf)
shelf.sync(b)
assert b.synced and shelf.sync_buttons["B"].text() == "Synced"
shelf.speed["A"].setValue(200) # A +2 %: B follows
shelf._tick()
assert b.deck.speed == pytest.approx(124 * 1.02 / 118)
shelf.speed["B"].setValue(0) # B moved by hand: unsynced
assert not b.synced
assert shelf.sync_buttons["B"].text() == "Sync to other track"
@@ -93,39 +90,13 @@ class TestSync:
assert a.deck.position == 0 and not a.deck.ended
class TestHorn:
def _horn(self):
x = (np.sin(np.arange(RATE * 2) / RATE * 2 * np.pi * 400) * 20000).astype(np.int16)
return Horn(np.stack([x, x], axis=1))
def _drain(self, horn):
total = 0
while True:
block = horn.render(4096)
if block is None:
return total / RATE
total += len(block)
def test_a_tap_plays_the_whole_recording(self):
horn = self._horn()
horn.press()
horn.render(441)
horn.release()
assert 0.01 + self._drain(horn) == pytest.approx(2.0, abs=0.1)
def test_holding_stretches_it(self):
horn = self._horn()
horn.press()
held = sum(len(horn.render(4096)) for _ in range(int(4 * RATE / 4096))) / RATE
horn.release()
assert held > 3.9
assert self._drain(horn) <= 2.0 # then the rest plays out
def test_the_bundled_recording_loads(self, qapp):
from lintunes.gui.dj_shelf import _load_horn
horn = Horn()
_load_horn(horn)
assert horn._src is not None and len(horn._src) > RATE
def test_the_bundled_horn_recording_loads(qapp):
# (Round 96 replaced "a tap plays the whole phrase" with the way a DJ
# horn really plays — see test_round96.TestHorn.)
from lintunes.gui.dj_shelf import _load_horn
horn = Horn()
_load_horn(horn)
assert horn._held is not None and len(horn._held) > RATE
def test_the_waveform_zooms_out_while_paused(shelf):