MusicDevices CoreMIDIMusicPlugin::getDevices() const { MusicDevices devices; // TODO: Return a different music type depending on the configuration // TODO: List the available devices devices.push_back(MusicDevice(this, "", MT_GM)); return devices; }
MusicDevices AlsaMusicPlugin::getDevices() const { MusicDevices devices; AlsaDevices::iterator d; AlsaDevices alsaDevices = getAlsaDevices(); // Since the default behavior is to use the first device in the list, // try to put something sensible there. We used to have 17:0 and 65:0 // as defaults. for (d = alsaDevices.begin(); d != alsaDevices.end();) { const int client = d->getClient(); if (client == 17 || client == 65) { devices.push_back(MusicDevice(this, d->getName(), d->getType())); d = alsaDevices.erase(d); } else { ++d; } } // 128:0 is probably TiMidity, or something like that, so that's // probably a good second choice. for (d = alsaDevices.begin(); d != alsaDevices.end();) { if (d->getClient() == 128) { devices.push_back(MusicDevice(this, d->getName(), d->getType())); d = alsaDevices.erase(d); } else { ++d; } } // Add the remaining devices in the order they were found. for (d = alsaDevices.begin(); d != alsaDevices.end(); ++d) devices.push_back(MusicDevice(this, d->getName(), d->getType())); return devices; }
MusicDevices WindowsMusicPlugin::getDevices() const { MusicDevices devices; int numDevs = midiOutGetNumDevs(); MIDIOUTCAPS tmp; for (int i = 0; i < numDevs; i++) { if (midiOutGetDevCaps(i, &tmp, sizeof(MIDIOUTCAPS)) != MMSYSERR_NOERROR) break; // There is no way to detect the "MusicType" so I just set it to MT_GM // The user will have to manually select his MT32 type device and his GM type device. devices.push_back(MusicDevice(this, tmp.szPname, MT_GM)); } return devices; }
MusicDevices WindowsMusicPlugin::getDevices() const { MusicDevices devices; int numDevs = midiOutGetNumDevs(); MIDIOUTCAPS tmp; Common::StringArray deviceNames; for (int i = 0; i < numDevs; i++) { if (midiOutGetDevCaps(i, &tmp, sizeof(MIDIOUTCAPS)) != MMSYSERR_NOERROR) break; deviceNames.push_back(tmp.szPname); } // Check for non-unique device names. This may happen if someone has devices with identical // names (e. g. more than one USB device of the exact same hardware type). It seems that this // does happen in reality sometimes. We generate index numbers for these devices. // This is not an ideal solution, since this index could change whenever another USB // device gets plugged in or removed, switched off or just plugged into a different port. // Unfortunately midiOutGetDevCaps() does not generate any other unique information // that could be used. Our index numbers which match the device order should at least be // a little more stable than just using the midiOutGetDevCaps() device ID, since a missing // device (e.g. switched off) should actually not be harmful to our indices (as it would be // when using the device IDs). The cases where users have devices with identical names should // be rare enough anyway. Common::Array<int> nonUniqueIndex; for (int i = 0; i < numDevs; i++) { int match = -1; for (int ii = 0; ii < i; ii++) { if (deviceNames[i] == deviceNames[ii]) { if (nonUniqueIndex[ii] == -1) nonUniqueIndex[ii] = 0; if (++match == 0) ++match; } } nonUniqueIndex.push_back(match); } // We now add the index number to the non-unique device names to make them unique. for (int i = 0; i < numDevs; i++) { if (nonUniqueIndex[i] != -1) deviceNames[i] = Common::String::format("%s - #%.02d", deviceNames[i].c_str(), nonUniqueIndex[i]); } for (Common::StringArray::iterator i = deviceNames.begin(); i != deviceNames.end(); ++i) // There is no way to detect the "MusicType" so I just set it to MT_GM // The user will have to manually select his MT32 type device and his GM type device. devices.push_back(MusicDevice(this, *i, MT_GM)); return devices; }
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; }
MusicDevices MT32EmuMusicPlugin::getDevices() const { MusicDevices devices; devices.push_back(MusicDevice(this, "", MT_MT32)); return devices; }
MusicDevices CMSMusicPlugin::getDevices() const { MusicDevices devices; devices.push_back(MusicDevice(this, "", MT_CMS)); return devices; }
MusicDevices AppleIIGSMusicPlugin::getDevices() const { MusicDevices devices; devices.push_back(MusicDevice(this, "", MT_APPLEIIGS)); return devices; }
MusicDevices NullMusicPlugin::getDevices() const { MusicDevices devices; // TODO: return a different music type? devices.push_back(MusicDevice(this, "", MT_GM)); return devices; }