v0.103.0: DJ mode's vocals slider has a small line at its middle, and holding its mic or note lights it green and shows just the vocals' or the instrumental's waveform for that deck — the slider stays put and the sound doesn't change

This commit is contained in:
2026-11-27 10:35:38 -08:00
parent c1479092bb
commit 3a97435552
3 changed files with 194 additions and 40 deletions
+73
View File
@@ -0,0 +1,73 @@
"""Round 135: the DJ vocals slider's middle is a small line, and holding its
mic or note shows just that stem's waveform — without moving the slider."""
import numpy as np
from PyQt6.QtCore import QPoint, Qt
from PyQt6.QtGui import QColor
from PyQt6.QtTest import QTest
from lintunes.dj import analysis, stems
from tests.test_round93 import RATE, _clicks, _loaded, shelf # noqa: F401 — fixture
def _slider(qapp):
from lintunes.gui.dj_shelf import VocalSlider
slider = VocalSlider(QColor("#5a9be0"))
slider.resize(220, slider.height())
return slider
def test_holding_an_icon_previews_and_leaves_the_value(qapp):
slider = _slider(qapp)
seen = []
slider.preview.connect(seen.append)
for kind in ("vocals", "instrumental"):
at = slider._icon_rect(kind).center().toPoint()
QTest.mousePress(slider, Qt.MouseButton.LeftButton, pos=at)
assert slider.held == kind
QTest.mouseRelease(slider, Qt.MouseButton.LeftButton, pos=at)
assert slider.held is None
assert slider.value() == 0 # the sound never changes
assert seen == ["vocals", None, "instrumental", None]
def test_the_middle_is_not_a_preview_and_the_track_still_slides(qapp):
slider = _slider(qapp)
seen = []
slider.preview.connect(seen.append)
mid = QPoint(int(slider._pos_of(0)), 4)
QTest.mousePress(slider, Qt.MouseButton.LeftButton, pos=mid)
QTest.mouseRelease(slider, Qt.MouseButton.LeftButton, pos=mid)
assert seen == []
lo, _ = slider._span()
end = QPoint(int(lo), slider.height() - 6) # on the track, not the icons
QTest.mousePress(slider, Qt.MouseButton.LeftButton, pos=end)
QTest.mouseRelease(slider, Qt.MouseButton.LeftButton, pos=end)
assert slider.value() == -100
def test_the_waveforms_show_the_held_stem(shelf):
a, _ = shelf.views
_loaded(shelf, a, shelf.tracks[0], _clicks(124, 0.1, 5), 124.0, 0.1)
n = a.deck.source.frames
vocals = np.zeros((n, 2), np.int16)
vocals[: n // 2] = 8000
instrumental = np.full((n, 2), 4000, np.int16)
shelf._apply_stems("/x.mp3", (vocals, instrumental, "htdemucs"))
full = a.peaks
assert a.shown_peaks is full
shelf.vocal_sliders["A"].preview.emit("vocals")
np.testing.assert_allclose(a.shown_peaks, analysis.peaks(vocals, RATE))
shelf.vocal_sliders["A"].preview.emit("instrumental")
np.testing.assert_allclose(a.shown_peaks, analysis.peaks(instrumental, RATE))
shelf.vocal_sliders["A"].preview.emit(None)
assert a.shown_peaks is full
assert a.deck.vocal_mix == 0 # what plays is untouched
shelf.overviews["A"].grab() # paints with the stem's peaks
shelf.lanes.grab()
def test_no_split_yet_shows_the_whole_song(shelf):
a, _ = shelf.views
_loaded(shelf, a, shelf.tracks[0], _clicks(124, 0.1, 5), 124.0, 0.1)
shelf.set_preview(a, "vocals")
assert a.shown_peaks is a.peaks