Última atividade 1753700969

Script for Novation Launchpad in mAirlist Inspired by Thomas "Kloppi" Kloppholzs' Mairlist-Launchpad-Script

Revisão 7ddbcc12c5ef4c02979ca69790ebdc4282191913

Launchpad.mls Bruto
1// Launchpad Script
2// Written by Thomas Mongstad.
3// Inspired by Thomas "Kloppi" Kloppholzs' Mairlist-Launchpad-Script
4// https://github.com/Lexorius/Mairlist-Launchpad-Script
5// Version 0.1.1
6// https://www.youtube.com/watch?v=BHzI3VjI2l8
7/////////////////////////////////////////////////////////////////////
8
9
10const
11 testing = 1;
12
13 Launchpad_Device = 4;
14
15 // Setup LED colours
16 cOff = 12; // LED - OFF
17
18 cLowRed = 13; // LED low Red
19 cHighRed = 15; // LED High Red
20 cBlinkRed = 11; // LED Blink RED
21
22 cLowGreen = 28; // LED low Green
23 cHighGreen = 60; // LED HIGH Green
24 cBlinkGreen = 56; // LED BlInK Green
25
26 cLowAmber = 29; // LED low Amber
27 cHighAmber = 63; // LED High Amber
28 cBlinkAmber = 59; // LED Blink Amber
29
30 cBlinkYellow = 58; // LED Blink Yellow
31 cHighYellow = 62; // LED High Yellow
32
33var
34 Buttons: array[-1..100] of integer;
35 RightButtons: array[-1..8] of integer;
36 TopButtons: array[-1..8] of integer;
37 Countdown: integer;
38 PlayerPad : array[-1..10] of array[-1..64] of integer;
39 Cartwall : array[-1..64] of integer;
40
41
42function initializeLaunchpad(value:integer):boolean;
43var
44 i: integer;
45begin
46 i:=0;
47 // Listing Midi devices to Log
48 MidiOutListdevices;
49
50 // Connecting to Launchpad
51 midioutopen(Launchpad_Device);
52
53 // Clear old LEDs
54 midiout(Launchpad_Device, 176, 0, 0);
55
56 // Set Timer
57 midiout(Launchpad_Device, 176, 0, 40);
58
59 // Initialize buttons on the right
60 RightButtons[0] := 8;
61 RightButtons[1] := 24;
62 RightButtons[2] := 40;
63 RightButtons[3] := 56;
64 RightButtons[4] := 72;
65 RightButtons[5] := 88;
66 RightButtons[6] := 104;
67 RightButtons[7] := 120;
68
69 // Initialize buttons on the top
70 TopButtons[0] := 104;
71 TopButtons[1] := 105;
72 TopButtons[2] := 106;
73 TopButtons[3] := 107;
74 TopButtons[4] := 108;
75 TopButtons[5] := 109;
76 TopButtons[6] := 110;
77 TopButtons[7] := 111;
78
79 // Initialize buttons
80 // Row 1
81 for i := 0 to 7 do
82 begin
83 Buttons[i] := i;
84 end;
85
86 // Row 2
87 for i := 8 to 15 do
88 begin
89 Buttons[i] := i+8;
90 end;
91
92 // Row 3
93 for i := 16 to 23 do
94 begin
95 Buttons[i] := i+16;
96 end;
97
98 // Row 4
99 for i := 24 to 31 do
100 begin
101 Buttons[i] := i+24;
102 end;
103
104 // Row 5
105 for i := 32 to 39 do
106 begin
107 Buttons[i] := i+32;
108 end;
109
110 // Row 6
111 for i := 40 to 47 do
112 begin
113 Buttons[i] := i+40;
114 end;
115
116 // Row 7
117 for i := 48 to 55 do
118 begin
119 Buttons[i] := i+48;
120 end;
121
122 // Row 8
123 for i := 56 to 63 do
124 begin
125 Buttons[i] := i+56;
126 end;
127
128
129 // Player Pad 1
130 PlayerPad[0][0] := Buttons[32]
131 PlayerPad[0][1] := Buttons[33]
132 PlayerPad[0][2] := Buttons[34]
133 PlayerPad[0][3] := Buttons[35]
134 PlayerPad[0][4] := Buttons[40]
135 PlayerPad[0][5] := Buttons[41]
136 PlayerPad[0][6] := Buttons[42]
137 PlayerPad[0][7] := Buttons[43]
138 PlayerPad[0][8] := Buttons[48]
139 PlayerPad[0][9] := Buttons[49]
140 PlayerPad[0][10] := Buttons[50]
141 PlayerPad[0][11] := Buttons[51]
142 PlayerPad[0][12] := Buttons[56]
143 PlayerPad[0][13] := Buttons[57]
144 PlayerPad[0][14] := Buttons[58]
145 PlayerPad[0][15] := Buttons[59]
146
147 // Player Pad 2
148 PlayerPad[1][0] := Buttons[36]
149 PlayerPad[1][1] := Buttons[37]
150 PlayerPad[1][2] := Buttons[38]
151 PlayerPad[1][3] := Buttons[39]
152 PlayerPad[1][4] := Buttons[44]
153 PlayerPad[1][5] := Buttons[45]
154 PlayerPad[1][6] := Buttons[46]
155 PlayerPad[1][7] := Buttons[47]
156 PlayerPad[1][8] := Buttons[52]
157 PlayerPad[1][9] := Buttons[53]
158 PlayerPad[1][10] := Buttons[54]
159 PlayerPad[1][11] := Buttons[55]
160 PlayerPad[1][12] := Buttons[60]
161 PlayerPad[1][13] := Buttons[61]
162 PlayerPad[1][14] := Buttons[62]
163 PlayerPad[1][15] := Buttons[63]
164
165 // Cartwall Row 1
166 Cartwall[1] := Buttons[0]
167 Cartwall[2] := Buttons[1]
168 Cartwall[3] := Buttons[2]
169 Cartwall[4] := Buttons[3]
170 Cartwall[5] := Buttons[4]
171 Cartwall[6] := Buttons[5]
172 Cartwall[7] := Buttons[6]
173 Cartwall[8] := Buttons[7]
174
175 // Cartwall Row 2
176 Cartwall[9] := Buttons[8]
177 Cartwall[10] := Buttons[9]
178 Cartwall[11] := Buttons[10]
179 Cartwall[12] := Buttons[11]
180 Cartwall[13] := Buttons[12]
181 Cartwall[14] := Buttons[13]
182 Cartwall[15] := Buttons[14]
183 Cartwall[16] := Buttons[15]
184
185 result:=true;
186
187end;
188
189function triggerAssistLED(value:integer):boolean;
190var
191 i: integer;
192begin
193for i := 0 to 7 do
194 begin
195 midiout(Launchpad_Device, 176, TopButtons[i], cHighGreen);
196 end;
197end;
198
199function triggeronairLED(value:integer):boolean;
200var
201 i: integer;
202begin
203 midiout(Launchpad_Device, 144, RightButtons[2], cHighRed);
204end;
205
206
207// Called when script is loaded
208procedure OnLoad;
209begin
210 initializeLaunchpad(0);
211 triggerAssistLED(0);
212 triggeronairLED(0);
213 Countdown := 0;
214
215 //Uncomment to light single button based on button ID
216 //midiout(Launchpad_Device, 144, RightButtons[0], cHighRed);
217
218end;
219
220// Turn "ON Air" button red
221procedure OnOnAir;
222begin
223 midiout(Launchpad_Device, 144, RightButtons[2], cHighRed);
224end;
225
226// Turn "ON Air" button off
227procedure OnOffAir;
228begin
229 midiout(Launchpad_Device, 144, RightButtons[2], cOff);
230end;
231
232// Turn TopButtons Red if Auto mode is active
233procedure OnAutomationOn(PlaylistIndex: integer);
234var
235 i: integer;
236begin
237 // Loop for all 8 buttons
238 for i := 0 to 7 do
239 begin
240 midiout(Launchpad_Device, 176, TopButtons[i], cHighRed);
241 systemlog('Script notification: Trigged Auto Mode');
242
243 end;
244end;
245
246// Turn TopButtons Green if Assist mode is active
247procedure OnAutomationOff(PlaylistIndex: integer);
248var
249 i: integer;
250begin
251 // Loop for all 8 buttons
252 for i := 0 to 7 do
253 begin
254 midiout(Launchpad_Device, 176, TopButtons[i], cHighGreen);
255 systemlog('Script notification: Trigged Assist Mode');
256 end;
257end;
258
259
260// Called when (playlist) player changes its state
261procedure OnPlayerStateChange(PlaylistIndex: integer; PlayerIndex: integer; OldState: TPlayerState; NewState: TPlayerState; Item: IPlaylistItem);
262var p:integer;
263begin
264
265if (OldState = psStopped) then
266 begin
267 for p := 0 to 15 do
268 begin
269 midiout(Launchpad_Device, 144, PlayerPad[PlayerIndex][p], cHighAmber);
270 end;
271 end
272else if (NewState = psLoaded) then
273 begin
274 for p := 0 to 15 do
275 begin
276 midiout(Launchpad_Device, 144, PlayerPad[PlayerIndex][p], cHighGreen);
277 end;
278 end
279else if (NewState = psEmpty) then
280 begin
281 for p := 0 to 15 do
282 begin
283 midiout(Launchpad_Device, 144, PlayerPad[PlayerIndex][p], cOff);
284 end;
285 end
286else if (NewState = psPlaying) then
287 begin
288 for p := 0 to 15 do
289 begin
290 midiout(Launchpad_Device, 144, PlayerPad[PlayerIndex][p], cHighRed);
291 end;
292 end
293else if (NewState = psFading) then
294 begin
295 for p := 0 to 15 do
296 begin
297 midiout(Launchpad_Device, 144, PlayerPad[PlayerIndex][p], cBlinkRed);
298 end;
299 end
300else if (NewState = psError) then
301 begin
302 for p := 0 to 15 do
303 begin
304 midiout(Launchpad_Device, 144, PlayerPad[PlayerIndex][p], cBlinkYellow);
305 end;
306 end
307
308else if (NewState = psLoading) then
309 begin
310 for p := 0 to 15 do
311 begin
312 midiout(Launchpad_Device, 144, PlayerPad[PlayerIndex][p], cBlinkGreen);
313 end;
314 end;
315
316end;
317
318// Called when a Cartwall has a State Change
319procedure OnCartwallPlayerStateChange(PlayerIndex: integer;
320 OldState: TPlayerState; NewState: TPlayerState;
321 Item: IAudioCartwallItem; PlaylistItem: IPlaylistItem;
322 OnAirMode: TCartwallOnAirMode);
323begin
324
325if (OldState = psStopped) then
326 begin
327 midiout(Launchpad_Device,144, Cartwall[PlayerIndex],cHighAmber);
328 end
329else if (NewState = psLoaded) then
330 begin
331 midiout(Launchpad_Device,144, Cartwall[PlayerIndex],cLowGreen);
332 end
333else if (NewState = psEmpty) then
334 begin
335 midiout(Launchpad_Device,144, Cartwall[PlayerIndex],cOff);
336 end
337else if (NewState = psPlaying) then
338 begin
339 midiout(Launchpad_Device,144, Cartwall[PlayerIndex],cHighRed);
340 end
341else if (NewState = psFading) then
342 begin
343 midiout(Launchpad_Device,144, Cartwall[PlayerIndex],cBlinkRed);
344 end
345else if (NewState = psLoading) then
346 begin
347 midiout(Launchpad_Device,144, Cartwall[PlayerIndex],cBlinkGreen);
348 end
349else if (NewState = psStopped) then
350 begin
351 midiout(Launchpad_Device,144, Cartwall[PlayerIndex],cHighGreen);
352 end;
353
354end;
355
356
357
358
359// Called when a MIDI message is received
360procedure OnMidiMessage(Device: integer; Status, Data1, Data2: byte);
361var
362row, i, i_div:integer;
363begin
364row := 0
365i := 0
366i_div := 0
367
368// Uncomment to see Data1 value of Data1
369//systemlog(Inttostr(Data1));
370
371 if(Status = 176) then
372 begin
373 // Toggle between AUTO and ASSIST
374 if (Data1 = 104) and (Data2 = 127) then
375 begin
376 ExecuteCommand('AUTOMATION 1 ON/OFF');
377 end
378 else if (Data1 = 105) and (Data2 = 127) then
379 begin
380 ExecuteCommand('AUTOMATION 1 ON/OFF');
381 end
382 else if (Data1 = 106) and (Data2 = 127) then
383 begin
384 ExecuteCommand('AUTOMATION 1 ON/OFF');
385 end
386 else if (Data1 = 107) and (Data2 = 127) then
387 begin
388 ExecuteCommand('AUTOMATION 1 ON/OFF');
389 end
390 else if (Data1 = 108) and (Data2 = 127) then
391 begin
392 ExecuteCommand('AUTOMATION 1 ON/OFF');
393 end
394 else if (Data1 = 109) and (Data2 = 127) then
395 begin
396 ExecuteCommand('AUTOMATION 1 ON/OFF');
397 end
398 else if (Data1 = 110) and (Data2 = 127) then
399 begin
400 ExecuteCommand('AUTOMATION 1 ON/OFF');
401 end
402 else if (Data1 = 111) and (Data2 = 127) then
403 begin
404 ExecuteCommand('AUTOMATION 1 ON/OFF');
405 end
406
407 end;
408
409 if(Status = 144) then
410 begin
411 // If any of right button are pressed
412 if (Data1 = 8) and (Data2 = 127) then
413 begin
414 systemlog('Ingen funksjon satt opp');
415 end
416 else if (Data1 = 24) and (Data2 = 127) then
417 begin
418 systemlog('Ingen funksjon satt opp');
419 end
420 else if (Data1 = 40) and (Data2 = 127) then
421 begin
422 ExecuteCommand('ON/OFF AIR');
423 end
424 else if (Data1 = 56) and (Data2 = 127) then
425 begin
426 ExecuteCommand('CARTWALL SHOW/HIDE');
427 end
428 else if (Data1 = 72) and (Data2 = 127) then
429 begin
430 systemlog('Ingen funksjon satt opp');
431 end
432 else if (Data1 = 88) and (Data2 = 127) then
433 begin
434 systemlog('Ingen funksjon satt opp');
435 end
436 else if (Data1 = 104) and (Data2 = 127) then
437 begin
438 systemlog('Ingen funksjon satt opp');
439 end
440 else if (Data1 = 120) and (Data2 = 127) then
441 begin
442 systemlog('Ingen funksjon satt opp');
443 end
444
445 // If any of Row 1 Cartwall are pressed
446 else if (Data1 = 0) and (Data2 = 127) then
447 begin
448 ExecuteCommand('CARTWALL 1 CLICK');
449 end
450 else if (Data1 = 1) and (Data2 = 127) then
451 begin
452 ExecuteCommand('CARTWALL 2 CLICK');
453 end
454 else if (Data1 = 2) and (Data2 = 127) then
455 begin
456 ExecuteCommand('CARTWALL 3 CLICK');
457 end
458 else if (Data1 = 3) and (Data2 = 127) then
459 begin
460 ExecuteCommand('CARTWALL 4 CLICK');
461 end
462 else if (Data1 = 4) and (Data2 = 127) then
463 begin
464 ExecuteCommand('CARTWALL 5 CLICK');
465 end
466 else if (Data1 = 5) and (Data2 = 127) then
467 begin
468 ExecuteCommand('CARTWALL 6 CLICK');
469 end
470 else if (Data1 = 6) and (Data2 = 127) then
471 begin
472 ExecuteCommand('CARTWALL 7 CLICK');
473 end
474 else if (Data1 = 7) and (Data2 = 127) then
475 begin
476 ExecuteCommand('CARTWALL 8 CLICK');
477 end
478
479 // If any of row 2 Cartwall are pressed
480 else if (Data1 = 16) and (Data2 = 127) then
481 begin
482 ExecuteCommand('CARTWALL 9 CLICK');
483 end
484 else if (Data1 = 17) and (Data2 = 127) then
485 begin
486 ExecuteCommand('CARTWALL 10 CLICK');
487 end
488 else if (Data1 = 18) and (Data2 = 127) then
489 begin
490 ExecuteCommand('CARTWALL 11 CLICK');
491 end
492 else if (Data1 = 19) and (Data2 = 127) then
493 begin
494 ExecuteCommand('CARTWALL 12 CLICK');
495 end
496 else if (Data1 = 20) and (Data2 = 127) then
497 begin
498 ExecuteCommand('CARTWALL 13 CLICK');
499 end
500 else if (Data1 = 21) and (Data2 = 127) then
501 begin
502 ExecuteCommand('CARTWALL 14 CLICK');
503 end
504 else if (Data1 = 22) and (Data2 = 127) then
505 begin
506 ExecuteCommand('CARTWALL 15 CLICK');
507 end
508 else if (Data1 = 23) and (Data2 = 127) then
509 begin
510 ExecuteCommand('CARTWALL 16 CLICK');
511 end
512
513
514 // If any of Player 1 Playerpads are pressed
515 else if (Data1 = 64) and (Data2 = 127) then
516 begin
517 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
518 end
519 else if (Data1 = 65) and (Data2 = 127) then
520 begin
521 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
522 end
523 else if (Data1 = 66) and (Data2 = 127) then
524 begin
525 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
526 end
527 else if (Data1 = 67) and (Data2 = 127) then
528 begin
529 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
530 end
531 else if (Data1 = 80) and (Data2 = 127) then
532 begin
533 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
534 end
535 else if (Data1 = 81) and (Data2 = 127) then
536 begin
537 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
538 end
539 else if (Data1 = 82) and (Data2 = 127) then
540 begin
541 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
542 end
543 else if (Data1 = 83) and (Data2 = 127) then
544 begin
545 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
546 end
547 else if (Data1 = 96) and (Data2 = 127) then
548 begin
549 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
550 end
551 else if (Data1 = 97) and (Data2 = 127) then
552 begin
553 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
554 end
555 else if (Data1 = 98) and (Data2 = 127) then
556 begin
557 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
558 end
559 else if (Data1 = 99) and (Data2 = 127) then
560 begin
561 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
562 end
563 else if (Data1 = 112) and (Data2 = 127) then
564 begin
565 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
566 end
567 else if (Data1 = 113) and (Data2 = 127) then
568 begin
569 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
570 end
571 else if (Data1 = 114) and (Data2 = 127) then
572 begin
573 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
574 end
575 else if (Data1 = 115) and (Data2 = 127) then
576 begin
577 ExecuteCommand('PLAYER 1-1 START/FADEOUT');
578 end
579
580
581 // If any of Player 2 Playerpads are pressed
582 else if (Data1 = 68) and (Data2 = 127) then
583 begin
584 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
585 end
586 else if (Data1 = 69) and (Data2 = 127) then
587 begin
588 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
589 end
590 else if (Data1 = 70) and (Data2 = 127) then
591 begin
592 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
593 end
594 else if (Data1 = 71) and (Data2 = 127) then
595 begin
596 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
597 end
598 else if (Data1 = 84) and (Data2 = 127) then
599 begin
600 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
601 end
602 else if (Data1 = 85) and (Data2 = 127) then
603 begin
604 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
605 end
606 else if (Data1 = 86) and (Data2 = 127) then
607 begin
608 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
609 end
610 else if (Data1 = 87) and (Data2 = 127) then
611 begin
612 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
613 end
614 else if (Data1 = 100) and (Data2 = 127) then
615 begin
616 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
617 end
618 else if (Data1 = 101) and (Data2 = 127) then
619 begin
620 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
621 end
622 else if (Data1 = 102) and (Data2 = 127) then
623 begin
624 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
625 end
626 else if (Data1 = 103) and (Data2 = 127) then
627 begin
628 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
629 end
630 else if (Data1 = 116) and (Data2 = 127) then
631 begin
632 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
633 end
634 else if (Data1 = 117) and (Data2 = 127) then
635 begin
636 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
637 end
638 else if (Data1 = 118) and (Data2 = 127) then
639 begin
640 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
641 end
642 else if (Data1 = 119) and (Data2 = 127) then
643 begin
644 ExecuteCommand('PLAYER 1-2 START/FADEOUT');
645 end
646 end;
647 end;
648
649
650begin
651end.