~mixxxdevelopers/mixxx/engine-control-refactor

« back to all changes in this revision

Viewing changes to mixxx/res/controllers/Reloop-Digital-Jockey2-Controller-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:
21
21
//boolean value that indicated if CUP LED is active
22
22
DigitalJockey2Controller.CUP_Button1_IsActive = false;
23
23
DigitalJockey2Controller.CUP_Button2_IsActive = false;
24
 
 
25
 
 
26
24
 
27
25
DigitalJockey2Controller.init = function(id){
28
26
    //print ("Initalizing Reloop Digital Jockey 2 Controler Edition.");
47
45
        
48
46
        //Looping
49
47
        engine.connectControl("[Channel1]","loop_enabled","DigitalJockey2Controller.LoopActiveLED1");
50
 
        engine.connectControl("[Channel2]","loop_enabled","DigitalJockey2Controller.LoopActiveLED2");
51
 
        
 
48
        engine.connectControl("[Channel2]","loop_enabled","DigitalJockey2Controller.LoopActiveLED2");
52
49
        //Key Lock
53
50
        engine.connectControl("[Channel1]","keylock","DigitalJockey2Controller.OnKeyLockChange1");
54
51
        engine.connectControl("[Channel2]","keylock","DigitalJockey2Controller.OnKeyLockChange2");
 
52
        //Flanger
 
53
        engine.connectControl("[Channel1]","flanger","DigitalJockey2Controller.OnFlangerChange1");
 
54
        engine.connectControl("[Channel2]","flanger","DigitalJockey2Controller.OnFlangerChange2");
55
55
}
56
56
DigitalJockey2Controller.resetLEDs = function(){
57
57
 
59
59
        midi.sendShortMsg(0x90, 0x19, DigitalJockey2Controller.ledOff);   // Turn on the Play LED1 off
60
60
        midi.sendShortMsg(0x90, 0x17, DigitalJockey2Controller.ledOff); //Turn CUP LED1 off
61
61
        midi.sendShortMsg(0x90, 0x18, DigitalJockey2Controller.ledOff); //Turn CUE LED1 off
62
 
        midi.sendShortMsg(0x90, 0x5, DigitalJockey2Controller.ledOff); //Turn PFL LED off
 
62
        midi.sendShortMsg(0x90, 0x05, DigitalJockey2Controller.ledOff); //Turn PFL LED off
63
63
        midi.sendShortMsg(0x90, 0x14, DigitalJockey2Controller.ledOff); //HighFilterKill
64
64
        midi.sendShortMsg(0x90, 0x15, DigitalJockey2Controller.ledOff); //MidFilterKill
65
65
        midi.sendShortMsg(0x90, 0x16, DigitalJockey2Controller.ledOff); //LowFilterKill
66
66
        midi.sendShortMsg(0x90, 0x1B, DigitalJockey2Controller.ledOff); //disable scratch control
67
67
        midi.sendShortMsg(0x90, 0x1A, DigitalJockey2Controller.ledOff); //disable search control
68
 
        midi.sendShortMsg(0x90, 0x1C, DigitalJockey2Controller.ledOff); //disable fx dry/wet control
69
 
        midi.sendShortMsg(0x90, 0x02, DigitalJockey2Controller.ledOff); //Turn KeyLock off
70
 
        midi.sendShortMsg(0x90, 0x12, DigitalJockey2Controller.ledOff); //Turn LED off
71
 
        midi.sendShortMsg(0x90, 0xe, DigitalJockey2Controller.ledOff); //Flanger
72
 
        midi.sendShortMsg(0x90, 0x1A, DigitalJockey2Controller.ledOff); //Search
 
68
        midi.sendShortMsg(0x90, 0x1C, DigitalJockey2Controller.ledOff); //disable fx dry/wet control
 
69
        midi.sendShortMsg(0x90, 0x02, DigitalJockey2Controller.ledOff); //Turn KeyLock off
 
70
        midi.sendShortMsg(0x90, 0x12, DigitalJockey2Controller.ledOff); //Loop1 LED Off
 
71
        midi.sendShortMsg(0x90, 0x0e, DigitalJockey2Controller.ledOff); //Flanger
 
72
        midi.sendShortMsg(0x90, 0x1A, DigitalJockey2Controller.ledOff); //Search
73
73
        midi.sendShortMsg(0x90, 0x1b, DigitalJockey2Controller.ledOff);//Scratch
74
74
        
75
75
        
82
82
        midi.sendShortMsg(0x90, 0x52, DigitalJockey2Controller.ledOff); //LowFilterKill
83
83
        midi.sendShortMsg(0x90, 0x57, DigitalJockey2Controller.ledOff); //disable scratch control
84
84
        midi.sendShortMsg(0x90, 0x56, DigitalJockey2Controller.ledOff); //disable search control
85
 
        midi.sendShortMsg(0x90, 0x58, DigitalJockey2Controller.ledOff); //disable fx dry/wet control
86
 
        midi.sendShortMsg(0x90, 0x3E, DigitalJockey2Controller.ledOff); //Turn KeyLock2 off
87
 
        midi.sendShortMsg(0x90, 0x4E, DigitalJockey2Controller.ledOff); //Loop2 LE
88
 
        midi.sendShortMsg(0x90, 0x45, DigitalJockey2Controller.ledOff); //Flanger 
89
 
        midi.sendShortMsg(0x90, 0x56, DigitalJockey2Controller.ledOff); //Search
90
 
        midi.sendShortMsg(0x90, 0x57, DigitalJockey2Controller.ledOff);//Scratch        
91
 
        
 
85
        midi.sendShortMsg(0x90, 0x58, DigitalJockey2Controller.ledOff); //disable fx dry/wet control
 
86
        midi.sendShortMsg(0x90, 0x3E, DigitalJockey2Controller.ledOff); //Turn KeyLock2 off
 
87
        midi.sendShortMsg(0x90, 0x4E, DigitalJockey2Controller.ledOff); //Loop2 LED Off
 
88
        midi.sendShortMsg(0x90, 0x45, DigitalJockey2Controller.ledOff); //Flanger
 
89
        midi.sendShortMsg(0x90, 0x56, DigitalJockey2Controller.ledOff); //Search
 
90
        midi.sendShortMsg(0x90, 0x57, DigitalJockey2Controller.ledOff);//Scratch
92
91
}
93
92
DigitalJockey2Controller.shutdown = function(id){
94
93
 //Turn all LEDs off by using init function
95
94
 DigitalJockey2Controller.resetLEDs();
96
95
}
97
 
 // Play button deck 1
 
