This file is indexed.

/usr/share/mixxx/controllers/Denon-MC3000-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
/**
 * Denon MC3000 controller script for v1.10.0 and v1.11.0
 *
 * Written by Bertrand Espern 2012
 *
 * 2012/05/11 V0.995 : first "good" version approuved and tested by me
 *
 * Special Thanks to the Programmers of Mixx and all the contributors
 *
 * Inspired primarily from Numark Total Control script file 
 *
 * 4 deck support, but no loop and no cue function on deck 3/4. Later...
 *
 **/

function mc3000(){}

// ----------   Global variables    ----------

mc3000.deck2ch = [0,2,1,3];

mc3000.nearEnd = [0,0,0,0];

mc3000.oldloopstart = [0,0,0,0];

mc3000.loophotcue = [0,0,0,0];
mc3000.loophotcuebeatnb = [8,8,8,8];

mc3000.hotcues = {23: 1, 24: 2, 25: 3, 32: 4, 72:5, 73:6, 74:7, 75:8};

mc3000.leds = {vinylmode: 6, keylock: 8, sync: 9, cue:38, play: 39, fxon1: 90, fxon2: 91,
cue1: 17, cue2: 19, cue3: 21, cue4: 23, cue5: 48, cue6: 50, cue7: 52, cue8: 54,
loopin: 36, loopout: 64, autoloop: 43, pfl1: 69, pfl2: 81, pfl3: 75, pfl4: 87,
efx1_1: 92, efx2_1: 93, efx3_1: 94, efx4_1: 95, efx1_2: 96, efx2_2: 97, efx3_2: 98, efx4_2: 99,
autoloop_dimmer: 83};

mc3000.state = {"shift1" : false, "shift2" : false, "alshift1" : false, "alshift2" : false, "pfl1" : 0, "pfl2" : 0 }; 

mc3000.vumetermaxled = [0,0,0,0];
mc3000.vumeteroffset = [9,41,25,57];

mc3000.scratch =[true,true,true,true];
//mc3000.scratch =[false,false,false,false];

mc3000.scratchpressed = [false,false,false,false];
mc3000.alpha =  (1.0/8);
mc3000.beta = mc3000.alpha/32;
mc3000.jog_sensitivity = 2.0;
mc3000.scratch_sensitivity = 1;

// BeatLoop 2 4 8 16 to 1 2 3 4 
mc3000.efx2no = [4,8,16,2];

// ----------   Functions    ----------

// called when the MIDI device is opened & set up
mc3000.init = function(id) {	

	mc3000.id = id;

	var i=0;

	for (i=1;i<=8;i++) {
		engine.connectControl("[Channel1]","hotcue_"+i+"_enabled","mc3000.hotcueSetLed");
		engine.connectControl("[Channel2]","hotcue_"+i+"_enabled","mc3000.hotcueSetLed");
	}

	for (i=1;i<=4;i++) {
		engine.connectControl("[Channel"+i+"]", "keylock", "mc3000.keylockSetLed");
		engine.connectControl("[Channel"+i+"]", "play", "mc3000.playSetLed");
		engine.connectControl("[Channel"+i+"]", "playposition", "mc3000.playPositionSetLed");
		engine.connectControl("[Channel"+i+"]", "PeakIndicator", "mc3000.peakIndicatorSetLed");
		engine.connectControl("[Channel"+i+"]", "VuMeter", "mc3000.vuMeterSetLeds");
		engine.connectControl("[Channel"+i+"]", "pfl", "mc3000.pflSetLed");
	}

	for (i=1;i<=2;i++) {
		engine.connectControl("[Channel"+i+"]", "loop_start_position", "mc3000.loopStartSetLed");
		engine.connectControl("[Channel"+i+"]", "loop_end_position", "mc3000.loopEndSetLed");
		engine.connectControl("[Channel"+i+"]", "loop_enabled", "mc3000.loopEnableSetLed");

		engine.connectControl("[Channel"+i+"]", "beatloop_2_enabled", "mc3000.beatLoopXSetLed");
		engine.connectControl("[Channel"+i+"]", "beatloop_4_enabled", "mc3000.beatLoopXSetLed");
		engine.connectControl("[Channel"+i+"]", "beatloop_8_enabled", "mc3000.beatLoopXSetLed");
		engine.connectControl("[Channel"+i+"]", "beatloop_16_enabled", "mc3000.beatLoopXSetLed");
		// PERFORMANCE EATER ?
		//engine.connectControl("[Channel"+i+"]", "beat_active", "mc3000.beatActiveSetLed");
	}

	mc3000.allLedOff();
}

