Skip to content

Commit

Permalink
backend.midi: Make programs choose the right instrument through registry
Browse files Browse the repository at this point in the history
  • Loading branch information
EmoonX committed Jan 19, 2025
1 parent 2196756 commit c3d90a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bottles/backend/utils/midi.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,16 @@ def __start(self):
sfid = synth.sfload(self.soundfont_path)
synth.program_select(0, sfid, 0, 0)
self.synth = synth

def register_as_current(self, config: BottleConfig):
"""
Update Wine registry with this instance's ID, instructing
MIDI mapping to load the correct instrument set on program startup.
"""
reg = Reg(config)
reg.add(
key="HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Multimedia\\MIDIMap",
value="CurrentInstrument",
data=f"#{self.id}",
value_type="REG_SZ",
)
1 change: 1 addition & 0 deletions bottles/backend/wine/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(
self.fluidsynth = None
if (soundfont_path := midi_soundfont) not in (None, ""):
self.fluidsynth = FluidSynth.find_or_create(soundfont_path)
self.fluidsynth.register_as_current(config)

# None = use global DXVK value
if program_dxvk is not None:
Expand Down

0 comments on commit c3d90a3

Please sign in to comment.