Forums > Javascript

Possible to get list of midi devices directly in js?

October 6, 2013 | 10:50 pm

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.



Lee
October 13, 2013 | 8:05 am

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?


October 13, 2013 | 9:17 am

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.



Lee
October 20, 2013 | 5:26 am

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.


October 20, 2013 | 9:07 am

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


Viewing 5 posts - 1 through 5 (of 5 total)