Helion-Engine / Helion

A modern fast paced Doom FPS engine
GNU General Public License v3.0
122 stars 10 forks source link

Improve SoundFont configuration options #598

Closed lemming104 closed 2 months ago

lemming104 commented 2 months ago

This change should work as-is, although it requires the user to enter file names (either absolute or relative paths) into the config option that I added. I am expecting to do some follow-up work to add a rudimentary file browser as an Options dialog. I would like to do that as a separate change, since the important stuff here already works, it's just not a great UX.

  1. Add a config option to the Audio options group, to control the default SoundFont file. I chose to create a config converter type for FileInfo, which is a little silly, but the intent is to add a specific type of Options control for editing options of that type, so I wanted to differentiate it from other strings (since existing specialized Options dialogs like the color picker all key off the underlying type).
  2. Make the main MusicPlayer class reuse the current FluidSynthPlayer if it already has one. When using a large SoundFont (especially if compressed), this noticeably decreases loading time between levels.
  3. Enable FluidSynthPlayer to change SoundFonts. It can actually do this on-the-fly while playing, which is kind of neat.

I have tested:

  1. Switch to a new valid SoundFont
  2. Switch back to a previously loaded SoundFont after (1)
  3. Switch to an invalid SoundFont (currently possible because I'm not testing the file path, just handling the exception if we pick a bad one)
  4. Recover from (4) by switching back to a valid SoundFont
  5. With a valid SoundFont loaded, switch tracks by starting a new game in a different episode than the one currently selected
  6. Verify that reasonable values are written to and loaded from the config file
  7. Verify that the default works correctly when there is no value stored in the config file