96
 
 
97
// Play button deck 1
98
98
DigitalJockey2Controller.playButton1 = function (channel, control, value) {
99
99
        DigitalJockey2Controller.playTrack(1, control, value);  
100
100
}
102
102
DigitalJockey2Controller.playButton2 = function (channel, control, value) {
103
103
        DigitalJockey2Controller.playTrack(2, control, value);
104
104
}
 
105
 
105
106
DigitalJockey2Controller.playTrack = function (channel, control, value) {
106
 
        //If no song is loaded
107
 
         if (engine.getValue("[Channel"+channel+"]", "duration") == 0) { 
108
 
                        return; 
109
 
        };
110
 
        //If a CUP is active, PlayButtons are disabled
111
 
        var isCupActive = engine.getValue("[Channel"+channel+"]","cue_default");
112
 
        if(isCupActive == true)
113
 
                return;
114
 
                
115
 
        var currentlyPlaying = engine.getValue("[Channel"+channel+"]","play");
116
107
        /*
117
108
         * We immediately want to start and stop playing as soon as play button has been pressed
118
109
         * KeyUp events are out of interest in this case
119
110
         */
120
111
        if(value == DigitalJockey2Controller.keyPressed){
121
 
                
 
112
                //If no song is loaded
 
113
                if (engine.getValue("[Channel"+channel+"]", "duration") == 0) { 
 
114
                                return; 
 
115
                };
 
116
                var currentlyPlaying = engine.getValue("[Channel"+channel+"]","play");
122
117
                if (currentlyPlaying == 1) {    // If currently playing
123
118
                        engine.setValue("[Channel"+channel+"]","play",0);    // Stop
124
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff);    // Turn off the Play LED
 
119
                        if(channel == 1) {
 
120
                                midi.sendShortMsg(0x90, 0x17, DigitalJockey2Controller.ledOff); //Turn CUP LED off
 
121
                                DigitalJockey2Controller.CUP_Button1_IsActive = false;
 
122
                        }
 
123
                        else if(channel == 2){
 
124
                                midi.sendShortMsg(0x90, 0x53, DigitalJockey2Controller.ledOff); //Turn CUP LED off
 
125
                                DigitalJockey2Controller.CUP_Button2_IsActive = false;
 
126
                        }
125
127
                }
126
128
                else {    // If not currently playing,
127
129
                        engine.setValue("[Channel"+channel+"]","play",1);    // Start
128
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn);    // Turn on the Play LED
129
130
                }
