Windows.Devices.Midi2.Transports.Synth
Types for reading the state of the built-in General MIDI synthesizer, changing its settings, and finding its endpoint so you can play it.
The synthesizer is a service transport, not a device driver. So it shows up in enumeration as a normal MIDI 2.0 endpoint, along with everything else on the PC. You don’t need anything in this namespace to play it. Open a connection to its endpoint, like any other, and send it Universal MIDI Packets. This namespace is for applications that want to change its settings, or that want to find its endpoint without enumerating.
Start with the static MidiSynthManager class.
var endpointId = MidiSynthManager.EndpointDeviceId;
if (!string.IsNullOrEmpty(endpointId))
{
var connection = session.CreateEndpointConnection(endpointId);
connection.Open();
}
EndpointDeviceId is empty when the transport isn’t installed. It’s also empty when the synthesizer is turned off, because then the endpoint doesn’t exist. Treat an empty string as “there’s no synthesizer to play right now,” not as an error.
You always send all of the settings at once, not just the one you changed. Build a MidiSynthConfig from the current MidiSynthStatus, change what you want to change, and send the whole thing back.
var config = new MidiSynthConfig(MidiSynthManager.GetStatus());
config.VolumeDecibels = -6.0;
MidiServiceTransportPluginConfigManager.SendUpdate(config); // apply now
MidiServiceTransportPluginConfigManager.SaveUpdate(config); // and keep it
SendUpdate changes the running service. SaveUpdate writes the change to the configuration, so it stays after the service restarts. If you send without saving, restarting the service undoes the change. If you save without sending, the change takes effect the next time the service starts.
Setting IsEnabled to false doesn’t mute the synthesizer. It removes the endpoint completely and lets go of the audio device. That’s on purpose. Some apps open every MIDI port they can find, and so do some Web MIDI pages in a browser. If the endpoint stayed, an app like that would keep the synthesizer open, which keeps the audio device open. Then an app that needs the audio device all to itself, in WASAPI exclusive mode or through ASIO, couldn’t have it.
Turning it back on creates the endpoint again with the same device id, so an app that saved the id finds it again.
A connected app should ask the synthesizer what it can play with MIDI Capability Inquiry Property Exchange, the same way it would ask any other device. The synthesizer answers ResourceList, DeviceInfo, ChannelList, and a full ProgramList. See How to read a device’s patch list.
MidiSynthManager.GetMelodicInstruments() is for when Property Exchange can’t help: showing instruments in a settings screen or instrument picker before any connection is open. The list comes from the sound set, so it doesn’t change when the settings do.
EndpointDeviceId and playing itmidi synth status | enable | disable | configureClick or tap the type name to view more details.
| Type | Description |
|---|---|
| MidiSynthAudioOutputMode | How the synthesizer opens the audio device it plays through |
| MidiSynthBankSelectMode | How the synthesizer reads an incoming bank select, so files written for different conventions find the right instrument |
| MidiSynthConfig | The complete set of settings for the built-in General MIDI synthesizer, sent to the service to apply or to save |
| MidiSynthDrumKitInfo | One drum kit in the synthesizer's sound set |
| MidiSynthInstrumentInfo | One melodic instrument in the synthesizer's sound set, with the bank and program which select it |
| MidiSynthManager | The entry point for reading the state of the built-in General MIDI synthesizer and finding its endpoint |
| MidiSynthRenderMode | Whether the synthesizer reproduces the older in-box synthesizer or plays the same sound set without its historic limits |
| MidiSynthSoundSetInfo | What the synthesizer's active sound set contains |
| MidiSynthStatus | What the built-in General MIDI synthesizer is set to right now |
