A useful tool to design cuelists with Javascript...enjoy!!

  

autowatch = 1;

inlets = 2;

outlets = 2;

var n = 0;

var h = 0;

var c = 60;

var task = new Task(mytask); // main task

var T = 60/c;

var del = 0;

setinletassist(0, "bang for counter");

setinletassist(1, "reset immediately to cue number");

setinletassist(2, "reset at next bang to cue number");

function mytask(){

   bang();

}

mytask.local = 1; // prevent triggering the task directly from Max

/* updates BPMs */

function bpm(x){

   c = x;

   T = 60/c;

}

/* scaled delay by the BPMs multiplied by 1/4 coefficient */

function delay(del){

   var delT = del * T * 4000;

   del = delT;

   return delT;

}

/* scaled fade by the BPMs multiplied by 1/4 coefficient */

function fade(x){

   var fadeT = x * T * 4000;

   return fadeT;

}

/* bang to advance the cuelist */

function bang(){

    n = n + 1;

    cuelist();

    outlet(0,n);

    outlet(1,n+1);

}

/* call the cue */

    function cue(x){

    n = x-1;

}

/* increment cueNumeber function */

function inc(){

    n = n;

    bang();

}

/* decrement cueNumeber function */

function dec(){

   n = n-2;

    bang();

}

/* call the cue via an int */

function msg_int(x){

    if (inlet == 1){

             n = x-1;

             }

   bang();

}

/* the messages are stored in an nested array in which 

the items represent the messagename as a 

symbol "name" , "name data" the datas a symbol */

var INIT = [

["matrix","preset 1"],

["pluto","start 11"],

["minnie","start 10"],

 delay(0)]; // just a bunch of messages and delay 0 ms if no delay

var READY = [

["matrix","preset 1"],

["pluto","start 11"],

["minnie","start 10"],

 delay(0)];

var CUE1 = [

["matrix","preset 2"],

["1_loop","Rec 1, Play 0"],

 delay(2/4)];

/* this is the cuelist container, 

simply add the name of the array you want to add */

var CUELIST = [INIT,READY,CUE1,CUE1_1];

/* this is the function to recall the CUELIST container */

function cuelist(){

   var i = n;

   var c = 0;

   var z = 0;

   CUELIST[i];

  

      for(k=0; k < CUELIST[i].length-1; k++){

             z = CUELIST[i].length-1;

              var a = CUELIST[i][k][0];

              var b = CUELIST[i][k][1];

             del = CUELIST[i][z];

              if (del != 0){

                   task.schedule(del);

               }

              messnamed(a,b);

       }

}