How to return true from a SchmittTrigger when it pass from high to low?

Hello there, I’m back for a n00b question :slight_smile:

Usually, that’s my code that return “true” when a trigger pass from low to high (thresholds = 2V):

mStartTrigger.process(params[TRIG_PARAM].value * 10.0f + inputs[TRIG_INPUT].value / 2.0f)

What if I have a mStopTrigger that needs to return “true” when it pass from high to low? Is it possible with the actual trigger code or I need to subclass it and make my own?

Thanks

You’re using the Schmitt trigger incorrectly. You need to rescale the voltage or you’re going to have problems triggering from hardware and other signals. See https://vcvrack.com/manual/VoltageStandards#triggers-and-gates for the standard.

Normally you use it like this.

if (schmittTrigger.process(rescale(x, 0.1f, 2.f, 0.f, 1.f))) {}

It seems like you’re asking for this.

if (schmittTrigger.process(rescale(x, 2.f, 0.1f, 0.f, 1.f))) {}
1 Like

Ohhh! I take insipiration by Befaco module:

Not sure how I would calculate x from your example, having a button that range from [0,1].

This way? float x = params[TRIG_PARAM].value * 2.0f + inputs[TRIG_INPUT].value;

Else, clicking on the button will never reach the threshold…

It will only pass from high to low when inverted. That is a trigger will always pass from low to high. When it is not high it is not triggering. You can invert any input with a minus sign.

-inputs[...].getVoltage()

I’m not sure I understand what you are trying to do? If it is not triggering it is stopped.

bool stopped = (inputs[...].isConnected() && inputs[...]getVoltage() <= 0)