diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index cb4fac2cc..db9f88887 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -64,6 +64,7 @@ extern HWND Window; #include "cmdlib.h" #include "s_sound.h" #include "files.h" +#include "i_musicinterns.h" #if FMOD_VERSION > 0x42899 && FMOD_VERSION < 0x43400 #error You are trying to compile with an unsupported version of FMOD. @@ -3478,6 +3479,11 @@ FMOD_RESULT FMODSoundRenderer::SetSystemReverbProperties(const REVERB_PROPERTIES #endif } +MIDIDevice* FMODSoundRenderer::CreateMIDIDevice() const +{ + return new SndSysMIDIDevice; +} + #endif // NO_FMOD diff --git a/src/sound/fmodsound.h b/src/sound/fmodsound.h index e85a993c5..34fdeb7ad 100644 --- a/src/sound/fmodsound.h +++ b/src/sound/fmodsound.h @@ -68,6 +68,8 @@ public: void DrawWaveDebug(int mode); + virtual MIDIDevice* CreateMIDIDevice() const override; + private: DWORD ActiveFMODVersion; int SFXPaused; diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp index d7788ae7a..ecca194e6 100644 --- a/src/sound/i_sound.cpp +++ b/src/sound/i_sound.cpp @@ -250,6 +250,11 @@ public: { return "Null sound module has no stats."; } + + virtual MIDIDevice* CreateMIDIDevice() const override + { + return nullptr; + } }; void I_InitSound () diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h index 4e565e885..db97c3555 100644 --- a/src/sound/i_sound.h +++ b/src/sound/i_sound.h @@ -85,6 +85,7 @@ public: typedef bool (*SoundStreamCallback)(SoundStream *stream, void *buff, int len, void *userdata); struct SoundDecoder; +class MIDIDevice; class SoundRenderer { @@ -157,6 +158,8 @@ public: virtual void DrawWaveDebug(int mode); + virtual MIDIDevice* CreateMIDIDevice() const = 0; + protected: virtual SoundDecoder *CreateDecoder(FileReader *reader); }; diff --git a/src/sound/music_midistream.cpp b/src/sound/music_midistream.cpp index 7cbffc7ad..6906aa4c5 100644 --- a/src/sound/music_midistream.cpp +++ b/src/sound/music_midistream.cpp @@ -273,7 +273,7 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype) const #endif case MDEV_SNDSYS: - return new SndSysMIDIDevice; + return GSnd->CreateMIDIDevice(); case MDEV_GUS: return new TimidityMIDIDevice(Args); diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index 601ec7200..e274c7bbf 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -2052,6 +2052,16 @@ void OpenALSoundRenderer::PrintDriversList() } } +MIDIDevice* OpenALSoundRenderer::CreateMIDIDevice() const +{ +#ifdef _WIN32 + extern UINT mididevice; + return new WinMIDIDevice(mididevice); +#else + return new OPLMIDIDevice(nullptr); +#endif +} + void OpenALSoundRenderer::PurgeStoppedSources() { // Release channels that are stopped diff --git a/src/sound/oalsound.h b/src/sound/oalsound.h index d69e2e367..951ae0fdc 100644 --- a/src/sound/oalsound.h +++ b/src/sound/oalsound.h @@ -131,6 +131,8 @@ public: virtual void PrintDriversList(); virtual FString GatherStats(); + virtual MIDIDevice* CreateMIDIDevice() const override; + private: struct { bool EXT_EFX;