130
131
        }
131
132
}
 
133
 
132
134
DigitalJockey2Controller.CueButton1 = function (channel, control, value) {
133
135
        DigitalJockey2Controller.Cue(1, control, value);        
134
136
}
140
142
        if (engine.getValue("[Channel"+channel+"]", "duration") == 0) { 
141
143
                        return; 
142
144
        };
143
 
        //midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn);
144
145
        // As soon as we press CUE, execute CUE Logic
145
146
        if(value == DigitalJockey2Controller.keyPressed){
146
147
                engine.setValue("[Channel"+channel+"]","cue_default",1);
149
150
                        midi.sendShortMsg(0x90, 0x17, DigitalJockey2Controller.ledOff); //Turn CUP LED off
150
151
                        DigitalJockey2Controller.CUP_Button1_IsActive = false;
151
152
                }
152
 
                if(channel == 2){
 
153
                else if(channel == 2){
153
154
                        midi.sendShortMsg(0x90, 0x55, DigitalJockey2Controller.ledOff);   // Turn on the Play LED off
154
155
                        midi.sendShortMsg(0x90, 0x53, DigitalJockey2Controller.ledOff); //Turn CUP LED off
155
156
                        DigitalJockey2Controller.CUP_Button2_IsActive = false;
156
157
                }
157
158
        
158
 
                //Turn CUE LED on
159
 
                midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn);
160
 
                
161
159
        }
162
 
        if(value == DigitalJockey2Controller.keyUp){
 
160
        else if(value == DigitalJockey2Controller.keyUp){
163
161
                engine.setValue("[Channel"+channel+"]","cue_default",0);
164
 
                //TURN CUE LED OFF
165
 
                midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff);
166
 
                
167
162
        }
168
163
        
169
164
}
173
168
DigitalJockey2Controller.CuePlayButton2 = function (channel, control, value) {
174
169
        DigitalJockey2Controller.CuePlay(2, control, value);    
175
170
}
 
171
 
 
172
DigitalJockey2Controller.CuePlayButton1 = function (channel, control, value) {
 
173
        DigitalJockey2Controller.CuePlay(1, control, value);    
 
174
}
 
175
DigitalJockey2Controller.CuePlayButton2 = function (channel, control, value) {
 
176
        DigitalJockey2Controller.CuePlay(2, control, value);    
 
177
}
176
178
DigitalJockey2Controller.CuePlay = function (channel, control, value) {
177
 
        //If no song is loaded
178
 
        if (engine.getValue("[Channel"+channel+"]", "duration") == 0) { 
179
 
                        return; 
180
 
        };
181
 
        var isCupActive = engine.getValue("[Channel"+channel+"]","cue_default");
182
 
        var currentlyPlaying = engine.getValue("[Channel"+channel+"]","play");
183
 
        
184
179
        // As soon as we press CUP, execute CUP Logic
185
180
        if(value == DigitalJockey2Controller.keyPressed){
186
 
                //If CUP is active, we disable and enable CUP in sequence as a user would do
187
 
                if(isCupActive == 1 || currentlyPlaying == 0){
188
 
                        //print ("isCUPActive" + isCupActive);
189
 
                        //print ("isPlaying" + currentlyPlaying);
190
 
                        
191
 
                        if(isCupActive == 1){   //diable CUP
192
 
                                engine.setValue("[Channel"+channel+"]","cue_default",0);
193
 
                                //Turn CUP LED off
194
 
                                midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff);
195
 
                                midi.sendShortMsg(0x90, 0x55, DigitalJockey2Controller.ledOff);   // Turn on the Play LED off
196
 
                                if(channel == 1)
197
 
                                        DigitalJockey2Controller.CUP_Button1_IsActive = false;
198
 
                                if(channel == 2)
199
 
                                        DigitalJockey2Controller.CUP_Button2_IsActive = false;
200
 
                        }
201
 
                        if(currentlyPlaying == 0){
202
 
                                engine.setValue("[Channel"+channel+"]","cue_default",1);
203
 
                                midi.sendShortMsg(0x90, 0x55, DigitalJockey2Controller.ledOff); // Turn on the Play LED off
204
 
                                //Turn CUP LED on
205
 
                                midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn);
206
 
                                if(channel == 1)
207
 
                                        DigitalJockey2Controller.CUP_Button1_IsActive = true;
208
 
                                if(channel == 2)
209
 
                                        DigitalJockey2Controller.CUP_Button2_IsActive = true;
210
 
                        }
211
 
                }
