~mixxxdevelopers/mixxx/engine-control-refactor

« back to all changes in this revision

Viewing changes to mixxx/res/controllers/Numark-Mixtrack-Pro-scripts.js

  • Committer: RJ Ryan
  • Date: 2013-06-04 00:41:29 UTC
  • mfrom: (2890.22.101 mixxx)
  • Revision ID: rryan@mixxx.org-20130604004129-8jjxkicsb3givu4a
MergingĀ fromĀ lp:mixxx.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Based on:
2
 
// Numark Mixtrack Mapping Script Functions
3
 
// 1/11/2010 - v0.1
4
 
// Matteo <matteo@magm3.com>
5
 
//
6
 
// Changes by James Ralston
7
 
//  5/18/2011
8
 
// 
9
 
// Changes:
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)
16
 
//
 
1
// Based on Numark Mixtrack Mapping Script Functions
 
2
// 1/11/2010 - v0.1 - Matteo <matteo@magm3.com>
 
3
//
 
4
// 5/18/2011 - Changed by James Ralston 
 
5
//  
17
6
// Known Bugs:
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
20
9
//
21
 
//
22
 
 
23
 
// Changes by DarĆ­o JosĆ© Freije
24
 
// 05/26/2012
25
 
//
26
 
// Cue:
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)
29
 
//
30
 
// Jog Wheels:
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)
34
 
//
35
 
// Stutter -> Adjust BeatGrid:
36
 
//      The Stutter Button work now to set the beatgrid in the correct place (usefull to sync well)
37
 
//
38
 
// Gain:
39
 
//      The 3rd knob of the "effect" section, is now "Gain" (pre-gain, very usefull for me)
40
 
//
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)
44
 
//
45
 
// Auto Loop:
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).
49
 
//
50
 
 
51
 
// More Changes:
52
 
// 06/02/2012
53
 
//
54
 
// Pitch Sliders:
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."       
59
 
//
60
 
// Peak Indicator:
61
 
//       in the light of SYNC button
62
 
//
63
 
// Cue:
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>
 
11
//
 
12
//      Almost all work like expected. Resume and Particularities:
 
13
//
 
14
// ************* Script now is Only for 1.11.0 and above *************
 
15
//
 
16
//      Delete + Effect: Brake Effect (maintain pressed).
 
17
//                       Flanger Delay (2nd knob of effect section): Adjust the speed of Brake.
 
18
//
 
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.
 
23
//
 
24
//      Load track:     Only if the track is paused. Put the pitch in 0 at load.
 
25
//
 
26
//      Keylock: disabled on wheel touch when in scratch mode (make noise anyway at exit scratch).
 
27
//
 
28
//      Gain:   The 3rd knob of the "effect" section is "Gain" (up to clip).
 
29
//
 
30
//      Effect: Flanger. 1st and 2nd knob modify Depth and Delay.
 
31
//
 
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.
 
35
//
 
36
//      Stutter: Adjust BeatGrid in the correct place (usefull to sync well).
 
37
//               LED Blink at each Beat of the grid.
 
38
//
 
39
//      Sync:   If the other deck is stopped, only sync tempo (not fase).
 
40
//              LED Blink at Clip Gain (Peak indicator).
 
41
//
 
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.
 
46
//
 
47
//      Auto Loop (LED ON):     Active at program Start.
 
48
//                              "1 Bar" button: Active an Instant 4 beat Loop. Press again to exit loop.
 
49
//
 
50
//      Scratch: 
 
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.
65
56
//
66
57
 
67
58
 
71
62
        NumarkMixTrackPro.id = id;      // Store the ID of this device for later use
72
63
        
73
64
        NumarkMixTrackPro.directoryMode = false;
74
 
        
75
65
        NumarkMixTrackPro.scratchMode = [false, false];
76
 
        
77
 
        NumarkMixTrackPro.manualLooping = [true, true];
 
66
        NumarkMixTrackPro.manualLoop = [true, true];
78
67
        NumarkMixTrackPro.deleteKey = [false, false];
79
68
        NumarkMixTrackPro.isKeyLocked = [0, 0];
80
 
        
 
69
        NumarkMixTrackPro.touch = [false, false];
 
70
        NumarkMixTrackPro.scratchTimer = [-1, -1];
 
71
 
81
72
        NumarkMixTrackPro.leds = [
82
73
                // Common
83
74
                { "directory": 0x73, "file": 0x72 },
104
95
                this.state = state;
105
96
        }
