fix(xod/core): fix xod/core/delta to work just like before adding pulses into tabtests

This commit is contained in:
Kirill Shumilov
2018-11-23 17:53:09 +03:00
parent 92ed038f5f
commit 76935afa8a
3 changed files with 19 additions and 18 deletions

View File

@@ -12,15 +12,16 @@ void evaluate(Context ctx) {
auto inValue = getValue<input_IN>(ctx);
if (isInputDirty<input_RST>(ctx)) {
state->refValue = 0;
emitValue<output_OUT>(ctx, inValue);
state->refValue = inValue;
emitValue<output_OUT>(ctx, 0);
return;
}
if (isInputDirty<input_REF>(ctx)) {
state->refValue = inValue;
if (!isInputDirty<input_UPD>(ctx)) {
return;
}
auto outValue = inValue - state->refValue;
emitValue<output_OUT>(ctx, outValue);
state->refValue = inValue;
}

View File

@@ -1,10 +1,10 @@
IN BIAS RST OUT
IN UPD RST OUT
0 no-pulse no-pulse 0
10 pulse no-pulse 0
30 no-pulse no-pulse 20
0 no-pulse no-pulse -10
20 no-pulse pulse 20
10 no-pulse no-pulse 10
10 pulse no-pulse 0
10 pulse pulse 10
50 no-pulse no-pulse 50
10 pulse no-pulse 10
30 no-pulse no-pulse 10
20 no-pulse pulse 0
30 pulse no-pulse 10
50 pulse no-pulse 20
10 pulse no-pulse -40
10 pulse pulse 0
5 pulse no-pulse -5
1 IN BIAS UPD RST OUT
2 0 no-pulse no-pulse no-pulse 0
3 10 pulse pulse no-pulse 0 10
4 30 no-pulse no-pulse no-pulse 20 10
5 0 20 no-pulse no-pulse no-pulse pulse -10 0
6 20 30 no-pulse pulse pulse no-pulse 20 10
7 10 50 no-pulse pulse no-pulse 10 20
8 10 pulse pulse no-pulse 0 -40
9 10 pulse pulse pulse 10 0
10 50 5 no-pulse pulse no-pulse 50 -5

View File

@@ -1,5 +1,5 @@
{
"description": "Outputs a difference between the current `IN` value and its reference value.",
"description": "Calculates difference between current and past input values.",
"nodes": [
{
"id": "HyJCAXqNG",
@@ -10,9 +10,9 @@
"type": "xod/patch-nodes/not-implemented-in-xod"
},
{
"description": "Triggers memoization of the input value as the reference value.",
"description": "Update: trigger a calculation and store the current `IN` value as the new “past” value.",
"id": "S1bhCQqVM",
"label": "REF",
"label": "UPD",
"position": {
"x": 102,
"y": 0
@@ -20,7 +20,7 @@
"type": "xod/patch-nodes/input-pulse"
},
{
"description": "The difference between `IN` and the reference value which was stored when `REF` received a pulse. Can be positive or negative. Always equals to 0 on the first update.",
"description": "The last difference value.",
"id": "SkFpRm9Nz",
"position": {
"x": 34,
@@ -29,7 +29,7 @@
"type": "xod/patch-nodes/output-number"
},
{
"description": "Resets the reference value to 0.",
"description": "Resets the stored past value to the current input value. Efficiently sets `OUT` to 0.",
"id": "SyYn0X5NM",
"label": "RST",
"position": {