Ticket #8967: backends_midi_dmedia.patch

File backends_midi_dmedia.patch, 4.2 KB (added by SF/canavan, 12 years ago)

updated patch

  • README

     
    5151 * 7.3 MT-32 emulation
    5252 * 7.4 MIDI emulation
    5353 * 7.5 Native MIDI support
    54  * 7.6 UNIX native and ALSA sequencer support
     54 * 7.6 UNIX native, ALSA and dmedia sequencer support
    5555 * 7.7 TiMidity++ MIDI server support
    5656 * 7.8 Using compressed audio files (MP3, Ogg Vorbis, Flac)
    5757 * 7.9 Output sample rate
     
    15231523command as described earlier in this section.
    15241524
    15251525
     15267.6.2) Playing sound with IRIX dmedia sequencer:                 [UNIX ONLY]
     1527---- ------------------------------------------
     1528If you are using IRIX,  driver with the sequencer support, you can
     1529set the environment variable SCUMMVM_PORT or the config file parameter
     1530dmedia_port to your sequencer port. The default is to use the first port.
     1531
     1532To get a list of configured midi interfaces on your system, run startmidi
     1533without parameters. Exaple output:
     1534
     1535  2 MIDI interfaces configured:
     1536          Serial Port 2
     1537          Software Synth
     1538
     1539In this example, you can configure ScummVM to use the "Software Synth"
     1540instead of the default "Serial Port 2" by adding a line
     1541
     1542   dmedia_port=Software Synth
     1543
     1544to your configuration file in the section [scummvm], or setting
     1545SCUMMVM_PORT=Software Synth in your environment.
     1546
     1547
    152615487.7) Using TiMidity++ MIDI server:
    15271549---- -----------------------------
    15281550If you system lacks any MIDI sequencer, but you still want better MIDI
  • backends/midi/dmedia.cpp

     
    3131
    3232#include "common/scummsys.h"
    3333#include "common/util.h"
     34#include "common/config-manager.h"
    3435#include "sound/musicplugin.h"
    3536#include "sound/mpu401.h"
    3637
     
    7172
    7273int MidiDriver_DMEDIA::open() {
    7374        int numinterfaces;
     75        int i;
     76        const char *var;
     77        char *portName;
    7478
    7579        if (_isOpen)
    7680                return MERR_ALREADY_OPEN;
    7781        _isOpen = true;
    7882
    79         warning("dmedia init");
    8083        numinterfaces = mdInit();
    8184        if (numinterfaces <= 0) {
    82                 fprintf(stderr,"No MIDI interfaces configured.\n");
     85                fprintf(stderr, "No MIDI interfaces configured.\n");
    8386                perror("Cannot initialize libmd for sound output");
    8487                return -1;
    8588        }
     
    8790        if (getenv("SCUMMVM_MIDIPORT")) {
    8891                _deviceNum = atoi(getenv("SCUMMVM_MIDIPORT"));
    8992                _midiportName = mdGetName(_deviceNum);
     93        } else {
     94                var = ConfMan.get("dmedia_port").c_str();
     95                if (strlen(var) > 0) {
     96                        for (i = 0; i < numinterfaces; i++) {
     97                                portName = mdGetName(i);
     98                                if (strcmp(var, portName) == 0) {
     99                                        _deviceNum = i;
     100                                        _midiportName = portName;
     101                                }
     102                        }
     103
     104                }
    90105        }
    91                 else
    92         {
    93                 _midiportName = mdGetName(0);
    94                 warning("SCUMMVM_MIDIPORT environment variable not set, using Port %s", _midiportName);
    95                 _deviceNum = 0;
    96         }
    97106
    98107        _midiPort = mdOpenOutPort(_midiportName);
    99108        if (!_midiPort) {
     
    152161        if (mdSend(_midiPort, &event, 1) != 1) {
    153162                warning("failed sending MIDI event (dump follows...)");
    154163                warning("MIDI Event (len=%u):", event.msglen);
    155                 for (int i=0; i<event.msglen; i++) warning("%02x ",(int)event.msg[i]);
     164                for (int i = 0; i < event.msglen; i++) warning("%02x ", (int)event.msg[i]);
    156165        }
    157166}
    158167
     
    171180        event.msg[2] = 0;
    172181
    173182        if (mdSend(_midiPort, &event, 1) != 1) {
    174                 fprintf(stderr,"failed sending MIDI SYSEX event (dump follows...)\n");
     183                fprintf(stderr, "failed sending MIDI SYSEX event (dump follows...)\n");
     184                for (int i = 0; i < event.msglen; i++) warning("%02x ", (int)event.msg[i]);
    175185        }
    176186}
    177187
     
    193203};
    194204
    195205MusicDevices DMediaMusicPlugin::getDevices() const {
     206        int numinterfaces;
     207        int i;
     208        char *portName;
    196209        MusicDevices devices;
     210
    197211        // TODO: Return a different music type depending on the configuration
    198         // TODO: List the available devices
    199         devices.push_back(MusicDevice(this, "", MT_GM));
     212
     213        numinterfaces = mdInit();
     214        if (numinterfaces <= 0) {
     215                fprintf(stderr, "No MIDI interfaces configured.\n");
     216        }
     217
     218        for (i=0; i<numinterfaces; i++) {
     219                portName = mdGetName(0);
     220                fprintf(stderr, "device %i %s\n", i, portName);
     221                devices.push_back(MusicDevice(this, portName, MT_GM));
     222        }
     223
    200224        return devices;
    201225}
    202226