From 3978d9f0ebf6bac3ec2b13282c45bf28d2ce13d2 Mon Sep 17 00:00:00 2001 From: Anthony van Winkle Date: Sun, 4 Feb 2024 17:16:56 -0800 Subject: [PATCH] Revert "Audio track volume control and SoundPlayer ducking" --- mpfmc/assets/sound.py | 6 ------ mpfmc/config_players/slide_player.py | 2 +- mpfmc/config_players/sound_player.py | 15 ++------------- mpfmc/core/audio/__init__.py | 11 +---------- mpfmc/tests/test_Display.py | 7 ++----- 5 files changed, 6 insertions(+), 35 deletions(-) diff --git a/mpfmc/assets/sound.py b/mpfmc/assets/sound.py index 62885e17..e9542c2e 100644 --- a/mpfmc/assets/sound.py +++ b/mpfmc/assets/sound.py @@ -556,12 +556,6 @@ def has_ducking(self): """Return whether or not this sound has ducking""" return self._ducking is not None - def set_ducking(self, ducking_settings=None): - if not ducking_settings: - self._ducking = None - return - self._ducking = DuckingSettings(self.machine, ducking_settings) - @property def key(self): """Return the unique key value for this sound""" diff --git a/mpfmc/config_players/slide_player.py b/mpfmc/config_players/slide_player.py index 97bf29ab..5dcf87e8 100644 --- a/mpfmc/config_players/slide_player.py +++ b/mpfmc/config_players/slide_player.py @@ -102,7 +102,7 @@ def play(self, settings, context, calling_context, priority=0, **kwargs): instance_dict = self._get_instance_dict(context) full_context = self._get_full_context(context) - self.machine.log.debug("SlidePlayer: Play called with settings=%s", settings) + self.machine.log.info("SlidePlayer: Play called with settings=%s", settings) settings = settings.get('slides', settings) diff --git a/mpfmc/config_players/sound_player.py b/mpfmc/config_players/sound_player.py index f17a2e99..39a159dd 100644 --- a/mpfmc/config_players/sound_player.py +++ b/mpfmc/config_players/sound_player.py @@ -75,16 +75,13 @@ def play(self, settings, context, calling_context, priority=0, **kwargs): # noq action: priority: volume: - ducking: loops: max_queue_time: block: Notes: - - Ducking settings only apply to sound assets without ducking config - (i.e. sound asset ducking overrides sound_player ducking) - - Markers cannot currently be specified/overridden in the sound_player - (they must be specified in the sounds section of a config file). + Ducking settings and markers cannot currently be specified/overridden in the + sound_player (they must be specified in the sounds section of a config file). """ settings = deepcopy(settings) @@ -138,15 +135,7 @@ def play(self, settings, context, calling_context, priority=0, **kwargs): # noq # Determine action to perform if action == 'play': - temp_ducking = None - if s.get('ducking') and not sound.has_ducking: - sound.set_ducking(s['ducking']) - temp_ducking = True - track.play_sound(sound, context, s) - # Remove the temporary ducking - if temp_ducking: - sound.set_ducking() elif action == 'stop': if 'fade_out' in s: diff --git a/mpfmc/core/audio/__init__.py b/mpfmc/core/audio/__init__.py index 865a3b1d..8ab96028 100644 --- a/mpfmc/core/audio/__init__.py +++ b/mpfmc/core/audio/__init__.py @@ -115,18 +115,9 @@ def __init__(self, mc): self.mc.events.add_handler("shutdown", self.shutdown) self.mc.events.add_handler("machine_var_master_volume", self._set_volume) - for track in self.tracks.keys(): - self.mc.events.add_handler(f"machine_var_{track}_volume", self._set_volume, track=track) def _set_volume(self, **kwargs): - track = kwargs.get("track") - if not track: - self.master_volume = kwargs['value'] - return - elif not track in self.tracks: - raise AttributeError(f"Track {track} not found in sound system.") - - self.tracks[track].set_volume(kwargs['value']) + self.master_volume = kwargs['value'] def shutdown(self, **kwargs): """Shuts down the audio interface""" diff --git a/mpfmc/tests/test_Display.py b/mpfmc/tests/test_Display.py index 75ff3657..2d9ad8cd 100644 --- a/mpfmc/tests/test_Display.py +++ b/mpfmc/tests/test_Display.py @@ -1,4 +1,3 @@ -from kivy.metrics import dp from mpfmc.uix.display import Display, DisplayOutput from mpfmc.tests.MpfMcTestCase import MpfMcTestCase @@ -12,14 +11,12 @@ def get_config_file(self): def test_display(self): # Make sure nested multiple displays are loaded properly and are centered - self.assertEqual(self.mc.root_window.system_size, [800, 600]) + self.assertEqual(self.mc.root_window.size, (800, 600)) self.assertIn('window', self.mc.displays) self.assertTrue(isinstance(self.mc.displays['window'], Display)) self.assertEqual(self.mc.displays['window'].size, [600, 200]) self.assertIsInstance(self.mc.displays['window'].parent, DisplayOutput) - self.assertEqual(self.mc.displays['window'].parent.pos[0], 0) - # Rounding DPI can cause single pixel offset, so accept within 1px - self.assertAlmostEqual(self.mc.displays['window'].parent.pos[1], dp(167), delta=1) + self.assertEqual(self.mc.displays['window'].parent.pos, (0, 167)) self.assertIn('dmd', self.mc.displays) self.assertTrue(isinstance(self.mc.displays['dmd'], Display))