Is it possible to make a widget color respond to an RGB-like message, communicated in a midi format?
For example:
Chn 1 Red
Chn 2 Green
Chn 3 Blue
Sending a note with different velocity combinations of these 3 channels would change the color of widget. If its possible, how would the implementation look like? Would it require dynamic css, "just" scripting for these variables, everything?
then in your custom module, you'd create a method in the OSCFilterIn to list these channels, and update them accordingly. Just update this to the addresses/midi channels/ports you are using
// hypothetical Channel 1 for Red
if (args[0].value === 1 && args[1].value === 1) {
receive("/chn1_Red", args[2].value)
}
Sorry to bother again.. I'm trying to be specific about where to direct the rgb values, accordingly to the note that's being sent.
For example note 12 on channel 1,2,3 would affect button_1
note 13 on the same channels would affect button_2...
etc
I'm going about filtering in the custom module, and got that working, but I'm failing to associate with the buttons. This is the current custom module
module.exports = {
oscInFilter: function(data) {
var { address, args, host, port } = data;
if (host === 'midi' && address === '/note') {
var channel = args[0].value;
var note = args[1].value;
var velocity = args[2].value;
if ((channel === 1 || channel === 2 || channel === 3) && (note >= 12 && note <= 19)) {
console.log("Filtered MIDI Note:", args);
let buttonId = 'button_' + (note - 23);
console.log("Sending to:", buttonId);
if (channel === 1) {
console.log("Channel 1, Sending Red Value:", velocity);
receive("/chn2_Red", velocity);
receive('/' + buttonId + '/chn2_Red', velocity);
}
if (channel === 2) {
console.log("Channel 2, Sending Green Value:", velocity);
receive("/chn3_Green", velocity);
receive('/' + buttonId + '/chn3_Green', velocity);
}
if (channel === 3) {
console.log("Channel 3, Sending Blue Value:", velocity);
receive("/chn4_Blue", velocity);
receive('/' + buttonId + '/chn4_Blue', velocity);
}
}
}
return { address, args, host, port };
}
};
It's generating and sending to the correct button_id, but I think it's the CSS part that I'm failing.