Modality-toolkit icon indicating copy to clipboard operation
Modality-toolkit copied to clipboard

collective: create OSC message to make a bitmask value

Open sensestage opened this issue 10 years ago • 5 comments

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.

sensestage avatar May 22 '15 12:05 sensestage

It may be easier to fix this in MantaOSC

sensestage avatar May 23 '15 14:05 sensestage

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");
)

LFSaw avatar Feb 11 '17 14:02 LFSaw

you have an idea for this, @adcxyz ?

LFSaw avatar Feb 11 '17 14:02 LFSaw

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);
	}

adcxyz avatar Feb 12 '17 20:02 adcxyz

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.

adcxyz avatar Feb 12 '17 22:02 adcxyz