Get Inlets/Outlets of Object from js

Sean Wilson's icon

Hi Max Kings....

Anyone know how to get the number of inlets/outlets of some object by reference through an API? I can't seem to find anything digging through the docs. Seems like an obvious API to expose, so hoping I missed something.

The only way I've found to do this is an insane waste of compute (similar method works for inlets)

function get_outlet_count(device) {
    // XXX: Can't find a way to get the count of outlets other than by creating
    // connections to them and counting the number that were successful.
    var tmp = this.patcher.newdefault(0, 0, 'value _');
    var i = 0;
    for (; i < 20; i++) {
        this.patcher.connect(device, i, res, 0);
        if (tmp.patchcords.inputs.length <= i) {
            break;
        }
    }
    this.patcher.remove(tmp);
    return i;
}
11OLSEN's icon
Sean Wilson's icon

That worked, thanks!!!