Make volume fade graph update much smoother.
VLC get_time and get_position are very granular, only updating about 3-4 times a second. Instead, calculate play_time by substracting track start time from current time and expressing that as milliseconds.
This commit is contained in:
parent
4eb3a98c95
commit
b706008101
@ -80,7 +80,7 @@ class Config(object):
|
||||
SCROLL_TOP_MARGIN = 3
|
||||
TEXT_NO_TRACK_NO_NOTE = "[Section header]"
|
||||
TOD_TIME_FORMAT = "%H:%M:%S"
|
||||
TIMER_MS = 100
|
||||
TIMER_MS = 10
|
||||
TRACK_TIME_FORMAT = "%H:%M:%S"
|
||||
VOLUME_VLC_DEFAULT = 75
|
||||
VOLUME_VLC_DROP3db = 65
|
||||
|
||||
@ -180,13 +180,13 @@ class FadeCurve:
|
||||
self.curve = self.GraphWidget.plot(self.graph_array)
|
||||
self.curve.setPen(Config.FADE_CURVE_FOREGROUND)
|
||||
|
||||
def tick(self, play_position) -> None:
|
||||
def tick(self, play_time) -> None:
|
||||
"""Update volume fade curve"""
|
||||
|
||||
if not self.GraphWidget:
|
||||
return
|
||||
|
||||
ms_of_graph = play_position - self.start_ms
|
||||
ms_of_graph = play_time - self.start_ms
|
||||
if ms_of_graph < 0:
|
||||
return
|
||||
|
||||
@ -333,7 +333,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.setupUi(self)
|
||||
|
||||
self.timer: QTimer = QTimer()
|
||||
self.even_tick: bool = True
|
||||
self.clock_counter: int = 0
|
||||
|
||||
self.music: music.Music = music.Music()
|
||||
self.playing: bool = False
|
||||
@ -1676,10 +1676,10 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.clock_counter is incrememted at each tick (100ms), and this
|
||||
value is used to determine the actions to take.
|
||||
|
||||
The Fade Volume graph is updated every 100ms.
|
||||
The Fade Volume graph is updated every 10ms.
|
||||
|
||||
The Time of Day clock and any cart progress bars are updated
|
||||
every tick (500ms).
|
||||
every 500ms.
|
||||
|
||||
All other timers are updated every second. As the timer displays
|
||||
have a one-second resolution, updating every 500ms can result in
|
||||
@ -1697,17 +1697,24 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
"""
|
||||
|
||||
# Update volume fade curve
|
||||
if self.current_track.track_id and self.current_track.fade_graph:
|
||||
self.current_track.fade_graph.tick(self.music.get_playtime())
|
||||
if (
|
||||
self.current_track.track_id and
|
||||
self.current_track.fade_graph and
|
||||
self.current_track.start_time
|
||||
):
|
||||
play_time = (
|
||||
datetime.now() - self.current_track.start_time
|
||||
).total_seconds() * 1000
|
||||
self.current_track.fade_graph.tick(play_time)
|
||||
|
||||
if self.clock_counter % 2 == 0:
|
||||
if self.clock_counter % 20 == 0:
|
||||
# Update TOD clock
|
||||
self.lblTOD.setText(datetime.now().strftime(
|
||||
Config.TOD_TIME_FORMAT))
|
||||
# Update carts
|
||||
self.cart_tick()
|
||||
|
||||
if self.clock_counter % 5 == 0:
|
||||
if self.clock_counter % 50 == 0:
|
||||
if not self.playing:
|
||||
return
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user