collective: create OSC message to make a bitmask value
For the Manta the 8 slider led values need to be sent as a bitmask to turn particular LEDs on.
So from 8 led elements, the collective would need to create a bitmask output to send as an OSC message.
It may be easier to fix this in MantaOSC
here's some starting points.
Create Manta MKtl
q = ();
q.mantaBinary = "/<PATH/TO/MANTAOSC>/MantaOSC 0 31417 57120";
q.mantaBinary.runInTerminal;
q.manta = MKtl('manta', "*manta");
q.manta.device.updateSrcAddr(port: 31417);
q.manta.device.updateRecvPort(57120);
// enable LED control
q.manta..sendSpecialMessage(\enableLEDControl);
// set slider LED
q.setSliderLED = {|q, mktl, idx = 0, color = "off"| // "amber", "red"
mktl.device.destination.sendMsg("/manta/led/slider", color, 0, 1<<(7-idx));
};
q.setSliderLEDs = {|q, mktl, idx, color = "off"| // "amber", "red"
mktl.device.destination.sendMsg("/manta/led/slider", color, 0, 255-(255>>idx));
}
// set specific LED
q.setSliderLED(q.manta, 0, "off")
// clear and set random "bargraph-style"
(
q.setSliderLEDs(q.manta, 8, "off");
q.setSliderLEDs(q.manta, 9.rand, "amber");
)
you have an idea for this, @adcxyz ?
I guess OSCMKtlDevice:send should convert its outValues to a bitmasked array if an entry in its desc says so.
Generally, not sure how much sense it makes to implement every single-device case, could be considered just-in-case coding.
@lfsaw, does off/amber/red work with strings as in your example already?
// roughly, this would be the place to do it:
send { |key, val|
var elDesc, oscPath, outvalues,valIndex;
// ... dont set if no destination
// prepare outmessage value for a collective - array of values to send
if ( val.isKindOf( Array ) ){
elDesc = mktl.collectiveDescriptionFor( key );
valIndex = 0;
oscPath = elDesc[\oscPath];
outvalues = List.new;
elDesc[\argTemplate].do { |it|
if ( it.isNil ) {
outvalues.add( val.at( valIndex ) ); valIndex = valIndex + 1;
}{
outvalues.add( it )
};
};
if ( valIndex < val.size ) {
outvalues = outvalues ++ (val.copyToEnd( valIndex ) ) };
outvalues = outvalues.asArray;
////// ADD HERE: elDesc[\bitMask] describes bitMask conversion properties ////
if (elDesc[\bitMask].notNil) {
// do conversions here
outvalues = ...
};
} {
// prepare outmessage for value of a single element:
// ...
};
// and send
destination.sendMsg(oscPath, *outvalues);
}
It may be easier to fix this in MantaOSC I agree, why not implement simple-to-use set methods for the 8 slider LEDs in mantaOSC.