コード例 #1
0
ファイル: dmedia.cpp プロジェクト: Akz-/residual
int MidiDriver_DMEDIA::open() {
	int numinterfaces;
	int i;
	const char *var;
	char *portName;

	if (_isOpen)
		return MERR_ALREADY_OPEN;
	_isOpen = true;

	numinterfaces = mdInit();
	if (numinterfaces <= 0) {
		fprintf(stderr, "No MIDI interfaces configured.\n");
		perror("Cannot initialize libmd for sound output");
		return -1;
	}

	if (getenv("RESIDUALVM_MIDIPORT")) {
		_deviceNum = atoi(getenv("RESIDUALVM_MIDIPORT"));
		_midiportName = mdGetName(_deviceNum);
	} 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);
	if (!_midiPort) {
		warning("Failed to open MIDI interface %s", _midiportName);
		return -1;
	}

	_fd = mdGetFd(_midiPort);
	if (!_fd) {
		warning("Failed to aquire filehandle for MIDI port %s", _midiportName);
		mdClosePort(_midiPort);
		return -1;
	}

	mdSetStampMode(_midiPort, MD_NOSTAMP);  /* don't use Timestamps */

	return 0;
}
コード例 #2
0
ファイル: midi.c プロジェクト: huangjs/cl
char *mus_midi_device_name(int sysdev)
{
  mus_midi_initialize();
  if (midi_ports > 0)
    return(mdGetName(MUS_AUDIO_DEVICE(sysdev)));
  return(NULL);
}
コード例 #3
0
ファイル: midi.c プロジェクト: huangjs/cl
char *mus_midi_describe(void)
{
  int i;
  char *buf = NULL;
  char name[64];
  mus_midi_initialize(); 
  if (midi_ports > 0)
    {
      buf = (char *)CALLOC(midi_ports * 64, sizeof(char));
      for (i = 0; i < midi_ports; i++)
	{
	  sprintf(name, "%s\n", mdGetName(i));
	  strcat(buf, name);
	}
    }
  else sprintf(buf, "no midi");
  return(buf);
}
コード例 #4
0
ファイル: dmedia.cpp プロジェクト: Akz-/residual
MusicDevices DMediaMusicPlugin::getDevices() const {
	int numinterfaces;
	int i;
	char *portName;
	MusicDevices devices;

	// TODO: Return a different music type depending on the configuration

	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;
}