106
97
 
 
98
        for (i=0x30; i<=0x73; i++) midi.sendShortMsg(0x90, i, 0x00);    // Turn off all the lights
 
99
 
107
100
        NumarkMixTrackPro.hotCue = {
108
101
                        //Deck 1 
109
102
                        0x5a:"1", 0x5b:"2", 0x5c:"3",
116
109
                for (var x=1; x<4; x++){
117
110
                        engine.connectControl("[Channel" + i +"]", "hotcue_"+ x +"_enabled", "NumarkMixTrackPro.onHotCueChange");
118
111
                }
119
 
                NumarkMixTrackPro.setLoopMode(i, true);
 
112
                NumarkMixTrackPro.setLoopMode(i, false);
120
113
        }
121
114
 
122
115
        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[0]["file"], true);
123
116
 
124
 
        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[1]["Cue"], true);
125
 
        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[2]["Cue"], true);
126
117
 
127
118
// Enable soft-takeover for Pitch slider
128
119
 
134
125
        engine.connectControl("[Channel1]","PeakIndicator","NumarkMixTrackPro.Channel1Clip");
135
126
        engine.connectControl("[Channel2]","PeakIndicator","NumarkMixTrackPro.Channel2Clip");
136
127
 
 
128
// Stutter beat light
 
129
        engine.connectControl("[Channel1]","beat_active","NumarkMixTrackPro.Stutter1Beat");
 
130
        engine.connectControl("[Channel2]","beat_active","NumarkMixTrackPro.Stutter2Beat");
 
131
 
 
132
 
137
133
}
138
134
 
 
135
 
139
136
NumarkMixTrackPro.Channel1Clip = function (value) {
140
137
        NumarkMixTrackPro.clipLED(value,NumarkMixTrackPro.leds[1]["sync"]);
141
138
 
146
143
 
147
144
}
148
145
 
 
146
NumarkMixTrackPro.Stutter1Beat = function (value) {
 
147
 
 
148
        var secondsBlink = 30;
 
149
        var secondsToEnd = engine.getValue("[Channel1]", "duration") * (1-engine.getValue("[Channel1]", "playposition"));
 
150
        
 
151
        if (secondsToEnd < secondsBlink && secondsToEnd > 1 && engine.getValue("[Channel1]", "play")) { // The song is going to end
 
152
 
 
153
                NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[1]["Cue"], value);
 
154
        }
 
155
        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[1]["stutter"], value);
 
156
 
 
157
}
 
158
 
 
159
NumarkMixTrackPro.Stutter2Beat = function (value) {
 
160
 
 
161
        var secondsBlink = 30;
 
162
        var secondsToEnd = engine.getValue("[Channel2]", "duration") * (1-engine.getValue("[Channel2]", "playposition"));
 
163
        
 
164
        if (secondsToEnd < secondsBlink && secondsToEnd > 1 && engine.getValue("[Channel2]", "play")) { // The song is going to end
 
165
 
 
166
                NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[2]["Cue"], value);
 
167
        }       
 
168
 
 
169
        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[2]["stutter"], value);
 
170
 
 
171
}
149
172
 
150
173
NumarkMixTrackPro.clipLED = function (value, note) {
151
174
 
171
194
 
172
195
}
173
196
 
174
 
NumarkMixTrackPro.groupToDeck = function(group) {
175
 
        var matches = group.match(/^\[Channel(\d+)\]$/);
176
 
        if (matches == null) {
177
 
                return -1;
178
 
        } else {
179
 
                return matches[1];
180
 
        }
181
 
}
182
 
 
183
197
NumarkMixTrackPro.samplesPerBeat = function(group) {
184
198
        // FIXME: Get correct samplerate and channels for current deck
185
199
        var sampleRate = 44100;
188
202
        return channels * sampleRate * 60 / bpm;
189
203
}
190
204
 
 
205
NumarkMixTrackPro.groupToDeck = function(group) {
 
206
 
 
207
        var matches = group.match(/^\[Channel(\d+)\]$/);
 
208
 
 
209
        if (matches == null) {
 
210
                return -1;
 
211
        } else {
 
212
                return matches[1];
 
213
        }
 
214
 
 
215
}
 
216
 
191
217
NumarkMixTrackPro.setLED = function(value, status) {
 
218
 
192
219
        status = status ? 0x64 : 0x00;
193
220
        midi.sendShortMsg(0x90, value, status);
194
221
}
235
262
        }
