2
// Numark Mixtrack Mapping Script Functions
4
// Matteo <matteo@magm3.com>
6
// Changes by James Ralston
10
// Remapped frequency filter keys (on regular Mixtrack) to hotcue keys 1,2,3 (on Mixtrack Pro)
11
// Mapped delete keys to clear hotque and loop (when pressing delete, then reloop)
12
// Changed jog wheel behavior when in scratch mode
13
// Added keylock (disabled on wheel touch when in scratch mode)
14
// Reworked the looping. Lights flash on errors (i.e. resize loop when no begin or end set).
15
// Reworked jog wheel behavior (stop on wheel touch in scratch mode)
1
// Based on Numark Mixtrack Mapping Script Functions
2
// 1/11/2010 - v0.1 - Matteo <matteo@magm3.com>
4
// 5/18/2011 - Changed by James Ralston
18
7
// Mixxx complains about an undefined variable on 1st load of the mapping (ignore it, then restart Mixxx)
19
8
// Each slide/knob needs to be moved on Mixxx startup to match levels with the Mixxx UI
23
// Changes by DarĆo JosĆ© Freije
27
// The CUE button is always with light on (for darkest places). It blink on Press.
28
// Added: Don't set Cue accidentaly at the end of the song (return to the lastest cue)
31
// Modify sensibility of the wheels in Scratch mode (lower now).
32
// In Scratch mode: with the Touch surface of the wheels: Scratch.
33
// With the edge of jog wheel: tempo Bend (like in Not Scratch mode)
35
// Stutter -> Adjust BeatGrid:
36
// The Stutter Button work now to set the beatgrid in the correct place (usefull to sync well)
39
// The 3rd knob of the "effect" section, is now "Gain" (pre-gain, very usefull for me)
41
// Pitch: Up, Up; Down, Down.
42
// The Pitch slide are now inverted, to match with the screen.
43
// Up in the controller -> Up in the Screen (+) (otherwise is very confusing to me)
46
// I'm very bad with Manual Loop, always use Auto Loop, so now the light of the button Manual is ON in the Auto mode.
47
// In auto mode, now the "1 Bar" button active an instant 4 beat Loop and turn On the Light.
48
// The 1/2 and x2 buttons works like before. To exit the Loop switch to "Manual" mode and press "Reloop" (like before).
55
// Moved to script for can have the Soft-takeover functionality
56
// "To prevent sudden wide parameter changes when the on-screen control diverges from a hardware control, use soft-takeover.
57
// While it's active on a particular parameter, manipulating the control on the hardware will have no effect until the position
58
// of the hardware control is close to that of the software, at which point it will take over and operate as usual."
61
// in the light of SYNC button
64
// Blink only on Press (not in release)
10
// 05/26/2012 to 06/27/2012 - Changed by DarĆo JosĆ© Freije <dario2004@gmail.com>
12
// Almost all work like expected. Resume and Particularities:
14
// ************* Script now is Only for 1.11.0 and above *************
16
// Delete + Effect: Brake Effect (maintain pressed).
17
// Flanger Delay (2nd knob of effect section): Adjust the speed of Brake.
19
// Delete + Hotcues: Clear Hotcues (First press Delete, then Hotcue).
20
// Delete + Reloop: Clear Loop.
21
// Delete + Manual: Set Quantize ON (for best manual loop) or OFF.
22
// Delete + Sync: Set Pitch to Zero.
24
// Load track: Only if the track is paused. Put the pitch in 0 at load.
26
// Keylock: disabled on wheel touch when in scratch mode (make noise anyway at exit scratch).
28
// Gain: The 3rd knob of the "effect" section is "Gain" (up to clip).
30
// Effect: Flanger. 1st and 2nd knob modify Depth and Delay.
32
// Cue: Don't set Cue accidentaly at the end of the song (return to the lastest cue).
33
// LED ON when stopped. LED OFF when playing.
34
// LED Blink at Beat time in the ultimates 30 seconds of song.
36
// Stutter: Adjust BeatGrid in the correct place (usefull to sync well).
37
// LED Blink at each Beat of the grid.
39
// Sync: If the other deck is stopped, only sync tempo (not fase).
40
// LED Blink at Clip Gain (Peak indicator).
42
// Pitch: Up, Up; Down, Down. Pitch slide are inverted, to match with the screen (otherwise is very confusing).
43
// Soft-takeover to prevent sudden wide parameter changes when the on-screen control diverges from a hardware control.
44
// The control will have no effect until the position is close to that of the software,
45
// at which point it will take over and operate as usual.
47
// Auto Loop (LED ON): Active at program Start.
48
// "1 Bar" button: Active an Instant 4 beat Loop. Press again to exit loop.
51
// In Stop mode, with Scratch OFF or ON: Scratch at touch, and Stop moving when the wheel stop moving.
52
// In Play mode, with Scratch OFF: Only Pitch bend.
53
// In Play mode, with Scratch ON: Scratch at touch and, in Backwards Stop Scratch when the wheel stop moving for 20ms -> BACKSPIN EFFECT!!!!.
54
// In Fordward Stop Scratch when the touch is released > Play Inmediatly (without breaks for well mix).
55
// Border of the wheels: Pitch Bend.
146
NumarkMixTrackPro.Stutter1Beat = function (value) {
148
var secondsBlink = 30;
149
var secondsToEnd = engine.getValue("[Channel1]", "duration") * (1-engine.getValue("[Channel1]", "playposition"));
151
if (secondsToEnd < secondsBlink && secondsToEnd > 1 && engine.getValue("[Channel1]", "play")) { // The song is going to end
153
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[1]["Cue"], value);
155
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[1]["stutter"], value);
159
NumarkMixTrackPro.Stutter2Beat = function (value) {
161
var secondsBlink = 30;
162
var secondsToEnd = engine.getValue("[Channel2]", "duration") * (1-engine.getValue("[Channel2]", "playposition"));
164
if (secondsToEnd < secondsBlink && secondsToEnd > 1 && engine.getValue("[Channel2]", "play")) { // The song is going to end
166
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[2]["Cue"], value);
169
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[2]["stutter"], value);
150
173
NumarkMixTrackPro.clipLED = function (value, note) {
265
NumarkMixTrackPro.LoadTrack = function(channel, control, value, status, group) {
267
// Load the selected track in the corresponding deck only if the track is paused
269
if(value && engine.getValue(group, "play") != 1)
271
engine.setValue(group, "LoadSelectedTrack", 1);
273
// cargar el tema con el pitch en 0
274
engine.softTakeover(group, "rate", false);
275
engine.setValue(group, "rate", 0);
276
engine.softTakeover(group, "rate", true);
278
else engine.setValue(group, "LoadSelectedTrack", 0);
282
NumarkMixTrackPro.flanger = function(channel, control, value, status, group) {
284
// if (!value) return;
286
var deck = NumarkMixTrackPro.groupToDeck(group);
290
if(NumarkMixTrackPro.deleteKey[deck-1]){
292
// Delete + Effect = Brake
294
// print ("Delay: " + engine.getValue("[Flanger]","lfoDelay"));
296
if (engine.getValue("[Flanger]","lfoDelay") < 5026) {
298
speed = engine.getValue("[Flanger]","lfoDelay") / 5025;
300
if (speed < 0) speed = 0;
304
speed = (engine.getValue("[Flanger]","lfoDelay") - 5009)/ 16,586666667
306
if (speed > 300) speed = 300;
309
// print ("Speed: " + speed);
311
engine.brake(deck, value, speed);
313
if (!value) NumarkMixTrackPro.toggleDeleteKey(channel, control, 1, status, group);
317
if (engine.getValue(group, "flanger")) {
318
engine.setValue(group, "flanger", 0);
320
engine.setValue(group, "flanger", 1);
238
327
NumarkMixTrackPro.cuebutton = function(channel, control, value, status, group) {
241
330
// Don't set Cue accidentaly at the end of the song
242
if(engine.getValue(group, "playposition") <= 0.97)
244
engine.setValue(group, "cue_default", value ? 1 : 0);
245
var deck = NumarkMixTrackPro.groupToDeck(group);
246
if (value) NumarkMixTrackPro.flashLED(NumarkMixTrackPro.leds[deck]["Cue"], 4);
331
if (engine.getValue(group, "playposition") <= 0.97) {
332
engine.setValue(group, "cue_default", value ? 1 : 0);
250
334
engine.setValue(group, "cue_preview", value ? 1 : 0);
339
NumarkMixTrackPro.beatsync = function(channel, control, value, status, group) {
341
var deck = NumarkMixTrackPro.groupToDeck(group);
343
if(NumarkMixTrackPro.deleteKey[deck-1]){
345
// Delete + SYNC = vuelve pitch a 0
346
engine.softTakeover(group, "rate", false);
347
engine.setValue(group, "rate", 0);
348
engine.softTakeover(group, "rate", true);
350
NumarkMixTrackPro.toggleDeleteKey(channel, control, value, status, group);
355
// si la otra deck esta en stop, sincronizo sĆ³lo el tempo (no el golpe)
356
if(!engine.getValue("[Channel2]", "play")) {
357
engine.setValue(group, "beatsync_tempo", value ? 1 : 0);
359
engine.setValue(group, "beatsync", value ? 1 : 0);
364
// si la otra deck esta en stop, sincronizo sĆ³lo el tempo (no el golpe)
365
if(!engine.getValue("[Channel1]", "play")) {
366
engine.setValue(group, "beatsync_tempo", value ? 1 : 0);
368
engine.setValue(group, "beatsync", value ? 1 : 0);
375
NumarkMixTrackPro.playbutton = function(channel, control, value, status, group) {
379
var deck = NumarkMixTrackPro.groupToDeck(group);
381
if (engine.getValue(group, "play")) {
382
engine.setValue(group, "play", 0);
384
engine.setValue(group, "play", 1);
256
390
NumarkMixTrackPro.loopIn = function(channel, control, value, status, group) {
257
391
var deck = NumarkMixTrackPro.groupToDeck(group);
259
if (NumarkMixTrackPro.manualLooping[deck-1]){
393
if (NumarkMixTrackPro.manualLoop[deck-1]){
260
394
if (!value) return;
261
395
// Act like the Mixxx UI
262
396
engine.setValue(group, "loop_in", status?1:0);
352
NumarkMixTrackPro.setLoopMode = function (deck, manual){
353
NumarkMixTrackPro.manualLooping[deck-1] = manual;
492
NumarkMixTrackPro.setLoopMode = function(deck, manual) {
494
NumarkMixTrackPro.manualLoop[deck-1] = manual;
354
495
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["manualLoop"], !manual);
355
496
engine.connectControl("[Channel" + deck + "]", "loop_start_position", "NumarkMixTrackPro.onLoopChange", !manual);
356
497
engine.connectControl("[Channel" + deck + "]", "loop_end_position", "NumarkMixTrackPro.onLoopChange", !manual);
357
498
engine.connectControl("[Channel" + deck + "]", "loop_enabled", "NumarkMixTrackPro.onReloopExitChange", !manual);
499
engine.connectControl("[Channel" + deck + "]", "loop_enabled", "NumarkMixTrackPro.onReloopExitChangeAuto", manual);
359
501
var group = "[Channel" + deck + "]"
392
541
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]['reloop_exit'], value);
544
NumarkMixTrackPro.onReloopExitChangeAuto = function(value, group, key){
545
var deck = NumarkMixTrackPro.groupToDeck(group);
546
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]['loop_end_position'], value);
395
549
// Stutters adjust BeatGrid
396
550
NumarkMixTrackPro.playFromCue = function(channel, control, value, status, group) {
398
var deck = NumarkMixTrackPro.groupToDeck(group);
400
if (engine.getValue(group, "beats_translate_curpos")){
403
engine.setValue(group, "beats_translate_curpos", 0);
404
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["stutter"], 0);
552
var deck = NumarkMixTrackPro.groupToDeck(group);
554
if (engine.getValue(group, "beats_translate_curpos")){
556
engine.setValue(group, "beats_translate_curpos", 0);
557
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["stutter"], 0);
406
engine.setValue(group, "beats_translate_curpos", 1);
407
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["stutter"], 1);
559
engine.setValue(group, "beats_translate_curpos", 1);
560
NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["stutter"], 1);
413
565
NumarkMixTrackPro.pitch = function(channel, control, value, status, group) {
431
586
adjustedJog = value - 128;
436
engine.scratchTick(deck, adjustedJog);
438
var gammaInputRange = 23; // Max jog speed
439
var maxOutFraction = 0.5; // Where on the curve it should peak; 0.5 is half-way
440
var sensitivity = 0.7; // Adjustment gamma
441
var gammaOutputRange = 3; // Max rate change
442
if (engine.getValue(group,"play")) {
443
adjustedJog = posNeg * gammaOutputRange * Math.pow(Math.abs(adjustedJog) / (gammaInputRange * maxOutFraction), sensitivity);
445
adjustedJog = gammaOutputRange * adjustedJog / (gammaInputRange * maxOutFraction);
447
engine.setValue(group, "jog", adjustedJog);
589
if (engine.getValue(group, "play")) {
591
if (NumarkMixTrackPro.scratchMode[deck-1] && posNeg == -1 && !NumarkMixTrackPro.touch[deck-1]) {
593
if (NumarkMixTrackPro.scratchTimer[deck-1] != -1) engine.stopTimer(NumarkMixTrackPro.scratchTimer[deck-1]);
594
NumarkMixTrackPro.scratchTimer[deck-1] = engine.beginTimer(20, "NumarkMixTrackPro.jogWheelStopScratch(" + deck + ")", true);
597
} else { // en stop hace scratch siempre
599
if (!NumarkMixTrackPro.touch[deck-1]){
601
if (NumarkMixTrackPro.scratchTimer[deck-1] != -1) engine.stopTimer(NumarkMixTrackPro.scratchTimer[deck-1]);
602
NumarkMixTrackPro.scratchTimer[deck-1] = engine.beginTimer(20, "NumarkMixTrackPro.jogWheelStopScratch(" + deck + ")", true);
607
engine.scratchTick(deck, adjustedJog);
609
if (engine.getValue(group,"play")) {
610
var gammaInputRange = 13; // Max jog speed
611
var maxOutFraction = 0.8; // Where on the curve it should peak; 0.5 is half-way
612
var sensitivity = 0.5; // Adjustment gamma
613
var gammaOutputRange = 2; // Max rate change
615
adjustedJog = posNeg * gammaOutputRange * Math.pow(Math.abs(adjustedJog) / (gammaInputRange * maxOutFraction), sensitivity);
616
engine.setValue(group, "jog", adjustedJog);
622
NumarkMixTrackPro.jogWheelStopScratch = function(deck) {
623
NumarkMixTrackPro.scratchTimer[deck-1] = -1;
624
engine.scratchDisable(deck);
626
if (NumarkMixTrackPro.isKeyLocked[deck-1] == 1) {
627
// print ("restaurando keylock");
628
// Restore the previous state of the Keylock
629
engine.setValue("[Channel"+deck+"]", "keylock", NumarkMixTrackPro.isKeyLocked[deck-1]);
630
NumarkMixTrackPro.isKeyLocked[deck-1] = 0;
451
635
NumarkMixTrackPro.wheelTouch = function(channel, control, value, status, group){
452
637
var deck = NumarkMixTrackPro.groupToDeck(group);
454
if (!NumarkMixTrackPro.scratchMode[deck-1]) return;
457
engine.scratchDisable(deck);
458
// Restore the previous state
459
engine.setValue(group, "keylock", NumarkMixTrackPro.isKeyLocked[deck-1]);
460
NumarkMixTrackPro.isKeyLocked[deck-1] = 0;
641
NumarkMixTrackPro.touch[deck-1]= false;
643
// paro el timer (si no existe da error mmmm) y arranco un nuevo timer.
644
// Si en 20 milisegundos no se mueve el plato, desactiva el scratch
646
if (NumarkMixTrackPro.scratchTimer[deck-1] != -1) engine.stopTimer(NumarkMixTrackPro.scratchTimer[deck-1]);
648
NumarkMixTrackPro.scratchTimer[deck-1] = engine.beginTimer(20, "NumarkMixTrackPro.jogWheelStopScratch(" + deck + ")", true);
652
// si esta en play y el modo scratch desactivado, al presionar el touch no hace nada
653
if (!NumarkMixTrackPro.scratchMode[deck-1] && engine.getValue(group, "play")) return;
462
655
// Save the current state of the keylock
463
656
NumarkMixTrackPro.isKeyLocked[deck-1] = engine.getValue(group, "keylock");
464
// Turn it off for scratching
657
// Turn the Keylock off for scratching
465
658
if (NumarkMixTrackPro.isKeyLocked[deck-1]){
466
659
engine.setValue(group, "keylock", 0);
663
if (NumarkMixTrackPro.scratchTimer[deck-1] != -1) engine.stopTimer(NumarkMixTrackPro.scratchTimer[deck-1]);
469
665
// change the 600 value for sensibility
470
666
engine.scratchEnable(deck, 600, 33+1/3, 1.0/8, (1.0/8)/32);
668
NumarkMixTrackPro.touch[deck-1]= true;