Skip to content

Commit

Permalink
Blood: Add option to select MIDI MME device
Browse files Browse the repository at this point in the history
  • Loading branch information
tmyqlfpir committed Sep 5, 2024
1 parent c073acf commit b2be48d
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions source/blood/src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "../src/driver_winmm.h"
#include "../src/midi.h"
#endif

void SaveGame(CGameMenuItemZEditBitmap *, CGameMenuEvent *);

Expand Down Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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);


Expand Down Expand Up @@ -1388,6 +1398,9 @@ void SetupOptionsMenu(void)
menuOptionsSound.Add(&itemOptionsSoundCDToggle, false);
menuOptionsSound.Add(&itemOptionsSoundMusicDevice, false);
menuOptionsSound.Add(&itemOptionsSoundSF2Bank, false);
#ifdef _WIN32
menuOptionsSound.Add(&itemOptionsSoundMIDIDevice, false);
#endif

menuOptionsSound.Add(&itemOptionsSoundApplyChanges, false);
menuOptionsSound.Add(&itemBloodQAV, false);
Expand Down Expand Up @@ -2187,15 +2200,35 @@ 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)
{
UNREFERENCED_PARAMETER(pItem);
WinMM_DeviceID = (unsigned int)itemOptionsSoundMIDIDevice.nValue;
WinMM_DeviceID--;
MIDI_Restart();
}
#endif

void SetSound(CGameMenuItemChain *pItem)
{
UNREFERENCED_PARAMETER(pItem);
Expand Down Expand Up @@ -2244,6 +2277,10 @@ void SetupOptionsSound(CGameMenuItemChain *pItem)
break;
}
}
#ifdef _WIN32
itemOptionsSoundMIDIDevice.nValue = int(WinMM_DeviceID+1);
itemOptionsSoundMIDIDevice.nRangeHigh = WinMMDrv_MIDI_GetNumDevices();
#endif

UpdateMusicDevice(NULL);
}
Expand Down

0 comments on commit b2be48d

Please sign in to comment.