// Called when the MIDI device is closed
mc3000.shutdown = function(id) {
	mc3000.allLedOff();
}

// === MISC TO MANAGE LEDS ===

mc3000.allLedOff = function () {
	// All leds off for deck 1 and 2
	for (var led in mc3000.leds) {
		mc3000.setled(1,mc3000.leds[led],0);
		mc3000.setled(2,mc3000.leds[led],0);	
	}
	// Pfl leds off for deck 1 and 2 are special
	mc3000.setled2(1,mc3000.leds["pfl1"],0);
	mc3000.setled2(2,mc3000.leds["pfl2"],0);

	// Vinylmode ON
	var i=0;
	for (i=1;i<=4;i++) mc3000.setled(i,mc3000.leds["vinylmode"],1);
}

mc3000.setled = function(deck,led,status) {
	var ledStatus = 75; // Default OFF
	switch (status) {
    		case  0 : ledStatus = 75; break; // OFF
		case false : ledStatus = 75; break; // OFF 
		case true  : ledStatus = 74; break; // ON
    		case  1 : ledStatus = 74; break; // ON
    		case  2 : ledStatus = 76; break; // BLINK
	}
	midi.sendShortMsg(0xB0+mc3000.deck2ch[deck-1], ledStatus, led);
}

mc3000.setled2 = function(deck,led,status) {
	midi.sendShortMsg(0xB0+mc3000.deck2ch[deck-1], status==1 ? 80 : 81, led);
}

// === MISC COMMON ===

mc3000.groupToDeck = function(group) {
	var matches = group.match(/^\[Channel(\d+)\]$/);
	if (matches == null) {
		return -1;
	} else {
		return matches[1];
	}
}

mc3000.loop2NoEfx = function(nbloop) {
	if (nbloop==1) nbloop=16;
	return Math.log(nbloop)/Math.log(2); //2 4 8 16 -> 1 2 3 4	
}

mc3000.samplesPerBeat = function(group) {
	var sampleRate = engine.getValue(group, "track_samplerate");
	var channels = 2;
	var bpm = engine.getValue(group, "file_bpm");
	return channels * sampleRate * 60 / bpm;
}

// Pitch Rate MSB/LSB
mc3000.rate = function(channel, control, value, status, group) {
	// 0..16383 -> -1..1
	var MSB = value;
	var LSB = control;
	var num14 = (MSB << 7) | LSB;  // Construct the 14-bit number
	var nrate = (num14-8192)/8192;
	engine.setValue(group, "rate", nrate);
}

// === MASTER ===
mc3000.micVolume = function(channel, control, value, status, group) {
	engine.setValue("[Microphone]", "volume", value/127);
}
mc3000.headMix = function(channel, control, value, status, group) {
	engine.setValue("[Master]", "headMix", (value-64)/64);
}
mc3000.headVolume = function(channel, control, value, status, group) {
	engine.setValue("[Master]", "headVolume", value/127*5);
}
mc3000.masterBalance = function(channel, control, value, status, group) {
	engine.setValue("[Master]", "balance", (value-64)/64);
}
mc3000.masterVolume = function(channel, control, value, status, group) {
	engine.setValue("[Master]", "volume", value/127*5);
}

