Skip to content

Commit

Permalink
Support ducking: option in sound_player
Browse files Browse the repository at this point in the history
  • Loading branch information
avanwinkle committed Jan 15, 2024
1 parent 4ae2fb5 commit fd919e3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 6 additions & 0 deletions mpfmc/assets/sound.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,12 @@ 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
15 changes: 13 additions & 2 deletions mpfmc/config_players/sound_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ def play(self, settings, context, calling_context, priority=0, **kwargs): # noq
action:
priority:
volume:
ducking:
loops:
max_queue_time:
block:
Notes:
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).
- 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).
"""
settings = deepcopy(settings)
Expand Down Expand Up @@ -135,7 +138,15 @@ 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

0 comments on commit fd919e3

Please sign in to comment.