/usr/share/mixxx/controllers/Korg-nanoKONTROL-2-scripts.js is in mixxx-data 2.0.0~dfsg-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 | function NK2() {}
NK2.debug=0;//set debug level
NK2.LEDflasheson=true;//false disables led flash timers for debugging purposes
NK2.numDecks=8;//set to 8 for all [Channels], to 4 for 4 [Channels] and 4 [Samplers], and to 2 for 2 [Channels] and 6 [Samplers]
//############################################################################
//defaults
//############################################################################
NK2.midiChannel=0xB0;
NK2.curNSMR="N";//default bank (NSMR refers to SMR buttons and "no button")
NK2.curDeck=0;//current deck (for bank selects) -- defaults to 0 = off - no deck selected
NK2.bankSelectState=0;//current state of marker set button (deck selector button - press marker set, hold, press S M or R button on any track to select that bank) -- future: marker set could also select left buttons, transport, etc for more banks
NK2.cycleState=0;//current state of cycle toggle button
NK2.MOD1state=0;
NK2.MOD2state=0;
NK2.LEDBankIndicator=false;
NK2.loopmove=0.0125;//how far to move loops with loop move functions
NK2.lastwavevalue=0;//used for wave zoom function
NK2.cueLoopLen=2;//default length for cueloops (jump to cue and start loop)
NK2.cueMoveToNum=-1;//used in cue button moves (cueclear function)
//############################################################################
//references
//############################################################################
NK2.MODcodes={"0000":0,"0001":1,"0010":2,"0011":3,"0100":4,"0101":5,"0110":6,"0111":7,"1000":8,"1001":9,"1010":10,"1011":11,"1100":12,"1101":13,"1110":14,"1111":15};//list of mod states
NK2.Banks=new Array("N", "S", "M", "R");
//list controls
NK2.Knob={1:0x10,2:0x11,3:0x12,4:0x13,5:0x14,6:0x15,7:0x16,8:0x17};
NK2.Sbutton={1:0x20,2:0x21,3:0x22,4:0x23,5:0x24,6:0x25,7:0x26,8:0x27};
NK2.Mbutton={1:0x30,2:0x31,3:0x32,4:0x33,5:0x34,6:0x35,7:0x36,8:0x37};
NK2.Rbutton={1:0x40,2:0x41,3:0x42,4:0x43,5:0x44,6:0x45,7:0x46,8:0x47};
NK2.leftButton={"trdown":0x3A,"trup":0x3B,"cycle":0x2E,"mset":0x3C,"mdown":0x3D,"mup":0x3E,"rev":0x2B,"ff":0x2C,"stop":0x2A,"play":0x29,"rec":0x2D};
NK2.faders={0x00:1,0x01:2,0x02:3,0x03:4,0x04:5,0x05:6,0x06:7,0x07:8};
//initialize decks
if (NK2.numDecks==8){
NK2.Deck={1:"[Channel1]",2:"[Channel2]",3:"[Channel3]",4:"[Channel4]",5:"[Channel5]",6:"[Channel6]",7:"[Channel7]",8:"[Channel8]"};//list of decks, applied to each strip - 8 strips, 8 decks. (8 decks, 0 samplers)
}else if (NK2.numDecks==4){
NK2.Deck={1:"[Channel1]",2:"[Channel2]",3:"[Channel3]",4:"[Channel4]",5:"[Sampler1]",6:"[Sampler2]",7:"[Sampler3]",8:"[Sampler4]"};//list of decks, applied to each strip - 8 strips, 8 decks. (4 decks, 4 samplers)
}else if (NK2.numDecks==2){
NK2.Deck={1:"[Channel1]",2:"[Channel2]",3:"[Sampler1]",4:"[Sampler2]",5:"[Sampler3]",6:"[Sampler4]",5:"[Sampler5]",6:"[Sampler6]"};//list of decks, applied to each strip - 8 strips, 8 decks. (2 decks, 6 samplers)
}
NK2.deckData={};//object to store deck data, like mute vols, etc.
NK2.deckData["[Master]"]={'muteVol':-1};
for (i=1; i<9; i++){//initialize Deck reference objects
NK2.deckData[NK2.Deck[i]]={};
NK2.deckData[NK2.Deck[i]]['deckNum']=i;//reverse lookup for deck numbers by name
NK2.deckData[NK2.Deck[i]]['muteVol']=-1;//store previous volume for mute functions
}
NK2.beatloopLengths=new Array(0.03125,0.0625, 0.125, 0.25, 0.5, 1, 2, 4, 8, 16, 32);//store loop lengths with presets in Mixxx
//############################################################################
//INIT & SHUTDOWN
//############################################################################
NK2.init = function init() { // called when the device is opened & set up
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
engine.setValue("[Master]", "num_decks", NK2.numDecks);
NK2.setup()
NK2.updateLEDs();
print("decks: "+engine.getValue("[Master]", "num_decks"))
};
NK2.shutdown = function shutdown() {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
engine.stopTimer(NK2.LEDtimer);
};
//############################################################################
//SCENE SET FUNCTIONS - configure controls for selected scenes
//############################################################################
NK2.bankSelect = function bankSelect(deck, bank) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
NK2.curNSMR=bank;
NK2.curDeck=deck;
NK2.doClearBank=false;//bank has just been selected. Don't clear the bank when bank select button is released
NK2.cycleState=0;
NK2.bankSelectState=0;
//find bank indicator led, if bank activated
if (NK2.curNSMR=="S"){
NK2.LEDBankIndicator=NK2.Sbutton[NK2.curDeck];
}else if (NK2.curNSMR=="M"){
NK2.LEDBankIndicator=NK2.Mbutton[NK2.curDeck];
}else if (NK2.curNSMR=="R"){
NK2.LEDBankIndicator=NK2.Rbutton[NK2.curDeck];
}
if (NK2.LEDflasheson===true){engine.stopTimer(NK2.LEDtimer);NK2.LEDtimer=engine.beginTimer(750, "NK2.indicatorLEDs()");}//start timer for LED indicator flasher
NK2.updateLEDs();
};
//############################################################################
//INPUT PROCESSING
//############################################################################
NK2.fader = function fader(channel, control, value, status, group) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
engine.setValue(NK2.Deck[NK2.faders[control]], "volume", value/128);
};
NK2.button = function button(channel, control, value, status, group) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//input received - gatekeeper function connected to all buttons
//get the control object for the current button on the current bank - associative array containing control info, LED state evaluators, press/release functions, etc.
var theControl=NK2.getControl(control);
if (theControl===false){return false;}//no control set for this button
if (value>0){//button was pressed
var command = theControl["pressEval"];
midi.sendShortMsg(NK2.midiChannel, control, 0x7F);//light LED while button pressed
}else{//button was released
var command = theControl["releaseEval"];
midi.sendShortMsg(NK2.midiChannel, control, NK2.Controls[control]["LEDstate"]);//restore LED state when button released
}
if (command!=false)eval(command);
};
NK2.knob = function knob(channel, control, value, status, group) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//input received - gatekeeper function connected to all knobs
//get the control object for the current button on the current bank - associative array containing control info, LED state evaluators, press/release functions, etc.
var theControl=NK2.getControl(control);
if (theControl===false){return false;}//no control set for this button
var command = theControl["pressEval"];
if (command!=false)eval(command);
};
NK2.cyclepress = function cyclepress() {//press cycle button
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (NK2.cycleState==0){
NK2.cycleState=1;
}else{
NK2.cycleState=0;
}
NK2.updateLEDs();
};
NK2.modpress = function modpress(button) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if(button=="BANK"){
NK2.doClearBank=true;//if false when released, bank has been switched, so don't clear the selected bank on release
NK2.bankSelectState=1;
}else if (button=="MOD1"){
NK2.MOD1state=1;
}else if (button=="MOD2"){
NK2.MOD2state=1;
};
NK2.updateLEDs();
};
NK2.modrelease = function modrelease(button) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if(button=="BANK"){
NK2.bankSelectState=0;
if (NK2.doClearBank===true){
if (NK2.curNSMR!="N"){NK2.cycleState=0;}
NK2.curNSMR="N";
NK2.curDeck=0;
NK2.LEDBankIndicator=false;
engine.stopTimer(NK2.LEDtimer);
NK2.updateLEDs();
}
return true;
}else if (button=="MOD1"){
NK2.MOD1state=0;
}else if (button=="MOD2"){
//reset cue move stuff
engine.stopTimer(NK2.cueMoveIndicator);
NK2.cueMoveToNum=-1;
NK2.cuemoveLastIndicator=-1;
NK2.MOD2state=0;
};
NK2.updateLEDs();
};
//############################################################################
//LED FUNCTIONS
//############################################################################
NK2.updateLEDs = function updateLEDs() {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//fires on mod press/release, bank switch - updates all LEDs
var midino;
var control;
var state=0;
for (var key in NK2.Controls){//clear hooks
var midino=key;
var thecontrol = NK2.getControl(key);
var LEDstateType=thecontrol["LEDstateType"];
var LEDstateEval=thecontrol["LEDstateEval"];
var LEDhookControl=thecontrol["LEDhookControl"];
var LEDhookFunction=thecontrol["LEDhookFunction"];
var LEDhookGroup=(thecontrol["LEDhookGroup"]=="default")?NK2.Deck[NK2.curDeck]:thecontrol["LEDhookGroup"];
//clear hooks
if (NK2.Controls[key]["LEDstateType"]==="hook" && LEDstateType==="hook"){//check if hooks are the same, if not, clear the hook
if(NK2.Controls[key]["LEDhookGroup"]==LEDhookGroup && NK2.Controls[key]["LEDhookControl"]==LEDhookControl && NK2.Controls[key]["LEDhookFunction"]==LEDhookFunction){
//hooks are the same - go to next control
if (NK2.debug>0){print("##################SKIPPING")};
continue;
}else{//not the same. clear the hook
if (NK2.debug>0){print("##################CLEARING####################")};
//engine.connectControl(NK2.Controls[key]["LEDhookGroup"], NK2.Controls[key]["LEDhookControl"], NK2.Controls[key]["LEDhookFunction"], true);
NK2.clearHook(NK2.Controls[key]["LEDhookGroup"], NK2.Controls[key]["LEDhookControl"], NK2.Controls[key]["LEDhookFunction"]);
}
}else if(NK2.Controls[key]["LEDstateType"]==="hook"){//clear the hook
//engine.connectControl(NK2.Controls[key]["LEDhookGroup"], NK2.Controls[key]["LEDhookControl"], NK2.Controls[key]["LEDhookFunction"], true);
NK2.clearHook(NK2.Controls[key]["LEDhookGroup"], NK2.Controls[key]["LEDhookControl"], NK2.Controls[key]["LEDhookFunction"]);
};
//engine.connectControl(NK2.Controls[key]["LEDhookGroup"], NK2.Controls[key]["LEDhookControl"], NK2.Controls[key]["LEDhookFunction"], true);
};//end clear hooks for
for (var key in NK2.Controls){//set new led settings
var midino=key;
var thecontrol = NK2.getControl(key);
var LEDstateType=thecontrol["LEDstateType"];
var LEDstateEval=thecontrol["LEDstateEval"];
var LEDhookControl=thecontrol["LEDhookControl"];
var LEDhookFunction=thecontrol["LEDhookFunction"];
var LEDhookGroup=(thecontrol["LEDhookGroup"]=="default")?NK2.Deck[NK2.curDeck]:thecontrol["LEDhookGroup"];
if (thecontrol["LEDstateType"]===false){continue;}//control has no LED, LED Type is not set, or LED doesn't change on this mod setting. skip to next control
//reset LED state storage
NK2.Controls[key]["LEDstate"]=0;
NK2.Controls[key]["LEDstateType"]=LEDstateType;
NK2.Controls[key]["LEDstateEval"]=LEDstateEval;
NK2.Controls[key]["LEDhookControl"]=LEDhookControl;
NK2.Controls[key]["LEDhookFunction"]=LEDhookFunction;
NK2.Controls[key]["LEDhookGroup"]=LEDhookGroup;
if (LEDstateType=="on"){//LED is always on
state=1;
NK2.Controls[key]["LEDstate"]=1;
}
else if (LEDstateType=="off"){//LED is always off
state=0;
NK2.Controls[key]["LEDstate"]=0;
}
else if (LEDstateType=="hook"){//LED is hooked to a mixxx control
NK2.setHook(LEDhookGroup, LEDhookControl, LEDhookFunction);//set hook
engine.trigger(LEDhookGroup, LEDhookControl);
continue;
}
else if (thecontrol["LEDstateType"]=="eval"){//LED state determined by evaluating a javascript statement
if (NK2.debug>2){print("##updateLEDs Eval: "+thecontrol["LEDstateEval"])};
if (NK2.debug>2){print("##updateLEDs midino: "+midino)};
if (NK2.debug>2){print("##evalstate: "+eval(thecontrol["LEDstateEval"]))};
state=eval(LEDstateEval);
NK2.Controls[key]["LEDstate"]=(state>0)?1:0;
}//end if
midi.sendShortMsg(NK2.midiChannel, midino, state*127);
state=0;//reset state
}//end for
};
NK2.indicatorLEDs = function indicatorLEDs(value,group,control){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
engine.stopTimer(NK2.flashTimer);//kill previous timer if exists
NK2.flashon=0;
NK2.flashcount=0;
NK2.flashTimer=engine.beginTimer(100, "NK2.flashIndicators()");
return true;
};
NK2.flashIndicators= function flashIndicators(){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (NK2.flashon==0){
if (NK2.flashcount>=2){NK2.stopFlashTimer();return;}
if (NK2.LEDBankIndicator!=false){midi.sendShortMsg(NK2.midiChannel, NK2.LEDBankIndicator, 0);}
NK2.flashon=1;
NK2.flashcount++;
}else {
if (NK2.flashcount>=2){NK2.stopFlashTimer();return;}
if (NK2.LEDBankIndicator!=false){midi.sendShortMsg(NK2.midiChannel, NK2.LEDBankIndicator, 127);}
NK2.flashon=0;
NK2.flashcount++;
}
}
NK2.stopFlashTimer = function stopFlashTimer() {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
engine.stopTimer(NK2.flashTimer);
NK2.flashcount=0;
if (NK2.LEDBankIndicator!=false){midi.sendShortMsg(NK2.midiChannel, NK2.LEDBankIndicator, NK2.Controls[NK2.LEDBankIndicator]["LEDstate"]);};//restore state
}
NK2.cueMoveIndicatorLEDs = function cueMoveIndicatorLEDs(control){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
NK2.cuemovecontrol=control;
if (NK2.cuemoveLastIndicator!=-1){midi.sendShortMsg(NK2.midiChannel, NK2.cuemoveLastIndicator, 0);}//turn off last indicator in case timer was interrupted (keeps last led from being left on if you switch "move to" buttons.
NK2.cuemoveLastIndicator=control;
NK2.cuemoveflashon=(NK2.cuemoveflashon!=0 && NK2.cuemoveflashon!=1)?0:NK2.cuemoveflashon;
if (NK2.cuemoveflashon==0){
midi.sendShortMsg(NK2.midiChannel, control, 0);
NK2.cuemoveflashon=1;
}else {
midi.sendShortMsg(NK2.midiChannel, control, 127);
NK2.cuemoveflashon=0;
}
return true;
};
NK2.binaryHookLEDs = function lightButtonLEDs(value,group,control){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//light button leds for simple binary values
value=value*127;
value=(value>127)?127:value;
value=(value<0)?0:value;
var state=(value>0)?1:0;
//iterate through Controls to find button(s) that's hooked to this control
for (var key in NK2.Controls){
if (NK2.Controls[key]["LEDhookControl"]==control && NK2.Controls[key]["LEDhookGroup"]==group){
var midino=key;
midi.sendShortMsg(NK2.midiChannel, midino, value);
NK2.Controls[key]["LEDstate"]=state;
}
}//end for
};
NK2.muteLEDs = function muteLEDs(value,group,control){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//light deck mute leds, also cancels mute if volume changes
//iterate through Controls to find button(s) that's hooked to this control
for (var key in NK2.Controls){
if (NK2.Controls[key]["LEDhookControl"]==control && NK2.Controls[key]["LEDhookGroup"]==group){
var midino=key;
var state=(value>0 || NK2.deckData[group]['muteVol']==-1)?0:1;
midi.sendShortMsg(NK2.midiChannel, midino, state*127);
NK2.Controls[key]["LEDstate"]=state;
if(NK2.deckData[group]['muteVol']!=-1 && value>0){NK2.deckData[group]['muteVol']=-1;}
}
}//end for
};
NK2.vuMeterL = function vuMeterL(value,group,control){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//light S buttons left to right for left VU meter
value=(value*7)+1;
for (var i=1; i<9; i++){
if (value>=i){midi.sendShortMsg(NK2.midiChannel, NK2.Sbutton[i], 127);}else{midi.sendShortMsg(NK2.midiChannel, NK2.Sbutton[i], 0);}
}
};
NK2.vuMeterR = function vuMeterR(value,group,control){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//light S buttons left to right for left VU meter
value=(value*7)+1;
for (var i=1; i<9; i++){
if (value>=i){midi.sendShortMsg(NK2.midiChannel, NK2.Mbutton[i], 127);}else{midi.sendShortMsg(NK2.midiChannel, NK2.Mbutton[i], 0);}
}
};
NK2.beatIndicatorRow = function beatIndicatorRow(value,group,control){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//light S buttons left to right for left VU meter
value=(value*127);
for (var i=1; i<9; i++){
midi.sendShortMsg(NK2.midiChannel, NK2.Rbutton[i], value);
}
};
//############################################################################
//BASIC FUNCTIONS - stuff that makes the other stuff work
//############################################################################
NK2.getFunctionName = function getFunctionName(){//return name of calling function
var re = /function (.*?)\(/
var s = NK2.getFunctionName.caller.toString();
var m = re.exec( s )
return m[1];
};
NK2.doNothing = function doNothing(){//dummy function - do nothing
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
return false;
};
NK2.setHook = function setHook(group, control, func){//clear hook
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
var done=false;
done=engine.connectControl(group, control, func);
return done;
};
NK2.clearHook = function clearHook(group, control, func){//clear hook
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
var done=false;
done=engine.connectControl(group, control, func, true);
return done;
};
NK2.getControl = function getControl(control){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
var theControl=NK2.Controls[control][NK2.curNSMR][NK2.getCurModCode()];//get control for current mod settings
if (theControl['isset']===false || typeof theControl === 'undefined'){
theControl=NK2.Controls[control][NK2.curNSMR][NK2.bin2dec(NK2.cycleState.toString()+NK2.bankSelectState.toString()+"00")];//get control without mods, only check cycle state and bank select
if (theControl['isset']===false || typeof theControl === 'undefined'){
theControl=NK2.Controls[control][NK2.curNSMR][NK2.bin2dec("0"+NK2.bankSelectState.toString()+"00")];//get control without mods or cycle - ONLY bank select
if (theControl['isset']===false || typeof theControl === 'undefined'){
theControl=NK2.Controls[control][NK2.curNSMR][0];//get control without mods, cycle or bank select
};
};
};
if (theControl['isset']===false || typeof theControl === 'undefined'){return false;}
//returns the array of control commands and LED state functions for the control pressed for the current bank/mods
return theControl;
};
NK2.getCurModCode = function getCurModCode(control){//returns the current mod code value
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
var codestr=NK2.cycleState.toString()+NK2.bankSelectState.toString()+NK2.MOD1state.toString()+NK2.MOD2state.toString();
//print("#####modcode: "+codestr);
return parseInt(codestr, 2);
};
NK2.bin2dec = function bin2dec(str){//convert binary string to decimal
return parseInt(str, 2);
};
//############################################################################
//FUNCTIONALITY - stuff that does stuff
//############################################################################
NK2.knobAdjust = function knobAdjust(group, control, value, min, max){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (group=="default"){group=NK2.Deck[NK2.curDeck];};
//use a knob to adjust a mixxx control
var range=max-min;
var newValue=min+((value/127)*range);
if (newValue>max)newValue=max;
if (newValue<min)newValue=min;
engine.setValue(group, control, newValue);
}
NK2.logKnobAdjust = function logKnobAdjust(group, control, value, min, max){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (group=="default"){group=NK2.Deck[NK2.curDeck];};
//use a knob to adjust a mixxx control
//on a logarithmic scale (0 min, 4 max)
//K = 4*(V)^2
//V = (K/4)^0.5 -- K= value coming from prog (0-4, logarithmic scale), V=value adjusted to linear 0-1
var range=max-min;
var adjustedValue=value/127;//adjust range so it's on a scale of 0 to 1 - logarithmic
var newValue=min+(range*Math.pow((adjustedValue),2));
if (newValue>max)newValue=max;
if (newValue<min)newValue=min;
engine.setValue(group, control, newValue);
}
NK2.toggleBinaryControlAll = function toggleBinaryControlAll(control){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
var newstate = (engine.getValue(NK2.Deck[1], control)==0)?1:0;
for (var i=1; i<9; i++){
engine.setValue(NK2.Deck[i], control, newstate);
};
}
NK2.wavezoomAll = function wavezoomAll(value){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
var range=6-1;
var newValue=Math.round(1+((value/127)*range));
if (newValue>6)newValue=6;
if (newValue<1)newValue=1;
if (NK2.lastwavevalue!=value){
for (var i=1; i<9; i++){
engine.setValue(NK2.Deck[i], "waveform_zoom", newValue);
};
}
NK2.lastwavevalue=value;
}
NK2.wavezoomDeck = function wavezoomDeck(value, group){
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (group=="default"){group=NK2.Deck[NK2.curDeck];};
var range=6-1;
var newValue=Math.round(1+((value/127)*range));
if (newValue>6)newValue=6;
if (newValue<1)newValue=1;
if (NK2.lastwavevalue!=value){
engine.setValue(group, "waveform_zoom", newValue);
}
NK2.lastwavevalue=value;
}
NK2.mutePress = function mutePress(deck){//press mute button - toggle mute for a deck
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (NK2.deckData[deck]['muteVol']<0){//deck is currently not muted. enable mute
NK2.deckData[deck]['muteVol']=engine.getValue(deck, "volume");
engine.setValue(deck, "volume", 0);
} else {//deck is currently muted. Unmute
engine.setValue(deck, "volume", NK2.deckData[deck]['muteVol']);
NK2.deckData[deck]['muteVol']=-1;
}
};
NK2.muteRelease = function muteRelease(deck){//release mute button
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if(NK2.deckData[deck]['muteVol']!=-1){
engine.setValue(deck, "volume", NK2.deckData[deck]['muteVol']);
NK2.deckData[deck]['muteVol']=-1;
};
return true;
};
NK2.binControlPress = function binControlPress(deck, control){//press button - toggle binary control for a deck
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (deck=="default"){deck=NK2.Deck[NK2.curDeck];};
var curstate=engine.getValue(deck, control);
if (curstate===0 || (control=="play" && engine.getValue(deck, "reverse")==1)){//control currently off
engine.setValue(deck, control,1);
//handle resets
if (control=="play"){engine.setValue(deck, "reverse",0);}
}else{
engine.setValue(deck, control,0);
}
};
NK2.binControlRelease = function binControlMomentary(deck, control){//release momentary button - reset control to 0 on release
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (deck=="default"){deck=NK2.Deck[NK2.curDeck];};
engine.setValue(deck, control,0);
};
NK2.releaseSetFalse = function releaseSetFalse(deck, control){//release pfl button
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
engine.setValue(deck, control,false);
return true;
};
NK2.cuePress = function cuePress(cue, button){//press hotcue
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (NK2.debug>2){print("##cue: "+cue)};
if (NK2.debug>2){print("##deck: "+NK2.Deck[NK2.curDeck])};
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_activate", 1);
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_activate", 0);
}
NK2.cueClear = function cueClear(cue, control){//clear hotcue - OR move hotcue to new button
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (NK2.debug>2){print("##cue: "+cue)};
if (NK2.debug>2){print("##deck: "+NK2.Deck[NK2.curDeck])};
if(engine.getValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_enabled")!=true){//hotcue not set - prepare to move next hotcue pressed to this button
NK2.cueMoveToNum=cue;
engine.stopTimer(NK2.cueMoveIndicator);
NK2.cueMoveIndicator=engine.beginTimer(100, "NK2.cueMoveIndicatorLEDs("+control+")");//start timer for LED indicator flasher showing the button we're moving to
return true;
}
if(NK2.cueMoveToNum>0){//hotcue set, but we're moving it, not clearing it.
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+NK2.cueMoveToNum+"_set", 1);
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+NK2.cueMoveToNum+"_position", engine.getValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_position"));
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_clear", 1);
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_clear", 0);
engine.stopTimer(NK2.cueMoveIndicator);
NK2.cueMoveToNum=-1;//reset
NK2.cuemoveLastIndicator=-1;
return true;
}
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_clear", 1);
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_clear", 0);
}
NK2.cueLoop = function cueLoop(cue){//jump to hotcue and start loop
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (engine.getValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_enabled")!==1){//set hotcue and start loop
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_activate", 1);
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_activate", 0);
engine.setValue(NK2.Deck[NK2.curDeck], "beatloop_"+NK2.cueLoopLen+"_activate", 1);
}else{//jump to existing cue and loop
//calculate start and end points
var startpos=engine.getValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_position");
var loopseconds = NK2.cueLoopLen*(1/(engine.getValue(NK2.Deck[NK2.curDeck], "bpm")/60));
var loopsamples = loopseconds*engine.getValue(NK2.Deck[NK2.curDeck], "track_samplerate")*2;//*2 to compensate for stereo samples
var endpos=startpos+loopsamples;
//disable loop if currently enabled
if (engine.getValue(NK2.Deck[NK2.curDeck], "loop_enabled")==true){engine.setValue(NK2.Deck[NK2.curDeck], "reloop_exit", 1);}
//set start and endpoints
engine.setValue(NK2.Deck[NK2.curDeck], "loop_start_position", startpos);
engine.setValue(NK2.Deck[NK2.curDeck], "loop_end_position", endpos);
//enable loop
engine.setValue(NK2.Deck[NK2.curDeck], "reloop_exit", 1);
}
}
NK2.saveLoop = function saveLoop(cue){//save the current loop inpoint as a hotcue
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (engine.getValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_enabled")==1){//hotcue is already set, return false
return false;
}else if (engine.getValue(NK2.Deck[NK2.curDeck], "loop_enabled")!=true){//no loop currently active, return false
return false;
}else{//save the loop as a hotcue
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_set", 1);
engine.setValue(NK2.Deck[NK2.curDeck], "hotcue_"+cue+"_position", engine.getValue(NK2.Deck[NK2.curDeck], "loop_start_position"));
return true;
}
}
NK2.beatjump = function (jumplen) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//jumps back certain number of beats depending on knob modifier
var curpos = engine.getValue(NK2.Deck[NK2.curDeck], "playposition")*engine.getValue(NK2.Deck[NK2.curDeck], "track_samples");
var numbeats = jumplen;
var backseconds = numbeats*(1/(engine.getValue(NK2.Deck[NK2.curDeck], "bpm")/60));
var backsamples = backseconds*engine.getValue(NK2.Deck[NK2.curDeck], "track_samplerate")*2;//*2 to compensate for stereo samples
var newpos = curpos-(backsamples);
if (NK2.debug){print("backseconds: "+backseconds);}
if (NK2.debug){print("backsamples: "+backsamples);}
if (NK2.debug){print("curpos: "+curpos);}
if (NK2.debug){print("newpos: "+newpos);}
if (NK2.debug){print("numbeats: "+numbeats);}
engine.setValue(NK2.Deck[NK2.curDeck], "playposition", newpos/engine.getValue(NK2.Deck[NK2.curDeck], "track_samples"));
};
NK2.beatloop = function beatloop(looplen, value) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//activate beatloop
if (value>0){//button was pressed
NK2.loopbuttonDown=true;
engine.setValue(NK2.Deck[NK2.curDeck], "beatloop_"+looplen+"_activate", 1);
} else {//button was released
NK2.loopbuttonDown=false;
};
};
NK2.beatlooproll = function beatlooproll(looplen, value) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//activate beatloop
if (value>0){//button was pressed
NK2.loopbuttonDown=true;
engine.setValue(NK2.Deck[NK2.curDeck], "beatlooproll_"+looplen+"_activate", 1);
} else {//button was released
NK2.loopbuttonDown=false;
};
};
NK2.reloopButton = function reloopButton(value) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
if (value>0){//button was pressed
engine.stopTimer(NK2.reloopTimer);
NK2.loopbuttonDown=true;
NK2.doreloop=true;
NK2.reloopTimer = engine.beginTimer(500, "NK2.disablereloop()", true);
} else {//button was released
NK2.loopbuttonDown=false;
if (NK2.doreloop===true) {engine.setValue(NK2.Deck[NK2.curDeck], "reloop_exit", 1);engine.setValue(NK2.Deck[NK2.curDeck], "reloop_exit", 0);};
NK2.doreloop=true;
engine.stopTimer(NK2.reloopTimer);
};
};
NK2.loopin = function loopin(value) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//activate beatloop
if (value>0){//button was pressed
engine.stopTimer(NK2.loopinTimer);
NK2.loopinbuttonDown=true;
NK2.doloopin=true;
NK2.loopinTimer = engine.beginTimer(500, "NK2.disableloopin()", true);
} else {//button was released
NK2.loopinbuttonDown=false;
if (NK2.doloopin===true) {engine.setValue(NK2.Deck[NK2.curDeck], "loop_in", 1);engine.setValue(NK2.Deck[NK2.curDeck], "loop_in", 0);};
NK2.doloopin=true;
engine.stopTimer(NK2.loopinTimer);
};
};
NK2.loopout = function loopout(value) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//activate beatloop
if (value>0){//button was pressed
engine.stopTimer(NK2.loopoutTimer);
NK2.loopoutbuttonDown=true;
NK2.doloopout=true;
NK2.loopoutTimer = engine.beginTimer(500, "NK2.disableloopout()", true);
} else {//button was released
NK2.loopoutbuttonDown=false;
if (NK2.doloopout===true) {engine.setValue(NK2.Deck[NK2.curDeck], "loop_out", 1);engine.setValue(NK2.Deck[NK2.curDeck], "loop_out", 0);};
NK2.doloopout=true;
engine.stopTimer(NK2.loopoutTimer);
};
};
NK2.disablereloop = function disablereloop() {
//timed function - fires half a second after pressing reloop. Don't do the reloop if you hold down the button (so you can move the loop without exiting)
NK2.doreloop=false;
};
NK2.disableloopin = function disableloopin() {
//timed function - fires half a second after pressing reloop. Don't do the reloop if you hold down the button (so you can move the loop without exiting)
NK2.doloopin=false;
};
NK2.disableloopout = function disableloopout() {
//timed function - fires half a second after pressing reloop. Don't do the reloop if you hold down the button (so you can move the loop without exiting)
NK2.doloopout=false;
};
NK2.loopminus = function loopminus() {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//shrinks loop or moves loop back
if (NK2.loopbuttonDown !== true && NK2.loopinbuttonDown!==true && NK2.loopoutbuttonDown!==true){engine.setValue(NK2.Deck[NK2.curDeck], "loop_halve", 1); engine.setValue(NK2.Deck[NK2.curDeck], "loop_halve", 0); return false;}//shrink loop if no loop button down
else if (NK2.loopbuttonDown === true && engine.getValue(NK2.Deck[NK2.curDeck], "loop_start_position")>=0 && engine.getValue(NK2.Deck[NK2.curDeck], "loop_end_position")>=0 ){
//move loop
var interval = NK2.loopmove*engine.getValue(NK2.Deck[NK2.curDeck], "track_samples")/engine.getValue(NK2.Deck[NK2.curDeck], "duration");
var start = engine.getValue(NK2.Deck[NK2.curDeck], "loop_start_position");
var end = engine.getValue(NK2.Deck[NK2.curDeck], "loop_end_position");
engine.setValue(NK2.Deck[NK2.curDeck], "loop_start_position", start-interval);
engine.setValue(NK2.Deck[NK2.curDeck], "loop_end_position", end-interval);
return true;
}
else if (NK2.loopinbuttonDown === true && engine.getValue(NK2.Deck[NK2.curDeck], "loop_start_position")>=0){
//move loop in point
var interval = NK2.loopmove*engine.getValue(NK2.Deck[NK2.curDeck], "track_samples")/engine.getValue(NK2.Deck[NK2.curDeck], "duration");
var start = engine.getValue(NK2.Deck[NK2.curDeck], "loop_start_position");
engine.setValue(NK2.Deck[NK2.curDeck], "loop_start_position", start-interval);
return true;
}
else if (NK2.loopoutbuttonDown === true && engine.getValue(NK2.Deck[NK2.curDeck], "loop_end_position")>=0){
//move loop out point
var interval = NK2.loopmove*engine.getValue(NK2.Deck[NK2.curDeck], "track_samples")/engine.getValue(NK2.Deck[NK2.curDeck], "duration");
var end = engine.getValue(NK2.Deck[NK2.curDeck], "loop_end_position");
engine.setValue(NK2.Deck[NK2.curDeck], "loop_end_position", end-interval);
return true;
};
};
NK2.loopplus = function loopplus() {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//grows loop or moves loop forward
if (NK2.loopbuttonDown !== true && NK2.loopinbuttonDown!==true && NK2.loopoutbuttonDown!==true){engine.setValue(NK2.Deck[NK2.curDeck], "loop_double", 1); engine.setValue(NK2.Deck[NK2.curDeck], "loop_double", 0); return false;}//shrink loop if no loop button down
else if (NK2.loopbuttonDown === true && engine.getValue(NK2.Deck[NK2.curDeck], "loop_start_position")>=0 && engine.getValue(NK2.Deck[NK2.curDeck], "loop_end_position")>=0 ){
//move loop
var interval = NK2.loopmove*engine.getValue(NK2.Deck[NK2.curDeck], "track_samples")/engine.getValue(NK2.Deck[NK2.curDeck], "duration");
var start = engine.getValue(NK2.Deck[NK2.curDeck], "loop_start_position");
var end = engine.getValue(NK2.Deck[NK2.curDeck], "loop_end_position");
engine.setValue(NK2.Deck[NK2.curDeck], "loop_start_position", start+interval);
engine.setValue(NK2.Deck[NK2.curDeck], "loop_end_position", end+interval);
return true;
}
else if (NK2.loopinbuttonDown === true && engine.getValue(NK2.Deck[NK2.curDeck], "loop_start_position")>=0){
//move loop in point
var interval = NK2.loopmove*engine.getValue(NK2.Deck[NK2.curDeck], "track_samples")/engine.getValue(NK2.Deck[NK2.curDeck], "duration");
var start = engine.getValue(NK2.Deck[NK2.curDeck], "loop_start_position");
engine.setValue(NK2.Deck[NK2.curDeck], "loop_start_position", start+interval);
return true;
}
else if (NK2.loopoutbuttonDown === true && engine.getValue(NK2.Deck[NK2.curDeck], "loop_end_position")>=0){
//move loop out point
var interval = NK2.loopmove*engine.getValue(NK2.Deck[NK2.curDeck], "track_samples")/engine.getValue(NK2.Deck[NK2.curDeck], "duration");
var end = engine.getValue(NK2.Deck[NK2.curDeck], "loop_end_position");
engine.setValue(NK2.Deck[NK2.curDeck], "loop_end_position", end+interval);
return true;
};
};
NK2.loopDial = function loopDial(value, deck) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//activates variable length loop depending on dial position. to exit, hit reloop/exit
if (deck=="default"){deck=NK2.Deck[NK2.curDeck];};
value=value/127;//change range from 0-1
value=Math.round(value*(NK2.beatloopLengths.length-1));
var newLoopLen=NK2.beatloopLengths[value];
if (engine.getValue(deck, "loop_enabled")==true){
var startpos=engine.getValue(deck, "loop_start_position");
var loopseconds = newLoopLen*(1/(engine.getValue(deck, "bpm")/60));
var loopsamples = loopseconds*engine.getValue(deck, "track_samplerate")*2;//*2 to compensate for stereo samples
var endpos=startpos+loopsamples;
engine.setValue(NK2.Deck[NK2.curDeck], "loop_end_position", endpos);
}else{
engine.setValue(deck, "beatloop_"+newLoopLen+"_activate", 1);
}
return true;
};
NK2.setOrientation = function setOrientation(deck, orientation) {//sets crossfader orientation for a deck
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
engine.setValue(deck, "orientation", orientation);
NK2.updateLEDs();
};
//############################################################################
//TEST FUNCTIONS - stuff to check out if the other stuff works
//############################################################################
NK2.test = function test(channel, control, value, status, group) {
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
print("channel: "+channel);
print("control: "+control.toString(16));
print("value: "+value);
print("status: "+status);
print("group: "+group);
print("test: ##"+status.toString(16)+control.toString(16)+"##");
print("loopbuttondown: ##"+NK2.loopbuttonDown+"##");
print("NK2.looplen: ##"+NK2.looplen+"##");
print("NK2.looplen.tostring: ##"+NK2.looplen.toString(16)+"##");
print("NK2.looptype: ##"+NK2.looptype+"##");
print("test: ##"+2+"##");
};
NK2.testLED=0;//used by test function
NK2.testleds=function testleds(){//sends LED on messages to all
midi.sendShortMsg(0xB0, NK2.testLED, 0);
if (NK2.testLED>=127){return false; }
NK2.testLED++
midi.sendShortMsg(0xB0, NK2.testLED, 0x7F);
NK2.LEDtimer=engine.beginTimer(100, "NK2.testleds()", true);
}
//############################################################################
//CONTROL CONFIG - initialize control command object and LED state tracker, bind commands to controls
//############################################################################
//initialize control object function - iterates through buttons and sets up empty slots for command arrays - unset controls are "false"
NK2.initControls = function initControls(obj) {//initialize controls array
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
for (var x in obj){
NK2.Controls[obj[x]]={"LEDstate":0, "LEDstateType":false, "LEDstateEval":false, "LEDhookControl":false, "LEDhookFunction":false, "LEDhookGroup":false};//init with empty LED tracking properties
for (var y in NK2.Banks){//iterate through bank modes
NK2.Controls[obj[x]][NK2.Banks[y]]={};//init empty
for (var z=0;z<16;z++){//iterate through mod codes
NK2.Controls[obj[x]][NK2.Banks[y]][z]={"isset":false, "pressEval":false, "releaseEval":false, "LEDstateType":false, "LEDstateEval":false, "LEDhookControl":false, "LEDhookFunction":false, "LEDhookGroup":false};
};//end for z
};//end for y
};//end for x
};
NK2.setup = function setup(obj) {//initialize controls array
if (NK2.debug>2){print("##function: "+NK2.getFunctionName())};
//initialize control object for buttons, knobs, etc.
NK2.Controls={};
NK2.initControls(NK2.Knob);
NK2.initControls(NK2.Sbutton);
NK2.initControls(NK2.Mbutton);
NK2.initControls(NK2.Rbutton);
NK2.initControls(NK2.leftButton);
//CONTROL SYNTAX
//NK2.Controls[midino]["N" (none), "S", "M", or "R"][MOD state: no mod = 0, bank select = 1, MOD 1 on = 2, MOD 2 on = 3]
//'PressEval', 'ReleaseEval' = code eval'd when button is pressed or released
/* MOD STATE - binary based
* 1st digit - cycle button - this is a toggle (others are momentary on), and has a LED (others don't)
* 2nd digit - bank select (marker set) button
* 3rd digit - MOD 1 - track down
* 4th digit - MOD 2 - track up
*
* eg:
* 0100 - (dec. 4) - bank select only
* 1101 - (dec. 5) - cycle, bank sel. and MOD 2
*
* decimal equivalents - 3 buttons = 8 states - 4 buttons, 16 states
0000 - 0
0001 - 1
0010 - 2
0011 - 3
0100 - 4
0101 - 5
0110 - 6
0111 - 7
1000 - 8
1001 - 9
1010 - 10
1011 - 11
1100 - 12
1101 - 13
1110 - 14
1111 - 15
*/
//eval strs can be false if no function on press or release - eg: knobs are false on release, since they don't release
//LEDstateType = false if control has no LED, "hook" if using connectControl, "eval" if using an eval statement to get initial LED state
//LEDstateType = "off" if LED is always off, "on" if LED is always on
//for HOOKS: LEDhookControl = mixxx control to connect to, LEDhookFunction = script function
//for HOOKS: LEDhookGroup = mixxx control group - literals accepted (eg: "[Channel1]", or "default", "sync" or "alt" = default, sync or alt deck for that channel
//for EVAL: LEDstateEval = javascript to evaluate to get LED state
//init: {"isset":false, "pressEval":false, "releaseEval":false, "LEDstateType":false, "LEDstateEval":false, "LEDhookControl":false, "LEDhookFunction":false, "LEDhookGroup":false}\
//bank select and mod buttons - marker set down and up
for (var j=0;j<4;j++){
NK2.Controls[NK2.leftButton["mset"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.modpress("BANK");', "releaseEval":'NK2.modrelease("BANK");', "LEDstateType":"on"};
NK2.Controls[NK2.leftButton["mdown"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.modpress("MOD1");', "releaseEval":'NK2.modrelease("MOD1");', "LEDstateType":"on"};
NK2.Controls[NK2.leftButton["mup"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.modpress("MOD2");', "releaseEval":'NK2.modrelease("MOD2");', "LEDstateType":"on"};
NK2.Controls[NK2.leftButton["cycle"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.cyclepress();', "releaseEval":false, "LEDstateType":"eval", "LEDstateEval":'(NK2.cycleState==0)?0:1;'};
};
//bank select button pressed - initialize bank select buttons
for (var i=1;i<9;i++){//i = strip number
for (var j=0;j<4;j++){
NK2.Controls[NK2.Sbutton[i]][NK2.Banks[j]][NK2.MODcodes["0100"]]={"isset":true, "pressEval":'NK2.bankSelect('+i+', "S");', "LEDstateType":"on"};
NK2.Controls[NK2.Mbutton[i]][NK2.Banks[j]][NK2.MODcodes["0100"]]={"isset":true, "pressEval":'NK2.bankSelect('+i+', "M");', "LEDstateType":"on"};
NK2.Controls[NK2.Rbutton[i]][NK2.Banks[j]][NK2.MODcodes["0100"]]={"isset":true, "pressEval":'NK2.bankSelect('+i+', "R");', "LEDstateType":"on"};
};
};
//N mode left buttons
NK2.toggleBinaryControlAll
NK2.Controls[NK2.leftButton["rev"]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.toggleBinaryControlAll("quantize");', "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["ff"]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.toggleBinaryControlAll("keylock");', "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["stop"]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.toggleBinaryControlAll("slip_enabled");', "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["play"]]["N"][0]={"isset":true, "pressEval":'NK2.mutePress("[Master]");', "releaseEval":'NK2.muteRelease("[Master]");', "LEDstateType":"hook", "LEDhookControl":'volume', "LEDhookFunction":'NK2.muteLEDs', "LEDhookGroup":"[Master]"};
//set common left button controls for S, M, and R modes (these controls can be overridden by resetting them later in the script)
for (var j=1;j<4;j++){
NK2.Controls[NK2.leftButton["rev"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "quantize");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'quantize', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["ff"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "keylock");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'keylock', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["rev"]][NK2.Banks[j]][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "quantize");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'quantize', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["ff"]][NK2.Banks[j]][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "keylock");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'keylock', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["stop"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "slip_enabled");', "releaseEval": false, "LEDstateType":"hook", "LEDhookControl":'slip_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["stop"]][NK2.Banks[j]][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "slip_enabled");', "releaseEval": false, "LEDstateType":"hook", "LEDhookControl":'slip_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["stop"]][NK2.Banks[j]][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "beats_translate_curpos");', "releaseEval":'NK2.binControlRelease("default", "beats_translate_curpos");', "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["play"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.doNothing();', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'play', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["rec"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.doNothing();', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'cue_default', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["play"]][NK2.Banks[j]][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "play");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'play', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["rec"]][NK2.Banks[j]][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "cue_default");', "releaseEval":'NK2.binControlRelease("default", "cue_default");', "LEDstateType":"hook", "LEDhookControl":'cue_default', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["play"]][NK2.Banks[j]][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "reverse");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'reverse', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["rec"]][NK2.Banks[j]][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "start");', "releaseEval":'NK2.binControlRelease("default", "start");', "LEDstateType":"hook", "LEDhookControl":'cue_default', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["rec"]][NK2.Banks[j]][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "start_stop");', "releaseEval":'NK2.binControlRelease("default", "start_stop");', "LEDstateType":"hook", "LEDhookControl":'cue_default', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["trdown"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "back");', "releaseEval":'NK2.binControlRelease("default", "back");', "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["trup"]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "fwd");', "releaseEval":'NK2.binControlRelease("default", "fwd");', "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["trdown"]][NK2.Banks[j]][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "rate_temp_down");', "releaseEval":'NK2.binControlRelease("default", "rate_temp_down");', "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["trup"]][NK2.Banks[j]][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "rate_temp_up");', "releaseEval":'NK2.binControlRelease("default", "rate_temp_up");', "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["trdown"]][NK2.Banks[j]][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "rate_perm_down");', "releaseEval":'NK2.binControlRelease("default", "rate_perm_down");', "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["trup"]][NK2.Banks[j]][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.binControlPress("default", "rate_perm_up");', "releaseEval":'NK2.binControlRelease("default", "rate_perm_up");', "LEDstateType":"off"};
};
//NO BANK/TRACK SELECTED - bank select button off - set slip mode, mute and pfl buttons
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["N"][0]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "slip_enabled");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'slip_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
NK2.Controls[NK2.Mbutton[i]]["N"][0]={"isset":true, "pressEval":'NK2.mutePress("'+NK2.Deck[i]+'");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'volume', "LEDhookFunction":'NK2.muteLEDs', "LEDhookGroup":NK2.Deck[i]};
NK2.Controls[NK2.Rbutton[i]]["N"][0]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "pfl");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'pfl', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
};
//CYCLE ON - momentary mute button
for (var i=1;i<9;i++){
NK2.Controls[NK2.Mbutton[i]]["N"][NK2.MODcodes["1000"]]={"isset":true, "pressEval":'NK2.mutePress("'+NK2.Deck[i]+'");', "releaseEval":'NK2.muteRelease("'+NK2.Deck[i]+'");', "LEDstateType":"hook", "LEDhookControl":'volume', "LEDhookFunction":'NK2.muteLEDs', "LEDhookGroup":NK2.Deck[i]};
};
//N mode + MOD1 - lo mid hi kills
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["N"][2]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "filterHighKill");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'filterHighKill', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
NK2.Controls[NK2.Mbutton[i]]["N"][2]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "filterMidKill");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'filterMidKill', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
NK2.Controls[NK2.Rbutton[i]]["N"][2]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "filterLowKill");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'filterLowKill', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
};
//CYCLE ON - N mode + MOD1 - MOMENTARY lo mid hi kills
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["N"][NK2.MODcodes["1010"]]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "filterHighKill");', "releaseEval":'NK2.binControlRelease("'+NK2.Deck[i]+'", "filterHighKill");', "LEDstateType":"hook", "LEDhookControl":'filterHighKill', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
NK2.Controls[NK2.Mbutton[i]]["N"][NK2.MODcodes["1010"]]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "filterMidKill");', "releaseEval":'NK2.binControlRelease("'+NK2.Deck[i]+'", "filterMidKill");', "LEDstateType":"hook", "LEDhookControl":'filterMidKill', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
NK2.Controls[NK2.Rbutton[i]]["N"][NK2.MODcodes["1010"]]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "filterLowKill");', "releaseEval":'NK2.binControlRelease("'+NK2.Deck[i]+'", "filterLowKill");', "LEDstateType":"hook", "LEDhookControl":'filterLowKill', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
};
//N mode + MOD1 + MOD2 + Bank Select - Track crossfader orientation - S=left, M=middle, R=right
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["N"][NK2.MODcodes["0111"]]={"isset":true, "pressEval":'NK2.setOrientation("'+NK2.Deck[i]+'", 0);', "releaseEval":false, "LEDstateType":"eval", "LEDstateEval":'(engine.getValue("'+NK2.Deck[i]+'", "orientation")==0)?1:0;'};
NK2.Controls[NK2.Mbutton[i]]["N"][NK2.MODcodes["0111"]]={"isset":true, "pressEval":'NK2.setOrientation("'+NK2.Deck[i]+'", 1);', "releaseEval":false, "LEDstateType":"eval", "LEDstateEval":'(engine.getValue("'+NK2.Deck[i]+'", "orientation")==1)?1:0;'};
NK2.Controls[NK2.Rbutton[i]]["N"][NK2.MODcodes["0111"]]={"isset":true, "pressEval":'NK2.setOrientation("'+NK2.Deck[i]+'", 2);', "releaseEval":false, "LEDstateType":"eval", "LEDstateEval":'(engine.getValue("'+NK2.Deck[i]+'", "orientation")==2)?1:0;'};
};
//N mode + MOD2 - keylock quantize
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["N"][1]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "flanger");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'flanger', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
NK2.Controls[NK2.Mbutton[i]]["N"][1]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "quantize");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'quantize', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
NK2.Controls[NK2.Rbutton[i]]["N"][1]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "keylock");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'keylock', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
};
//M mode - hotcues 1-24
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["M"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.cuePress('+i+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+i+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[i]]["M"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.cuePress('+(i+8)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+8)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["M"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.cuePress('+(i+16)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+16)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//M mode, with cycle toggled on - hotcues 9-32
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["M"][NK2.MODcodes["1000"]]={"isset":true, "pressEval":'NK2.cuePress('+(i+8)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+8)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[i]]["M"][NK2.MODcodes["1000"]]={"isset":true, "pressEval":'NK2.cuePress('+(i+16)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+16)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["M"][NK2.MODcodes["1000"]]={"isset":true, "pressEval":'NK2.cuePress('+(i+24)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+24)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//M mode - CLEAR (with MOD2) hotcues 1-24
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["M"][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.cueClear('+i+', control);', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+i+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[i]]["M"][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.cueClear('+(i+8)+', control);', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+8)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["M"][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.cueClear('+(i+16)+', control);', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+16)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//M mode, with cycle toggled on - CLEAR (with MOD2) hotcues 9-32
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["M"][NK2.MODcodes["1001"]]={"isset":true, "pressEval":'NK2.cueClear('+(i+8)+', control);', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+8)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[i]]["M"][NK2.MODcodes["1001"]]={"isset":true, "pressEval":'NK2.cueClear('+(i+16)+', control);', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+16)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["M"][NK2.MODcodes["1001"]]={"isset":true, "pressEval":'NK2.cueClear('+(i+24)+', control);', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+24)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//M mode - Jump to Hotcue and start loop (with MOD1) hotcues 1-24
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["M"][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.cueLoop('+i+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+i+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[i]]["M"][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.cueLoop('+(i+8)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+8)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["M"][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.cueLoop('+(i+16)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+16)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//M mode, with cycle toggled on - Jump to Hotcue and start loop (with MOD1) hotcues 9-32
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["M"][NK2.MODcodes["1010"]]={"isset":true, "pressEval":'NK2.cueLoop('+(i+8)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+8)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[i]]["M"][NK2.MODcodes["1010"]]={"isset":true, "pressEval":'NK2.cueLoop('+(i+16)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+16)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["M"][NK2.MODcodes["1010"]]={"isset":true, "pressEval":'NK2.cueLoop('+(i+24)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+24)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//M mode with MOD1 and MOD2 - temporary loop controls - same as R mode, but only while holding mod buttons
var looplens={1:.125, 2:.25, 3:.5, 4:1, 5:2, 6:4, 7:8, 8:16}//array of loop and beatjump lengths
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["M"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.beatjump('+looplens[i]+');', "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.Mbutton[i]]["M"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.beatlooproll('+looplens[i]+', value);', "releaseEval":'NK2.beatlooproll('+looplens[i]+', value);', "LEDstateType":"hook", "LEDhookControl":'beatloop_'+looplens[i]+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["M"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.beatloop('+looplens[i]+', value);', "releaseEval":'NK2.beatloop('+looplens[i]+', value);', "LEDstateType":"hook", "LEDhookControl":'beatloop_'+looplens[i]+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//loophalve loopdouble
NK2.Controls[NK2.leftButton["trdown"]]["M"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.loopminus();', "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["trup"]]["M"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.loopplus();', "releaseEval":false, "LEDstateType":"off"};
//reloop exit
NK2.Controls[NK2.leftButton["stop"]]["M"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.reloopButton(value);', "releaseEval":'NK2.reloopButton(value);', "LEDstateType":"hook", "LEDhookControl":'loop_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
//loopin loopout
NK2.Controls[NK2.leftButton["rev"]]["M"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.loopin(value);', "releaseEval":'NK2.loopin(value);', "LEDstateType":"hook", "LEDhookControl":'loop_start_position', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["ff"]]["M"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.loopout(value);', "releaseEval":'NK2.loopout(value);', "LEDstateType":"hook", "LEDhookControl":'loop_end_position', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
//R mode with cycle - loops and beatjumps
var looplens={1:.125, 2:.25, 3:.5, 4:1, 5:2, 6:4, 7:8, 8:16}//array of loop and beatjump lengths
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["R"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.beatjump('+looplens[i]+');', "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.Mbutton[i]]["R"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.beatlooproll('+looplens[i]+', value);', "releaseEval":'NK2.beatlooproll('+looplens[i]+', value);', "LEDstateType":"hook", "LEDhookControl":'beatloop_'+looplens[i]+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["R"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.beatloop('+looplens[i]+', value);', "releaseEval":'NK2.beatloop('+looplens[i]+', value);', "LEDstateType":"hook", "LEDhookControl":'beatloop_'+looplens[i]+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//loophalve loopdouble
NK2.Controls[NK2.leftButton["trdown"]]["R"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.loopminus();', "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.leftButton["trup"]]["R"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.loopplus();', "releaseEval":false, "LEDstateType":"off"};
//reloop exit
NK2.Controls[NK2.leftButton["stop"]]["R"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.reloopButton(value);', "releaseEval":'NK2.reloopButton(value);', "LEDstateType":"hook", "LEDhookControl":'loop_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
//loopin loopout
NK2.Controls[NK2.leftButton["rev"]]["R"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.loopin(value);', "releaseEval":'NK2.loopin(value);', "LEDstateType":"hook", "LEDhookControl":'loop_start_position', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.leftButton["ff"]]["R"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.loopout(value);', "releaseEval":'NK2.loopout(value);', "LEDstateType":"hook", "LEDhookControl":'loop_end_position', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
//R mode with cycle - shorter loops and beatjumps
var shortlooplens={1:0.03125, 2:0.0625, 3:0.125, 4:0.25, 5:0.5, 6:1, 7:2, 8:4};//array of shorter loop and beatjump lengths
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["R"][NK2.MODcodes["1000"]]={"isset":true, "pressEval":'NK2.beatjump('+shortlooplens[i]+');', "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.Mbutton[i]]["R"][NK2.MODcodes["1000"]]={"isset":true, "pressEval":'NK2.beatlooproll('+shortlooplens[i]+', value);', "releaseEval":'NK2.beatlooproll('+shortlooplens[i]+', value);', "LEDstateType":"hook", "LEDhookControl":'beatloop_'+shortlooplens[i]+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["R"][NK2.MODcodes["1000"]]={"isset":true, "pressEval":'NK2.beatloop('+shortlooplens[i]+', value);', "releaseEval":'NK2.beatloop('+shortlooplens[i]+', value);', "LEDstateType":"hook", "LEDhookControl":'beatloop_'+shortlooplens[i]+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//R mode - Jump to Hotcue and start loop (with MOD1) hotcues 1-24
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["R"][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.cueLoop('+i+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+i+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[i]]["R"][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.cueLoop('+(i+8)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+8)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["R"][NK2.MODcodes["0010"]]={"isset":true, "pressEval":'NK2.cueLoop('+(i+16)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+16)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//R mode, with cycle toggled on - Jump to Hotcue and start loop (with MOD1) hotcues 9-32
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["R"][NK2.MODcodes["1010"]]={"isset":true, "pressEval":'NK2.cueLoop('+(i+8)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+8)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[i]]["R"][NK2.MODcodes["1010"]]={"isset":true, "pressEval":'NK2.cueLoop('+(i+16)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+16)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["R"][NK2.MODcodes["1010"]]={"isset":true, "pressEval":'NK2.cueLoop('+(i+24)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+24)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//R mode, with MOD2 - save current loop inpoint as hotcue 1-24
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["R"][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.saveLoop('+i+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+i+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[i]]["R"][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.saveLoop('+(i+8)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+8)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["R"][NK2.MODcodes["0001"]]={"isset":true, "pressEval":'NK2.saveLoop('+(i+16)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+16)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//M mode, with cycle and MOD2 - save current loop inpoint as hotcue 9-32
for (var i=1;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["R"][NK2.MODcodes["1001"]]={"isset":true, "pressEval":'NK2.saveLoop('+(i+8)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+8)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[i]]["R"][NK2.MODcodes["1001"]]={"isset":true, "pressEval":'NK2.saveLoop('+(i+16)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+16)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[i]]["R"][NK2.MODcodes["1001"]]={"isset":true, "pressEval":'NK2.saveLoop('+(i+24)+');', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'hotcue_'+(i+24)+'_enabled', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":"default"};
};
//S mode - vumeters and beat indicator
NK2.Controls[NK2.Sbutton[1]]["S"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":false, "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'VuMeterL', "LEDhookFunction":'NK2.vuMeterL', "LEDhookGroup":"default"};
NK2.Controls[NK2.Mbutton[1]]["S"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":false, "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'VuMeterR', "LEDhookFunction":'NK2.vuMeterR', "LEDhookGroup":"default"};
NK2.Controls[NK2.Rbutton[1]]["S"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":false, "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'beat_active', "LEDhookFunction":'NK2.beatIndicatorRow', "LEDhookGroup":"default"};
for (var i=2;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["S"][NK2.MODcodes["1000"]]={"isset":true, "pressEval":false, "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.Mbutton[i]]["S"][NK2.MODcodes["1000"]]={"isset":true, "pressEval":false, "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.Rbutton[i]]["S"][NK2.MODcodes["1000"]]={"isset":true, "pressEval":false, "releaseEval":false, "LEDstateType":"off"};
};
//master VU meter -
NK2.Controls[NK2.Sbutton[1]]["N"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":false, "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'VuMeterL', "LEDhookFunction":'NK2.vuMeterL', "LEDhookGroup":"[Master]"};
NK2.Controls[NK2.Mbutton[1]]["N"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[1]+'", "bpm_tap");', "releaseEval":false, "LEDstateType":"hook", "LEDhookControl":'VuMeterR', "LEDhookFunction":'NK2.vuMeterR', "LEDhookGroup":"[Master]"};
for (var i=2;i<9;i++){
NK2.Controls[NK2.Sbutton[i]]["N"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":false, "releaseEval":false, "LEDstateType":"off"};
NK2.Controls[NK2.Mbutton[i]]["N"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "bpm_tap");', "releaseEval":false, "LEDstateType":"off"};
};
//BPM TAP for each track - MOD1 and MOD2 - N mode
for (var i=1;i<9;i++){
NK2.Controls[NK2.Rbutton[i]]["N"][NK2.MODcodes["0011"]]={"isset":true, "pressEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "beatsync");', "releaseEval":'NK2.binControlPress("'+NK2.Deck[i]+'", "beatsync");', "LEDstateType":"hook", "LEDhookControl":'beat_active', "LEDhookFunction":'NK2.binaryHookLEDs', "LEDhookGroup":NK2.Deck[i]};
};
//############# KNOBS
//N mode
NK2.Controls[NK2.Knob[1]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.wavezoomAll(value);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[2]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.logKnobAdjust("[Master]", "headVolume", value, 0, 5);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[3]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.knobAdjust("[Master]", "headMix", value, -1, 1);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[4]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.knobAdjust("[Master]", "balance", value, -1, 1);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[5]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.logKnobAdjust("[Master]", "volume", value, 0, 5);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[6]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.knobAdjust("[Flanger]", "lfoPeriod", value, 50000, 2000000);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[7]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.knobAdjust("[Flanger]", "lfoDepth", value, 0, 1);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[8]]["N"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.knobAdjust("[Flanger]", "lfoDelay", value, 50, 10000);', "LEDstateType":"off"};
//SMR MODES
for (var j=1;j<4;j++){
NK2.Controls[NK2.Knob[1]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.wavezoomDeck(value, "default");', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[2]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.logKnobAdjust("default", "filterLow", value, 0, 4);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[3]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.logKnobAdjust("default", "filterMid", value, 0, 4);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[4]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.logKnobAdjust("default", "filterHigh", value, 0, 4);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[5]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.logKnobAdjust("default", "pregain", value, 0, 4);', "LEDstateType":"off"};
NK2.Controls[NK2.Knob[6]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.knobAdjust("default", "rate", value, -1, 1);', "LEDstateType":"off"};
//NK2.Controls[NK2.Knob[7]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.knobAdjust("default", "");', "LEDstateType":"off"};
//NK2.Controls[NK2.Knob[8]][NK2.Banks[j]][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.knobAdjust("default", "");', "LEDstateType":"off"};
}
//R mode - loop dial
NK2.Controls[NK2.Knob[8]]["R"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.loopDial(value, "default");', "LEDstateType":"off"};
//M mode - loop dial
NK2.Controls[NK2.Knob[8]]["M"][NK2.MODcodes["0000"]]={"isset":true, "pressEval":'NK2.loopDial(value, "default");', "LEDstateType":"off"};
};//end setup function
/*
NOTES:
*
*/
|