// === PLAYLIST ===
mc3000.selectKnob = function(channel, control, value, status, group) {
	var offset = value==0 ? 250:-250;

	// AUTOLOOP + SelectKnob ? -> MOVE LOOP
	if (mc3000.state["alshift1"] || mc3000.state["alshift2"]){
		if (mc3000.state["alshift1"]) mc3000.moveLoop("[Channel1]",offset);
		if (mc3000.state["alshift2"]) mc3000.moveLoop("[Channel2]",offset);
		return;
	}
	
	// SHIFT + SelectKnob ? -> MOVE CUE
	if (mc3000.state["shift1"] || mc3000.state["shift2"]) {
		if (mc3000.state["shift1"]) {
			var curpos = engine.getValue("[Channel1]","cue_point");
	 		engine.setValue("[Channel1]","cue_point",curpos+offset);
		}
		if (mc3000.state["shift2"]) {
			var curpos = engine.getValue("[Channel2]","cue_point");
	 		engine.setValue("[Channel2]","cue_point",curpos+offset);
		}
		return;
	} 

	// NORMAL MODE - NEXT/PREV TRACK
	if (value == 0) { 
		engine.setValue(group, "SelectNextTrack", 1);
	} else {
		engine.setValue(group, "SelectPrevTrack", 1);
	}
}

// === KILL ===
mc3000.killMid = function(channel, control, value, status, group) {
	engine.setValue(group, "filterMidKill", !engine.getValue(group, "filterMidKill"));
}

// BT USED FOR BASS IS USED FOR HIGH if SHIFT
mc3000.killBass = function(channel, control, value, status, group) {
	if (mc3000.state["shift1"] || mc3000.state["shift2"]) {
		engine.setValue(group, "filterHighKill", !engine.getValue(group, "filterHighKill"));
	}else{
		engine.setValue(group, "filterLowKill", !engine.getValue(group, "filterLowKill"));
	}
}
// === FLANGER ===
// Flanger knob Depth, Delay, Period
mc3000.lfoDepth = function(channel, control, value, status, group) {
// 0..127 -> 0..1
	engine.setValue(group, "lfoDepth", value/127);
}
mc3000.lfoDelay = function(channel, control, value, status, group) {
// 0..127 -> 50..10000
	engine.setValue(group, "lfoDelay", 50+(value/127)*9950);
}
mc3000.lfoPeriod = function(channel, control, value, status, group) {
// 0..127 -> 50000..2000000
	engine.setValue(group, "lfoPeriod", 50000+(value/127)*1950000);
}

// === CUE AND HOTCUE ===
mc3000.cue_default = function(channel, control, value, status, group) {
	var isPressed = (status & 0xF0)==0x90 ? 1 : 0;
	print("cue_def - status = "+status+" group = "+group); 
	engine.setValue(group,"cue_default", isPressed);
	mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["cue"],isPressed);
}


mc3000.hotcueset = function(channel, control, value, status, group) {
	var deck=mc3000.groupToDeck(group);
	var nocue=mc3000.hotcues[control];
	var is_play = engine.getValue(group,"play")==1 ? true: false;	

	if ((status & 0xF0) !== 0x90) {    // Is Relesead ?
	 	if (mc3000.state["alshift"+deck] || mc3000.state["shift"+deck]) return; // DO NOTHING ON RELEASE IF ALSHIFT OR SHIFT
		engine.setValue(group,"hotcue_"+nocue+"_activate",0);
		return;
	}

	// AUTOLOOP + HOTCUE MODE ?
	if (mc3000.state["alshift"+deck]) {
		if (engine.getValue(group,"hotcue_"+nocue+"_enabled")) {
			mc3000.setLoopAtHotCue(group,nocue,mc3000.loophotcuebeatnb[deck-1]);
			if (!is_play) engine.setValue(group, "reloop_exit", 1);
			// TO AVOID DIRECT LOOP AFTER RELEASED AUTOLOOP
			mc3000.oldloopstart[deck-1] = engine.getValue(group, "loop_start_position");
		}
		return;
	}

	// WITH SHIFT ?
	if (mc3000.state["shift"+deck]) {
        	engine.setValue(group,"hotcue_"+nocue+"_clear",1);
		return;
	}

	if (is_play) {
		// LOOP HOTCUE OR NORMAL HOTCUE ?
		if (mc3000.loophotcue[deck-1]==nocue) {
  			mc3000.loophotcue[deck-1]=0; 
			engine.setValue(group, "reloop_exit", 1);
		} else {
			engine.setValue(group,"hotcue_"+nocue+"_activate",1);
		}
	} else {
			engine.setValue(group,"hotcue_"+nocue+"_activate",1);
	}
}

