Skip to content

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

Open

Description

@sensestage

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.

Activity

  1. sensestage commented on May 23, 2015

    @sensestage
    ContributorAuthor

    It may be easier to fix this in MantaOSC

  2. added this to the Later / Optional milestone on Jun 2, 2015
  3. LFSaw commented on Feb 11, 2017

    @LFSaw
    Member

    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");
    )
    
  4. LFSaw commented on Feb 11, 2017

    @LFSaw
    Member

    you have an idea for this, @adcxyz ?

  5. adcxyz commented on Feb 12, 2017

    @adcxyz
    Contributor

    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);
    	}
    
  6. adcxyz commented on Feb 12, 2017

    @adcxyz
    Contributor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions