I’m trying to figure out how to load soundfont files in SDL_mixer, then play MIDI files using the soundfont. To set up FluidSynth (SDL_mixer backend for playing MIDIs) and soundfonts, it looks like you first have to load your soundfont using Mix_SetSoundFonts(), then call Mix_OpenAudio(). You have to do it in this order, based on an old post.
My current order of functions in my program is: call SDL_Init(SDL_INIT_AUDIO), call Mix_Init(MIX_INIT_MID), call Mix_SetSoundFonts(), call Mix_OpenAudio(), then load a MIDI using Mix_LoadMUS() and play it using Mix_PlayMusic().
When I do this, the MIDI plays with Windows’s built-in MIDI player, not using the soundfont, so this don’t work. Mix_GetError() doesn’t say anything despite the failure.
I also read in the GitHub repository that you can set the environment variable SDL_SOUNDFONTS to a soundfont file, then SDL will use that to play MIDIs. I tried setting the variable then playing a MIDI; it didn’t play with the soundfont either (I’m on Windows 10).
I’m out of ideas. Does anyone know how to use soundfonts and SDL_mixer’s FluidSynth backend? I’d prefer a way to load soundfonts using Mix_SetSoundFonts() rather than the environment variable since the function is more flexible.
Thank you for your time!