212
 
                else{
213
 
                        //If track is playing, CUP = CUE
214
 
                        engine.setValue("[Channel"+channel+"]","cue_default",1);
215
 
                        engine.setValue("[Channel"+channel+"]","cue_default",0);
216
 
                        engine.setValue("[Channel"+channel+"]","player",0);
 
181
                //If no song is loaded
 
182
                if (engine.getValue("[Channel"+channel+"]", "duration") == 0) { 
 
183
                                return; 
 
184
                };
 
185
                var currentlyPlaying = engine.getValue("[Channel"+channel+"]","play");
 
186
                //print ("isPlaying" + currentlyPlaying);
 
187
                if(currentlyPlaying == 1){
217
188
                        if(channel == 1) {
218
189
                                midi.sendShortMsg(0x90, 0x19, DigitalJockey2Controller.ledOff);   // Turn on the Play LED off
219
 
                                midi.sendShortMsg(0x90, 0x17, DigitalJockey2Controller.ledOff); //Turn CUP LED off
220
 
                                DigitalJockey2Controller.CUP_Button1_IsActive = false;
221
190
                        }
222
 
                        if(channel == 2){
 
191
                        else if(channel == 2){
223
192
                                midi.sendShortMsg(0x90, 0x55, DigitalJockey2Controller.ledOff);   // Turn on the Play LED off
224
 
                                midi.sendShortMsg(0x90, 0x53, DigitalJockey2Controller.ledOff); //Turn CUP LED off
225
 
                                DigitalJockey2Controller.CUP_Button2_IsActive = false;
226
193
                        }
227
194
                }
 
195
 
 
196
                engine.setValue("[Channel"+channel+"]","cue_default",1);
 
197
                engine.setValue("[Channel"+channel+"]","cue_default",0);
 
198
                engine.setValue("[Channel"+channel+"]","play",1);
 
199
 
 
200
                if(channel == 1) {
 
201
                        DigitalJockey2Controller.CUP_Button1_IsActive = true;
 
202
                }
 
203
                else if(channel == 2){
 
204
                        DigitalJockey2Controller.CUP_Button2_IsActive = true;
 
205
                }
228
206
                
229
207
        }
230
208
}
240
218
        if(value == DigitalJockey2Controller.keyPressed){
241
219
                if(isHeadPhoneActive == 1){
242
220
                        engine.setValue("[Channel"+channel+"]","pfl",0);
243
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff); //Turn LED off
244
221
                }
245
222
                else{
246
223
                        engine.setValue("[Channel"+channel+"]","pfl",1);
247
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn); //Turn LED off
248
224
                }
249
225
        }
250
226
}
255
231
                var isKillButtonIsActive = engine.getValue("[Channel"+deck+"]","filterLowKill");
256
232
                if(isKillButtonIsActive == true){
257
233
                        engine.setValue("[Channel"+deck+"]","filterLowKill",0);
258
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff);
259
234
                }
260
235
                else{
261
236
                        engine.setValue("[Channel"+deck+"]","filterLowKill",1);
262
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn);
263
237
                }
264
238
        }
265
239
}
269
243
                var isKillButtonIsActive = engine.getValue("[Channel"+deck+"]","filterMidKill");
270
244
                if(isKillButtonIsActive == true){
271
245
                        engine.setValue("[Channel"+deck+"]","filterMidKill",0);
272
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff);
273
246
                }
274
247
                else{
275
248
                        engine.setValue("[Channel"+deck+"]","filterMidKill",1);
276
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn);
277
249
                }
278
250
        }
279
251
}
284
256
                var isKillButtonIsActive = engine.getValue("[Channel"+deck+"]","filterHighKill");
