diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index 21ba53b5b..b01754324 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -1598,6 +1598,7 @@ SoundStream *FMODSoundRenderer::OpenStream(const char *filename_or_data, int fla FMOD::Sound *stream; FMOD_RESULT result; bool url; + FString patches; InitCreateSoundExInfo(&exinfo); mode = FMOD_SOFTWARE | FMOD_2D | FMOD_CREATESTREAM; @@ -1614,7 +1615,20 @@ SoundStream *FMODSoundRenderer::OpenStream(const char *filename_or_data, int fla exinfo.fileoffset = offset; if ((*snd_midipatchset)[0] != '\0') { - exinfo.dlsname = snd_midipatchset; +#ifdef _WIN32 + // If the path does not contain any path separators, automatically + // prepend $PROGDIR to the path. + if (strcspn(snd_midipatchset, ":/\\") == strlen(snd_midipatchset)) + { + patches << "$PROGDIR/" << snd_midipatchset; + patches = NicePath(patches); + } + else +#endif + { + patches = NicePath(snd_midipatchset); + } + exinfo.dlsname = patches; } url = (offset == 0 && length == 0 && strstr(filename_or_data, "://") > filename_or_data); diff --git a/src/sound/music_fluidsynth_mididevice.cpp b/src/sound/music_fluidsynth_mididevice.cpp index d50e236b7..7914aa256 100644 --- a/src/sound/music_fluidsynth_mididevice.cpp +++ b/src/sound/music_fluidsynth_mididevice.cpp @@ -42,6 +42,7 @@ #include "m_swap.h" #include "w_wad.h" #include "v_text.h" +#include "cmdlib.h" // MACROS ------------------------------------------------------------------ @@ -471,7 +472,21 @@ int FluidSynthMIDIDevice::LoadPatchSets(const char *patches) count = 0; while (tok != NULL) { - if (FLUID_FAILED != fluid_synth_sfload(FluidSynth, tok, count == 0)) + FString path; +#ifdef _WIN32 + // If the path does not contain any path separators, automatically + // prepend $PROGDIR to the path. + if (strcspn(tok, ":/\\") == strlen(tok)) + { + path << "$PROGDIR/" << tok; + path = NicePath(path); + } + else +#endif + { + path = NicePath(tok); + } + if (FLUID_FAILED != fluid_synth_sfload(FluidSynth, path, count == 0)) { DPrintf("Loaded patch set %s.\n", tok); count++;