mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
Patch #2658665: Implement getDevices() in backends/midi/dmedia.cpp
svn-id: r39437
This commit is contained in:
@@ -53,7 +53,7 @@ Table of Contents:
|
||||
* 7.3 MT-32 emulation
|
||||
* 7.4 MIDI emulation
|
||||
* 7.5 Native MIDI support
|
||||
* 7.6 UNIX native and ALSA sequencer support
|
||||
* 7.6 UNIX native, ALSA and dmedia sequencer support
|
||||
* 7.7 TiMidity++ MIDI server support
|
||||
* 7.8 Using compressed audio files (MP3, Ogg Vorbis, Flac)
|
||||
* 7.9 Output sample rate
|
||||
@@ -1537,6 +1537,28 @@ Once either TiMidity or FluidSynth are running, use the 'aconnect -o -l'
|
||||
command as described earlier in this section.
|
||||
|
||||
|
||||
7.6.2) Playing sound with IRIX dmedia sequencer: [UNIX ONLY]
|
||||
---- ------------------------------------------
|
||||
If you are using IRIX, driver with the sequencer support, you can
|
||||
set the environment variable SCUMMVM_PORT or the config file parameter
|
||||
dmedia_port to your sequencer port. The default is to use the first port.
|
||||
|
||||
To get a list of configured midi interfaces on your system, run startmidi
|
||||
without parameters. Exaple output:
|
||||
|
||||
2 MIDI interfaces configured:
|
||||
Serial Port 2
|
||||
Software Synth
|
||||
|
||||
In this example, you can configure ScummVM to use the "Software Synth"
|
||||
instead of the default "Serial Port 2" by adding a line
|
||||
|
||||
dmedia_port=Software Synth
|
||||
|
||||
to your configuration file in the section [scummvm], or setting
|
||||
SCUMMVM_PORT=Software Synth in your environment.
|
||||
|
||||
|
||||
7.7) Using TiMidity++ MIDI server:
|
||||
---- -----------------------------
|
||||
If you system lacks any MIDI sequencer, but you still want better MIDI
|
||||
|
||||
+36
-12
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/util.h"
|
||||
#include "common/config-manager.h"
|
||||
#include "sound/musicplugin.h"
|
||||
#include "sound/mpu401.h"
|
||||
|
||||
@@ -71,15 +72,17 @@ MidiDriver_DMEDIA::MidiDriver_DMEDIA() {
|
||||
|
||||
int MidiDriver_DMEDIA::open() {
|
||||
int numinterfaces;
|
||||
int i;
|
||||
const char *var;
|
||||
char *portName;
|
||||
|
||||
if (_isOpen)
|
||||
return MERR_ALREADY_OPEN;
|
||||
_isOpen = true;
|
||||
|
||||
warning("dmedia init");
|
||||
numinterfaces = mdInit();
|
||||
if (numinterfaces <= 0) {
|
||||
fprintf(stderr,"No MIDI interfaces configured.\n");
|
||||
fprintf(stderr, "No MIDI interfaces configured.\n");
|
||||
perror("Cannot initialize libmd for sound output");
|
||||
return -1;
|
||||
}
|
||||
@@ -87,12 +90,18 @@ int MidiDriver_DMEDIA::open() {
|
||||
if (getenv("SCUMMVM_MIDIPORT")) {
|
||||
_deviceNum = atoi(getenv("SCUMMVM_MIDIPORT"));
|
||||
_midiportName = mdGetName(_deviceNum);
|
||||
}
|
||||
else
|
||||
{
|
||||
_midiportName = mdGetName(0);
|
||||
warning("SCUMMVM_MIDIPORT environment variable not set, using Port %s", _midiportName);
|
||||
_deviceNum = 0;
|
||||
} else {
|
||||
var = ConfMan.get("dmedia_port").c_str();
|
||||
if (strlen(var) > 0) {
|
||||
for (i = 0; i < numinterfaces; i++) {
|
||||
portName = mdGetName(i);
|
||||
if (strcmp(var, portName) == 0) {
|
||||
_deviceNum = i;
|
||||
_midiportName = portName;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
_midiPort = mdOpenOutPort(_midiportName);
|
||||
@@ -152,7 +161,7 @@ void MidiDriver_DMEDIA::send(uint32 b) {
|
||||
if (mdSend(_midiPort, &event, 1) != 1) {
|
||||
warning("failed sending MIDI event (dump follows...)");
|
||||
warning("MIDI Event (len=%u):", event.msglen);
|
||||
for (int i=0; i<event.msglen; i++) warning("%02x ",(int)event.msg[i]);
|
||||
for (int i = 0; i < event.msglen; i++) warning("%02x ", (int)event.msg[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +180,8 @@ void MidiDriver_DMEDIA::sysEx (const byte *msg, uint16 length) {
|
||||
event.msg[2] = 0;
|
||||
|
||||
if (mdSend(_midiPort, &event, 1) != 1) {
|
||||
fprintf(stderr,"failed sending MIDI SYSEX event (dump follows...)\n");
|
||||
fprintf(stderr, "failed sending MIDI SYSEX event (dump follows...)\n");
|
||||
for (int i = 0; i < event.msglen; i++) warning("%02x ", (int)event.msg[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,10 +203,24 @@ public:
|
||||
};
|
||||
|
||||
MusicDevices DMediaMusicPlugin::getDevices() const {
|
||||
int numinterfaces;
|
||||
int i;
|
||||
char *portName;
|
||||
MusicDevices devices;
|
||||
|
||||
// TODO: Return a different music type depending on the configuration
|
||||
// TODO: List the available devices
|
||||
devices.push_back(MusicDevice(this, "", MT_GM));
|
||||
|
||||
numinterfaces = mdInit();
|
||||
if (numinterfaces <= 0) {
|
||||
fprintf(stderr, "No MIDI interfaces configured.\n");
|
||||
}
|
||||
|
||||
for (i=0; i<numinterfaces; i++) {
|
||||
portName = mdGetName(0);
|
||||
fprintf(stderr, "device %i %s\n", i, portName);
|
||||
devices.push_back(MusicDevice(this, portName, MT_GM));
|
||||
}
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user