home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Aplikacje_64-bitowe / Mixxx / mixxx-1.9.0-win64.exe / midi / M-Audio-Xponent-scripts.js < prev    next >
Text File  |  2011-02-04  |  20KB  |  520 lines

  1. function MaudioXponent () {}
  2.  
  3. // ----------   Global variables    ----------
  4.  
  5. MaudioXponent.id = "";   // The ID for the particular device being controlled for use in debugging, set at init time
  6. MaudioXponent.off = 0x80;
  7. MaudioXponent.on = 0x90;
  8. MaudioXponent.mastermeter = 0;  //1 for master meter, 0 for channel meter
  9. MaudioXponent.flashprogress = 8; //flash duration on progress meters
  10. MaudioXponent.leds = {
  11.     "play": 0x24,
  12.     "cue": 0x23,
  13.     "back": 0x21,
  14.     "fwd": 0x22,
  15.     "in": 0x29,
  16.     "out": 0x2B,
  17.     "loop": 0x2A,
  18.     "loop1": 0x25,
  19.     "loop2": 0x26,
  20.     "loop4": 0x27,
  21.     "loop8": 0x28,
  22.     "leftkey": 0x1C,
  23.     "rightkey": 0x1D,
  24.     "key": 0x1E,
  25.     "pluskey": 0x1F,
  26.     "minkey": 0x20,
  27.     "cue1": 0x17,
  28.     "cue2": 0x18,
  29.     "cue3": 0x19,
  30.     "cue4": 0x1A,
  31.     "cue5": 0x1B,
  32.     "fx1": 0x0C,
  33.     "fx2": 0x0D,
  34.     "fx3": 0x0E,
  35.     "fx4": 0x0F,
  36.     "leftp": 0x10,
  37.     "rightp": 0x11,
  38.     "bigx": 0x12,
  39.     "big-": 0x13,
  40.     "head": 0x14,
  41.     "scratch": 0x15,
  42.     "fadarbutton": 0x07,
  43.     "sync": 0x02,
  44.     "low": 0x08,
  45.     "middle": 0x09,
  46.     "hight": 0x0A,
  47.     "gain": 0x0B,
  48.     "shift": 0x2C
  49. };
  50. MaudioXponent.binleds = {
  51.     8:  "filterLowKill",
  52.     9:  "filterMidKill",
  53.     10: "filterHighKill",
  54.     18: "keylock",
  55.     19: "reverse",
  56.     20: "pfl",
  57.     33: "back",
  58.     34: "fwd",
  59.     36: "play"
  60. };
  61. MaudioXponent.hotcues = {
  62.     23: 1,
  63.     24: 2,
  64.     25: 3,
  65.     26: 4,
  66.     27: 5
  67. };
  68. MaudioXponent.timer = [-1, -1];  // Temporary storage of timer IDs
  69. MaudioXponent.state = { 
  70.     "flashes" : 0, 
  71.     "faderpos" : 0, 
  72.     "shift1" : 0, 
  73.     "shift2" : 0, 
  74.     "scrmode1" : 0, 
  75.     "scrmode2" : 0, 
  76.     "plnumberpos" : 0, 
  77.     "plnumberneg" : 0,
  78.     "scratching1" : 0,
  79.     "scratching2" : 0,
  80. }; // Temporary state variables
  81.  
  82. // ----------   Functions    ----------
  83.  
  84. MaudioXponent.init = function (id) {    // called when the MIDI device is opened & set up
  85.     
  86.     //This code light on all leds and then light off
  87.     midi.sendShortMsg(0xB3,0x14,0x00);
  88.     midi.sendShortMsg(0xB3,0x15,0x00);
  89.     for (var led in MaudioXponent.leds) {
  90.     midi.sendShortMsg(MaudioXponent.on,MaudioXponent.leds[led],0x01);
  91.     midi.sendShortMsg(MaudioXponent.on + 1,MaudioXponent.leds[led],0x01);
  92.     MaudioXponent.pauseScript(15);
  93.     }
  94.     midi.sendShortMsg(0xB3,0x12,0x7F);
  95.     midi.sendShortMsg(0xB3,0x13,0x7F);
  96.     midi.sendShortMsg(0xB3,0x14,0x7F);
  97.     midi.sendShortMsg(0xB3,0x15,0x7F);
  98.     MaudioXponent.pauseScript(500);
  99.     for (var led in MaudioXponent.leds) {
  100.     midi.sendShortMsg(MaudioXponent.on,MaudioXponent.leds[led],0x00);
  101.     midi.sendShortMsg(MaudioXponent.on + 1,MaudioXponent.leds[led],0x00);
  102.     MaudioXponent.pauseScript(15);
  103.     }
  104.     midi.sendShortMsg(0xB3,0x14,0x00);
  105.     midi.sendShortMsg(0xB3,0x15,0x00);
  106.     //end of light on all leds
  107.  
  108.     MaudioXponent.flashdur1 = 0;
  109.     MaudioXponent.flashdur2 = 0;
  110.     engine.connectControl("[Channel1]","visual_playposition","MaudioXponent.playPositionMeter1");
  111.     engine.connectControl("[Channel2]","visual_playposition","MaudioXponent.playPositionMeter2");
  112.     if (MaudioXponent.mastermeter == 1) {
  113.     engine.connectControl("[Master]","VuMeterL","MaudioXponent.volumeLEDs1");
  114.     engine.connectControl("[Master]","VuMeterR","MaudioXponent.volumeLEDs2");
  115.     } else {
  116.     engine.connectControl("[Channel1]","VuMeter","MaudioXponent.volumeLEDs1");
  117.     engine.connectControl("[Channel2]","VuMeter","MaudioXponent.volumeLEDs2");
  118.     }
  119.  
  120.     engine.connectControl("[Channel1]","hotcue_1_enabled","MaudioXponent.hotcue");
  121.     engine.connectControl("[Channel1]","hotcue_2_enabled","MaudioXponent.hotcue");
  122.     engine.connectControl("[Channel1]","hotcue_3_enabled","MaudioXponent.hotcue");
  123.     engine.connectControl("[Channel1]","hotcue_4_enabled","MaudioXponent.hotcue");
  124.     engine.connectControl("[Channel1]","hotcue_5_enabled","MaudioXponent.hotcue");
  125.     engine.connectControl("[Channel2]","hotcue_1_enabled","MaudioXponent.hotcue");
  126.     engine.connectControl("[Channel2]","hotcue_2_enabled","MaudioXponent.hotcue");
  127.     engine.connectControl("[Channel2]","hotcue_3_enabled","MaudioXponent.hotcue");
  128.     engine.connectControl("[Channel2]","hotcue_4_enabled","MaudioXponent.hotcue");
  129.     engine.connectControl("[Channel2]","hotcue_5_enabled","MaudioXponent.hotcue");
  130.  
  131.     engine.connectControl("[Channel1]", "loop_enabled", "MaudioXponent.onLoopExit");
  132.     engine.connectControl("[Channel1]", "loop_start_position", "MaudioXponent.onLoopIn");
  133.     engine.connectControl("[Channel1]", "loop_end_position", "MaudioXponent.onLoopOut");
  134.     engine.connectControl("[Channel2]", "loop_enabled", "MaudioXponent.onLoopExit");
  135.     engine.connectControl("[Channel2]", "loop_start_position", "MaudioXponent.onLoopIn");
  136.     engine.connectControl("[Channel2]", "loop_end_position", "MaudioXponent.onLoopOut");
  137.  
  138.     //engine.connectControl("[Channel1]","bpm","MaudioXponent.bpmsync");
  139.  
  140. };
  141.  
  142. MaudioXponent.wheel = function (channel, control, value, status) {
  143.     var currentdeck = channel+1;
  144.     
  145.     // In either case, register the movement
  146.  
  147.     if (MaudioXponent.state["shift"+currentdeck] == 1) {
  148.         if (value > 64) {
  149.             MaudioXponent.state["plnumberpos"]++;
  150.             if (MaudioXponent.state["plnumberpos"] % 12 == 0) {
  151.                 engine.setValue("[Playlist]","SelectTrackKnob",1);
  152.             }
  153.         } else if (value < 64) {
  154.             MaudioXponent.state["plnumberneg"]++;
  155.             if (MaudioXponent.state["plnumberneg"] % 12 == 0) {
  156.                 engine.setValue("[Playlist]","SelectTrackKnob",-1);
  157.             }  
  158.         }
  159.     }else{
  160.         if (MaudioXponent.state["scratching"+currentdeck] == 1) { //scratch mode on
  161.         engine.scratchTick(currentdeck, value-64);
  162.         } else {  //normal wheel mode
  163.             engine.setValue("[Channel"+currentdeck+"]", "jog", (value-64)/8);
  164.         }
  165.     }
  166. };
  167.  
  168. MaudioXponent.wheelbuton = function(channel, control, value, status) {
  169.     var currentdeck = channel+1;
  170.     if (MaudioXponent.state["scrmode"+currentdeck] == 1) { //scratch mode on
  171.     engine.scratchEnable(currentdeck, 3*128, 33+1/3, 1.0/8, (1.0/8)/32);
  172.     MaudioXponent.state["scratching"+currentdeck] = true;
  173.     }
  174. };
  175.  
  176. MaudioXponent.wheelbutoff = function(channel, control, value, status) {
  177.     var currentdeck = channel+1;
  178.     engine.scratchDisable (currentdeck);
  179.     MaudioXponent.state["scratching"+currentdeck] = false;
  180. };
  181.  
  182. MaudioXponent.pauseScript = function(ms) {
  183.     startDate = new Date();
  184.     currentDate = null;
  185.     while(currentDate-startDate < ms) currentDate = new Date();
  186. };
  187.  
  188. MaudioXponent.playPositionMeter1 = function(value) {
  189.     if (value >= 0.75) {
  190.     MaudioXponent.flashdur1++;;
  191.     if (MaudioXponent.flashdur1 == MaudioXponent.flashprogress) {
  192.         midi.sendShortMsg(0xB3,0x14,0x00);
  193.     }
  194.     if (MaudioXponent.flashdur1 >= MaudioXponent.flashprogress*2) {
  195.         midi.sendShortMsg(0xB3,0x14,MaudioXponent.convert(value));
  196.         MaudioXponent.flashdur1 = 0;
  197.     }
  198.     }else{
  199.     midi.sendShortMsg(0xB3,0x14,MaudioXponent.convert(value));
  200.     }
  201. };
  202.  
  203. MaudioXponent.playPositionMeter2 = function(value) {
  204.     if (value >= 0.75) {
  205.     MaudioXponent.flashdur2++;;
  206.     if (MaudioXponent.flashdur2 == MaudioXponent.flashprogress) {
  207.         midi.sendShortMsg(0xB3,0x15,0x00);
  208.     }
  209.     if (MaudioXponent.flashdur2 >= MaudioXponent.flashprogress*2) {
  210.         midi.sendShortMsg(0xB3,0x15,MaudioXponent.convert(value));
  211.         MaudioXponent.flashdur2 = 0;
  212.     }
  213.     }else{
  214.     midi.sendShortMsg(0xB3,0x15,MaudioXponent.convert(value));
  215.     }
  216. };
  217.  
  218. MaudioXponent.volumeLEDs1 = function(value) {
  219.     midi.sendShortMsg(0xB3,0x12,MaudioXponent.convert(value));
  220. };
  221.  
  222. MaudioXponent.volumeLEDs2 = function(value) {
  223.     midi.sendShortMsg(0xB3,0x13,MaudioXponent.convert(value));
  224. };
  225.  
  226. MaudioXponent.convert = function(value) {
  227.     value = value*127;
  228.     value = value.toFixed(0);
  229.     value = value.toString(16);
  230.     return (value);
  231. };
  232.  
  233. MaudioXponent.actbin = function(channel, control, value, status) {    // Generic binary button
  234.     script.debug(channel, control, value, status);
  235.     var currentdeck = channel+1;
  236.     var activenow = engine.getValue("[Channel"+currentdeck+"]", MaudioXponent.binleds[control]);
  237.     if (activenow) {    // If currently active
  238.         engine.setValue("[Channel"+currentdeck+"]",MaudioXponent.binleds[control], 0);    // Stop
  239.         midi.sendShortMsg(MaudioXponent.off + channel,control, 0x00);    // Turn off the LED
  240.     }else {    // If not currently active
  241.         engine.setValue("[Channel"+currentdeck+"]",MaudioXponent.binleds[control], 1);    // Start
  242.         midi.sendShortMsg(MaudioXponent.on + channel,control, 0x01);    // Turn on the LED
  243.     }
  244. };
  245.  
  246. MaudioXponent.actbinstop = function(channel, control, value, status) {    // Generic binary button
  247.     script.debug(channel, control, value, status);
  248.     var currentdeck = channel+1;
  249.     engine.setValue("[Channel"+currentdeck+"]",MaudioXponent.binleds[control],0);    // Stop
  250.     midi.sendShortMsg(MaudioXponent.off + channel,control,0x00);    // Turn off the LED
  251. };
  252.  
  253. MaudioXponent.hotcue = function(channel, control, value, status) {    // Generic binary button
  254.     var channelnow = 0;
  255.     if (control == "[Channel2]") {
  256.     channelnow = 1;
  257.     }
  258.     switch (value) {
  259.     case "hotcue_1_enabled":
  260.         if (channel == 1){
  261.             midi.sendShortMsg(MaudioXponent.on + channelnow,0x17,0x01);    // Turn on the LED
  262.         }else{
  263.             midi.sendShortMsg(MaudioXponent.on + channelnow,0x17,0x00);    // Turn off the LED
  264.         }
  265.     break;
  266.     case "hotcue_2_enabled":
  267.         if (channel == 1){
  268.             midi.sendShortMsg(MaudioXponent.on + channelnow,0x18,0x01);    // Turn on the LED
  269.         }else{
  270.             midi.sendShortMsg(MaudioXponent.on + channelnow,0x18,0x00);    // Turn off the LED
  271.         }
  272.     break;
  273.     case "hotcue_3_enabled":
  274.         if (channel == 1){
  275.             midi.sendShortMsg(MaudioXponent.on + channelnow,0x19,0x01);    // Turn on the LED
  276.         }else{
  277.             midi.sendShortMsg(MaudioXponent.on + channelnow,0x19,0x00);    // Turn off the LED
  278.         }
  279.     break;
  280.     case "hotcue_4_enabled":
  281.         if (channel == 1){
  282.             midi.sendShortMsg(MaudioXponent.on + channelnow,0x1A,0x01);    // Turn on the LED
  283.         }else{
  284.             midi.sendShortMsg(MaudioXponent.on + channelnow,0x1A,0x00);    // Turn off the LED
  285.         }
  286.     break;
  287.     case "hotcue_5_enabled":
  288.         if (channel == 1){
  289.             midi.sendShortMsg(MaudioXponent.on + channelnow,0x1B,0x01);    // Turn on the LED
  290.         }else{
  291.             midi.sendShortMsg(MaudioXponent.on + channelnow,0x1B,0x00);    // Turn off the LED
  292.         }
  293.     break;
  294.     }
  295. };
  296.  
  297. MaudioXponent.hotcueset = function(channel, control, value, status) {
  298.     //MaudioXponent.debug(channel, control, value, status)
  299.     var currentdeck = channel+1;
  300.     if (MaudioXponent.state["shift"+currentdeck] == 1) {
  301.         engine.setValue("[Channel"+currentdeck+"]","hotcue_"+MaudioXponent.hotcues[control]+"_clear",1);
  302.     }else{
  303.         engine.setValue("[Channel"+currentdeck+"]","hotcue_"+MaudioXponent.hotcues[control]+"_activate",1);
  304.     }
  305. };
  306.  
  307. MaudioXponent.onLoopIn = function(channel, control, value, status) 
  308. {
  309.     channelnow = control == "[Channel2]" ? 1 : 0;
  310.     midi.sendShortMsg(MaudioXponent.on + channelnow, 0x29, 
  311.               engine.getValue (control, value) != -1);
  312.     /* TODO.
  313.     if (-1 == engine.getValue(control, "loop_end_position")) 
  314.     {
  315.     MaudioXponent.state["flashes"] = 0;  // initialize number of flashes
  316.     MaudioXponent.timer[channelnow] = engine.beginTimer(
  317.         250, "MaudioXponent.flashled("+ channelnow +",\"0x2B\")");
  318.     }
  319.     */
  320. }
  321.  
  322. MaudioXponent.onLoopOut = function(channel, control, value, status) 
  323. {
  324.     channelnow = control == "[Channel2]" ? 1 : 0;
  325.     /*
  326.     if (MaudioXponent.timer[channelnow] != -1) { 
  327.     engine.stopTimer (MaudioXponent.timer[channelnow]);
  328.     MaudioXponent.timer[channelnow] = -1;
  329.     }
  330.     */
  331.     midi.sendShortMsg(MaudioXponent.on + channelnow, 0x2B, 
  332.               engine.getValue (control, value) != -1);
  333. }
  334.  
  335. MaudioXponent.onLoopExit = function(channel, control, value, status) 
  336. {
  337.     channelnow = control == "[Channel2]" ? 1 : 0;
  338.     midi.sendShortMsg(MaudioXponent.on + channelnow, 0x2A, 
  339.               engine.getValue (control, value) == 1);
  340. }
  341.  
  342. MaudioXponent.loopin = function(channel, control, value, status) {
  343.     //MaudioXponent.debug(channel, control, value, status)
  344.     var currentdeck = channel+1;
  345.     engine.setValue("[Channel"+currentdeck+"]","loop_in", 1);
  346. };
  347.  
  348. MaudioXponent.loopout = function(channel, control, value, status) {
  349.     //MaudioXponent.debug(channel, control, value, status)
  350.     var currentdeck = channel+1;
  351.     engine.setValue("[Channel"+currentdeck+"]", "loop_out", 1);
  352. };
  353.  
  354. MaudioXponent.loopexit = function(channel, control, value, status) {
  355.     var currentdeck = channel+1;
  356.     var activenow = engine.getValue("[Channel"+currentdeck+"]", "reloop_exit");
  357.     engine.setValue("[Channel"+currentdeck+"]", "reloop_exit", 1);
  358. };
  359.  
  360. MaudioXponent.flashled = function (channel, control) {
  361.     MaudioXponent.state["flashes"]++;
  362.     if (MaudioXponent.state["flashes"] % 2 == 0) {
  363.         midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  364.     }else {
  365.         midi.sendShortMsg(MaudioXponent.on + channel,control,0x00);    // Turn off the LED
  366.     }
  367. };
  368.  
  369. MaudioXponent.faderbuttonon = function(channel, control, value, status) {
  370.     //script.debug(channel, control, value, status);
  371.     MaudioXponent.state["faderpos"] = engine.getValue("[Master]","crossfader");
  372.     if (MaudioXponent.state["faderpos"] <= -0.90 && channel == 1) {
  373.     midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  374.     engine.setValue("[Master]","crossfader",0);
  375.     }else if (MaudioXponent.state["faderpos"] >= 0.90 && channel == 0) {
  376.     midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  377.     engine.setValue("[Master]","crossfader",0);
  378.     }
  379. };
  380.  
  381. MaudioXponent.faderbuttonoff = function(channel, control, value, status) {
  382.     //script.debug(channel, control, value, status);
  383.     if (MaudioXponent.state["faderpos"] <= -0.90 && channel == 1) {
  384.     midi.sendShortMsg(MaudioXponent.on + channel,control,0x00);    // Turn off the LED
  385.     engine.setValue("[Master]","crossfader",MaudioXponent.state["faderpos"]);
  386.     }else if (MaudioXponent.state["faderpos"] >= 0.90 && channel == 0) {
  387.     midi.sendShortMsg(MaudioXponent.on + channel,control,0x00);    // Turn off the LED
  388.     engine.setValue("[Master]","crossfader",MaudioXponent.state["faderpos"]);
  389.     }
  390. };
  391.  
  392. MaudioXponent.bpmsync = function(channel, control, value) {
  393.     print (channel);
  394.     print (control);
  395. };
  396.  
  397. MaudioXponent.pitch = function(channel, control, value, status) {
  398.     var currentdeck = channel+1;
  399.     engine.setValue("[Channel"+currentdeck+"]","rate",script.pitch(control, value, status));
  400. };
  401.  
  402. MaudioXponent.secondaryon = function(channel, control, value, status) {
  403.     var currentdeck = channel+1;
  404.     midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  405.     MaudioXponent.state["shift"+currentdeck] = 1;
  406. };
  407.  
  408. MaudioXponent.secondaryoff = function(channel, control, value, status) {
  409.     var currentdeck = channel+1;
  410.     midi.sendShortMsg(MaudioXponent.on + channel,control,0x00);    // Turn on the LED
  411.     MaudioXponent.state["shift"+currentdeck] = 0;
  412. };
  413.  
  414. MaudioXponent.flanger = function(channel, control, value, status) {
  415.     //script.debug(channel, control, value, status);
  416.     if (control == 12) {
  417.         var activenow = engine.getValue("[Channel1]","flanger");
  418.         if (activenow == 1) {    // If currently active
  419.             midi.sendShortMsg(MaudioXponent.on+1,control,0x00);    // Turn off the LED
  420.             engine.setValue("[Channel1]","flanger",0);
  421.         }else{
  422.             midi.sendShortMsg(MaudioXponent.on+1,control,0x01);    // Turn on the LED
  423.             engine.setValue("[Channel1]","flanger",1);
  424.         }
  425.     }else if (control == 13) {
  426.         var activenow = engine.getValue("[Channel2]","flanger");
  427.         if (activenow == 1) {    // If currently active
  428.             midi.sendShortMsg(MaudioXponent.on+1,control,0x00);    // Turn off the LED
  429.             engine.setValue("[Channel2]","flanger",0);
  430.         }else{
  431.             midi.sendShortMsg(MaudioXponent.on+1,control,0x01);    // Turn on the LED
  432.             engine.setValue("[Channel2]","flanger",1);
  433.         }
  434.     }
  435. };
  436.  
  437. MaudioXponent.scrmode = function(channel, control, value, status) {
  438.     var currentdeck = channel+1;
  439.     if (MaudioXponent.state["scrmode"+currentdeck] == 1) {
  440.         midi.sendShortMsg(MaudioXponent.on + channel,control,0x00);    // Turn off the LED
  441.         MaudioXponent.state["scrmode"+currentdeck] = 0;
  442.     }else{
  443.         midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  444.         MaudioXponent.state["scrmode"+currentdeck] = 1;
  445.     }
  446. };
  447.  
  448. MaudioXponent.playlist = function(channel, control, value, status) {
  449.     var currentdeck = channel+1;
  450.     switch (control) {
  451.     case 28:
  452.         midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  453.         engine.setValue("[Playlist]","SelectPrevTrack",1);
  454.     break;
  455.     case 29:
  456.         midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  457.         engine.setValue("[Playlist]","SelectNextTrack",1);
  458.     break;
  459.     case 30:
  460.         midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  461.         var activenow = engine.getValue("[Channel"+currentdeck+"]","play");
  462.         if (activenow == 1) {    // If currently active
  463.             engine.setValue("[Playlist]","LoadSelectedIntoFirstStopped",1);
  464.         }else{
  465.             engine.setValue("[Channel"+currentdeck+"]","LoadSelectedTrack",1);
  466.         }
  467.     break;
  468.     case 31:
  469.         midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  470.         engine.setValue("[Playlist]","SelectPrevPlaylist",1);
  471.     break;
  472.     case 32:
  473.         midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  474.         engine.setValue("[Playlist]","SelectNextPlaylist",1);
  475.     break;
  476.     }
  477. };
  478.  
  479. MaudioXponent.playlistoff = function(channel, control, value, status) {
  480.     midi.sendShortMsg(MaudioXponent.off + channel,control,0x00);    // Turn off the LED
  481. };
  482.  
  483. MaudioXponent.cuedefon = function(channel, control, value, status) {
  484.     var currentdeck = channel+1;
  485.     engine.setValue("[Channel"+currentdeck+"]","cue_default",1);
  486.     midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  487. };
  488.  
  489. MaudioXponent.cuedefoff = function(channel, control, value, status) {
  490.     var currentdeck = channel+1;
  491.     engine.setValue("[Channel"+currentdeck+"]","cue_default",0);
  492.     midi.sendShortMsg(MaudioXponent.off + channel,control,0x00);    // Turn off the LED
  493. };
  494.  
  495. MaudioXponent.volbuttonon = function(channel, control, value, status) {
  496.     //script.debug(channel, control, value, status);
  497.     var currentdeck = channel+1;
  498.     engine.setValue("[Channel"+currentdeck+"]","volume",0);
  499.     midi.sendShortMsg(MaudioXponent.on + channel,control,0x01);    // Turn on the LED
  500. };
  501.  
  502. MaudioXponent.volbuttonoff = function(channel, control, value, status) {
  503.     //script.debug(channel, control, value, status);
  504.     var currentdeck = channel+1;
  505.     engine.setValue("[Channel"+currentdeck+"]","volume",1);
  506.     midi.sendShortMsg(MaudioXponent.off + channel,control,0x00);    // Turn off the LED
  507. };
  508.  
  509. MaudioXponent.shutdown = function (id) {    // called when the MIDI device is closed
  510.  
  511.     for (var led in MaudioXponent.leds) {
  512.     midi.sendShortMsg(MaudioXponent.on,MaudioXponent.leds[led],0x00); // Turn off deck 1 lights
  513.     midi.sendShortMsg(MaudioXponent.on + 1,MaudioXponent.leds[led],0x00); // Turn off deck 2 lights
  514.     }
  515.     midi.sendShortMsg(0xB3,0x14,0x00);
  516.     midi.sendShortMsg(0xB3,0x15,0x00);
  517.  
  518. };
  519.  
  520.