236
263
}
237
264
 
 
265
NumarkMixTrackPro.LoadTrack = function(channel, control, value, status, group) {
 
266
 
 
267
        // Load the selected track in the corresponding deck only if the track is paused
 
268
 
 
269
        if(value && engine.getValue(group, "play") != 1) 
 
270
        {
 
271
                engine.setValue(group, "LoadSelectedTrack", 1);
 
272
 
 
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);
 
277
        }
 
278
        else engine.setValue(group, "LoadSelectedTrack", 0);
 
279
 
 
280
}
 
281
 
 
282
NumarkMixTrackPro.flanger = function(channel, control, value, status, group) {
 
283
 
 
284
//      if (!value) return;
 
285
 
 
286
        var deck = NumarkMixTrackPro.groupToDeck(group);
 
287
        
 
288
        var speed = 1;
 
289
 
 
290
        if(NumarkMixTrackPro.deleteKey[deck-1]){
 
291
 
 
292
        // Delete + Effect = Brake
 
293
 
 
294
//      print ("Delay: " + engine.getValue("[Flanger]","lfoDelay"));
 
295
 
 
296
                if (engine.getValue("[Flanger]","lfoDelay") < 5026) {
 
297
 
 
298
                        speed = engine.getValue("[Flanger]","lfoDelay") / 5025;
 
299
 
 
300
                        if (speed < 0) speed = 0;
 
301
 
 
302
                } else {
 
303
 
 
304
                        speed = (engine.getValue("[Flanger]","lfoDelay") - 5009)/ 16,586666667
 
305
 
 
306
                        if (speed > 300) speed = 300;
 
307
                }
 
308
 
 
309
//      print ("Speed: " + speed);
 
310
 
 
311
                engine.brake(deck, value, speed);
 
312
 
 
313
                if (!value) NumarkMixTrackPro.toggleDeleteKey(channel, control, 1, status, group);
 
314
 
 
315
        } else {
 
316
                if (!value) return;
 
317
                if (engine.getValue(group, "flanger")) {
 
318
                        engine.setValue(group, "flanger", 0);
 
319
                }else{
 
320
                        engine.setValue(group, "flanger", 1);
 
321
                }
 
322
        }
 
323
 
 
324
}
 
325
 
 
326
 
238
327
NumarkMixTrackPro.cuebutton = function(channel, control, value, status, group) {
239
328
 
240
329
 
241
330
        // Don't set Cue accidentaly at the end of the song
242
 
        if(engine.getValue(group, "playposition") <= 0.97) 
243
 
        {
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);
247
 
        }
248
 
        else
249
 
        {
 
331
        if (engine.getValue(group, "playposition") <= 0.97) {
 
332
                        engine.setValue(group, "cue_default", value ? 1 : 0);
 
333
        } else {
250
334
                engine.setValue(group, "cue_preview", value ? 1 : 0);
251
335
        }
252
336
 
253
 
 
254
 
}
 
337
}
 
338
 
 
339
NumarkMixTrackPro.beatsync = function(channel, control, value, status, group) {
 
340
 
 
341
        var deck = NumarkMixTrackPro.groupToDeck(group);
 
342
 
 
343
        if(NumarkMixTrackPro.deleteKey[deck-1]){
 
344
 
 
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);
 
349
 
 
350
                NumarkMixTrackPro.toggleDeleteKey(channel, control, value, status, group);
 
351
 
 
352
        } else {
 
353
 
 
354
                        if (deck == 1) {
 
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);
 
358
                                } else {
 
359
                                                engine.setValue(group, "beatsync", value ? 1 : 0);
 
360
                                        }
 
361
                        }
 
362
 
 
363
                        if (deck == 2) {
 
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);
 
367
                                } else {
 
368
                                                engine.setValue(group, "beatsync", value ? 1 : 0);
 
369
                                        }
 
370
                        }
 
371
                }
 
372
}
 
373
 
 
374
 
 
375
NumarkMixTrackPro.playbutton = function(channel, control, value, status, group) {
 
376
 
 
377
        if (!value) return;
 
378
 
 
379
        var deck = NumarkMixTrackPro.groupToDeck(group);
 
380
 
 
381
        if (engine.getValue(group, "play")) {
 
382
                engine.setValue(group, "play", 0);
 
383
        }else{
 
384
                engine.setValue(group, "play", 1);
 
385
        }
 
386
 
 
387
}
 
388
 
255
389
 
256
390
NumarkMixTrackPro.loopIn = function(channel, control, value, status, group) {
257
391
        var deck = NumarkMixTrackPro.groupToDeck(group);
258
392
        
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);
287
421
        
288
422
        if (!value) return;
289
423
        