// ==== Set a loop at the hotcue_X_position
mc3000.setLoopAtHotCue = function (group,nohotcue,nbbeat) {
	var position = engine.getValue(group,"hotcue_"+nohotcue+"_position");
	var deck = mc3000.groupToDeck(group);

	// Old HotCue Led Off if exist
	if (mc3000.loophotcue[deck-1]>0) mc3000.hotcueSetLed(0,group,"hotcue_"+mc3000.loophotcue[deck-1]);

	// if loop set, exit from loop	
	if (engine.getValue(group, "loop_enabled")) engine.setValue(group, "reloop_exit", 1);

	// Set new loop_start
	engine.setValue(group, "loop_start_position", position);
	// Delete loop_end	
	engine.setValue(group, "loop_end_position", -1);
	// Set Loop End
	engine.setValue(group, "loop_end_position", position+(mc3000.samplesPerBeat(group)*nbbeat));
	
	mc3000.loophotcue[deck-1]=nohotcue;	
	
	// New HotCue Led Blink
	mc3000.hotcueSetLed (2,group,"hotcue_"+nohotcue);
}

mc3000.shift = function(channel, control, value, status, group) {
	mc3000.state["shift"+mc3000.groupToDeck(group)] = (status & 0xF0)==0x90 ? true : false; // 1 if pressed
}

mc3000.vinylmode = function(channel, control, value, status, group) {
	var deck = mc3000.groupToDeck(group);
	mc3000.scratch[deck-1] = !mc3000.scratch[deck-1];
}

// FX ON 1 to toggle flanger ON/OFF
mc3000.fxon1 = function(channel, control, value, status, group) {
	var newValue = !engine.getValue(group, "flanger");
	engine.setValue(group, "flanger", newValue);
	mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["fxon1"],newValue);
}

// FX ON 2 to toggle quantize / or grid adjust if shift
mc3000.fxon2 = function(channel, control, value, status, group) {
	if (mc3000.state["shift"+mc3000.groupToDeck(group)]) {
		engine.setValue(group, "beats_translate_curpos",true);
	}else{
		var newValue = !engine.getValue(group, "quantize");
		engine.setValue(group, "quantize", newValue);
		mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["fxon2"],newValue);
	}
}

// JOG with WHEELTOUCH
mc3000.wheelTouch = function (channel, control, value, status, group) {
	var deck = mc3000.groupToDeck(group);
	if (mc3000.scratch[deck-1]) {
		if ((status & 0xF0)==0x90) {    // Is pressed ?
			engine.scratchEnable(deck, 100, 330, mc3000.alpha, mc3000.beta); // 128, 33+1/3 aussi
		} else { 
			engine.scratchDisable(deck);
		}
		mc3000.scratchpressed[deck-1] = (status & 0xF0)==0x90 ? true : false;
	}
}
 
// The wheel that actually controls the scratching
mc3000.jogWheel = function (channel, control, value, status, group) {
	var deck = mc3000.groupToDeck(group);
	var adjustedJog = value - 64; // Control centers on 0x40 (64)

	if (mc3000.scratch[deck-1]) {
		if (mc3000.scratchpressed[deck-1]) {
			engine.scratchTick(deck,adjustedJog/mc3000.scratch_sensitivity);
			return;
		}
	}
	
	var gammaInputRange = 64;	// Max jog speed
	var maxOutFraction = 0.5;	// Where on the curve it should peak; 0.5 is half-way
	var sensitivity = 0.5;		// Adjustment gamma 0.5 def
	var gammaOutputRange = 3;	// Max rate change
	adjustedJog = gammaOutputRange * adjustedJog / (gammaInputRange * maxOutFraction);
	engine.setValue(group, "jog", adjustedJog/mc3000.jog_sensitivity);
}

// RATE TEMP UP if PLAY else FWD / END
mc3000.bendUp = function(channel, control, value, status, group) {
	var isPressed = (status & 0xF0)==0x90 ? 1 : 0;
	if (engine.getValue(group,"play") == 1) {
		engine.setValue(group, "rate_temp_up", isPressed);		
	}else{
		if ((mc3000.state["shift"+mc3000.groupToDeck(group)]) && isPressed) {
			engine.setValue(group,"end",1);
		} else {
			engine.setValue(group, "fwd",isPressed);
		}
	}
}

