practical midi device notification question

Aug 12, 2009 at 12:17am

practical midi device notification question

Hi

having found nothing on the max objects site and after searching the max forumm, here it goes.

Is there a way or an object that sends a notification (bang) when a midi device is plugged in the usb hub?

For sure there is an internal update, since when you double click a [notein] or [ctlin], you can see your device and select it.

For efficiency, when a I load a patch, I have a
[loadbang]
|
[port "E-MU XMidi1X1"] < - for example
|
[noteout] 
.

Of course this is fine if my usb device is plugged before I load the patch.

So, would it be possible to have a bang, notifying when a usb has be plugged in.

This would be very practical. Especially, when your building patches for other people that do not know MAX.

thanks a lot

phil

#45082
Aug 12, 2009 at 10:15pm

Not sure if this is possible with max – is would be good to know if there was a rescan option in max, or ableton and any other program I use for that matter.
So far unlike plugins – any hardware must be connected and switched on before the program starts.
Not quite sure – so corrections are most welcome.

#162483
Aug 13, 2009 at 12:03am

All i know is that for sure something happens when something is plugged/unplugged. If not how would obj. like ctlin-out see them.

And it happens without having to restart max.

phil

#162484
Aug 13, 2009 at 12:42am

OS X or Windows?

If OS X, CoreMIDI notifies attached clients when the status of the MIDI system changes. I assume this is what C74 use to update their internal representation.

It’s certainly possible to write a Max external that will receive CoreMIDI notifications and output those, and I was experimenting with a CoreMIDI object some time ago. I’ll see if I can find the code.

It also used to be possible to talk to CoreMIDI via Java, so doing it in mxj seems possible, though Apple have officially deprecated their java-coremidi support as of 10.4.x

#162485
Aug 13, 2009 at 2:06am

>OS X or Windows?
Os X

>If OS X, CoreMIDI notifies attached clients when the status of the MIDI system changes. I assume this is what C74 use to update their internal representation.

Probably?

>It’s certainly possible to write a Max external that will receive CoreMIDI notifications and output those, and I was experimenting with a CoreMIDI object some time ago. I’ll see if I can find the code.

Was it your code? I just searched for one in the maxobject list and found nothing.

>It also used to be possible to talk to CoreMIDI via Java, so doing it in mxj seems possible, though Apple have officially deprecated their java-coremidi support as of 10.4.x

Too bad I don’t know java.
Too apple are like that.

Thanks a lot john

hope you find the code.

#162486
Aug 13, 2009 at 6:02am
phil hughes wrote on Thu, 13 August 2009 14:06
>Was it your code? I just searched for one in the maxobject list and found nothing.

I didn’t release it. I was experimenting with direct CoreMIDI communication to work around a few bugs I was experiencing. I wasn’t doing anything with the system-change notifications, but the object was definitely receiving them internally.

Doesn’t appear to be on my drive at present, a dig through the archive will be needed. Even then, I’m not sure whether it will be a simple matter to rip everything else out and just output the notification messages.

#162487
Aug 13, 2009 at 6:59am

hi john

There is a [coremidi] < - object. But w. and inlet?
Don,t know what it does?

Thanks . I will search the forum. Bed time for now 3 am.

thanks

phil

#162488
Aug 13, 2009 at 3:39pm

Hi john

I ‘ve find this
http://www.cycling74.com/forums/index.php?t=msg&goto=43152&rid=6204&S=835b2f1cbb3c8a6bbcfd37bac1b2669b#msg_43152

Where you say you’ve created the code but nowhere is it to be seen in this thread or any other.

thanks a lot

phil

#162489
Aug 13, 2009 at 4:03pm

another solution (which is not as elegant), is to poll midinfo and see if the list of devices changes… if it changes or you find a particular device, then stop polling…

just a thought.

#162490
Aug 13, 2009 at 4:37pm

hi justin,

@ the moment I am not concerned w. elegance so your solution seems fine. Only problem is, how do you do it??

Thanks an sorry for my ignorance but I’m here to learn. Wink

phil

#162491
Aug 13, 2009 at 5:18pm

I agree that this is ugly but here is one way of doing it

– Pasted Max Patch, click to expand. –

Ciao,
_yvan

#162492
Aug 13, 2009 at 5:50pm

Hi yvan