290
 
        if (NumarkMixTrackPro.manualLooping[deck-1]){
 
424
        if (NumarkMixTrackPro.manualLoop[deck-1]){
291
425
                // Act like the Mixxx UI
292
426
                engine.setValue(group, "loop_out", status?1:0);
293
427
                return;
294
428
        }
 
429
 
 
430
        var isLoopActive = engine.getValue(group, "loop_enabled");
295
431
                
296
 
        // Set a 4 beat auto loop
297
 
        engine.setValue(group,"beatloop_4_activate",1);
298
 
        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["loop_end_position"], true);
 
432
        // Set a 4 beat auto loop or exit the loop
 
433
 
 
434
        if(!isLoopActive){
 
435
                engine.setValue(group,"beatloop_4",1);
 
436
        }else{
 
437
                engine.setValue(group,"beatloop_4",0);
 
438
        }
299
439
 
300
440
}
301
441
 
318
458
NumarkMixTrackPro.reLoop = function(channel, control, value, status, group) {
319
459
        var deck = NumarkMixTrackPro.groupToDeck(group);
320
460
        
321
 
        if (NumarkMixTrackPro.manualLooping[deck-1]){
 
461
        if (NumarkMixTrackPro.manualLoop[deck-1]){
322
462
                // Act like the Mixxx UI (except for working delete)
323
463
                if (!value) return;
324
464
                if (NumarkMixTrackPro.deleteKey[deck-1]){
349
489
        }
350
490
}
351
491
 
352
 
NumarkMixTrackPro.setLoopMode = function (deck, manual){
353
 
        NumarkMixTrackPro.manualLooping[deck-1] = manual;
 
492
NumarkMixTrackPro.setLoopMode = function(deck, manual) {
 
493
 
 
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);
358
500
        
359
501
        var group = "[Channel" + deck + "]"
360
502
        if (manual){
363
505
                NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["reloop_exit"], engine.getValue(group, "loop_enabled"));
364
506
        }else{
365
507
                NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["loop_start_position"], false);
366
 
 
367
 
                if (engine.getValue(group,"loop_enabled")){
368
 
                        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["loop_end_position"], true);
369
 
                }else{
370
 
                        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["loop_end_position"], false);
371
 
                        }
372
 
 
 
508
                NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["loop_end_position"], engine.getValue(group, "loop_enabled"));
373
509
                NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["reloop_exit"], false);           
374
510
        }
375
511
}
378
514
        if (!value) return;
379
515
        
380
516
        var deck = NumarkMixTrackPro.groupToDeck(group);
 
517
 
 
518
        if(NumarkMixTrackPro.deleteKey[deck-1]){
 
519
                // activar o desactivar quantize
 
520
 
 
521
                if (engine.getValue(group, "quantize")) {
 
522
                        engine.setValue(group, "quantize", 0);
 
523
                }else{
 
524
                        engine.setValue(group, "quantize", 1);
 
525
                }
 
526
 
 
527
                NumarkMixTrackPro.toggleDeleteKey(channel, control, value, status, group);
 
528
        } else {
381
529
        
382
 
        NumarkMixTrackPro.setLoopMode(deck, !NumarkMixTrackPro.manualLooping[deck-1]);
 
530
                NumarkMixTrackPro.setLoopMode(deck, !NumarkMixTrackPro.manualLoop[deck-1]);
 
531
        }
383
532
}
384
533
 
385
534
NumarkMixTrackPro.onLoopChange = function(value, group, key){
392
541
        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]['reloop_exit'], value);
393
542
}
394
543
 
 
544
NumarkMixTrackPro.onReloopExitChangeAuto = function(value, group, key){
 
545
        var deck = NumarkMixTrackPro.groupToDeck(group);
 
546
        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]['loop_end_position'], value);
 
547
}
 
548
 
395
549
// Stutters adjust BeatGrid
396
550
NumarkMixTrackPro.playFromCue = function(channel, control, value, status, group) {
397
551
 
398
 
var deck = NumarkMixTrackPro.groupToDeck(group);
399
 
 
400
 
if (engine.getValue(group, "beats_translate_curpos")){
401
 
 
402
 
 
403
 
        engine.setValue(group, "beats_translate_curpos", 0);
404
 
        NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["stutter"], 0);
 
552
        var deck = NumarkMixTrackPro.groupToDeck(group);
 
553
 
 
554
        if (engine.getValue(group, "beats_translate_curpos")){
 
555
 
 
556
                engine.setValue(group, "beats_translate_curpos", 0);
 
557
                NumarkMixTrackPro.setLED(NumarkMixTrackPro.leds[deck]["stutter"], 0);
405
558
        }else{
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);
408
561
        }