// RATE TEMP DOWN if PLAY else BACK / START
mc3000.bendDown = function(channel, control, value, status, group) {
	var isPressed = (status & 0xF0)==0x90 ? 1 : 0;

	if (engine.getValue(group,"play") == 1) {
		engine.setValue(group, "rate_temp_down", isPressed);
	}else{
		if ((mc3000.state["shift"+mc3000.groupToDeck(group)]) && isPressed) {
			engine.setValue(group,"start",1);
		} else {
			engine.setValue(group, "back", isPressed);
		}
	}
}

// === LOOP CONTROL ===

mc3000.efx_beatLoopX = function(channel, control, value, status, group) {
	var deck = mc3000.groupToDeck(group);
	var nbbeat = mc3000.efx2no[(control-18)-((deck-1)*64)];

	if (mc3000.state["alshift"+deck]) {	
		mc3000.setled(deck,mc3000.leds["efx"+mc3000.loop2NoEfx(mc3000.loophotcuebeatnb[deck-1])+"_"+deck],0);
		mc3000.setled(deck,mc3000.leds["efx"+mc3000.loop2NoEfx(nbbeat)+"_"+deck],2);
		mc3000.loophotcuebeatnb[deck-1]=nbbeat;
	} else {
		engine.setValue(group, "beatloop_"+nbbeat+"_activate",1);
	}

}	

// Shift and autoloop : delete loop point ELSE BeatLoopAtHotCue
mc3000.autoLoop = function(channel, control, value, status, group) {
	var deck = mc3000.groupToDeck(group);
	var i=0;	
	if ((status & 0xF0)==0x90) {
		// LIGHT LED EFX + CUE  EN MODE CUE LOOP
		// EFX = BEATLOOP NB
		for (i=1;i<=4;i++) mc3000.setled(deck,mc3000.leds["efx"+i+"_"+deck],0);
		mc3000.setled(deck,mc3000.leds["efx"+mc3000.loop2NoEfx(mc3000.loophotcuebeatnb[deck-1])+"_"+deck],2);
		
		for (i=1;i<=8;i++) mc3000.hotcueSetLed(0,group,"hotcue_"+i);
		if (mc3000.loophotcue[deck-1] > 0) mc3000.hotcueSetLed(2,group,"hotcue_"+mc3000.loophotcue[deck-1]);
		print ("hotcue_"+mc3000.loophotcue[deck-1]);
		
		// DELETE LOOP POINTS IF SHIFT
		if (mc3000.state["shift"+deck]) {
			engine.setValue(group, "reloop_exit", 1);
			engine.setValue(group, "loop_end_position", -1);
			engine.setValue(group, "loop_start_position", -1);
		}
		// INIT TO PREPARE MOVELOOP IF NEEDED
		mc3000.oldloopstart[deck-1] = engine.getValue(group, "loop_start_position");

	} else { //released
		// RESTORE LED STATE EFX + CUE_X
		var beatp=0;
		for (i=1;i<=4;i++) {
			 beatp=Math.pow(2,i);
			 mc3000.setled(deck,mc3000.leds["efx"+i+"_"+deck],engine.getValue(group,"beatloop_"+beatp+"_enabled"));
		}
		for (i=1;i<=8;i++) {
			if (engine.getValue(group,"hotcue_"+i+"_enabled")) { 
				mc3000.hotcueSetLed(1,group,"hotcue_"+i);
			} else {
				mc3000.hotcueSetLed(0,group,"hotcue_"+i);
			}
		}

		// IF MOVE LOOP APPLIED
		if (mc3000.oldloopstart[deck-1] != engine.getValue(group, "loop_start_position")) {
			engine.setValue(group, "reloop_exit", 1);
		}
				
	}

	mc3000.state["alshift"+deck] = (status & 0xF0)==0x90 ? true : false ; // true if pressed
}

mc3000.loopCutM = function(channel, control, value, status, group) {
	var start = engine.getValue(group, "loop_start_position");
	var end = engine.getValue(group, "loop_end_position");
	if ((start != -1) && (end != -1)) engine.setValue(group, "loop_halve", 1);
}

