diff --git a/app/config.py b/app/config.py index d1b717a..83c1fcd 100644 --- a/app/config.py +++ b/app/config.py @@ -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 diff --git a/app/musicmuster.py b/app/musicmuster.py index a94eeff..581d850 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -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