Using a boolean value to determine if a ctlbus value is set

This is the solution I found that works. Not really sure why. The problem seemed to be in the trigDetector SynthDef, not my sh SynthDef like I mentioned previously, though it has a different problem now. Perhaps new thread on that if I can’t figure it out :slight_smile: The main change was how I set signal, which I called outSignal before. BTW, using the belaScope tool helped a bunch. I think using SendTrig is messing me and my normal programming brain up.

	SynthDef(\trigDetector, {
		arg ctlBus, deviceId;

		var all = Array.fill(digitalPins.size, { |i|
		    DigitalIn.ar(digitalPins[i]);
		});
		
		// Convert all the bit array to a binary value
		var allId = all.reverse.reduce({ arg total, bit; total * 2 + bit }, 0);
		
		// Make sure they are set by delaying a little bit
		var delay_allId = TDelay.ar(in: allId, dur: 0.001);

		// Create bitmasks.  
		//  velMask is how many bit used for velocity
		//  devMask used for devices, of which there are only 2
		var velMask = pow(2, digitalPins.size - triggerCount) -1;
		var devMask = pow(2, triggerCount) - 1;

		// Use the masks to get the velocity and device that was activated
		var velocity = allId.bitAnd(velMask);
		var device = (allId >> (digitalPins.size - triggerCount)).bitAnd(devMask);

		// scale button between 0 and 1 based on velMask
		var button = velocity / velMask;

		// Combined this line to make it work
		var signal = Trig.ar( Select.ar(abs(device - deviceId) < 0.1, [K2A.ar(0), delay_allId * button]), 0.1);
		
		Out.ar(ctlBus, signal);
		Out.kr(ctlBus, signal);
		
		// SendTrig.ar(HPZ1.ar(delay_allId), 25, allId);
		// button.belaScope(2);
		// delay_allId.belaScope(0);
		// Pulse.ar(330.0, 0.5, 1.0, 0.0).belaScope(1);
	}).send(s);

Thanks everyone for all the help, each reply gets me a little closer to understanding.