/usr/share/mixxx/controllers/EKS-Otus.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 | //
// EKS Otus HID controller script v1.0
// Copyright (C) 2012, Sean M. Pappalardo, Ilkka Tuohela
// but feel free to tweak this to your heart's content!
// For Mixxx version 1.11.x
//
// EKS Otus HID interface specification
function EKSOtusController() {
this.controller = new HIDController();
// Initialized to firmware version by version response packet
this.version_major = undefined;
this.version_minor = undefined;
this.controller.activeDeck = 1;
this.controller.LEDColors = { off: 0x0, red: 0x0f, green: 0xf0, amber: 0xff };
this.controller.deckOutputColors = { 1: "red", 2: "green", 3: "red", 4: "green"};
// Static variables for HID specs
this.wheelLEDCount = 60;
this.buttonLEDCount = 22;
this.sliderLEDCount = 20;
this.registerInputPackets = function() {
var packet = undefined;
var name = undefined;
var offset = 0;
packet = new HIDPacket("control",[0x0,0x35],64);
packet.addControl("hid","wheel_position",2,"H");
packet.addControl("hid","wheel_speed",4,"h");
packet.addControl("hid","timestamp",6,"I");
packet.addControl("hid","slider_value",10,"H");
packet.addControl("hid","slider_position",12,"H");
packet.addControl("hid","rate_encoder",14,"B",undefined,true);
packet.addControl("hid","jog_se",15,"B",undefined,true);
packet.addControl("hid","jog_sw",16,"B",undefined,true);
packet.addControl("hid","rate_encoder",17,"B",undefined,true);
packet.addControl("hid","gain_1",18,"H");
packet.addControl("hid","gain_2",20,"H");
packet.addControl("hid","eq_high_1",22,"H");
packet.addControl("hid","eq_high_2",24,"H");
packet.addControl("hid","eq_mid_1",26,"H");
packet.addControl("hid","eq_mid_2",28,"H");
packet.addControl("hid","eq_low_1",30,"H");
packet.addControl("hid","eq_low_2",32,"H");
packet.addControl("hid","crossfader",34,"H");
packet.addControl("hid","headphones",36,"H");
packet.addControl("hid","trackpad_x",38,"H");
packet.addControl("hid","trackpad_y",40,"H");
packet.addControl("hid","slider_pos_2",42,"H");
packet.addControl("hid","slider_pos_1",44,"H");
packet.addControl("hid","keylock",46,"I",0x1);
packet.addControl("hid","beatloop_8",46,"I",0x2);
packet.addControl("hid","beatloop_4",46,"I",0x4);
packet.addControl("hid","beatloop_2",46,"I",0x8);
packet.addControl("hid","beatloop_1",46,"I",0x10);
packet.addControl("hid","loop_in",46,"I",0x20);
packet.addControl("hid","loop_out",46,"I",0x40);
packet.addControl("hid","reloop_exit",46,"I",0x80);
packet.addControl("hid","slider_scale",46,"I",0x100);
packet.addControl("hid","jog_se_button",46,"I",0x200);
packet.addControl("hid","eject_right",46,"I",0x400);
packet.addControl("hid","deck_switch",46,"I",0x800);
packet.addControl("hid","eject_left",46,"I",0x1000);
packet.addControl("hid","jog_sw_button",46,"I",0x2000);
packet.addControl("hid","stop",46,"I",0x4000);
packet.addControl("hid","play",46,"I",0x8000);
packet.addControl("hid","cue",46,"I",0x10000);
packet.addControl("hid","reverse",46,"I",0x20000);
packet.addControl("hid","brake",46,"I",0x40000);
packet.addControl("hid","fastforward",46,"I",0x80000);
packet.addControl("hid","jog_nw_button",46,"I",0x100000);
packet.addControl("hid","jog_touch",46,"I",0x200000);
packet.addControl("hid","trackpad_left",46,"I",0x400000);
packet.addControl("hid","trackpad_right",46,"I",0x800000);
packet.addControl("hid","hotcue_1",46,"I",0x1000000);
packet.addControl("hid","hotcue_2",46,"I",0x2000000);
packet.addControl("hid","hotcue_3",46,"I",0x4000000);
packet.addControl("hid","hotcue_4",46,"I",0x8000000);
packet.addControl("hid","hotcue_5",46,"I",0x10000000);
packet.addControl("hid","hotcue_6",46,"I",0x20000000);
packet.addControl("hid","touch_slider",46,"I",0x40000000)
packet.addControl("hid","touch_trackpad",46,"I",0x80000000);
packet.addControl("hid","packet_number",51,"B");
packet.addControl("hid","deck_status",52,"B");
this.controller.registerInputPacket(packet);
packet = new HIDPacket("firmware_version",[0xa,0x4],64);
packet.addControl("hid","major",2,"B");
packet.addControl("hid","minor",3,"B");
this.controller.registerInputPacket(packet);
packet = new HIDPacket("trackpad_mode",[0x5,0x3],64);
packet.addControl("hid","status",2,"B");
this.controller.registerInputPacket(packet);
}
this.registerOutputPackets = function() {
var packet = undefined;
var name = undefined;
var offset = 0;
packet = new HIDPacket("button_leds",[0x16,0x18],32);
offset = 2;
packet.addOutput("hid","jog_nw",offset++,"B");
packet.addOutput("hid","jog_ne",offset++,"B");
packet.addOutput("hid","jog_se",offset++,"B");
packet.addOutput("hid","jog_sw",offset++,"B");
packet.addOutput("hid","beatloop_8",offset++,"B");
packet.addOutput("hid","beatloop_4",offset++,"B");
packet.addOutput("hid","beatloop_2",offset++,"B");
packet.addOutput("hid","beatloop_1",offset++,"B");
packet.addOutput("hid","loop_in",offset++,"B");
packet.addOutput("hid","loop_out",offset++,"B");
packet.addOutput("hid","reloop_exit",offset++,"B");
packet.addOutput("hid","eject_right",offset++,"B");
packet.addOutput("hid","deck_switch",offset++,"B");
packet.addOutput("hid","trackpad_right",offset++,"B");
packet.addOutput("hid","trackpad_left",offset++,"B");
packet.addOutput("hid","eject_left",offset++,"B");
packet.addOutput("hid","stop",offset++,"B");
packet.addOutput("hid","play",offset++,"B");
packet.addOutput("hid","reverse",offset++,"B");
packet.addOutput("hid","cue",offset++,"B");
packet.addOutput("hid","brake",offset++,"B");
packet.addOutput("hid","fastforward",offset++,"B");
this.controller.registerOutputPacket(packet);
packet = new HIDPacket("slider_leds",[0x17,0x16],32);
offset = 2;
packet.addOutput("pitch","slider_1",offset++,"B");
packet.addOutput("pitch","slider_2",offset++,"B");
packet.addOutput("pitch","slider_3",offset++,"B");
packet.addOutput("pitch","slider_4",offset++,"B");
packet.addOutput("pitch","slider_5",offset++,"B");
packet.addOutput("pitch","slider_6",offset++,"B");
packet.addOutput("pitch","slider_7",offset++,"B");
packet.addOutput("pitch","slider_8",offset++,"B");
packet.addOutput("pitch","slider_9",offset++,"B");
packet.addOutput("pitch","slider_10",offset++,"B");
packet.addOutput("pitch","slider_11",offset++,"B");
packet.addOutput("pitch","slider_12",offset++,"B");
packet.addOutput("pitch","slider_13",offset++,"B");
packet.addOutput("pitch","slider_14",offset++,"B");
packet.addOutput("pitch","slider_15",offset++,"B");
packet.addOutput("pitch","slider_16",offset++,"B");
packet.addOutput("pitch","slider_17",offset++,"B");
packet.addOutput("pitch","slider_scale_1",offset++,"B");
packet.addOutput("pitch","slider_scale_2",offset++,"B");
packet.addOutput("pitch","slider_scale_3",offset++,"B");
this.controller.registerOutputPacket(packet);
packet = new HIDPacket("led_wheel_left",[0x14,0x20],32);
offset = 2;
for (var led_index=1;led_index<=this.wheelLEDCount/2;led_index++)
packet.addOutput("hid","wheel_" + led_index,offset++,"B");
this.controller.registerOutputPacket(packet);
packet = new HIDPacket("led_wheel_right",[0x15,0x20],32);
offset = 2;
for (var led_index=this.wheelLEDCount/2+1;led_index<=this.wheelLEDCount;led_index++)
packet.addOutput("hid","wheel_" + led_index,offset++,"B");
this.controller.registerOutputPacket(packet);
packet = new HIDPacket("request_firmware_version",[0xa,0x2],32);
this.controller.registerOutputPacket(packet);
packet = new HIDPacket("set_trackpad_mode",[0x5,0x3],32);
packet.addControl("hid","mode",2,"B");
this.controller.registerOutputPacket(packet);
packet = new HIDPacket("set_ledcontrol_mode",[0x1d,0x3],32);
packet.addControl("hid","mode",2,"B");
this.controller.registerOutputPacket(packet);
}
// Otus specific output packet to request device firmware version
this.requestFirmwareVersion = function() {
var packet = this.controller.getOutputPacket("request_firmware_version");
if (packet==undefined)
return;
HIDDebug("Requesting firmware version " + packet.name);
packet.send();
}
// Set LED Control Mode on Otus firmware versions > 1.6. Major and minor must
// contain the version numbers for firmware as received from response.
// Valid modes are:
// 0 disable all LEDs
// 1 Re-enable LEDs
// 2 Revert to built-in light functionality
this.setLEDControlMode = function(mode) {
var controller = this.controller;
if (this.version_major<=1 && this.version_minor<6) {
// Firmware version does not support LED Control Mode Setting
return;
}
if (mode!=0 && mode!=1 && mode!=2) {
HIDDebug("Unknown value for LED Control Mode Setting: " + mode);
return;
}
var packet = controller.getOutputPacket("set_ledcontrol_mode");
var field = packet.getField("hid","mode");
if (field==undefined) {
HIDDebug("EksOtus.setLEDControlMode error fetching field mode");
return;
}
field.value = mode;
packet.send();
}
// Firmware version response. Required to finish device INIT
this.FirmwareVersionResponse = function(packet,delta) {
var controller = this.controller;
var field_major = packet.getField("hid","major");
var field_minor = packet.getField("hid","minor");
if (field_major==undefined || field_minor==undefined) {
HIDDebug("Error parsing response version packet");
return;
}
this.version_major = field_major.value;
this.version_minor = field_minor.value;
controller.initialized = true;
this.setLEDControlMode(1);
if (controller.activeDeck!=undefined) {
controller.setOutput("hid","deck_switch", controller.LEDColors[controller.deckOutputColors[controller.activeDeck]]);
controller.switchDeck(controller.activeDeck);
} else {
var value = controller.LEDColors["amber"];
this.controller.setOutputToggle("hid","deck_switch",value);
}
this.updateLEDs();
HIDDebug("EKS " + EksOtus.id +
" v"+EksOtus.version_major+"."+EksOtus.version_minor+
" initialized"
);
}
// Otus specific output packet to set the trackpad control mode
this.setTrackpadMode = function(mode) {
if (mode!=0 && mode!=1) {
HIDDebug("Unsupported trackpad mode value: " + mode);
return;
}
var packet = this.controller.getOutputPacket("set_trackpad_mode");
if (packet==undefined) {
HIDDebug("Output not registered: set_trackpad_mode");
return;
}
var field = packet.getField("hid","mode");
if (field==undefined) {
HIDDebug("EksOtus.setTrackpadMode error fetching field mode");
return;
}
field.value = mode;
packet.send();
}
// Response to above trackpad mode packet
this.TrackpadModeResponse = function(packet,delta) {
field = packet.getField("hid","status");
if (field==undefined) {
HIDDebug("Error parsing field status from packet");
return;
}
if (field.value==1) {
HIDDebug("Trackpad mode successfully set");
} else {
HIDDebug("Trackpad mode change failed");
}
}
// Generic unsigned short to -1..0..1 range scaling
this.plusMinus1Scaler = function(group,name,value) {
if (value<32768)
return value/32768-1;
else
return (value-32768)/32768;
}
// Volume slider scaling for 0..1..5 scaling
this,volumeScaler = function(group,name,value) {
return script.absoluteNonLin(value, 0, 1, 5, 0, 65536);
}
// EQ scaling function for 0..1..4 scaling
this.eqScaler = function(group,name,value) {
return script.absoluteNonLin(value, 0, 1, 4, 0, 65536);
}
// Mandatory call from init() to initialize hardware
this.initializeHIDController = function() {
this.registerInputPackets();
this.registerOutputPackets();
}
this.shutdownHardware = function() {
this.setLEDControlMode(2);
this.setTrackpadMode(1);
}
}
EksOtus = new EKSOtusController();
// Initialize device state, send request for firmware. Otus is not
// usable before we receive a valid firmware version response.
EksOtus.init = function (id) {
EksOtus.id = id;
EksOtus.LEDUpdateInterval = 250;
// Valid values: 1 for mouse mode, 0 for xy-pad mode
EksOtus.trackpadMode = 0;
EksOtus.deckSwitchClicked = false;
// Wheel absolute position value
EksOtus.wheelPosition = undefined;
// Wheel spin animation details
EksOtus.activeTrackDuration = undefined;
// Group registered to update spinning platter details
EksOtus.activeSpinningPlatterGroup = undefined;
// Virtual record spin time, 1.8 for 33 1/3 RPM, 1.33 for 45 RPM
EksOtus.revTime = 1.8;
// Wheel LED index, range 1-60
EksOtus.activeSpinningPlatterLED = undefined;
// Call the HID packet parser initializers
EksOtus.initializeHIDController();
var controller = EksOtus.controller;
// Set callbacks for packets here to avoid issues in callback handling
controller.setPacketCallback("firmware_version",EksOtus.FirmwareVersionWrapper);
controller.setPacketCallback("trackpad_mode",EksOtus.TrackpadModeWrapper);
controller.ignoredControlChanges = [
"mask","timestamp","packet_number","deck_status", "wheel_speed",
// These return the Otus slider position scaled by the 'slider scale'
"slider_pos_1","slider_pos_2", "slider_value"
];
// Scratch parameters
controller.scratchintervalsPerRev = 1024;
controller.scratchAlpha = 1.0/8;
controller.rampedScratchEnable = true;
EksOtus.setTrackpadMode(this.trackpadMode);
// Note: Otus is not considered initialized before we get
// response to this packet
EksOtus.requestFirmwareVersion();
// Link controls and register callbacks
EksOtus.registerCallbacks();
engine.softTakeover("[Master]","headVolume",true);
engine.softTakeover("[Master]","headMix",true);
for (var deck in controller.deckOutputColors) {
engine.softTakeover("[Channel"+deck+"]","pregain",true);
engine.softTakeover("[Channel"+deck+"]","volume",true);
}
if (EksOtus.LEDUpdateInterval!=undefined) {
controller.timers["led_update"] = engine.beginTimer(
EksOtus.LEDUpdateInterval,
"EksOtus.updateLEDs(true)"
);
}
}
EksOtus.outputCallback = function(value,group,key) {
var controller = EksOtus.controller;
if (group=="deck") {
if (controller.activeDeck==undefined)
return;
group = controller.resolveGroup("deck");
}
if (value==1)
EksOtus.controller.setOutput("deck",key,
controller.LEDColors[controller.deckOutputColors[controller.activeDeck]],
true
);
else
EksOtus.controller.setOutput("deck",key,controller.LEDColors.off,true);
}
EksOtus.updateLEDs = function(from_timer) {
var controller = EksOtus.controller;
controller.getOutputPacket("button_leds").send();
controller.getOutputPacket("slider_leds").send();
controller.getOutputPacket("led_wheel_left").send();
controller.getOutputPacket("led_wheel_right").send();
}
// Device cleanup function
EksOtus.shutdown = function() {
engine.softTakeover("[Master]","headVolume",false);
engine.softTakeover("[Master]","headMix",false);
for (var deck in controller.deckOutputColors) {
engine.softTakeover("[Channel"+deck+"]","pregain",false);
engine.softTakeover("[Channel"+deck+"]","volume",false);
}
EksOtus.shutdownHardware(2);
HIDDebug("EKS "+EksOtus.id+" shut down");
}
// Mandatory default handler for incoming packets
EksOtus.incomingData = function(data,length) {
EksOtus.controller.parsePacket(data,length);
}
EksOtus.FirmwareVersionWrapper = function(packet,data) {
return EksOtus.FirmwareVersionResponse(packet,data);
}
EksOtus.TrackpadModeWrapper = function(packet,data) {
return EksOtus.TrackpadModeResponse(packet,data);
}
// Callback to set current loaded track's duration for wheel led animation
EksOtus.loadedTrackDuration = function(value) {
EksOtus.activeTrackDuration = value;
}
// Link virtual HID naming of input and LED controls to mixxx
// Note: HID specification has more fields than we map here.
EksOtus.registerCallbacks = function() {
var controller = EksOtus.controller;
controller.linkModifier("hid","eject_right","shift");
controller.linkModifier("hid","touch_slider","pitch");
controller.linkControl("hid","play","deck","play");
controller.linkControl("hid","cue","deck","cue_default");
controller.linkControl("hid","reverse","deck","reverse");
controller.linkControl("hid","eject_left","deck","pfl");
controller.linkControl("hid","jog_touch","deck","jog_touch");
controller.linkControl("hid","wheel_position","deck","jog_wheel");
controller.linkControl("hid","jog_se_button","deck","LoadSelectedTrack");
controller.linkControl("hid","jog_se","[Playlist]","SelectTrackKnob");
controller.linkControl("hid","crossfader","[Master]","crossfader");
controller.linkControl("hid","gain_1","deck1","pregain");
controller.linkControl("hid","gain_2","deck2","pregain");
controller.linkControl("hid","eq_high_1","deck1","filterHigh");
controller.linkControl("hid","eq_high_2","deck2","filterHigh");
controller.linkControl("hid","eq_mid_1","deck1","filterMid");
controller.linkControl("hid","eq_mid_2","deck2","filterMid");
controller.linkControl("hid","eq_low_1","deck1","filterLow");
controller.linkControl("hid","eq_low_2","deck2","filterLow");
controller.setScaler("jog",EksOtus.jogScaler);
controller.setScaler("jog_scratch",EksOtus.wheelScaler);
controller.setScaler("crossfader",EksOtus.plusMinus1Scaler);
controller.setScaler("pregain",EksOtus.eqScaler);
controller.setScaler("filterHigh",EksOtus.eqScaler);
controller.setScaler("filterMid",EksOtus.eqScaler);
controller.setScaler("filterLow",EksOtus.eqScaler);
controller.setCallback("control","hid","hotcue_1",EksOtus.hotcue);
controller.setCallback("control","hid","hotcue_2",EksOtus.hotcue);
controller.setCallback("control","hid","hotcue_3",EksOtus.hotcue);
controller.setCallback("control","hid","hotcue_4",EksOtus.hotcue);
controller.setCallback("control","hid","hotcue_5",EksOtus.hotcue);
controller.setCallback("control","hid","hotcue_6",EksOtus.hotcue);
controller.setCallback("control","hid","beatloop_1",EksOtus.beatloop);
controller.setCallback("control","hid","beatloop_2",EksOtus.beatloop);
controller.setCallback("control","hid","beatloop_4",EksOtus.beatloop);
controller.setCallback("control","hid","beatloop_8",EksOtus.beatloop);
controller.linkControl("hid","loop_in","deck","loop_in");
controller.linkControl("hid","loop_out","deck","loop_out");
controller.linkControl("hid","reloop_exit","deck","reloop_exit");
controller.setCallback("control","hid","deck_switch",EksOtus.deckSwitch);
//controller.linkControl("hid","headphones","[Master]","headphones");
controller.setCallback("control","hid","headphones",EksOtus.headphones);
controller.setCallback("control","hid","slider_scale",EksOtus.pitchSlider);
controller.setCallback("control","hid","slider_value",EksOtus.pitchSlider);
controller.setCallback("control","hid","slider_position",EksOtus.pitchSlider);
controller.setCallback("control","hid","slider_pos_1",EksOtus.pitchSlider);
controller.setCallback("control","hid","slider_pos_2",EksOtus.pitchSlider);
controller.linkOutput("hid","beatloop_8","deck","beatloop_8_enabled",EksOtus.outputCallback);
controller.linkOutput("hid","beatloop_4","deck","beatloop_4_enabled",EksOtus.outputCallback);
controller.linkOutput("hid","beatloop_2","deck","beatloop_2_enabled",EksOtus.outputCallback);
controller.linkOutput("hid","beatloop_1","deck","beatloop_1_enabled",EksOtus.outputCallback);
controller.linkOutput("hid","loop_in","deck","loop_in",EksOtus.outputCallback);
controller.linkOutput("hid","loop_out","deck","loop_out",EksOtus.outputCallback);
controller.linkOutput("hid","reloop_exit","deck","reloop_exit",EksOtus.outputCallback);
controller.linkOutput("hid","eject_left","deck","pfl",EksOtus.outputCallback);
controller.linkOutput("hid","play","deck","play",EksOtus.outputCallback);
controller.linkOutput("hid","reverse","deck","reverse",EksOtus.outputCallback);
controller.linkOutput("hid","cue","deck","cue_default",EksOtus.outputCallback);
}
// Default scaler for jog values
EksOtus.wheelScaler = function(group,name,value) {
if (EksOtus.wheelPosition==undefined) {
EksOtus.wheelPosition = value;
return 0;
}
var delta = EksOtus.wheelPosition - value;
if (delta>32768)
return 0;
EksOtus.wheelPosition = value;
if (delta>-8 && delta<8)
return -delta/4;
return -delta/16;
}
EksOtus.jogScaler = function(group,name,value) {
if (EksOtus.wheelPosition==undefined) {
EksOtus.wheelPosition = value;
return 0;
}
var delta = EksOtus.wheelPosition - value;
if (delta>32768)
return 0;
EksOtus.wheelPosition = value;
return -delta/64;
}
// Deck rate adjustment with top corner wheels
EksOtus.rate_wheel = function(field) {
var controller = EksOtus.controller;
if (controller.activeDeck==undefined)
return;
var active_group = controller.resolveGroup(field.group);
var current = engine.getValue(active_group,"rate");
if (field.delta<0)
engine.setValue(active_group,"rate",current+0.003);
else
engine.setValue(active_group,"rate",current-0.003);
}
// Reset all wheel LEDs to given color. If color is undefined,
// use 'off'
EksOtus.resetWheelLEDs = function (color) {
var controller = EksOtus.controller;
if (color==undefined || !(color in controller.LEDColors))
color = "off";
for (i=1;i<=EksOtus.wheelLEDCount;i++)
controller.setOutput("jog","wheel_"+i,color,false);
EksOtus.updateLEDs(true);
}
// Rotation of the Otus 'corner' wheels.
// Note right bottom wheel is library browser encoder and not handled here
EksOtus.corner_wheel = function(field) {
// TODO - attach some functionality these corner wheels!
print("CORNER " + field.name + " delta " + field.delta);
}
// Hotcues activated with normal press, cleared with shift
EksOtus.hotcue = function (field) {
var controller = EksOtus.controller;
var command;
if (controller.activeDeck==undefined ||
field.value==controller.buttonStates.released)
return;
var active_group = controller.resolveDeckGroup(controller.activeDeck);
if (controller.modifiers.get("shift"))
command = field.name + "_clear";
else
command = field.name + "_activate";
engine.setValue(active_group,command,true);
}
// Beatloops activated with normal presses to beatloop_1 - beatloop_8
EksOtus.beatloop = function (field) {
var controller = EksOtus.controller;
var command;
if (controller.activeDeck==undefined ||
field.value==controller.buttonStates.released)
return;
var active_group = controller.resolveDeckGroup(controller.activeDeck);
command = field.name + "_activate";
engine.setValue(active_group,command,true);
}
EksOtus.beat_align = function (field) {
var controller = EksOtus.controller;
if (controller.activeDeck==undefined)
return;
var active_group = controller.resolveGroup(field.group);
if (controller.modifiers.get("shift")) {
// if (field.value==controller.buttonStates.released) return;
engine.setValue(active_group,"beats_translate_curpos",field.value);
} else {
if (field.value==controller.buttonStates.released)
return;
if (!engine.getValue(active_group,"quantize"))
engine.setValue(active_group,"quantize",true);
else
engine.setValue(active_group,"quantize",false);
}
}
// Pitch slider modifies track speed directly
EksOtus.pitchSlider = function (field) {
var controller = EksOtus.controller;
if (controller.activeDeck==undefined)
return;
if (controller.modifiers.get("pitch")) {
var active_group = controller.resolveDeckGroup(controller.activeDeck);
if (field.name=="slider_position") {
if (field.value==0)
return;
var value = EksOtus.plusMinus1Scaler(
active_group,field.name,field.value
);
engine.setValue(active_group,"rate",value);
}
}
}
// Set pregain, if modifier shift is active, deck volume otherwise
EksOtus.volume_pregain = function (field) {
var controller = EksOtus.controller;
if (controller.activeDeck==undefined)
return;
var active_group = controller.resolveGroup(field.group);
if (controller.modifiers.get("shift")) {
value = script.absoluteNonLin(field.value, 0, 1, 5, 0, 65536);
engine.setValue(active_group,"pregain",value);
} else {
value = field.value / 65536;
engine.setValue(active_group,"volume",value);
}
}
// Set headphones volume, if modifier shift is active, pre/main mix otherwise
EksOtus.headphones = function (field) {
var controller = EksOtus.controller;
if (controller.modifiers.get("shift")) {
value = script.absoluteNonLin(field.value, 0, 1, 5, 0, 65536);
engine.setValue("[Master]","headVolume",value);
} else {
value = EksOtus.plusMinus1Scaler(field.group,field.name,field.value);
engine.setValue("[Master]","headMix",value);
}
}
// Control effects or somethig with XY pad
EksOtus.xypad = function(field) {
var controller = EksOtus.controller;
if (controller.activeDeck==undefined)
return;
print ("XYPAD group " + field.group +
" name " + field.name + " value " + field.value
);
}
// Function called when the special 'Deck Switch' button is pressed
// TODO - add code for 'hold deck_switch and press hot_cue[1-4]
// to select deck 1-4
EksOtus.deckSwitch = function(field) {
var controller = EksOtus.controller;
if (EksOtus.initialized==false)
return;
if (field.value == controller.buttonStates.released) {
if (EksOtus.deckSwitchClicked==false) {
EksOtus.deckSwitchClicked=true;
controller.timers["deck_switch"] = engine.beginTimer(
250,"EksOtus.deckSwitchClickedClear()"
);
} else {
EksOtus.deckSwitchDoubleClick();
}
}
}
// Timer to clear the double click status for deck switch
EksOtus.deckSwitchClickedClear = function() {
EksOtus.deckSwitchClicked = false;
var controller = EksOtus.controller;
if (controller.timers["deck_switch"]!=undefined) {
engine.stopTimer(controller.timers["deck_switch"]);
delete controller.timers["deck_switch"];
}
}
// Function to handle case when 'deck_switch' button was double clicked
EksOtus.deckSwitchDoubleClick = function() {
var controller = EksOtus.controller;
EksOtus.deckSwitchClicked = false;
if (controller.timers["deck_switch"]!=undefined) {
engine.stopTimer(controller.timers["deck_switch"]);
delete controller.timers["deck_switch"];
}
controller.switchDeck();
controller.setOutput("hid","deck_switch", controller.LEDColors[controller.deckOutputColors[controller.activeDeck]]);
EksOtus.updateLEDs();
HIDDebug("Active EKS Otus deck now " + controller.activeDeck);
}
// Switch the visual LED feedback on platter LEDs to active deck
// NOTE this is now disabled, it causes HID input errors in firmware!
EksOtus.activateSpinningPlatterLEDs = function() {
var controller = EksOtus.controller;
var active_group = controller.resolveDeckGroup(controller.activeDeck);
if (active_group==undefined)
return;
if (!(controller.activeDeck in controller.deckOutputColors)) {
HIDDebug("LED color not mapped to deck " % controller.activeDeck);
return;
}
if (active_group==undefined) {
EksOtus.disableSpinningPlatterLEDs();
return;
}
if (EksOtus.activeSpinningPlatterGroup !=undefined) {
EksOtus.disableSpinningPlatterLEDs();
}
EksOtus.activeSpinningPlatterGroup = active_group;
EksOtus.loadedTrackDuration(engine.getValue(active_group,"duration"));
EksOtus.enableSpinningPlatterLEDs();
}
// Enable spinning platter LED functionality for active virtual deck
EksOtus.enableSpinningPlatterLEDs = function() {
if (EksOtus.activeSpinningPlatterGroup==undefined)
return;
engine.connectControl(
EksOtus.activeSpinningPlatterGroup,
"visual_playposition",
"EksOtus.circleLEDs"
);
engine.connectControl(
EksOtus.activeSpinningPlatterGroup,
"duration",
"EksOtus.loadedTrackDuration"
)
EksOtus.resetWheelLEDs("off",false);
}
// Disable spinning platter LED functionality for active virtual deck
EksOtus.disableSpinningPlatterLEDs = function() {
if (EksOtus.activeSpinningPlatterGroup==undefined)
return;
engine.connectControl(
EksOtus.activeSpinningPlatterGroup,
"visual_playposition",
"EksOtus.circleLEDs",
true
);
engine.connectControl(
EksOtus.activeSpinningPlatterGroup,
"duration",
"EksOtus.loadedTrackDuration",
true
)
EksOtus.resetWheelLEDs("off",false);
}
// Callback from engine to set every third LED in circling pattern according to
// the track position. Careful not to enable sending all 60 positions, it may
// cause too much HID traffic!
EksOtus.circleLEDs = function(position) {
var controller = EksOtus.controller;
if (position<0 || position>1) {
EksOtus.resetWheelLEDs("off",false);
return;
}
// Only update every third LED to save HID packet bandwidth
var wheelLEDSplit = 3;
var wheelLEDGroups = EksOtus.wheelLEDCount/wheelLEDSplit;
var timeRemaining = ((1-position)*EksOtus.activeTrackDuration) | 0;
var track_pos = position * EksOtus.activeTrackDuration;
var revolutions = track_pos / EksOtus.revTime;
var led_index = (((revolutions-(revolutions|0))*wheelLEDGroups)|0)*wheelLEDSplit;
led_index++;
if (led_index==EksOtus.activeSpinningPlatterLED)
return;
EksOtus.activeSpinningPlatterLED = led_index;
EksOtus.resetWheelLEDs("off",false);
var led_color = controller.deckOutputColors[controller.activeDeck];
controller.setOutput("jog","wheel_"+(led_index),led_color);
EksOtus.updateLEDs();
}
|