409
562
 
410
 
 
411
563
}
412
564
 
413
565
NumarkMixTrackPro.pitch = function(channel, control, value, status, group) {
424
576
 
425
577
NumarkMixTrackPro.jogWheel = function(channel, control, value, status, group) {
426
578
        var deck = NumarkMixTrackPro.groupToDeck(group);
 
579
 
 
580
//      if (!NumarkMixTrackPro.touch[deck-1] && !engine.getValue(group, "play")) return;
 
581
 
427
582
        var adjustedJog = parseFloat(value);
428
583
        var posNeg = 1;
429
584
        if (adjustedJog > 63) { // Counter-clockwise
431
586
                adjustedJog = value - 128;
432
587
        }
433
588
 
434
 
 
435
 
 
436
 
                engine.scratchTick(deck, adjustedJog);
437
 
 
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);
444
 
                } else {
445
 
                        adjustedJog = gammaOutputRange * adjustedJog / (gammaInputRange * maxOutFraction);
446
 
                }
447
 
                engine.setValue(group, "jog", adjustedJog);
448
 
 
 
589
        if (engine.getValue(group, "play")) {
 
590
 
 
591
                if (NumarkMixTrackPro.scratchMode[deck-1] && posNeg == -1 && !NumarkMixTrackPro.touch[deck-1]) {
 
592
 
 
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);
 
595
                } 
 
596
 
 
597
        } else { // en stop hace scratch siempre
 
598
        
 
599
                if (!NumarkMixTrackPro.touch[deck-1]){
 
600
 
 
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);
 
603
                }
 
604
 
 
605
        }
 
606
 
 
607
        engine.scratchTick(deck, adjustedJog);
 
608
 
 
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
 
614
 
 
615
                adjustedJog = posNeg * gammaOutputRange * Math.pow(Math.abs(adjustedJog) / (gammaInputRange * maxOutFraction), sensitivity);
 
616
                engine.setValue(group, "jog", adjustedJog);     
 
617
        }
 
618
 
 
619
}
 
620
 
 
621
 
 
622
NumarkMixTrackPro.jogWheelStopScratch = function(deck) {
 
623
        NumarkMixTrackPro.scratchTimer[deck-1] = -1;
 
624
        engine.scratchDisable(deck);
 
625
 
 
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;
 
631
                }
 
632
                
449
633
}
450
634
 
451
635
NumarkMixTrackPro.wheelTouch = function(channel, control, value, status, group){
 
636
 
452
637
        var deck = NumarkMixTrackPro.groupToDeck(group);
453
638
 
454
 
        if (!NumarkMixTrackPro.scratchMode[deck-1]) return;
455
 
 
456
639
        if(!value){
457
 
                engine.scratchDisable(deck);
458
 
                // Restore the previous state
459
 
                engine.setValue(group, "keylock", NumarkMixTrackPro.isKeyLocked[deck-1]);
460
 
                NumarkMixTrackPro.isKeyLocked[deck-1] = 0;
 
640
 
 
641
                NumarkMixTrackPro.touch[deck-1]= false;
 
642
 
 
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
 
645
 
 
646
                if (NumarkMixTrackPro.scratchTimer[deck-1] != -1) engine.stopTimer(NumarkMixTrackPro.scratchTimer[deck-1]);
 
647
 
 
648
                NumarkMixTrackPro.scratchTimer[deck-1] = engine.beginTimer(20, "NumarkMixTrackPro.jogWheelStopScratch(" + deck + ")", true);
 
649
 
461
650
        } else {
 
651
 
 
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;
 
654
 
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);
467
660
                }
468
661
 
 
662
 
 
663
                if (NumarkMixTrackPro.scratchTimer[deck-1] != -1) engine.stopTimer(NumarkMixTrackPro.scratchTimer[deck-1]);
 
664
 
469
665
                // change the 600 value for sensibility
470
666
                engine.scratchEnable(deck, 600, 33+1/3, 1.0/8, (1.0/8)/32);
 
667
 
 
668
                NumarkMixTrackPro.touch[deck-1]= true;
471
669
        }
472
670
}
473
671
 
511
709
        } else {
512
710
                if (value) {
513
711
                        engine.setValue(group, "hotcue_" + hotCue + "_activate", 1);
514
 
 
 
712
                        
515
713
                }else{
516
714
 
517
715
                        engine.setValue(group, "hotcue_" + hotCue + "_activate", 0);