Skip to content
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

Merged
merged 10 commits into from
Jul 10, 2019
50 changes: 49 additions & 1 deletion res/controllers/midi-components-0.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@
print('ERROR: No hotcue number specified for new HotcueButton.');
return;
}
if (options.colors !== undefined || options.sendRGB !== undefined) {

Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
this.colorIdKey = 'hotcue_' + options.number + '_color_id';

if (options.colors === undefined) {
options.colors = color.predefinedColorsList();
}
}
this.number = options.number;
this.outKey = 'hotcue_' + this.number + '_enabled';
Button.call(this, options);
Expand All @@ -301,8 +309,48 @@
shift: function () {
this.inKey = 'hotcue_' + this.number + '_clear';
},
getColor: function() {
if (this.colorIdKey !== undefined) {
return color.predefinedColorFromId(engine.getValue(this.group,this.colorIdKey));
} else {
return false;
Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
}
},
output: function(value) {
var outval = this.outValueScale(value);
if (this.colorIdKey !== undefined && outval !== this.off) {
Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
this.outputColor(engine.getValue(this.group, this.colorIdKey));
Be-ing marked this conversation as resolved.
Show resolved Hide resolved
} else {
this.send(outval);
}
},
outputColor: function (id) {
var color = this.colors[id];
Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
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!");
Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
return;
}
this.sendRGB(color);
} else if (typeof color === 'number') {
this.send(color);
}
},
connect: function() {
Button.prototype.connect.call(this); // call parent connect
if (undefined !== this.group && this.colorIdKey !== undefined) {
this.connections.push(engine.makeConnection(this.group, this.colorIdKey, function (id) {
Swiftb0y marked this conversation as resolved.
Show resolved Hide resolved
if (engine.getValue(this.group,this.outKey)) {
this.outputColor(id);
}
}));
}
},
});

var SamplerButton = function (options) {
if (options.number === undefined) {
print('ERROR: No sampler number specified for new SamplerButton.');
Expand Down