285
257
                if(isKillButtonIsActive == true){
286
258
                        engine.setValue("[Channel"+deck+"]","filterHighKill",0);
287
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff);
288
259
                }
289
260
                else{
290
261
                        engine.setValue("[Channel"+deck+"]","filterHighKill",1);
291
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn);
292
262
                }
293
263
        }
294
264
}
298
268
                var isKillButtonIsActive = engine.getValue("[Channel"+deck+"]","filterLowKill");
299
269
                if(isKillButtonIsActive == true){
300
270
                        engine.setValue("[Channel"+deck+"]","filterLowKill",0);
301
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff);
302
271
                }
303
272
                else{
304
273
                        engine.setValue("[Channel"+deck+"]","filterLowKill",1);
305
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn);
306
274
                }
307
275
        }
308
276
}
312
280
                var isKillButtonIsActive = engine.getValue("[Channel"+deck+"]","filterMidKill");
313
281
                if(isKillButtonIsActive == true){
314
282
                        engine.setValue("[Channel"+deck+"]","filterMidKill",0);
315
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff);
316
283
                }
317
284
                else{
318
285
                        engine.setValue("[Channel"+deck+"]","filterMidKill",1);
319
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn);
320
286
                }
321
287
        }
322
288
}
326
292
                var isKillButtonIsActive = engine.getValue("[Channel"+deck+"]","filterHighKill");
327
293
                if(isKillButtonIsActive == true){
328
294
                        engine.setValue("[Channel"+deck+"]","filterHighKill",0);
329
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff);
330
295
                }
331
296
                else{
332
297
                        engine.setValue("[Channel"+deck+"]","filterHighKill",1);
333
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn);
334
298
                }
335
299
        }
336
300
}
640
604
                        midi.sendShortMsg(0x90, 0x18, DigitalJockey2Controller.ledOff); //Turn CUE LED1 off
641
605
                }
642
606
                else{ //if deck is playing but not in CUE modus
643
 
                        if( engine.getValue("[Channel1]","cue_default") == 0){
 
607
                        if(DigitalJockey2Controller.CUP_Button1_IsActive == false){
644
608
                                midi.sendShortMsg(0x90, 0x19, DigitalJockey2Controller.ledOn);   // Turn on the Play LED1 on
645
609
                        }
646
610
                }       
652
616
                        midi.sendShortMsg(0x90, 0x54, DigitalJockey2Controller.ledOff); //Turn CUE LED2 off
653
617
                }
654
618
                else{
655
 
                        if( engine.getValue("[Channel2]","cue_default") == 0)
 
619
                        if(DigitalJockey2Controller.CUP_Button2_IsActive == false)
656
620
                                midi.sendShortMsg(0x90, 0x55, DigitalJockey2Controller.ledOn);   // Turn on the Play LED2 on
657
621
                }       
658
622
}
740
704
}
741
705
DigitalJockey2Controller.OnPFL_Button1 = function (value){
742
706
        if(value == 1){
743
 
                        midi.sendShortMsg(0x90, 0x5, DigitalJockey2Controller.ledOn); //Turn LED off
 
707
                        midi.sendShortMsg(0x90, 0x05, DigitalJockey2Controller.ledOn); //Turn LED off
744
708
                }
745
709
                else{
746
 
                        midi.sendShortMsg(0x90, 0x5, DigitalJockey2Controller.ledOff); //Turn LED off
 
710
                        midi.sendShortMsg(0x90, 0x05, DigitalJockey2Controller.ledOff); //Turn LED off
747
711
                }
748
712
}
749
713
DigitalJockey2Controller.OnPFL_Button2 = function (value){
760
724
                engine.setValue(group,"loop_in",1);
761
725
        }
762
726
        else{
763
 
                midi.sendShortMsg(status, control, DigitalJockey2Controller.ledOff); //Turn LED on
 
727
                midi.sendShortMsg(status, control, DigitalJockey2Controller.ledOff); //Turn LED off
764
728
        }
765
729
}
766
730
DigitalJockey2Controller.LoopOut = function (channel, control, value, status, group) {
769
733
                engine.setValue(group,"loop_out",1);
770
734
        }
