How do I repopulate a umenu MIDI device list while keeping current MIDI Device selected?

MAX.XAM's icon

Hello all,

I am wanting to have a umenu MIDI device list repopulate after plugging in a new MIDI device or removing a unused MIDI device, but I want the list to stay on the current selected MIDI Device. Currently the device list will repopulate, but the MIDI device at the top of the list will be auto-selected after plugging in or removing a device. In my setup I usually have 4 or 5 MIDI devices connected to my win 10 system.

Help please! :)

Max Patch
Copy patch and select New From Clipboard in Max.

Source Audio's icon

If You want to keep selected midi device, don't repopulate the menu.
If You want to select new plugged midi device, repopulate and select it

MAX.XAM's icon

Hi Source,

Yeah, I understand that. Maybe umenu can't do what I want it to do. I want the MIDI device list to update in the background after hot-swapping devices. In the pasted max patch you'll notice that I have a button used for manual re-population of the umenu. I was hoping to be able to get around a manual refresh of device list.

Source Audio's icon

This aute detect devices is a new thing, introduced in Max 8,
which I don't use.
But here is a way I usually store and recall selected midi devices
after populating umenu.

Max Patch
Copy patch and select New From Clipboard in Max.

See if it can be of any help.
Last selected midi device gets stored into value object,
and whenever midiinfo outputs something, it recalls that
menu item (if it is still available)

Floating Point's icon

Yes you can do it! Just save the selected item in the value object, then retrieve it after the umenu has been repopulated:

Max Patch
Copy patch and select New From Clipboard in Max.

MAX.XAM's icon

Thanks Source and Floating! Both of your examples helped me greatly. :)