Increment previous value & peculiar equals node behaviour

Hi :)

I’m going through the vvvv tutorials and I’m wondering how to increment a value every x amount of time.

If I were using Processing or P5 then I would do currentValue += increment every frame.

In my vvvv patch I’ve decided to use an LFO joined to a counter as my timer. The value of the counter is added to the position every time the LFO crosses a threshold. Is this the best approach to repeatedly increment a value in vvvv?

Also, one weird thing I encountered. I tried to use ‘equals’ logic to reset my counter, say when counter equals 1000 reset the counter to 0. However vvvv does not let me connect the equals output to the reset pin of the counter even though they are both boolean values. Oddly it does let me do it if I create a new equals node which has boolean inputs manually entered.

image

The Integrator node represents the += operation.

since vvvv also has a update method, you can do exactly the same like this:

image

and this does exactly the same but even more close to how a programmer would do it:
image
pseudo-code would look like this:

public class MyPatch
{
	float Value = 0;

	void Update()
	{
		var newValue = Value + 0.02;

		if (Value > 1)
			newValue = -1;

		Value = newValue;

		// Damper + Circle things
	}
}

callmenames-2020-03-22.vl (12.1 KB)

1 Like

Hey, thank you for pointing me at the Integrator node and taking the time to show me the patches. Super helpful.

Option two is very programmery :) Also a good example of how to use the IF region.

I have not understood what pads are in Gamma and how they work. Do you know if there is documentation? For example how does the pad know what it should get initialised to at the beginning.

a pad (aka property) is just a field of the surrounding data type/patch. it is initialized with the default value on creation of the instance (just like in any other OOP language). if you want to initialize it with another value on create, you can do it like that:

image

so you can can read and write into pads from any operation (method). the general rule we have is:

  • reading from pads happens as the first thing in an operation
  • writing to pads happens as the last thing in an operation

more on the gray book:
https://thegraybook.vvvv.org/reference/language/properties.html

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.