I will look @ your patch in a min. but before, here is what I came up with. It works but gosh…

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 142 407 20 196617 t b;
#P newex 166 390 84 196617 prepend set port;
#P newex 166 452 40 196617 ctlout;
#B color 5;
#P number 172 335 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 172 270 27 196617 – 1;
#P message 166 421 155 196617 port “E-MU XMidi1X1″;
#P newex 172 291 27 196617 t b i;
#P newex 172 312 27 196617 int;
#P user umenu 44 355 100 196647 1 64 371 1;
#X add “to MaxMSP 1″;
#X add “to MaxMSP 2″;
#X add “E-MU XMidi1X1″;
#P number 177 245 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 161 246 15 0;
#P newex 161 225 40 196617 change;
#P newex 161 193 34 196617 zl len;
#P newex 161 170 61 196617 zl group 10;
#P toggle 110 28 15 0;
#P newex 110 46 58 196617 metro 100;
#P newex 170 145 67 196617 route append;
#P newex 44 121 45 196617 midiinfo;
#B color 5;
#P button 44 91 15 0;
#P message 71 91 59 196617 controllers;
#P comment 213 247 100 196617 < -reports changes;
#P window linecount 2;
#P comment 172 48 100 196617 < - but you don't want this !;
#P connect 3 0 4 0;
#P fasten 2 0 4 0 76 113 49 113;
#P connect 4 0 13 0;
#P fasten 18 0 13 0 177 352 49 352;
#P fasten 6 0 2 0 115 75 76 75;
#P connect 7 0 6 0;
#P connect 20 0 21 0;
#P fasten 6 0 8 0 115 76 166 76;
#P fasten 5 0 8 0 175 166 166 166;
#P connect 8 0 9 0;
#P connect 9 0 10 0;
#P connect 10 0 11 0;
#P fasten 13 1 20 0 139 380 171 380;
#P connect 20 0 16 0;
#P connect 21 0 16 0;
#P connect 16 0 19 0;
#P fasten 4 0 5 0 49 141 175 141;
#P connect 12 0 17 0;
#P connect 17 0 15 0;
#P connect 15 0 14 0;
#P connect 14 0 18 0;
#P connect 10 0 12 0;
#P connect 15 1 14 1;
#P window clipboard copycount 22;

thanks

phil

#162493
Aug 13, 2009 at 9:54pm
phil hughes wrote on Fri, 14 August 2009 03:39
Hi john
I ‘ve find this
http://www.cycling74.com/forums/index.php?t=msg&goto=43152&rid=6204&S=835b2f1cbb3c8a6bbcfd37bac1b2669b#msg_43152
Where you say you’ve created the code but nowhere is it to be seen in this thread or any other.

I’m talking there about the ability to create virtual in/out ports in Max, and at the time there were fewer options to control how that was done. The code I talk about is a command line app that just checks the port ID numbers from outside Max – so no use to you, sorry.

I’m a fan of putting things like input-device selection under user control anyway. So why not put the notification under the user’s control too – provide a “rescan MIDI” button next to your port selector that clears and re-populates it? No need to (expensively) poll at all then. Something like:

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P hidden newex 109 232 40 196617 ctlin;
#P hidden newex 109 209 45 196617 r midiin;
#P hidden newex 44 232 45 196617 notein;
#P hidden newex 44 209 45 196617 r midiin;
#P hidden newex 133 166 45 196617 s midiin;
#P hidden newex 151 140 22 196617 b 1;
#P message 151 114 63 196617 rescan MIDI;
#P hidden newex 79 58 48 196617 loadbang;
#P hidden newex 43 86 46 196617 midiinfo;
#P user umenu 43 113 100 196647 1 64 129 1;
#P hidden connect 0 1 5 0;
#P hidden connect 8 0 9 0;
#P hidden connect 6 0 7 0;
#P hidden connect 4 0 1 1;
#P hidden connect 3 0 4 0;
#P hidden connect 2 0 1 1;
#P hidden connect 1 0 0 0;
#P window clipboard copycount 10;

#162494
Aug 14, 2009 at 9:52pm

Thanks again john.

But in the end, clicking somewhere to fetch your controller is exactly what I was trying to avoid. I remember ,in the pass, when using other software such as Ableton, you did not have to select it. It was plug and go.

When i built patches for friends that’s exactly what I want them to experience.

So by clicking a bang < - of course it's ridiculously easy, but so is clicking on a ctlin to select your device. So why built a patch module for that.

I was just trying (for efficiency and practicality) to get away from this.

thanks again

phil

#162495

You must be logged in to reply to this topic.