Forums > Max For Live

multi observer with js

September 14, 2012 | 7:07 pm

hi.
my js knowledge is very little but i figured how to observe multiple ids already .
i´d like to have an js object / observer thats capable of getting large lists of ids in its input, store those in an array, observe them and spit out the changed value and its id .got pointed in the right direction already but the script i wrote is crashing ableton when using track send ids and moving a send. maybe its also some inefficiency in the script i wrote . does not happen if i feed it with track_activator ids .
could someone else please have a look at that ?

here´s what i did:

inlets=1;
outlets=2;

function list()
{
var input;
if(inlet==0)
input=arrayfromargs(arguments); // makes an array called "input" from the input list
post("the list contains",arguments.length, "elements"); // how many elements ( ids ) has our input list
post(input[0]); // post the first element (id) just to check its working

var api = new Array();

for (n=0;n

September 14, 2012 | 8:27 pm

Never mind . Thank you apask. !!!
Works with all ids you feed it with ( as a list )

Here it is:

inlets = 1;

outlets = 2;

sendids = new Array();

prev = -1;

function list() {

    if (arguments.length) {

        nids = arguments.length;

        if (prev > nids) {

            sendids.length = 0;

            post("nids =", nids, "n");
        }

        prev = nids;

        for (i = 0; i < nids; i++) {
            sendids[i] = new LiveAPI(callback, "id "+arguments[i]);
            sendids[i].property = "value";
            sendids[i].id = "id";
        }
    }
    function callback(args)
    {
        outlet(0, args[1]);
        outlet(1, this.id);
    }
}

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