From 625b1dab40566897e56fceb2a9b19aa4edf2b345 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 20 Jan 2005 20:35:29 +0000 Subject: [PATCH] Added midi device selection code for windows Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2099 --- README | 8 +++++++- src/dosbox.cpp | 5 +++-- src/gui/midi_win32.h | 21 ++++++++++++++++++++- src/hardware/mixer.cpp | 42 ++++++++++++++++++++++++++++++++++++------ 4 files changed, 66 insertions(+), 10 deletions(-) diff --git a/README b/README index e134421e..666ae326 100644 --- a/README +++ b/README @@ -409,7 +409,13 @@ MIXER /NOSHOW Prevents DOSBox from showing the result if you set one of the volume levels. - + + /LISTMIDI + Lists the available midi devices on your pc (Windows). To select a + device other than the Windows default midi-mapper, add a line + 'config=id' to the [midi] section in the configuration file, where + 'id' is the number for the device as listed by LISTMIDI. + IMGMOUNT A utility to mount disk images and CD-ROM images in DOSBox. diff --git a/src/dosbox.cpp b/src/dosbox.cpp index 98294652..73180920 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* $Id: dosbox.cpp,v 1.81 2004-12-07 21:49:06 qbix79 Exp $ */ +/* $Id: dosbox.cpp,v 1.82 2005-01-20 20:35:28 qbix79 Exp $ */ #include #include @@ -289,7 +289,8 @@ void DOSBOX_Init(void) { "intelligent -- Operate in Intelligent mode.\n" "device -- Device that will receive the MIDI data from MPU-401.\n" " This can be default,alsa,oss,win32,coreaudio,none.\n" - "config -- Special configuration options for the device.\n" + "config -- Special configuration options for the device. In Windows put\n" + " the id of the device you want to use. See README for details.\n" ); #if C_DEBUG diff --git a/src/gui/midi_win32.h b/src/gui/midi_win32.h index 514f498b..c4979219 100644 --- a/src/gui/midi_win32.h +++ b/src/gui/midi_win32.h @@ -16,11 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $Id: midi_win32.h,v 1.10 2005-01-20 20:35:29 qbix79 Exp $ */ + #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include +#include +#include class MidiHandler_win32: public MidiHandler { private: @@ -34,11 +38,26 @@ public: bool Open(const char * conf) { if (isOpen) return false; m_event = CreateEvent (NULL, true, true, NULL); - MMRESULT res = midiOutOpen(&m_out, MIDI_MAPPER, (DWORD)m_event, 0, CALLBACK_EVENT); + MMRESULT res; + if(conf && *conf) { + std::string strconf(conf); + std::istringstream configmidi(strconf); + unsigned int nummer = midiOutGetNumDevs(); + configmidi >> nummer; + if(nummer < midiOutGetNumDevs()){ + MIDIOUTCAPS mididev; + midiOutGetDevCaps(nummer, &mididev, sizeof(MIDIOUTCAPS)); + LOG_MSG("MIDI:win32 selected %s",mididev.szPname); + res = midiOutOpen(&m_out, nummer, (DWORD)m_event, 0, CALLBACK_EVENT); + } + } else { + res = midiOutOpen(&m_out, MIDI_MAPPER, (DWORD)m_event, 0, CALLBACK_EVENT); + } if (res != MMSYSERR_NOERROR) return false; isOpen=true; return true; }; + void Close(void) { if (!isOpen) return; isOpen=false; diff --git a/src/hardware/mixer.cpp b/src/hardware/mixer.cpp index ae763f73..fa0ff21a 100644 --- a/src/hardware/mixer.cpp +++ b/src/hardware/mixer.cpp @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* $Id: mixer.cpp,v 1.28 2005-01-20 20:35:28 qbix79 Exp $ */ + /* Remove the sdl code from here and have it handeld in the sdlmain. That should call the mixer start from there or something. @@ -26,6 +28,15 @@ #include #include +#if defined (WIN32) +//Midi listing +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#endif + #include "SDL.h" #include "mem.h" #include "pic.h" @@ -399,13 +410,12 @@ public: } if (!w) vol1=vol0; } - void ShowVolume(char * name,float vol0,float vol1) { - WriteOut("%-8s %3.0f:%-3.0f %+3.2f:%-+3.2f \n",name, - vol0*100,vol1*100, - 20*log(vol0)/log(10.0f),20*log(vol1)/log(10.0f) - ); - } + void Run(void) { + if(cmd->FindExist("/LISTMIDI")) { + ListMidi(); + return; + } if (cmd->FindString("MASTER",temp_line,false)) { MakeVolume((char *)temp_line.c_str(),mixer.mastervol[0],mixer.mastervol[1]); } @@ -424,6 +434,26 @@ public: for (chan=mixer.channels;chan;chan=chan->next) ShowVolume(chan->name,chan->volmain[0],chan->volmain[1]); } +private: + void ShowVolume(char * name,float vol0,float vol1) { + WriteOut("%-8s %3.0f:%-3.0f %+3.2f:%-+3.2f \n",name, + vol0*100,vol1*100, + 20*log(vol0)/log(10.0f),20*log(vol1)/log(10.0f) + ); + } + + void ListMidi(){ +#if defined (WIN32) + unsigned int total = midiOutGetNumDevs(); + for(unsigned int i=0;i