771
735
        else{
772
 
                midi.sendShortMsg(status, control, DigitalJockey2Controller.ledOff); //Turn LED on
 
736
                midi.sendShortMsg(status, control, DigitalJockey2Controller.ledOff); //Turn LED off
773
737
        }
774
738
}
775
739
DigitalJockey2Controller.ReloopExit = function (channel, control, value, status, group){
780
744
        else{
781
745
                engine.setValue(group,"reloop_exit",0);
782
746
        }
783
 
}
 
747
        var actBeatLoop = engine.getValue(group, "beatloop");
 
748
        print("ReloopExit.actBeatLoop=" + actBeatLoop);
 
749
        if (actBeatLoop != "0") {
 
750
                print("Set BeatLoop To Zero");
 
751
                engine.setValue(group,"beatloop","0");
 
752
        }
 
753
}
784
754
DigitalJockey2Controller.BeatLoop = function (channel, control, value, status, group) {
785
755
        if(value == DigitalJockey2Controller.keyPressed){
786
 
                midi.sendShortMsg(status, control, DigitalJockey2Controller.ledOn); //Turn LED on
787
 
                if(channel == 1)
788
 
                    engine.setValue(group,"beatloop_4",1);
789
 
                else
790
 
                    engine.setValue(group,"beatloop_4",1);
 
756
                midi.sendShortMsg(status, control, DigitalJockey2Controller.ledOn); //Turn LED on
 
757
                engine.setValue(group,"beatloop","4");
791
758
        }
792
759
        else{
793
 
                midi.sendShortMsg(status, control, DigitalJockey2Controller.ledOff); //Turn LED on
 
760
                midi.sendShortMsg(status, control, DigitalJockey2Controller.ledOff); //Turn LED off
794
761
        }
795
 
}
796
 
 
 
762
}
797
763
DigitalJockey2Controller.LoopActiveLED1 = function (value){
798
764
        //if loop is active, we exit the loop
799
765
        if(value == 1){
800
766
                midi.sendShortMsg(0x90, 0x12, DigitalJockey2Controller.ledOn); //Turn LED on
801
767
        }
802
768
        else{
803
 
                midi.sendShortMsg(0x90, 0x12, DigitalJockey2Controller.ledOff); //Turn LED on
 
769
                midi.sendShortMsg(0x90, 0x12, DigitalJockey2Controller.ledOff); //Turn LED off
804
770
        }
805
771
        
806
772
}
810
776
                midi.sendShortMsg(0x90, 0x4E, DigitalJockey2Controller.ledOn); //Turn LED on
811
777
        }
812
778
        else{
813
 
                midi.sendShortMsg(0x90, 0x4E, DigitalJockey2Controller.ledOff); //Turn LED on
 
779
                midi.sendShortMsg(0x90, 0x4E, DigitalJockey2Controller.ledOff); //Turn LED off
814
780
        }
815
781
        
816
782
}
820
786
        var flanger = engine.getValue("[Channel1]", "flanger");
821
787
            if(flanger){
822
788
                engine.setValue("[Channel1]", "flanger", 0);
823
 
                midi.sendShortMsg(0x90, 0xe, DigitalJockey2Controller.ledOff); //Turn LED off
824
789
            }
825
790
            else{
826
791
                engine.setValue("[Channel1]", "flanger", 1);
827
 
                    midi.sendShortMsg(0x90, 0xe, DigitalJockey2Controller.ledOn); //Turn LED on
828
792
            }
829
793
        }
830
794
}
833
797
        var flanger = engine.getValue("[Channel2]", "flanger");
834
798
            if(flanger){
835
799
                engine.setValue("[Channel2]", "flanger", 0);
836
 
                midi.sendShortMsg(0x90, 0x45, DigitalJockey2Controller.ledOff); //Turn LED off
837
800
            }
838
801
            else{
839
802
                engine.setValue("[Channel2]", "flanger", 1);
840
 
                    midi.sendShortMsg(0x90, 0x45, DigitalJockey2Controller.ledOn); //Turn LED on
841
803
            }
842
804
        }
843
805
}
880
842
        if(value == DigitalJockey2Controller.keyPressed){
881
843
                if(isKeyLock == 1){
882
844
                        engine.setValue("[Channel"+channel+"]","keylock",0);
883
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOff); //Turn LED off
884
845
                }
