# USB audio/MIDI devices

**URL:** <https://forum.juce.com/t/usb-audio-midi-devices/4352>\
**Category:** General JUCE discussion\
**Created:** [October 1, 2009, 7:35pm UTC](https://forum.juce.com/t/usb-audio-midi-devices/4352 "2009-10-01T19:35:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![eugene](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@eugene](https://forum.juce.com/u/eugene)\
**Post date:** [October 1, 2009, 7:35pm UTC](https://forum.juce.com/t/usb-audio-midi-devices/4352/1 "2009-10-01T19:35:44Z")

</div>

Hi Jules,

My questions are specifically related to USB Audio/MIDI devices that use the generic OS drivers.

1. Is it possible to get notification from the AudioDeviceManager when the audio/MIDI device list changes? In the situation I’m working with, it’s conceivable that the user will add or remove USB audio devices on the fly. I’ve thought of periodically polling the device names and detecting a change that way. This will not be foolproof though, since the device names are generic - “USB Audio Device” (in Windows anyway). The user could switch devices in between polls, and the names would look the same.

2. Related to the above; if my application enables a USB MIDI device, and then at some point the user decides to unplug the device, juce continually generates asserts (the call to midiInAddBuffer in MidiInThread::writeBlock() fails). How should the application recover from this situation?

3. My application is only concerned with MIDI, so I’m calling AudioDeviceManager::initialise() with 0 input and 0 output channels. This worked in version 1.46, but now in 1.50 an error is returned: “Can’t open the audio device! This may be because another application is currently using the same device - if so, you should close any other applications and try again!”. Ignoring the error does not seem to have any ill effects. Is it no longer valid to specify 0 I/O channels?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 1, 2009, 7:40pm UTC](https://forum.juce.com/t/usb-audio-midi-devices/4352/2 "2009-10-01T19:40:31Z")

</div>

Better notification of device changes is on my to-do-list…

And TBH I don’t think I’ve ever tried it with 0 ins and outs, so it might just be something simple that needs tweaking to allow it. There’s no reason why it should fail. Thanks - I’ll take a look at that soon.

---

<div class="post-metadata">

**Author:** ![jordanh](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@jordanh](https://forum.juce.com/u/jordanh)\
**Post date:** [April 8, 2011, 3:14am UTC](https://forum.juce.com/t/usb-audio-midi-devices/4352/3 "2011-04-08T03:14:08Z")

</div>

What is the current state of automatic MIDI device updating? Just wondering if we can avoid having to set up a separate poller thread which repeatedly calls MidiInput::getDevices() waiting for a change. We came across the MidiNotification[http://xmidi.com/docs/coremidi80.html](http://xmidi.com/docs/coremidi80.html) class in CoreMIDI and assume there’s something similar in Windows, but were wondering what your plans were in terms of adding this kind of functionality into JUCE? Thanks!

J

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 8, 2011, 8:15am UTC](https://forum.juce.com/t/usb-audio-midi-devices/4352/4 "2011-04-08T08:15:23Z")

</div>

I may be working on a project shortly for which I’ll need to know about midi device removals, so will probably need to implement that…

---

<div class="post-metadata">

**Author:** ![jordanh](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@jordanh](https://forum.juce.com/u/jordanh)\
**Post date:** [April 9, 2011, 2:59am UTC](https://forum.juce.com/t/usb-audio-midi-devices/4352/5 "2011-04-09T02:59:51Z")

</div>

> [@jules](#):
>
> I may be working on a project shortly for which I’ll need to know about midi device removals, so will probably need to implement that…

😃
