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

collective: create OSC message to make a bitmask value #189

Open
sensestage opened this issue May 22, 2015 · 5 comments
Open

collective: create OSC message to make a bitmask value #189

sensestage opened this issue May 22, 2015 · 5 comments

Comments

@sensestage
Copy link
Contributor

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
Copy link
Contributor Author

It may be easier to fix this in MantaOSC

@LFSaw LFSaw added this to the Later / Optional milestone Jun 2, 2015
@LFSaw
Copy link
Member

LFSaw commented Feb 11, 2017

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
Copy link
Member

LFSaw commented Feb 11, 2017

you have an idea for this, @adcxyz ?

@adcxyz
Copy link
Contributor

adcxyz commented Feb 12, 2017

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
Copy link
Contributor

adcxyz commented Feb 12, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants