Added midi device selection code for windows
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2099
This commit is contained in:
parent
2e2f007ec2
commit
625b1dab40
4 changed files with 66 additions and 10 deletions
8
README
8
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.
|
||||
|
|
|
@ -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 <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -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
|
||||
|
|
|
@ -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 <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
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;
|
||||
|
|
|
@ -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 <dirent.h>
|
||||
#include <math.h>
|
||||
|
||||
#if defined (WIN32)
|
||||
//Midi listing
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#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<total;i++) {
|
||||
MIDIOUTCAPS mididev;
|
||||
midiOutGetDevCaps(i, &mididev, sizeof(MIDIOUTCAPS));
|
||||
WriteOut("%2d\t \"%s\"\n",i,mididev.szPname);
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
static void MIXER_ProgramStart(Program * * make) {
|
||||
|
|
Loading…
Add table
Reference in a new issue