v0.83.0: Preferences › DJ shows the space saved vocal splits use and says what they are; README gets a DJ mode section

This commit is contained in:
2026-10-27 08:59:52 -07:00
parent cd4edcf81f
commit 5150a1d145
5 changed files with 152 additions and 20 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
"""LinTunes — iTunes-style music library manager and player for Linux."""
__version__ = "0.82.0"
__version__ = "0.83.0"
+6
View File
@@ -307,6 +307,12 @@ def _size(folder: Path) -> int:
return total
def cache_size() -> int:
"""Bytes the whole split cache takes on disk now (both engines)."""
root = cache_root()
return _size(root) if root.is_dir() else 0
def prune(limit_gb: float | None = None, keep: str | None = None) -> int:
"""Delete the songs used longest ago until the cache is under
``limit_gb`` (config.json's when None). ``keep`` (a key) is never
+56 -19
View File
@@ -9,7 +9,7 @@ from PyQt6.QtWidgets import (
QColorDialog, QMenu, QDoubleSpinBox, QComboBox, QInputDialog,
QMessageBox, QApplication, QSizePolicy,
)
from PyQt6.QtCore import Qt, QTimer
from PyQt6.QtCore import Qt, QTimer, pyqtSignal
from PyQt6.QtGui import QDoubleValidator, QFont, QColor, QFontInfo
from lintunes import loudness, theme
@@ -114,6 +114,9 @@ class PreferencesDialog(QDialog):
omitted the music-folder row is simply left out.
"""
# The split cache's size in bytes, measured on a worker thread.
_stem_cache_measured = pyqtSignal(int)
def __init__(self, prefs, lastfm, parent=None, *,
music_folder=None, on_music_folder_change=None):
super().__init__(parent)
@@ -143,7 +146,8 @@ class PreferencesDialog(QDialog):
("Appearance", [self._build_general_group(),
self._build_colors_group()]),
("Visualizer", [self._build_visualizer_group()]),
("DJ", [self._build_dj_engine_group(), self._build_dj_group()]),
("DJ", [self._build_dj_engine_group(), self._build_dj_group(),
self._build_dj_cache_group()]),
("Integrations", [self._build_lastfm_group(),
self._build_acoustid_group(),
self._build_web_server_group()])):
@@ -413,24 +417,10 @@ class PreferencesDialog(QDialog):
gentle.setChecked(stems.gentle_choice(self._prefs))
gentle.toggled.connect(lambda on: self._prefs.set("dj_stem_gentle", on))
form.addRow("", gentle)
cache = QLineEdit(f"{stems.cache_limit_gb():g}")
cache.setValidator(QDoubleValidator(0.0, 10000.0, 2, cache))
cache.setMaximumWidth(80)
cache.setToolTip("Separated songs are kept up to this much disk space "
"on this computer; past it, the songs used longest "
"ago are deleted (they're split again if needed).")
cache.editingFinished.connect(self._save_stem_cache_limit)
cache_row = QHBoxLayout()
cache_row.addWidget(cache)
cache_row.addWidget(QLabel("GB"))
cache_row.addStretch(1)
form.addRow("Keep up to:", cache_row)
self._dj_cache_edit = cache
if stems.available():
note = QLabel("Demucs is set up. Songs are split when they load onto "
"a deck, or ahead of time with a playlist's or "
"song's “Prepare for DJ”. Splits are kept, up to "
"the size above.")
"song's “Prepare for DJ”.")
else:
note = QLabel("Demucs isn't set up on this computer (a one-time ~1 GB "
"download). In a terminal:\n" + stems.setup_command())
@@ -441,6 +431,54 @@ class PreferencesDialog(QDialog):
self._dj_gentle_check = gentle
return group
def _build_dj_cache_group(self) -> QGroupBox:
"""How much disk the saved vocal splits (both engines) may take,
and how much they take now."""
from lintunes.dj import stems
group = QGroupBox("Saved vocal splits")
form = QFormLayout(group)
form.addRow(self._note(
"Each song split into vocals and instrumental is saved on this "
"computer, so the vocals slider works at once the next time it's "
"on a deck. Past the limit, the songs used longest ago are "
"deleted; they're split again if you load them later."))
cache = QLineEdit(f"{stems.cache_limit_gb():g}")
cache.setValidator(QDoubleValidator(0.0, 10000.0, 2, cache))
cache.setMaximumWidth(80)
cache.editingFinished.connect(self._save_stem_cache_limit)
cache_row = QHBoxLayout()
cache_row.addWidget(cache)
cache_row.addWidget(QLabel("GB"))
cache_row.addStretch(1)
form.addRow("Keep up to:", cache_row)
self._dj_cache_edit = cache
self._dj_cache_used = QLabel("Measuring…")
form.addRow("Using now:", self._dj_cache_used)
self._stem_cache_measured.connect(self._show_stem_cache_used)
self._measure_stem_cache()
return group
def _measure_stem_cache(self, prune_to: float | None = None):
"""Walk the cache off the GUI thread (pruning first, when given a
new limit) and report its size back through a signal."""
from lintunes.dj import stems
def work():
if prune_to is not None:
stems.prune(prune_to)
try:
self._stem_cache_measured.emit(stems.cache_size())
except RuntimeError:
pass # the dialog was closed meanwhile
threading.Thread(target=work, daemon=True,
name="lintunes-stems-measure").start()
def _show_stem_cache_used(self, size: int):
gb = size / 1024 ** 3
text = f"{gb:.2f} GB" if gb >= 0.1 else f"{size / 1024 ** 2:.0f} MB"
self._dj_cache_used.setText(text)
def _save_stem_cache_limit(self):
"""config.json, not preferences: how much disk to give the splits
is this machine's business. A lower limit applies at once."""
@@ -455,8 +493,7 @@ class PreferencesDialog(QDialog):
return
config[stems.CACHE_LIMIT_KEY] = value
save_config(config)
threading.Thread(target=stems.prune, args=(value,), daemon=True,
name="lintunes-stems-prune").start()
self._measure_stem_cache(prune_to=value)
# ---- Wrapped ----