Merge lp:~zestoi/mixxx/controller_scripts into lp:~mixxxdevelopers/mixxx/trunk
- controller_scripts
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 3226 |
Proposed branch: | lp:~zestoi/mixxx/controller_scripts |
Merge into: | lp:~mixxxdevelopers/mixxx/trunk |
Diff against target: |
429 lines (+80/-166) 3 files modified
mixxx/res/controllers/Hercules-DJ-Console-Mk2-hid-scripts.js (+5/-2) mixxx/res/controllers/Novation-Launchpad-scripts.js (+63/-69) mixxx/res/controllers/common-controller-scripts.js (+12/-95) |
To merge this branch: | bzr merge lp:~zestoi/mixxx/controller_scripts |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mixxx Development Team | Pending | ||
Review via email: mp+107559@code.launchpad.net |
Commit message
Description of the change
* use engine.spinback() and engine.brake() in launchpad and mk2 mappings and the common-
* add in missing led feedback for channel2 eq kills in the herc mapping
* fix for the led feedback in the launchpad mapping - cause by the different runtime environment after the merge of madjester's code last night (i think) where 'this' is now in the engine as opposed to the controller instance
- 3218. By Zestoi
-
remove debug
- 3219. By Zestoi
-
removed javascript implementation of spinback/brake and renamed script.
spinbackDefault to script.spinback and script.brakeDefault to script.brake - 3220. By Zestoi
-
whitespace
- 3221. By Zestoi
-
fixed new context for incomingData() and used new lambda style calling of engine.
connectControl( )
Preview Diff
1 | === modified file 'mixxx/res/controllers/Hercules-DJ-Console-Mk2-hid-scripts.js' |
2 | --- mixxx/res/controllers/Hercules-DJ-Console-Mk2-hid-scripts.js 2012-05-26 14:22:39 +0000 |
3 | +++ mixxx/res/controllers/Hercules-DJ-Console-Mk2-hid-scripts.js 2012-05-29 18:21:20 +0000 |
4 | @@ -231,6 +231,9 @@ |
5 | c.feedback("[Channel1]", "filterHighKill", c.kill_status); |
6 | c.feedback("[Channel1]", "filterMidKill", c.kill_status); |
7 | c.feedback("[Channel1]", "filterLowKill", c.kill_status); |
8 | + c.feedback("[Channel2]", "filterHighKill", c.kill_status); |
9 | + c.feedback("[Channel2]", "filterMidKill", c.kill_status); |
10 | + c.feedback("[Channel2]", "filterLowKill", c.kill_status); |
11 | |
12 | // |
13 | // clear/setup any initial leds |
14 | @@ -261,10 +264,10 @@ |
15 | engine.setValue(g, "flanger", v > 0); |
16 | break; |
17 | case 2: |
18 | - script.spinback(g, v > 0); |
19 | + engine.spinback(parseInt(g.substring(8,9)), v > 0); |
20 | break; |
21 | case 3: |
22 | - script.brake(g, v > 0); |
23 | + engine.brake(parseInt(g.substring(8,9)), v > 0); |
24 | } |
25 | break; |
26 | case "hotcue": |
27 | |
28 | === modified file 'mixxx/res/controllers/Novation-Launchpad-scripts.js' |
29 | --- mixxx/res/controllers/Novation-Launchpad-scripts.js 2012-05-26 14:22:39 +0000 |
30 | +++ mixxx/res/controllers/Novation-Launchpad-scripts.js 2012-05-29 18:21:20 +0000 |
31 | @@ -25,6 +25,8 @@ |
32 | this.vumeters = []; |
33 | |
34 | var self = NovationLaunchpad; |
35 | + self.instance = this; // needed for incoming data from the launchpad |
36 | + |
37 | this.colors = self.colors(); |
38 | this.capture = self.capture; |
39 | this.feedback = self.feedback; |
40 | @@ -153,10 +155,11 @@ |
41 | |
42 | // led feedback for loop in/out buttons to show loop status |
43 | |
44 | - this.feedback(group, "loop_enabled", function(self, g, e, value) { |
45 | - var offset = g == "[Channel1]" ? 0 : 4; // ???? |
46 | - self.send("3," + (offset + 0), self.colors[value > 0 ? 'hi_green' : 'lo_green'], page); |
47 | - self.send("3," + (offset + 1), self.colors[value > 0 ? 'hi_green' : 'lo_green'], page); |
48 | + engine.connectControl(group, "loop_enabled", function(value, g, e) { |
49 | + var offset = g == "[Channel1]" ? 0 : 4; // value not closed |
50 | + this.send("3," + (offset + 0), this.colors[value > 0 ? 'hi_green' : 'lo_green'], 1); |
51 | + this.send("3," + (offset + 1), this.colors[value > 0 ? 'hi_green' : 'lo_green'], 1); |
52 | + this.feedback_cache[g + e] = value; |
53 | }); |
54 | |
55 | // hotcues or needle drop with shift2 pressed |
56 | @@ -185,10 +188,11 @@ |
57 | this.toggle("7," + (offset + 0), "press", 1, 'hi_yellow', 'lo_red', group, "play"); |
58 | |
59 | // flash play button when near end of track |
60 | - this.feedback(group, "playposition", function(self, g, e, value) { |
61 | + engine.connectControl(group, "playposition", function(value, g, e) { |
62 | if (value > 0.9 && engine.getValue(g, "play") > 0) { |
63 | - self.send(g == "[Channel1]" ? "7,0" : "7,4", self.colors['flash_hi_red'], 1); |
64 | + this.send(g == "[Channel1]" ? "7,0" : "7,4", this.colors['flash_hi_red'], 1); |
65 | } |
66 | + this.feedback_cache[g + e] = value; |
67 | }); |
68 | |
69 | // sync or move beatgrid when shift is pressed |
70 | @@ -233,15 +237,23 @@ |
71 | }, |
72 | |
73 | // |
74 | + // empty shutdown method |
75 | + // |
76 | + |
77 | + shutdown: function() { |
78 | + }, |
79 | + |
80 | + // |
81 | // convert incoming midi to a 'name' and call callbacks (if any) |
82 | // |
83 | |
84 | incomingData: function(channel, control, value, status, group) { |
85 | - if ((name = this.control2name["" + status + control]) != undefined) { |
86 | - if (this.callbacks[name] != undefined) { |
87 | - var callbacks = this.callbacks[name]; |
88 | + var me = NovationLaunchpad.instance; |
89 | + if ((name = me.control2name["" + status + control]) != undefined) { |
90 | + if (me.callbacks[name] != undefined) { |
91 | + var callbacks = me.callbacks[name]; |
92 | for (var i=0; i<callbacks.length; i++) { |
93 | - if ((callbacks[i][1] == 0 || callbacks[i][1] == this.page) && typeof(callbacks[i][2]) == 'function') { |
94 | + if ((callbacks[i][1] == 0 || callbacks[i][1] == me.page) && typeof(callbacks[i][2]) == 'function') { |
95 | |
96 | // |
97 | // check we need to call for this value change: all, press, release |
98 | @@ -255,7 +267,7 @@ |
99 | // call a callback function for this control |
100 | // |
101 | |
102 | - callbacks[i][2](this, group, name, value); |
103 | + callbacks[i][2].call(me, group, name, value); |
104 | } |
105 | } |
106 | } |
107 | @@ -351,35 +363,6 @@ |
108 | }, |
109 | |
110 | // |
111 | - // map a callback to an event from mixxx |
112 | - // |
113 | - |
114 | - feedback: function(g, e, f) { |
115 | - if (g != "" && e != "") { |
116 | - engine.connectControl(g, e, "NovationLaunchpad.feedbackData"); |
117 | - if (this.feedbacks[g + e] == undefined) { |
118 | - this.feedbacks[g + e] = []; |
119 | - } |
120 | - this.feedbacks[g + e].push(f); |
121 | - } |
122 | - }, |
123 | - |
124 | - // |
125 | - // call callbacks from mixxx events |
126 | - // |
127 | - |
128 | - feedbackData: function(v, g, e) { |
129 | - this.feedback_cache[g + e] = v; |
130 | - if (this.feedbacks[g + e] != undefined) { |
131 | - for (func in this.feedbacks[g + e]) { |
132 | - if (typeof(this.feedbacks[g + e][func]) == "function") { |
133 | - this.feedbacks[g + e][func](this, g, e, v); |
134 | - } |
135 | - } |
136 | - } |
137 | - }, |
138 | - |
139 | - // |
140 | // map a callback to a launchpad button name |
141 | // |
142 | |
143 | @@ -414,25 +397,27 @@ |
144 | |
145 | // launchpad => mixxx |
146 | |
147 | - this.capture(name, "all", page, function(self, g, name, value) { |
148 | + this.capture(name, "all", page, function(g, name, value) { |
149 | + |
150 | if (callback == undefined) { |
151 | engine.setValue(group, event, value); |
152 | } |
153 | else if (typeof(callback) == "function") { |
154 | if (values == "all" || (values == "press" && value > 0) || (values == "release" && value == 0)) { |
155 | - callback(group, event, value); |
156 | + callback.call(this, group, event, value); |
157 | } |
158 | } |
159 | |
160 | if (values == "all" || (values == "press" && value > 0) || (values == "release" && value == 0)) { |
161 | - self.send(name, self.colors[value > 0 ? on_color : off_color], page); |
162 | + this.send(name, this.colors[value > 0 ? on_color : off_color], page); |
163 | } |
164 | }); |
165 | |
166 | // mixxx => launchpad |
167 | |
168 | - this.feedback(group, event, function(self, g, e, value) { |
169 | - self.send(name, self.colors[value > 0 ? on_color : off_color], page); |
170 | + engine.connectControl(group, event, function(value, g, e) { |
171 | + this.send(name, this.colors[value > 0 ? on_color : off_color], page); |
172 | + this.feedback_cache[g + e] = value; |
173 | }); |
174 | |
175 | // init led |
176 | @@ -445,27 +430,28 @@ |
177 | // |
178 | |
179 | toggle: function(name, values, page, on_color, off_color, group, event, callback) { |
180 | - this.capture(name, "press", page, function(self, g, name, value) { |
181 | - if (typeof(self.toggle_cache[page][name]) == "undefined") { |
182 | - self.toggle_cache[page][name] = 0; |
183 | + this.capture(name, "press", page, function(g, name, value) { |
184 | + if (typeof(this.toggle_cache[page][name]) == "undefined") { |
185 | + this.toggle_cache[page][name] = 0; |
186 | } |
187 | - self.toggle_cache[page][name] = self.toggle_cache[page][name] == 0 ? 1 : 0; |
188 | + this.toggle_cache[page][name] = this.toggle_cache[page][name] == 0 ? 1 : 0; |
189 | |
190 | if (callback == undefined) { |
191 | - engine.setValue(group, event, self.toggle_cache[page][name]); |
192 | + engine.setValue(group, event, this.toggle_cache[page][name]); |
193 | } |
194 | else if (typeof(callback) == "function") { |
195 | - callback(group, event, self.toggle_cache[page][name]); |
196 | + callback.call(this, group, event, this.toggle_cache[page][name]); |
197 | } |
198 | |
199 | - self.send(name, self.colors[self.toggle_cache[page][name] > 0 ? on_color : off_color], page); |
200 | + this.send(name, this.colors[this.toggle_cache[page][name] > 0 ? on_color : off_color], page); |
201 | }); |
202 | |
203 | // mixxx => launchpad |
204 | |
205 | - this.feedback(group, event, function(self, g, e, value) { |
206 | - self.send(name, self.colors[value > 0 ? on_color : off_color], page); |
207 | - self.toggle_cache[page][name] = value > 0 ? 1 : 0; |
208 | + engine.connectControl(group, event, function(value, g, e) { |
209 | + this.send(name, this.colors[value > 0 ? on_color : off_color], page); |
210 | + this.toggle_cache[page][name] = value > 0 ? 1 : 0; |
211 | + this.feedback_cache[g + e] = value; |
212 | }); |
213 | |
214 | // init led |
215 | @@ -478,11 +464,14 @@ |
216 | // |
217 | |
218 | hotcue: function(name, page, group, num) { |
219 | - this.capture(name, "press", page, function(self, g, name, value) { |
220 | - if (self.shift2) { |
221 | + |
222 | + // launchpad => mixxx |
223 | + |
224 | + this.capture(name, "press", page, function(g, name, value) { |
225 | + if (this.shift2) { |
226 | engine.setValue(group, "playposition", (num-1)/8); |
227 | } |
228 | - else if (self.shift) { |
229 | + else if (this.shift) { |
230 | engine.setValue(group, "hotcue_" + num + "_clear", 1); |
231 | } |
232 | else { |
233 | @@ -490,8 +479,11 @@ |
234 | } |
235 | }); |
236 | |
237 | - this.feedback(group, "hotcue_" + num + "_enabled", function(self, g, e, value) { |
238 | - self.send(name, self.colors[value > 0 ? 'hi_red' : 'black'], page); |
239 | + // mixxx => launchpad |
240 | + |
241 | + engine.connectControl(group, "hotcue_" + num + "_enabled", function(value, g, e) { |
242 | + this.send(name, this.colors[value > 0 ? 'hi_red' : 'black'], page); |
243 | + this.feedback_cache[g + e] = value; |
244 | }); |
245 | }, |
246 | |
247 | @@ -538,8 +530,8 @@ |
248 | // launchpad => mixxx |
249 | |
250 | for (var btn=0; btn<nbtns; btn++) { |
251 | - this.capture((y-btn)+","+x, "press", page, function(self, g, name, value) { |
252 | - var cap = name.match(/^(\d+),\d+/); |
253 | + this.capture((y-btn)+","+x, "press", page, function(g, name, value) { |
254 | + var cap = name.match(/^(\d+),\d+/); // value not closed |
255 | var num = y - cap[1] + 1; |
256 | engine.setValue(group, action, incr * num); |
257 | }); |
258 | @@ -548,15 +540,16 @@ |
259 | |
260 | // mixxx => launchpad |
261 | |
262 | - this.feedback(group, action, function(self, g, e, value) { |
263 | + engine.connectControl(group, action, function(value, g, e) { |
264 | for (btn=0; btn<nbtns; btn++) { |
265 | if (value > btn*incr) { |
266 | - self.send((y-btn)+","+x, self.colors[on_color], page); |
267 | + this.send((y-btn)+","+x, this.colors[on_color], page); |
268 | } |
269 | else { |
270 | - self.send((y-btn)+","+x, self.colors[off_color], page); |
271 | + this.send((y-btn)+","+x, this.colors[off_color], page); |
272 | } |
273 | } |
274 | + this.feedback_cache[g + e] = value; |
275 | }); |
276 | }, |
277 | |
278 | @@ -567,17 +560,18 @@ |
279 | vumeter: function(y, x, page, nbtns, on_color, off_color, group, action) { |
280 | var incr = 1 / nbtns; |
281 | this.vumeters.push([ y, x, page, nbtns, on_color, off_color, group, action ]); |
282 | - this.feedback(group, action, function(self, g, e, value) { |
283 | - if (self.vumeter_shift > 0) { |
284 | + engine.connectControl(group, action, function(value, g, e) { |
285 | + if (this.vumeter_shift > 0) { |
286 | for (btn=0; btn<nbtns; btn++) { |
287 | if (value > btn*incr) { |
288 | - self.send((y-btn)+","+x, self.colors[on_color], page); |
289 | + this.send((y-btn)+","+x, this.colors[on_color], page); |
290 | } |
291 | else { |
292 | - self.send((y-btn)+","+x, self.colors[off_color], page); |
293 | + this.send((y-btn)+","+x, this.colors[off_color], page); |
294 | } |
295 | } |
296 | } |
297 | + this.feedback_cache[g + e] = value; |
298 | }); |
299 | }, |
300 | |
301 | |
302 | === modified file 'mixxx/res/controllers/common-controller-scripts.js' |
303 | --- mixxx/res/controllers/common-controller-scripts.js 2012-05-27 12:48:11 +0000 |
304 | +++ mixxx/res/controllers/common-controller-scripts.js 2012-05-29 18:21:20 +0000 |
305 | @@ -123,112 +123,29 @@ |
306 | } |
307 | |
308 | /* -------- ------------------------------------------------------ |
309 | - script.spinbackDefault |
310 | - Purpose: wrapper around spinback() that can be directly mapped |
311 | + script.spinback |
312 | + Purpose: wrapper around engine.spinback() that can be directly mapped |
313 | from xml for a spinback effect |
314 | + e.g: <key>script.spinback</key> |
315 | Input: channel, control, value, status, group |
316 | Output: none |
317 | -------- ------------------------------------------------------ */ |
318 | -script.spinbackDefault = function(channel, control, value, status, group) { |
319 | - // disable on note-off or zero value note/cc |
320 | - script.spinback(group, ((status & 0xF0) != 0x80 && value > 0)); |
321 | +script.spinback = function(channel, control, value, status, group) { |
322 | + // disable on note-off or zero value note/cc |
323 | + engine.spinback(parseInt(group.substring(8,9)), ((status & 0xF0) != 0x80 && value > 0)); |
324 | } |
325 | |
326 | /* -------- ------------------------------------------------------ |
327 | - script.brakeDefault |
328 | - Purpose: wrapper around brake() that can be directly mapped |
329 | + script.brake |
330 | + Purpose: wrapper around engine.brake() that can be directly mapped |
331 | from xml for a brake effect |
332 | + e.g: <key>script.brake</key> |
333 | Input: channel, control, value, status, group |
334 | Output: none |
335 | -------- ------------------------------------------------------ */ |
336 | -script.brakeDefault = function(channel, control, value, status, group) { |
337 | - // disable on note-off or zero value note/cc |
338 | - script.brake(group, ((status & 0xF0) != 0x80 && value > 0)); |
339 | -} |
340 | - |
341 | -/* -------- ------------------------------------------------------ |
342 | - script.spinback |
343 | - Purpose: Activate or disable a spinback effect on the chosen deck |
344 | - Input: group, enable/disable, [delay], [factor], [inital rate] |
345 | - Output: None |
346 | - -------- ------------------------------------------------------ */ |
347 | -script.spinback = function(group, activate, factor, rate, delay) { |
348 | - if (factor == undefined) factor = 0.8; |
349 | - if (rate == undefined) rate = -10; |
350 | - if (delay == undefined) delay = 5; |
351 | - script.deckSpinbackBrake(group, activate, factor, rate, delay); |
352 | -} |
353 | - |
354 | -/* -------- ------------------------------------------------------ |
355 | - script.brake |
356 | - Purpose: Activate or disable a brake effect on the chosen deck |
357 | - Input: group, enable/disable, [delay], [factor], [inital rate] |
358 | - Output: None |
359 | - -------- ------------------------------------------------------ */ |
360 | -script.brake = function(group, activate, factor, rate, delay) { |
361 | - if (factor == undefined) factor = 0.95; |
362 | - if (rate == undefined) rate = 1; |
363 | - if (delay == undefined) delay = 0; |
364 | - script.deckSpinbackBrake(group, activate, factor, rate, delay); |
365 | -} |
366 | - |
367 | -script.deckSpinbackBrakeData = {}; |
368 | - |
369 | -script.deckSpinbackBrake = function(group, activate, factor, rate, delay) { |
370 | - |
371 | - if (activate != undefined) { |
372 | - |
373 | - // store the current settings |
374 | - |
375 | - if (script.deckSpinbackBrakeData[group] == undefined) { |
376 | - script.deckSpinbackBrakeData[group] = { timer: null, delay: delay, factor: factor, rate: rate }; |
377 | - } |
378 | - else { |
379 | - script.deckSpinbackBrakeData[group].delay = delay; |
380 | - script.deckSpinbackBrakeData[group].factor = factor; |
381 | - script.deckSpinbackBrakeData[group].rate = rate; |
382 | - } |
383 | - |
384 | - // kill timer when both enabling or disabling |
385 | - |
386 | - if (script.deckSpinbackBrakeData[group].timer != null) { |
387 | - engine.stopTimer(script.deckSpinbackBrakeData[group].timer); |
388 | - script.deckSpinbackBrakeData[group].timer = null; |
389 | - } |
390 | - |
391 | - // enable/disable scratch2 mode |
392 | - |
393 | - engine.setValue(group, 'scratch2_enable', activate ? 1 : 0); |
394 | - |
395 | - if (activate) { |
396 | - // save keylock status and disable it |
397 | - if ((script.deckSpinbackBrakeData[group].keylock = engine.getValue(group, "keylock")) > 0) { |
398 | - engine.setValue(group, "keylock", 0); |
399 | - } |
400 | - |
401 | - // setup timer and send first scratch2 'tick' if activating |
402 | - script.deckSpinbackBrakeData[group].timer = engine.beginTimer(50, 'script.deckSpinbackBrake("' + group + '")'); |
403 | - engine.setValue(group, 'scratch2', script.deckSpinbackBrakeData[group].rate); |
404 | - } |
405 | - |
406 | - // re-enable keylock if needed |
407 | - |
408 | - else if (script.deckSpinbackBrakeData[group].keylock) { |
409 | - engine.setValue(group, "keylock", 1); |
410 | - } |
411 | - } |
412 | - else { |
413 | - // being called from a timer |
414 | - |
415 | - engine.setValue(group, 'scratch2', script.deckSpinbackBrakeData[group].rate); |
416 | - |
417 | - if (script.deckSpinbackBrakeData[group].delay > 0) { |
418 | - script.deckSpinbackBrakeData[group].delay--; |
419 | - } |
420 | - else { |
421 | - script.deckSpinbackBrakeData[group].rate *= script.deckSpinbackBrakeData[group].factor; |
422 | - } |
423 | - } |
424 | +script.brake = function(channel, control, value, status, group) { |
425 | + // disable on note-off or zero value note/cc |
426 | + engine.brake(parseInt(group.substring(8,9)), ((status & 0xF0) != 0x80 && value > 0)); |
427 | } |
428 | |
429 | // bpm - Used for tapping the desired BPM for a deck |