-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Components JS HotcueColor integration #2030
Conversation
I have also noticed that the HotcueButton complains ('ERROR: No hotcue number specified for new HotcueButton.') when subclassing it via |
This is expected behaviour, you are required to specify the hotcue number. |
This is cool! Will come super handy when mapping the MidiFighter! |
I know, but that doesn't make any sense when you just want to inherit the prototype of the HotcueButton. My question was if this will be an issue when inheriting the HotcueButton like that (because it will cause the constructor to return early).
I think this is essential since many controllers either don't support setting colors via SysEx or don't have it documented (like most numark products). |
In your examples you specify the property 'colors' as an array. This is assuming that the predefined colors have consecutive ids starting with 0. This assumption is true now, but maybe it's not in the future. You should pass an object with color ids as keys instead of an array. I think you don't need to change anything in the code, just keep this in mind when documenting. |
@Be-ing can you gives us a hand? |
Okay, I'll take a look. My first thought is that I'd rather add new, optional functionality to HotcueButton than add a new class. |
I did that initially at first but it made the code more polluted so figured to just split it into its separate class. This is how the class looks when the color functionality is integrated: var HotcueButton = function (options) {
if (options.number === undefined) {
print('ERROR: No hotcue number specified for new HotcueButton.');
return;
}
if (options.sendRGB !== undefined || options.colors !== undefined) {
if (options.colors === undefined) {
options.colors = color.predefinedColorsList();
}
this.colorIdKey = 'hotcue_' + options.number + '_color_id';
this.getColor = function() {
return color.jsColorFrom(engine.getValue(this.group, this.colorIdKey))
};
this.output = function(value) {
if (value > 0) {
var id = engine.getValue(this.group, this.colorIdKey)
var color = this.colors[id]
if (color instanceof Array) {
if (color.length !== 3) {
print("ERROR: invalid color array for id: " + id);
return;
}
if (this.sendRGB === undefined) {
print("ERROR: no custom method for sending rgb defined!");
return;
}
this.sendRGB(color);
} else if (typeof color === 'number') {
this.send(color);
}
} else {
this.send(this.off);
}
};
this.connect = function() {
if (undefined !== this.group &&
undefined !== this.outKey &&
undefined !== this.output &&
typeof this.output === 'function') {
this.connections[0] = engine.makeConnection(this.group, this.outKey, this.output);
}
if (undefined !== this.group) {
this.connections[1] = engine.makeConnection(this.group, this.colorIdKey, this.output);
}
}
}
this.number = options.number;
this.outKey = 'hotcue_' + this.number + '_enabled';
Button.call(this, options);
};
HotcueButton.prototype = new Button({
unshift: function () {
this.inKey = 'hotcue_' + this.number + '_activate';
},
shift: function () {
this.inKey = 'hotcue_' + this.number + '_clear';
},
}); I prefer the separate class approach to be honest.
@Be-ing since you probably coded that part, can you explain why that works / doesn't work? |
|
Sorry, I forgot to document that detail. I added that to the documentation on the wiki:
|
ohh, right, so my mistake was actually that I forgot to define a group when creating the Buttons in my test code. |
@Be-ing, have you made a decision if you prefer a separate class or not? What approach would you recommend? I really want to finish my NS6II mapping which depends on this feature. |
@Be-ing, IMO this is now finished. I've used it for a while now in my WIP NS6II mapping and it worked flawlessly. Can we merge this soon? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some preliminary comments, but I don't fully understand the code because I have not been following the discussions about hotcue colors too closely. Could you and/or @ferranpujolcamins document how the new color
object works on https://mixxx.org/wiki/doku.php/midi_scripting ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some preliminary comments, but I don't fully understand the code because I have not been following the discussions about hotcue colors too closely. Could you and/or @ferranpujolcamins document how the new color
object works on https://mixxx.org/wiki/doku.php/midi_scripting ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some preliminary comments, but I don't fully understand the code because I have not been following the discussions about hotcue colors too closely. Could you and/or @ferranpujolcamins document how the new color
object works on https://mixxx.org/wiki/doku.php/midi_scripting ?
Sorry for the duplicate comments. GitHub is having some issues right now... |
I'm sorry, I didn't find time to write some documentation. Here is what I came up so far. I don't want to publish it to the wiki right away because I don't know if I am properly explaining everything: Colored HotcuesAs most DJing applications, mixxx is capable of colored hotcues. There are several ways of accessing and processing color information in scripts. To keep compability with color limited hardware, we provide a [n] colors colorpalette: [Insert here].
The
Please note that I didn't really care about formatting and all that stuff since this is just a proposal. |
ping @Be-ing what do you think about the documentation I wrote? |
This depends on PR mixxxdj#2030. If the PR is merged, custom hot cue colors will immediately work with this mapping. In the meantime, the pads will light up in the mode's color (i.e. white in hot cue mode, blue in cue loop mode).
@Swiftb0y Thanks, nice work. The documentation looks good to me. As far as I'm concerned, the only thing blocking this is the current usage of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, sorry for slacking on my response. The documentation you posted above helps me understand the code better but I am still confused on what exactly a color ID is. Is that a number? A hex code? A special JS object created by the script engine?
Related: #2153 |
The colors API introduced the CO |
Co-Authored-By: Be <be.0@gmx.com>
I am trying to natively integrate the hotcue colors feature into components js. It's not nearly finished yet but I need some help so I decided to open this PR prematurely. For some reason, the custom
connect
method doesn't get called. The sampler buttons use a hack and set the outKey to null which causesconnect
to get called but I don't understand why that works...SampleCode:
TEST.btn1
).sendRGB
) which is a custom send function for translating the color and sending it out via sysex (seeTEST.btn2
).It will not perform any translation of the color and use the color codes of the predefined colors list.
TEST.btn3
)