# Refresh AudioDeviceSelectorComponent?

**URL:** <https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181>\
**Category:** General JUCE discussion\
**Created:** [March 2, 2017, 11:17am UTC](https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181 "2017-03-02T11:17:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aros](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Aros](https://forum.juce.com/u/Aros)\
**Post date:** [March 2, 2017, 11:17am UTC](https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181/1 "2017-03-02T11:17:53Z")

</div>

I have been wondering… Is there a way to refresh AudioDeviceSelectorComponent MIDI inputs/outpus? The thing is that if I connect my MIDI keyboard while the application is running it will not show. I always have to restart my app. Well, I have been doing this for years and since you don’t change your inputs very often it’s not a big deal, but the users keep asking for this. I think that even Ableton needs to be restarted when you connect some audio/midi devices while it is running so hey, it’s an industry standard 😃 But well, if there is a way to do this in JUCE, I’d like to know…

I have checked AudioDeviceSelectorComponent and also AudioDeviceManager but I don’t see any function that looks to do something like this.

Thanks!

---

<div class="post-metadata">

**Author:** ![Aros](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Aros](https://forum.juce.com/u/Aros)\
**Post date:** [March 8, 2017, 12:44pm UTC](https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181/2 "2017-03-08T12:44:49Z")

</div>

Hi Jules,  
I noticed you got this “let-someone-else-handle-it-so-that-I-don’t-have-to-waste-my-time-with-trivial-things-and-if-nobody-knows-and-the-guy-keeps-asking-then-fine-I’ll-have-a-look-at-it” forum posting algorithm and I thing it works very well! So keep it up 🙂 But this thread seems to have moved to the “nobody-knows-and-he’s-still-bothering” phase.

Thanks!

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [March 8, 2017, 1:27pm UTC](https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181/3 "2017-03-08T13:27:31Z")

</div>

See this thread and my answer here:

> [@MIDI device rescan (Windows)](https://forum.juce.com/t/midi-device-rescan-windows/20307/5):
>
> My specific use case is adding virtual MIDI ports via [virtualMIDI](http://www.tobias-erichsen.de/software/virtualmidi.html) - what you’re suggesting may very well work for USB MIDI (though I’m not sure based on what I’ve read about how Windows handles MIDI ports) but virtualMIDI appears to create actual WDM devices without any sort of USB intermediary which JUCE’s Windows MIDI implementation seems to have trouble picking up without restarting the application while the mentioned apps’ “rescan” functions handle it fine. In the meantime I’m also contacti…

---

<div class="post-metadata">

**Author:** ![Aros](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Aros](https://forum.juce.com/u/Aros)\
**Post date:** [March 8, 2017, 2:24pm UTC](https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181/4 "2017-03-08T14:24:51Z")

</div>

Hello Fabian,

you mean that about the background process or the one about Windows Runtime MIDI API? I guess the former… But I don’t quite get it. Is this a Windows specific problem? That is would I just have the same kind of issue on Linux, or would the Linux version of my App simply refresh the device selector window just like that when something is connected?

So if I get this right, the problem is that Windows only provides the application with the list of available device just once (hence the need to restart the app). I understand that by restarting the background process it would get the current list of the devices. But how does that help the main application? How would you pass that information to the main process. You mean by sending some kind of handle to the process? Would that be valid in the main app?

Thanks for your answer!

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [March 8, 2017, 2:39pm UTC](https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181/5 "2017-03-08T14:39:56Z")

</div>

Well I mean both of my answers. You have two options:

1. You try the new Windows Runtime Midi API which will limit your app to Windows 10 Anniversary update (and may be affected by other bugs related to Bluetooth midi).

or

1. You run a utility process which handles all the midi of your app. You need to send _all_ of your MIDI to that utility app by some means of IPC. When the user re-scans you re-launch the utility app.

---

<div class="post-metadata">

**Author:** ![Aros](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Aros](https://forum.juce.com/u/Aros)\
**Post date:** [March 8, 2017, 2:59pm UTC](https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181/6 "2017-03-08T14:59:14Z")

</div>

Hm… I see.

So 1) makes no sense and 2) means that the separate process would just handle everything related to MIDI, so if I wanted to say play a MIDI track, instead of sending the MIDI messages to the MIDI output, I would send them to that background process (encoding it somehow in IPC) and that process would send them to the MIDI output. What a pain in the neck…

So please just let me ask the question again: Is this a Windows specific problem? Would JUCE on another platform refresh the MIDI ins/outs on it’s own when calling getDevices()?

Thanks

---

<div class="post-metadata">

**Author:** ![t0m](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/t0m/32/16413_2.png) [@t0m](https://forum.juce.com/u/t0m)\
**Post date:** [March 8, 2017, 5:31pm UTC](https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181/7 "2017-03-08T17:31:18Z")

</div>

It’s a Windows specific problem.

Just a comment on 1): If you use the new Windows Runtime Midi API then your app will run on all Windows versions, but you’ll only get dynamic device refreshes when running on Windows 10 Anniversary and later.

---

<div class="post-metadata">

**Author:** ![Aros](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@Aros](https://forum.juce.com/u/Aros)\
**Post date:** [March 8, 2017, 10:10pm UTC](https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181/8 "2017-03-08T22:10:45Z")

</div>

Thanks, that sounds much better. I will look into it.

---

<div class="post-metadata">

**Author:** ![oxxyyd](https://avatars.discourse-cdn.com/v4/letter/o/e47c2d/32.png) [@oxxyyd](https://forum.juce.com/u/oxxyyd)\
**Post date:** [March 9, 2017, 11:55am UTC](https://forum.juce.com/t/refresh-audiodeviceselectorcomponent/21181/9 "2017-03-09T11:55:28Z")

</div>

Hmm, what are you really talking about? Usb-midi or din?

When I disconnect my midi-keyboard (connected to my Windows PC) it immediately disappears from the list of midi devices on the audiodeviceselectorcomponent. If I reconnect it, it immediately pops up before my eyes, even its check-status is restored. The only catch is that I need to uncheck/check it again, but I’m sure I could fix that programatically if I cared enough.

If it’s a DIN connector on the midi device It’s probably a completely different thing. Then it would be up to the the soundcard to implement some sort of continues scanning of the midi ports and report any changes back to the computer via its USB interface.
