Holding specified amount of channels when their value change

Hey,

I’m quite stuck on what seems a fairly basic problem so hoped someone could help me out.

I have a (null) CHOP with 10 channels, all 1 sample. These channels all start with a value of 0, but can arbitrarily jump from 0 to 1 and back to 0.

When the first channel switches from 0 to 1 (say, channel 4), I want to keep outputting its value of 1. Every subsequent channel that switches from 0 to 1 while channel 4 is high, I want to set low. Only once channel 4 goes back to 0 do I want to start listening again for changes. If channel 9 is the first to switch from a 0 to a 1, I want to keep channel 9 high and all the others low. Multiple channels can switch from 0 to 1 in a single frame, in which case I’m fine with holding one of those channels at random.

Bonus points if it’s not just a single channel, but multiple - say the first two channels that switch from 0 to 1 I want to output high (lets say channel 5 and 8), everything that subsequently triggers 0 to 1 I want to keep outputting a 0. Once either channel 5 or 8 switch back to 0 (or both at the same time) I want to start listening for channels that change from 0-1 again, until I’ve got two channels high again

Hope that’s clear!

Thank you

I’ve written a c++ plug-in that does what I need it to do

Still curious how to do this with nodes but the cpp solution works just fine.

Hi @Cherub,

The Hold CHOP set to Sample “Off to On” is sufficient for what you are trying to do.

The first input of the Hold CHOP should be supplied with the output from your original CHOP containing the 10 channels. The second input, used for triggering the sample, should come from a Math CHOP which takes the original channels with Combine Channels set to “Maximum” - so whenever the first value of the original channels is > 0, the Hold CHOP will sample all channels and then ignore any further changes until all channels, at least ones, have been set to 0 again.
Slight complication, as the Hold CHOP does only resample on “Off to On” - it will hold the last state even if all incoming channels are 0. For that reason, take the final channels and multiply them with the channel coming from the Math.

Hope this makes sense.
Cheers
Markus
base_hold.tox (790 Bytes)

Thanks for your reply! I have been tinkering with hold chops a bit but just got really stuck. This doesn’t fully do what I want it to do though -

Set channel 2 to 1, the output is correct: chan2. Now set chan5 or any other to 1, the output is still correct (chan2 is still high). Now set chan2 to 0, the output is now incorrect (chan2 is still high, even though it went low). This is due to the math1 CHOP set to Maximum (the maximum is still 1, because chan5 is high). I reckon there must be a switch somewhere maybe, to flip between observing “none active, one flips high” and “one is high, wait for it to go low to switch back to none active” sorta thing.

Anyway, this is purely an exercise in TD now, the C++ implementation works a charm…! Added a ‘number of active channels’ option so it’s not just one channel that can go active, but a defined amount. Added a trigger chance (so it’s not just first come first serve, the channels need to roll higher than a user defined threshold to trigger) and a timeout system (if a channel goes low, wait for x seconds before one can go high again). Don’t want to waste your time!

Thanks!

Hi @Cherub,

ah - I see - yes missed that point.
So I changed it a bit, instead of taking the maximum, I add the channels together and feed it into a Logic CHOP set to be “on” if the input is in a specific range. This then triggers the Hold CHOP, now sampling “While On”. You can change the upper bounds value in the Logic CHOP to determine how many channels can be “high”

I think this is correct?

cheers
Markus
base_hold.tox (8.5 KB)