# MidiInput::openDevice() not working on Windows?

**URL:** <https://forum.juce.com/t/midiinput-opendevice-not-working-on-windows/57908>\
**Category:** General JUCE discussion\
**Created:** [September 17, 2023, 6:13am UTC](https://forum.juce.com/t/midiinput-opendevice-not-working-on-windows/57908 "2023-09-17T06:13:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![monsoon](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@monsoon](https://forum.juce.com/u/monsoon)\
**Post date:** [September 17, 2023, 6:13am UTC](https://forum.juce.com/t/midiinput-opendevice-not-working-on-windows/57908/1 "2023-09-17T06:13:33Z")

</div>

I’m trying to get input from a midi device to a VST3 plugin. I use this pattern:

deviceManager.setMidiInputDeviceEnabled (input.identifier, true);  
deviceManager.addMidiInputDeviceCallback (input.identifier, this);

This works fine on MacOS and it works fine in Reaper on Windows. However, in Ableton Live on Windows, the setMidiInputDeviceEnabled() fails. I tracked it down to a problem in MidiInput::openDevice(). This line generates a runtime exception in Live:

```
    wrapper.reset (MidiService::getService().createInputWrapper (*in, deviceIdentifier, *callback));

```

In addition, this same problem occurs in Cubase if the WinRT MIDI option in Cubase is turned off.

Does anybody have experience getting JUCE MIDI input in VST3 to work on Windows?

---

<div class="post-metadata">

**Author:** ![monsoon](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@monsoon](https://forum.juce.com/u/monsoon)\
**Post date:** [September 17, 2023, 7:15am UTC](https://forum.juce.com/t/midiinput-opendevice-not-working-on-windows/57908/2 "2023-09-17T07:15:02Z")

</div>

It seems to be a problem with the Win32 MidiInOpen call when the device has already been opened in the host. Apparently in that situation a plugin cannot open that same device. Since the WinRT option in Cubase doesn’t have this problem, I’m guessing this limitation has been fixed in WinRT MIDI.

---

<div class="post-metadata">

**Author:** ![kriskeillor](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kriskeillor/32/20074_2.png) [@kriskeillor](https://forum.juce.com/u/kriskeillor)\
**Post date:** [September 17, 2023, 8:25am UTC](https://forum.juce.com/t/midiinput-opendevice-not-working-on-windows/57908/3 "2023-09-17T08:25:47Z")

</div>

Unfortunate that its a run time exception.

Can you modify the plugin to give an alert about the MIDI status?

I assume the host retains full MIDI control, there is no way to make changes from the plugin, only request services?

---

<div class="post-metadata">

**Author:** ![monsoon](https://avatars.discourse-cdn.com/v4/letter/m/e9a140/32.png) [@monsoon](https://forum.juce.com/u/monsoon)\
**Post date:** [September 17, 2023, 6:54pm UTC](https://forum.juce.com/t/midiinput-opendevice-not-working-on-windows/57908/4 "2023-09-17T18:54:02Z")

</div>

Yes, it’s not really a JUCE issue, but trying to connect to a midi device from a plugin on Windows is a pain. Probably the best strategy is to advise the user to take steps to make sure the host does not open a connection to the device, thus freeing it up for the plugin. It wouldn’t be easy to catch the error and display a meaningful error message since the way to workaround this would be different for every DAW.
