diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index cb4fac2cca..db9f888877 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 e85a993c57..34fdeb7ad7 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 d7788ae7a3..ecca194e68 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 4e565e885f..db97c3555f 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 7cbffc7adf..6906aa4c57 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 601ec72002..e274c7bbff 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 d69e2e3674..951ae0fdca 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;