Possible to get list of midi devices directly in js?

    Oct 07 2013 | 5:50 am
    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.

    • Oct 13 2013 | 3:05 pm
      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?
    • Oct 13 2013 | 4:17 pm
      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.
    • Oct 20 2013 | 12:26 pm
      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.
    • Oct 20 2013 | 4:07 pm
      Thanks, and yes, that's what I've ended up doing in the patch