pulse-on-change(number)

xod/core/pulse-on-change(number)

Emits a pulse every time input value changes.
pulse-on-change(number)
@/pulse-on-change(number)
Emits a pulse every time input value changes.
INnumber
pulse-on-change(number)
IN
OUT
OUTpulse

C++ implementation

node {
    Number sample = NAN;

    void evaluate(Context ctx) {
        auto newValue = getValue<input_IN>(ctx);

        if (!isSettingUp() && newValue != sample)
            emitValue<output_OUT>(ctx, 1);

        sample = newValue;
    }
}

Tabular tests

INOUT
0no-pulse
12pulse
23pulse
23no-pulse
45pulse
0pulse
0no-pulse