From 549fad83000a8997c5ee257179e699f1e03724d2 Mon Sep 17 00:00:00 2001 From: tmyqlfpir <80724828+tmyqlfpir@users.noreply.github.com> Date: Sun, 8 Sep 2024 10:42:28 +1000 Subject: [PATCH 1/2] Audiolib: Move minmm and midi headers to include dir --- source/audiolib/{src => include}/driver_winmm.h | 0 source/audiolib/{src => include}/midi.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename source/audiolib/{src => include}/driver_winmm.h (100%) rename source/audiolib/{src => include}/midi.h (100%) diff --git a/source/audiolib/src/driver_winmm.h b/source/audiolib/include/driver_winmm.h similarity index 100% rename from source/audiolib/src/driver_winmm.h rename to source/audiolib/include/driver_winmm.h diff --git a/source/audiolib/src/midi.h b/source/audiolib/include/midi.h similarity index 100% rename from source/audiolib/src/midi.h rename to source/audiolib/include/midi.h From c6ec695934d17bc3f0bbdcb4aa957e11baf5071a Mon Sep 17 00:00:00 2001 From: tmyqlfpir <80724828+tmyqlfpir@users.noreply.github.com> Date: Fri, 6 Sep 2024 06:05:37 +1000 Subject: [PATCH 2/2] Blood: Add option to select MIDI MME device --- source/blood/src/menu.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/source/blood/src/menu.cpp b/source/blood/src/menu.cpp index 56824fb8bc..7ccc30f10d 100644 --- a/source/blood/src/menu.cpp +++ b/source/blood/src/menu.cpp @@ -39,6 +39,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "screen.h" #include "sound.h" #include "view.h" +#ifdef _WIN32 // required for MME midi device selection +#include "driver_winmm.h" +#include "midi.h" +#endif void SaveGame(CGameMenuItemZEditBitmap *, CGameMenuEvent *); @@ -622,6 +626,9 @@ void UpdateMusicVolume(CGameMenuItemSlider *pItem); void UpdateSoundRate(CGameMenuItemZCycle *pItem); void UpdateNumVoices(CGameMenuItemSlider *pItem); void UpdateMusicDevice(CGameMenuItemZCycle *pItem); +#ifdef _WIN32 +void UpdateMidiDevice(CGameMenuItemSlider *pItem); +#endif void SetSound(CGameMenuItemChain *pItem); void PreDrawSound(CGameMenuItem *pItem); const char *pzSoundRateStrings[] = { @@ -669,6 +676,9 @@ CGameMenuItemSlider itemOptionsSoundNumVoices("VOICES:", 3, 66, 120, 180, NumVoi CGameMenuItemZBool itemOptionsSoundCDToggle("REDBOOK AUDIO:", 3, 66, 130, 180, false, UpdateCDToggle, NULL, NULL); CGameMenuItemZCycle itemOptionsSoundMusicDevice("MIDI DRIVER:", 3, 66, 140, 180, 0, UpdateMusicDevice, pzMusicDeviceStrings, ARRAY_SIZE(pzMusicDeviceStrings), 0); CGameMenuItemChain itemOptionsSoundSF2Bank("SF2 BANK", 3, 66, 150, 180, 0, &menuOptionsSoundSF2, 0, NULL, 0); +#ifdef _WIN32 +CGameMenuItemSlider itemOptionsSoundMIDIDevice("MIDI DEVICE:", 3, 66, 150, 180, 0, 0, 255, 1, UpdateMidiDevice, -1, -1, kMenuSliderValue); +#endif CGameMenuItemChain itemOptionsSoundApplyChanges("APPLY CHANGES", 3, 66, 160, 180, 0, NULL, 0, SetSound, 0); @@ -1388,6 +1398,10 @@ void SetupOptionsMenu(void) menuOptionsSound.Add(&itemOptionsSoundCDToggle, false); menuOptionsSound.Add(&itemOptionsSoundMusicDevice, false); menuOptionsSound.Add(&itemOptionsSoundSF2Bank, false); +#ifdef _WIN32 + if (WinMMDrv_MIDI_GetNumDevices() > 0) // do not add this item if only 1 midi device is detected + menuOptionsSound.Add(&itemOptionsSoundMIDIDevice, false); +#endif menuOptionsSound.Add(&itemOptionsSoundApplyChanges, false); menuOptionsSound.Add(&itemBloodQAV, false); @@ -2187,15 +2201,33 @@ void UpdateMusicDevice(CGameMenuItemZCycle *pItem) UNREFERENCED_PARAMETER(pItem); itemOptionsSoundSF2Bank.bEnable = 0; itemOptionsSoundSF2Bank.bNoDraw = 1; +#ifdef _WIN32 + itemOptionsSoundMIDIDevice.bEnable = 0; + itemOptionsSoundMIDIDevice.bNoDraw = 1; +#endif switch (nMusicDeviceValues[itemOptionsSoundMusicDevice.m_nFocus]) { case ASS_SF2: itemOptionsSoundSF2Bank.bEnable = 1; itemOptionsSoundSF2Bank.bNoDraw = 0; break; +#ifdef _WIN32 + case ASS_WinMM: + itemOptionsSoundMIDIDevice.bEnable = 1; + itemOptionsSoundMIDIDevice.bNoDraw = 0; + break; +#endif } } +#ifdef _WIN32 +void UpdateMidiDevice(CGameMenuItemSlider *pItem) +{ + WinMM_DeviceID = (unsigned int)pItem->nValue-1; + MIDI_Restart(); +} +#endif + void SetSound(CGameMenuItemChain *pItem) { UNREFERENCED_PARAMETER(pItem); @@ -2244,6 +2276,10 @@ void SetupOptionsSound(CGameMenuItemChain *pItem) break; } } +#ifdef _WIN32 + itemOptionsSoundMIDIDevice.nValue = int(WinMM_DeviceID+1); + itemOptionsSoundMIDIDevice.nRangeHigh = WinMMDrv_MIDI_GetNumDevices(); +#endif UpdateMusicDevice(NULL); }