Triggering a binary 'pulse' value

Hey!

I’m trying to trigger a value ‘pulse’ that only lasts for a frame.

I want to move a variable from 0 to 1 in a frame, and then move it back to 0 for the next frame. (Note: I am simulating a quick ‘mouse click’ which resets the buffers of a shader that I have pulled from ShaderToy).

My current approach is using the TriggerCHOP. I have reduced the decay length, the release length and the attack length to 0.001. I am triggering manually by clicking ‘Pulse’ - it feels a bit slow but ~maybe~ workable. The main problem with this is that I can’t figure out how to trigger the ‘pulse’ on the triggerChop from python code.

Does anyone have any ideas about how to trigger a quick, one-shot ‘pulse’ value in Touch Designer?

Also Note:
I found another simiar thread on this question: derivative.ca/forum/viewtopi … =27&t=5227. It suggested the TriggerCHOP, and elburz suggested the AnimationCOMP but I was confused by his explanation, and unsure if it was the right solution for this problem as the original post was a little more vague.

Thanks!!

Hey Sam,

The format here looks like:

op('trigger1').par.triggerpulse.pulse()

Take a look at the example below to see it in action:
trigger_pulse_example.tox (1.44 KB)

Another option would be to set your target part to one value, then change it back one frame later. From a CHOP execute that looks like:

[code]cmd = “op(‘constant1’).par.value0 = 0”

def onOffToOn(channel, sampleIndex, val, prev):

op('constant1').par.value0 		= 1
run(cmd, delayFrames = 1 )


return[/code]

See the example to see that function - here the trail CHOP is used just so you can see that the event actually happened:
base_one_frame.tox (1.43 KB)

1 Like

Amazing!!

Matt, Thank you so much!

:slight_smile:

Sorry for reopening this old conversation. I just wanted to ask whether it is normal to experience a little frame drop when using the first solution suggested by Matt.@raganmd
I am using the CHOP Execute to refresh the list of files in a Folder DAT, and there are just a few files.

As a follow up question, why does the frame rate dramatically drops if instead of using the CHOP Execute, I connect an LFO CHOP with Type “pulse” to a Logic with Rising Edge (like in the operator snippets) and export it directly to the Pulse parameter? Does it get triggered every frame?

Thanks in advance,

Roberto

Hi @roberto_fusco - frame drops might depend on a lot of things. To track down what’s happening for you I might first check to make sure the folder DAT itself isn’t causing any issues. You can do that by making sure it’s disconnected from your list of files.

If you’re using a replicator to make your list - then that’s probably the source of your frame drop. Replicators create operators on the fly, which is great for a lot of use cases, but can also be expensive and cause performance issues when linked to a live UI element.

Some operators cook every frame - trigger CHOPs, Logic CHOPs, LFOs are good examples here. I’d bet you’re essentially pulsing that refresh parameter constantly which would be part of your slow down.