885
846
                else{
886
847
                        engine.setValue("[Channel"+channel+"]","keylock",1);
887
 
                        midi.sendShortMsg(0x90, control, DigitalJockey2Controller.ledOn); //Turn LED off
888
848
                }
889
849
        }
890
850
}
905
865
                midi.sendShortMsg(0x90, 0x3E, DigitalJockey2Controller.ledOff); //Turn KeyLock off
906
866
        }
907
867
}
 
868
 
 
869
DigitalJockey2Controller.OnFlangerChange1 = function(value){
 
870
        if(value == 1){
 
871
                midi.sendShortMsg(0x90, 0x0e, DigitalJockey2Controller.ledOn); //Turn LED on
 
872
        }
 
873
        else{
 
874
                midi.sendShortMsg(0x90, 0x0e, DigitalJockey2Controller.ledOff); //Turn LED off
 
875
        }
 
876
}
 
877
DigitalJockey2Controller.OnFlangerChange2 = function(value){
 
878
        if(value == 1){
 
879
                midi.sendShortMsg(0x90, 0x45, DigitalJockey2Controller.ledOn); //Turn LED on
 
880
        }
 
881
        else{
 
882
                midi.sendShortMsg(0x90, 0x45, DigitalJockey2Controller.ledOff); //Turn LED off
 
883
        }
 
884
}
 
885
 
 
886
DigitalJockey2Controller.LoopPlusMinusChannel1 = function (channel, control, value, status, group) {
 
887
        DigitalJockey2Controller.LoopPlusMinus(channel, control, value, status, group); 
 
888
}
 
889
DigitalJockey2Controller.LoopPlusMinusChannel2 = function (channel, control, value, status, group) {
 
890
        DigitalJockey2Controller.LoopPlusMinus(channel, control, value, status, group); 
 
891
}
 
892
 
 
893
DigitalJockey2Controller.beatloops = ["0.125", "0.25", "0.5", "1", "2", "4", "8", "16"];
 
894
 
 
895
DigitalJockey2Controller.getPrevBeatLoop = function (beatloop) {
 
896
        var i = 0;
 
897
        for (i = 0; i < DigitalJockey2Controller.beatloops.length; i++) {
 
898
                if (DigitalJockey2Controller.beatloops[i] == beatloop) {
 
899
                        if (i > 0)
 
900
                                return DigitalJockey2Controller.beatloops[i - 1];
 
901
                        else
 
902
                                return DigitalJockey2Controller.beatloops[0];
 
903
                }
 
904
        }
 
905
        return "0";
 
906
}
 
907
 
 
908
DigitalJockey2Controller.getNextBeatLoop = function (beatloop) {
 
909
        var i = 0;
 
910
        for (i = 0; i < DigitalJockey2Controller.beatloops.length; i++) {
 
911
                if (DigitalJockey2Controller.beatloops[i] == beatloop) {
 
912
                        if (i < DigitalJockey2Controller.beatloops.length - 1)
 
913
                                return DigitalJockey2Controller.beatloops[i + 1];
 
914
                        else
 
915
                                return DigitalJockey2Controller.beatloops[DigitalJockey2Controller.beatloops.length - 1];
 
916
                }
 
917
        }
 
918
        return "0";
 
919
}
 
920
 
 
921
DigitalJockey2Controller.LoopPlusMinus = function (channel, control, value, status, group) {
 
922
        var actBeatLoop = engine.getValue(group, "beatloop");
 
923
        print("LoopPlusMinus.actBeatLoop=" + actBeatLoop);
 
924
        if (actBeatLoop != "0") {
 
925
                if (value == 0x3F) {
 
926
                        var prevBeatLoop = DigitalJockey2Controller.getPrevBeatLoop(actBeatLoop);
 
927
                        print("LoopPlusMinus.prevBeatLoop=" + prevBeatLoop);
 
928
                        engine.setValue(group,"beatloop",prevBeatLoop);
 
929
                }
 
930
                else if (value == 0x41) {
 
931
                        var nextBeatLoop = DigitalJockey2Controller.getNextBeatLoop(actBeatLoop);
 
932
                        print("LoopPlusMinus.nextBeatLoop=" + nextBeatLoop );
 
933
                        engine.setValue(group,"beatloop",nextBeatLoop);
 
934
                }
 
935
        }
 
936
}
 
 
b'\\ No newline at end of file'