libsdl-org / SDL_mixer

An audio mixer that supports various file formats for Simple Directmedia Layer.
zlib License
403 stars 137 forks source link

Ability to specify MIDI output device? #635

Open fragglet opened 1 day ago

fragglet commented 1 day ago

Hi, this is a feature request / inquiry about whether this idea would be accepted as an extension to the API.

Native MIDI output always uses the "default" MIDI device for the system, and there is currently no way to specify an alternative. In some cases, users want to be able to override the default. A simple example is that some really dedicated Doom players will buy a Roland SC-55 (the original MIDI synthesizer used when composing Doom's music), and want to be able to select that instead of the system's built-in MIDI synthesizer.

Some ideas I have for how this might be implemented:

  1. Allow the device to be specified in an environment variable or SDL hint. Simple to implement, but it provides no ability to enumerate the available options, and is kind of crude.
  2. Add a proper API that allows the MIDI output devices to be enumerated and a specific device chosen
  3. Reuse the soundfont system and treat alternative MIDI devices as though they're "sound fonts". The sound font API is already pretty similar to what we'd need for the device API. This approach could be nice since it avoids making the SDL_mixer API any bigger, and any programs that have already integrated with the soundfont API would get the upgrade.
AlexMax commented 1 day ago

Odamex currently relies on PortMidi in order to work around SDL_Mixer's incomplete support of post-Vista MIDI. We use it primarily to control volume, but it also allows our users to play MIDI through actual hardware or virtual MIDI synthesizers if they so choose.