Skip to content

Commit

Permalink
Add option to adjust volume of music tracks
Browse files Browse the repository at this point in the history
  • Loading branch information
dyceron committed Jul 26, 2024
1 parent 491f024 commit b0a8ff7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/open_samus_returns_rando/specific_patches/cosmetic_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def patch_cosmetics(editor: PatcherEditor, configuration: dict) -> None:
tunables = editor.get_file("system/tunables/tunables.bmtun", Bmtun)
tunable_cosmetics(tunables, configuration)
music_shuffle(editor, configuration)
volume_patches(editor, configuration)


def tunable_cosmetics(tunables: Bmtun, configuration: dict) -> None:
Expand Down Expand Up @@ -48,3 +49,14 @@ def music_shuffle(editor: PatcherEditor, configuration: dict) -> None:
original_track = f"sounds/streams/music/{original}.bcwav"
new_track = temp_dict[f"sounds/streams/music/{new}.bcwav"]
editor.replace_asset(original_track, new_track)


def volume_patches(editor: PatcherEditor, configuratiin: dict) -> None:
sounds = editor.get_file("system/snd/scenariomusicdefs.bmdefs")
properties = sounds.raw["sounds"]
for sound in sounds:
# Apply the configuration value to the track volume
properties["volume"] *= configuration["cosmetic_patches"]["custom_volume"]
# Prevent track volume from being greater than 1.0
if properties["volume"] > 1.0:
properties["volume"] = 1.0

0 comments on commit b0a8ff7

Please sign in to comment.