I'm having a bit of a time figuring out how the observers work. Basically I just want to send back a color to the controller based on the track color to some buttons. I guess I have to put in the addColorObserver somewhere, but how do I put it into a function? I might be a bit slow, I read Tom's page about it, but didn't emerge any the wiser.
I already have detection of track, rgb-buttons and midi to/from working (at least as much as the controller allows for now). Here is the code I'm using to send MIDI back, nothing much yet, but at least it works as intended. My question is just where I'll put the observer in this scenario?
Code: Select all
function rgbLedMidiOut(channelIn, controlIn, hue, sat, bri) {
var midiChannelOut = [176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187];
var channelSelect = 0;
if (channelIn == 176) {
channelSelect = 0;
} else if (channelIn == 177) {
channelSelect = 3;
} else if (channelIn == 178) {
channelSelect = 6;
} else if (channelIn == 179) {
channelSelect = 9;
}
println(midiChannelOut[channelSelect]);
println(midiChannelOut[channelSelect] + 1);
println(midiChannelOut[channelSelect] + 2);
host.getMidiOutPort(0).sendMidi(midiChannelOut[channelSelect], controlIn, hue);
host.getMidiOutPort(0).sendMidi((midiChannelOut[channelSelect] + 1), controlIn, sat);
host.getMidiOutPort(0).sendMidi((midiChannelOut[channelSelect] + 2), controlIn, bri);
}