mc3000.loopCutP = function(channel, control, value, status, group) {
	var start = engine.getValue(group, "loop_start_position");
	var end = engine.getValue(group, "loop_end_position");
	if ((start != -1) && (end != -1)) engine.setValue(group, "loop_double", 1);
}

mc3000.loopIn = function(channel, control, value, status, group) {
	if (engine.getValue(group, "loop_enabled")) engine.setValue(group, "reloop_exit", 1);
	engine.setValue(group, "loop_in", 1);
	engine.setValue(group, "loop_end_position", -1);
}

mc3000.loopOut = function(channel, control, value, status, group) {
	var start = engine.getValue(group, "loop_start_position");
	var end = engine.getValue(group, "loop_end_position");
	if (start != -1) {
		if (end != -1) {
			engine.setValue(group, "reloop_exit", 1);
		} else {
			engine.setValue(group, "loop_out", 1);
		}
	}
}


// === EXPERIMENTAL ===
// CF MODE for test 
mc3000.cfMode = function(channel, control, value, status, group) {
	// BACKLOOP de -4 ?
	print ("BackLoop ?");
	engine.setValue("[Channel1]", "beatloop_4", 1);
}
mc3000.moveLoop = function (group,offset) {
		var start = engine.getValue(group, "loop_start_position");
		var end = engine.getValue(group, "loop_end_position");

		if ((start != -1) && (end != -1)) {
			engine.setValue(group, "loop_start_position", start+offset);
			engine.setValue(group, "loop_end_position", end+offset);
		}
}

// === SET LED FUNCTIONS ===

mc3000.hotcueSetLed = function(value, group, control) {
	mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["cue"+control[7]],value);
}

mc3000.pflSetLed = function(value,group) {
	mc3000.setled2(mc3000.groupToDeck(group),mc3000.leds["pfl"+mc3000.groupToDeck(group)],value);
}

mc3000.playSetLed = function(value,group) {
	mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["play"],value);
}

mc3000.keylockSetLed = function(value,group) {
	mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["keylock"],value);
}

mc3000.loopStartSetLed = function (value, group) {
	mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["loopin"],value == -1 ? false: true);
}

mc3000.loopEndSetLed = function (value, group) {
	mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["loopout"],value == -1 ? false: true);
}

mc3000.loopEnableSetLed = function(value, group, control) {
	mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["autoloop"],value);
}

mc3000.beatLoopXSetLed = function(value, group, control) {
	var deck = mc3000.groupToDeck(group);	
	mc3000.setled(deck,mc3000.leds["efx"+mc3000.loop2NoEfx(control[9])+"_"+deck],value);
}

mc3000.beatActiveSetLed = function (value,group){
	mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["sync"],value);
}

mc3000.peakIndicatorSetLed = function (value, group) {
	mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["sync"],value);
}

mc3000.vuMeterSetLeds = function (value,group){
	var deck = mc3000.groupToDeck(group);
	var maxled = Math.round ((value-0.07)*7);
	var curled = mc3000.vumetermaxled[deck-1];
	if (maxled !== curled) {
		var i=0; 
		var offset = mc3000.vumeteroffset[deck-1];
		if (maxled > curled) {
			for (i=curled+1;i<=maxled;i++) midi.sendShortMsg(0xB0+mc3000.deck2ch[deck-1], 80, i+offset);
		}else{
			for (i=maxled+1;i<=curled;i++) midi.sendShortMsg(0xB0+mc3000.deck2ch[deck-1], 81, i+offset);
		}
		mc3000.vumetermaxled[deck-1] = maxled;
	}		 
}

mc3000.playPositionSetLed = function (playposition, group) {
	var nearEnd = 0;

	if (playposition < 0.80) nearEnd = 0;
	if (playposition > 0.80) nearEnd = 2;  // The song is going to end
	if (playposition == 1)   nearEnd = 0;	

	if (nearEnd !== mc3000.nearEnd[mc3000.groupToDeck(group)-1]) {
		mc3000.setled(mc3000.groupToDeck(group),mc3000.leds["sync"],nearEnd);
		mc3000.nearEnd[mc3000.groupToDeck(group)-1] = nearEnd;
	}
}