Possible to get list of midi devices directly in js?

Oct 6, 2013 at 10:50pm

Possible to get list of midi devices directly in js?

I’ve searched the forum, looked through all the example patches, and read the documentation and still can’t quite get my head around this one. Is there a way to query and assign the list of available midi devices directly from js without having to actually create a midiinfo object and bang it?

I’m aware that this.max takes “midilist”, and I’m a bit naive about javascript, but I’d assumed that “max.midilist” would return an array. However, if I try to assign it:

var mididevices = max.midilist;

then mididevices.length returns zero.

I’m sure that I’m missing something relatively simple; would love to know whether this is possible.

#267292
Oct 13, 2013 at 8:05am

If you look at the doc for midilist:

midilist()
Prints the names of all current MIDI devices in the Max window.

So, sounds like this is not what you are after.

What do you want to do with the midilist once you have it?

#267919
Oct 13, 2013 at 9:17am

Prints the names of all current MIDI devices in the Max window.

Yeah, I’d hoped that doing this in JS would allow me to assign the list of devices rather than simply posting it.

What I’d like to do is match an argument to the js object to a string in the list of midi devices to determine whether a given output device is connected, then send it a predetermined sequence of raw midi data (sysex and ccs) stored in either a coll or a dict for initialization.

I like JS for setting up the initial conditions for a patch, so I’d hoped to find some js-specific equivalent to banging the inlets of midiinfo. Obviously I can just script midiinfo into being and destroy it when I’m done with it, but I was hoping for a more elegant solution.

#267926
Oct 20, 2013 at 5:26am

I think that’s what you’ll have to do for JS, personally i wouldn’t bother scripting it, i’d just leave have the midiinfo object there.

#268502
Oct 20, 2013 at 9:07am

Thanks, and yes, that’s what I’ve ended up doing in the patch

#268509

You must be logged in to reply to this topic.