v0.64.0: DJ mode round two — vocals models, Prepare for DJ, deck volumes, ½×/2×, scrubbing, air horn

- Preferences › DJ: vocals model (Best / Balanced / Fast) and gentle CPU
  use (a quarter of the cores, lowest priority — measured only ~20%
  slower). Splits are cached per model; a deck uses the best one.
- Prepare for DJ on a playlist or songs: BPM and vocals ahead of time.
- Each deck: a volume fader on the outer edge, labelled beside Tempo; a
  ½×/1×/2× switch for half/double-time counting.
- Drag a waveform to scrub (backwards too).
- Crossfader: a handle twice as tall, a middle line, a snap to centre;
  narrower. "calculated, saved" is gone from the BPM line.
- Keep pitch shows a checkmark. An air horn to hold.
- The visualizer draws the mix; the sidebar art hides in DJ mode.
- The Library button has the transport buttons' 8 px corners.
This commit is contained in:
2026-10-17 03:13:59 -07:00
parent 8298450814
commit 6d6a0c2385
16 changed files with 1029 additions and 97 deletions
+84 -2
View File
@@ -160,6 +160,7 @@ class MainWindow(QMainWindow):
layout.addWidget(self._transport)
# DJ mode (Round 93): the shelf is made the first time it opens.
self._dj = None
self._dj_prep_worker = None
self._dj_on = False
self._dj_anim = None
self._dj_resize_from = None
@@ -302,6 +303,7 @@ class MainWindow(QMainWindow):
self._cassette.show_friend_menu)
self._sidebar.playlist_selected.connect(self._show_playlist)
self._sidebar.tree.export_requested.connect(self._export_playlist)
self._sidebar.tree.dj_prepare_requested.connect(self._prepare_playlist_for_dj)
self._sidebar.art.download_art_requested.connect(
lambda tid: self._download_album_art([tid]))
self._content.currentChanged.connect(self._update_totals)
@@ -314,6 +316,7 @@ class MainWindow(QMainWindow):
view.table.download_art_requested.connect(self._download_album_art)
view.table.identify_requested.connect(self._identify_tracks)
view.table.bpm_requested.connect(self._calculate_bpm)
view.table.dj_prepare_requested.connect(self._prepare_for_dj)
view.table.remove_from_library_requested.connect(
lambda ids: self._delete_tracks(ids, delete_files=False))
view.table.delete_from_library_requested.connect(
@@ -668,12 +671,16 @@ class MainWindow(QMainWindow):
for worker in (self._andtunes_planner, self._andtunes_worker,
self._export_worker, self._url_worker,
self._bpm_worker, self._server_check,
self._upload_worker):
self._upload_worker, self._dj_prep_worker):
if worker is not None and worker.busy():
return worker
return None
def _confirm_cancel_sync(self):
if self._dj_prep_worker is not None and self._dj_prep_worker.busy():
# What's prepared is kept; the song being split is abandoned.
self._dj_prep_worker.cancel()
return
if self._bpm_worker is not None and self._bpm_worker.busy():
# Nothing to lose: what's been measured is kept.
self._bpm_worker.cancel()
@@ -2077,6 +2084,77 @@ class MainWindow(QMainWindow):
return
self._enqueue_identify(tracks)
# ---- Prepare for DJ ----
def _prepare_playlist_for_dj(self, pid: str):
playlist = self._manager.library.playlists.get(pid)
if playlist is not None:
self._prepare_for_dj(list(playlist.track_ids))
def _prepare_for_dj(self, track_ids: list[int]):
"""BPM and vocals for these songs now, so they load onto a deck
instantly — with the vocals model chosen in Preferences › DJ."""
from lintunes.dj import stems
from lintunes.dj.prepare import DjPrepWorker
if self._busy_worker() is not None:
self.statusBar().showMessage(
"Wait for the current transfer to finish first", 6000)
return
if not stems.available():
QMessageBox.information(
self, "Prepare for DJ",
"Separating vocals needs Demucs, which isn't set up on this "
"computer. It's a one-time ~1 GB download:\n\n" + stems.setup_command())
return
items, seen = [], set()
for tid in track_ids:
track = self._manager.library.tracks.get(tid)
if track is None or not track.location or tid in seen:
continue
seen.add(tid)
label = (f"{track.artist} — {track.name}" if track.artist
else track.name) or Path(track.location).name
items.append((tid, track.location, label, bool(track.bpm)))
if not items:
return
model = stems.model_choice(self._prefs)
worker = DjPrepWorker(items, model, stems.gentle_choice(self._prefs), self)
self._dj_prep_bpm = {}
worker.bpm_found.connect(self._dj_prep_bpm.__setitem__)
worker.progress.connect(self._on_dj_prep_progress)
worker.finished.connect(self._on_dj_prep_finished)
self._dj_prep_worker = worker
self._sync_label.setText(f"Preparing for DJ ({stems.MODELS[model][0]})…")
self._sync_progress.setRange(0, len(items))
self._sync_progress.setValue(0)
self._sync_cancel.show()
self._sync_label.show()
self._sync_progress.show()
worker.start()
def _on_dj_prep_progress(self, done: int, total: int, label: str):
self._sync_progress.setRange(0, total)
self._sync_progress.setValue(done)
if label:
short = label if len(label) <= 48 else label[:47] + "…"
where = f"{done + 1} of {total} · " if total > 1 else ""
self._sync_label.setText(f"DJ {where}{short}")
def _on_dj_prep_finished(self, summary: dict):
self._hide_sync_widgets()
found, self._dj_prep_bpm = self._dj_prep_bpm, {}
if found:
self._manager.set_tracks_bpm(found)
msg = (f"Prepared {summary['done']} song(s) for DJ"
f" · {summary['split']} vocals separated · {summary['bpm']} BPM found")
if summary["cancelled"]:
msg = "Prepare for DJ stopped — " + msg[0].lower() + msg[1:]
if summary["failed"]:
msg += f" · {summary['failed']} couldn't be done"
if not summary["cancelled"]:
sounds.play_done(self._prefs)
self.statusBar().showMessage(msg, 12000)
# ---- Calculate BPM ----
def _calculate_bpm(self, track_ids: list[int]):
@@ -2323,6 +2401,8 @@ class MainWindow(QMainWindow):
shelf.setFixedHeight(0)
shelf.show()
shelf.start()
shelf.set_visualizer(self._transport._visualizer)
self._sidebar.art.hide() # room for the lists instead
self._animate_shelf(0, target)
else:
shelf = self._dj
@@ -2333,7 +2413,7 @@ class MainWindow(QMainWindow):
def _ensure_dj(self):
if self._dj is None:
from lintunes.gui.dj_shelf import DjShelf
shelf = DjShelf(self._manager)
shelf = DjShelf(self._manager, self._prefs)
shelf.hide()
shelf.message.connect(lambda msg: self.statusBar().showMessage(msg, 8000))
shelf.decks_changed.connect(self._on_decks_changed)
@@ -2394,8 +2474,10 @@ class MainWindow(QMainWindow):
def _dj_closed(self):
if self._dj_on:
return # reopened mid-close
self._dj.set_visualizer(None)
self._dj.stop()
self._dj.hide()
self._sidebar.art.show()
self.player.set_suspended(False)
self._transport.set_dj_mode(False)