Improve logging and FadeCurve generation. Tidy.
This commit is contained in:
parent
e179e57459
commit
e9a3047f00
@ -13,6 +13,7 @@ from sqlalchemy.orm import scoped_session
|
|||||||
|
|
||||||
# App imports
|
# App imports
|
||||||
from config import Config
|
from config import Config
|
||||||
|
from log import log
|
||||||
from models import PlaylistRows
|
from models import PlaylistRows
|
||||||
import helpers
|
import helpers
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ class FadeCurve:
|
|||||||
|
|
||||||
audio = helpers.get_audio_segment(track_path)
|
audio = helpers.get_audio_segment(track_path)
|
||||||
if not audio:
|
if not audio:
|
||||||
|
log.error(f"FadeCurve: could not get audio for {track_path=}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Start point of curve is Config.FADE_CURVE_MS_BEFORE_FADE
|
# Start point of curve is Config.FADE_CURVE_MS_BEFORE_FADE
|
||||||
@ -116,7 +118,7 @@ class PlaylistTrack:
|
|||||||
self.end_time: Optional[dt.datetime] = None
|
self.end_time: Optional[dt.datetime] = None
|
||||||
self.fade_at: Optional[int] = None
|
self.fade_at: Optional[int] = None
|
||||||
self.fade_graph: Optional[FadeCurve] = None
|
self.fade_graph: Optional[FadeCurve] = None
|
||||||
self.fade_graph_start_updates: Optional[datetime] = None
|
self.fade_graph_start_updates: Optional[dt.datetime] = None
|
||||||
self.fade_length: Optional[int] = None
|
self.fade_length: Optional[int] = None
|
||||||
self.path: Optional[str] = None
|
self.path: Optional[str] = None
|
||||||
self.playlist_id: Optional[int] = None
|
self.playlist_id: Optional[int] = None
|
||||||
@ -163,7 +165,6 @@ class PlaylistTrack:
|
|||||||
self.fade_length = track.silence_at - track.fade_at
|
self.fade_length = track.silence_at - track.fade_at
|
||||||
|
|
||||||
# Initialise and add FadeCurve in a thread as it's slow
|
# Initialise and add FadeCurve in a thread as it's slow
|
||||||
# Import in separate thread
|
|
||||||
self.fadecurve_thread = QThread()
|
self.fadecurve_thread = QThread()
|
||||||
self.worker = AddFadeCurve(
|
self.worker = AddFadeCurve(
|
||||||
self,
|
self,
|
||||||
@ -198,9 +199,8 @@ class PlaylistTrack:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Calculate time fade_graph should start updating
|
# Calculate time fade_graph should start updating
|
||||||
if self.fade_at:
|
|
||||||
update_graph_at_ms = max(0, self.fade_at - Config.FADE_CURVE_MS_BEFORE_FADE - 1)
|
update_graph_at_ms = max(0, self.fade_at - Config.FADE_CURVE_MS_BEFORE_FADE - 1)
|
||||||
self.fade_graph_start_updates = now + timedelta(milliseconds=update_graph_at_ms)
|
self.fade_graph_start_updates = now + dt.timedelta(milliseconds=update_graph_at_ms)
|
||||||
|
|
||||||
|
|
||||||
class AddFadeCurve(QObject):
|
class AddFadeCurve(QObject):
|
||||||
@ -229,9 +229,11 @@ class AddFadeCurve(QObject):
|
|||||||
Create fade curve and add to PlaylistTrack object
|
Create fade curve and add to PlaylistTrack object
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.playlist_track.fade_graph = FadeCurve(
|
fc = FadeCurve(self.track_path, self.track_fade_at, self.track_silence_at)
|
||||||
self.track_path, self.track_fade_at, self.track_silence_at
|
if not fc:
|
||||||
)
|
log.error(f"Failed to create FadeCurve for {self.track_path=}")
|
||||||
|
else:
|
||||||
|
self.playlist_track.fade_graph = fc
|
||||||
self.finished.emit()
|
self.finished.emit()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1240,9 +1240,19 @@ class PlaylistModel(QAbstractTableModel):
|
|||||||
if plr:
|
if plr:
|
||||||
# Check this isn't a header row
|
# Check this isn't a header row
|
||||||
if self.is_header_row(row_number):
|
if self.is_header_row(row_number):
|
||||||
|
log.error(
|
||||||
|
"Tried to set next row on header row: "
|
||||||
|
f"playlistmodel.set_next_track({row_number=}, "
|
||||||
|
f"{self.playlist_id=}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
# Check track is readable
|
# Check track is readable
|
||||||
if file_is_unreadable(plr.track.path):
|
if file_is_unreadable(plr.track.path):
|
||||||
|
log.error(
|
||||||
|
"Tried to set next row on unreadable row: "
|
||||||
|
f"playlistmodel.set_next_track({row_number=}, "
|
||||||
|
f"{self.playlist_id=}"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
track_sequence.next.set_plr(session, plr)
|
track_sequence.next.set_plr(session, plr)
|
||||||
self.signals.next_track_changed_signal.emit()
|
self.signals.next_track_changed_signal.emit()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user