Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Audio track volume control and SoundPlayer ducking" #462

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions mpfmc/assets/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
2 changes: 1 addition & 1 deletion mpfmc/config_players/slide_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
15 changes: 2 additions & 13 deletions mpfmc/config_players/sound_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
11 changes: 1 addition & 10 deletions mpfmc/core/audio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down
7 changes: 2 additions & 5 deletions mpfmc/tests/test_Display.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from kivy.metrics import dp
from mpfmc.uix.display import Display, DisplayOutput
from mpfmc.tests.MpfMcTestCase import MpfMcTestCase

Expand All @@ -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))
Expand Down
Loading