Bodysoulspirit's picture
Bodysoulspirit commented on Bodysoulspirit's Discussion, “Help with stateful nodes

Thank you Jaymie !

Will take myself some time to study your answer but already wanted to thank you :)

cremaschi's picture
mic commented on serge_gam's Discussion, “Vuo 2 beta / run Python script

You could using "append text" to build the script. See the example attached, that changes the IP value each time the phue_on is called.

jstrecker's picture
Jaymie commented on Bodysoulspirit's Discussion, “Help with stateful nodes

Once you get used to pointers and certain patterns become familiar, it gets easier :) You don't have to put all of your conscious focus into this being the address of that, you just know in the back of your mind.

The vuo.math.count node class's code is actually more complicated than it needs to be. There was a limitation in earlier versions of Vuo that meant we had to use more pointers than would otherwise be necessary. When we fixed that, we didn't go back and simplify the vuo.math.count code. (Now that you've brought it to our attention, we will.)

First, here's an annotated version of your code, since you've already familiar with it. I've left in the comments for the parts you already understood.

// Define the `nodeInstanceInit` function. It returns a value of type `VuoGenericType1 *`.
// Think of it like this:
//
// VuoGenericType1 * nodeInstanceInit(VuoGenericType1 setCount)
// {
//    // … body of the function …
// }
// 
// The `VuoInputData` is special syntax required by the Vuo compiler to recognize a parameter as an input port.
VuoGenericType1 * nodeInstanceInit
(
        // Function parameter of type `VuoGenericType1` named `setCount`.
        VuoInputData(VuoGenericType1) setCount
)
{
    // Declare a variable of type `VuoGenericType1 *` named `countState`.
    // Allocate a piece of memory the right size to hold a `VuoGenericType1` value. (The memory just holds uninitialized data at this point.)
    // Set `countState` to the address of that memory.
    VuoGenericType1 *countState = (VuoGenericType1 *) malloc(sizeof(VuoGenericType1));
 
    // Register `countState` with Vuo's reference-counting system.
    // Later during the composition execution, when the reference count of `countState` goes down to 0, the `free` function will be called to deallocate `countState`.
    // See https://api.vuo.org/latest/group___managing_memory.html
    VuoRegister(countState, free);
 
    // Copy the value of `setCount` into the piece of memory that `countState` points to.
    *countState = setCount;
 
    return countState; // Return the pointer
}
 
// Define the `nodeInstanceEvent` function.
// Think of it like this:
//
// void nodeInstanceEvent(VuoGenericType1 **countState, VuoGenericType1 increment, bool incrementEvent, VuoGenericType1 setCount, bool setCountEvent, VuoGenericType1 *count)
// {
//    …
// }
//
// The `VuoInstanceData`, `VuoInputEvent`, etc. are special syntax required by the Vuo compiler.
void nodeInstanceEvent
(
        // Function parameter of type `VuoGenericType1 **` named `countState`.
        // The `VuoInstanceData` adds an extra layer of pointers, making `countState` an output parameter.
        // See https://stackoverflow.com/questions/42403940/c-input-and-out-parameters-of-a-function .
        // The value of `*countState` in this function is the same as the value returned from the `nodeInstanceInit` function.
        VuoInstanceData(VuoGenericType1 *) countState,
 
        VuoInputData(VuoGenericType1, {"defaults":{"VuoInteger":1, "VuoReal":1.0}}) increment, // Ok I get this, we declare a Vuo Port
        VuoInputEvent({"eventBlocking":"none","data":"increment"}) incrementEvent, // Here we declare event blocking, ok
        VuoInputData(VuoGenericType1, {"defaults":{"VuoInteger":0, "VuoReal":0.0}}) setCount, // Another port, ok
        VuoInputEvent({"eventBlocking":"none","data":"setCount"}) setCountEvent, // Ok
 
        // Function parameter of type `VuoGenericType1 **` named `count`.
        // The `VuoOutputData` adds an extra layer of pointers, making `count` another output parameter.
        VuoOutputData(VuoGenericType1) count // Ok, this is the ouput port of the node
)
{
    if (incrementEvent) // Ok, each time the node receives an event do ...
        // Add `increment` to the count stored in the node instance data.
        // `**countState` is the piece of memory allocated in `nodeInstanceInit`.
        // `*countState` is a pointer to that memory.
        // `countState` is a pointer to a pointer to that memory.
        **countState += increment;
    if (setCountEvent) // when this receives en event, do ...
        // Set the count stored in the node instance data to `setCount`.
        **countState = setCount;
 
    // Set the output port's value to the count stored in the node instance data.
    // `*count` is the piece of memory where the output port value is stored (created by Vuo outside of this function).
    // `count` is a pointer to that memory (passed into this function by Vuo).
    *count = **countState;
}

Here's a simplified version with one fewer level of pointers for the node instance data:

// Think of it as:
// 
// VuoGenericType1 nodeInstanceInit(VuoGenericType1 setCount)
// {
//    …
// }
VuoGenericType1 nodeInstanceInit
(
        VuoInputData(VuoGenericType1) setCount
)
{
    return setCount;
}
 
// Think of it as:
//
// void nodeInstanceEvent(VuoGenericType1 *countState, VuoGenericType1 increment, bool incrementEvent, VuoGenericType1 setCount, bool setCountEvent, VuoGenericType1 *count)
// {
//    …
// }
void nodeInstanceEvent
(
        // Function parameter of type `VuoGenericType1 *` named `countState`.
        // The first time this function is called, `*countState` is the value that was returned from `nodeInstanceInit()`.
        VuoInstanceData(VuoGenericType1) countState,
 
        VuoInputData(VuoGenericType1, {"defaults":{"VuoInteger":1, "VuoReal":1.0}}) increment,
        VuoInputEvent({"eventBlocking":"none","data":"increment"}) incrementEvent,
        VuoInputData(VuoGenericType1, {"defaults":{"VuoInteger":1, "VuoReal":1.0}}) decrement,
        VuoInputEvent({"eventBlocking":"none","data":"decrement"}) decrementEvent,
        VuoInputData(VuoGenericType1, {"defaults":{"VuoInteger":0, "VuoReal":0.0}}) setCount,
        VuoInputEvent({"eventBlocking":"none","data":"setCount"}) setCountEvent,
        VuoOutputData(VuoGenericType1) count
)
{
    if (incrementEvent)
        *countState += increment;
    if (decrementEvent)
        *countState -= decrement;
    if (setCountEvent)
        *countState = setCount;
    *count = *countState;
}
jstrecker's picture
Jaymie commented on eledtech's Discussion, “FFGL Inputs

You could do that using the FFGL SDK and the Vuo SDK together.

Probably a good starting point would be to build something with each SDK individually. With the FFGL SDK, build an FFGL plugin that works in Resolume. With the Vuo SDK, build an application that runs a Vuo composition.

Once you've gotten a simple example working with each SDK to make sure you have the basics down, you could then add code into the FFGL plugin to make it run a Vuo composition. The process would be something like this:

  • Use the Vuo SDK's command-line tools to compile and link the composition into a dylib.
  • Copy VuoRunner.framework and the above dylib into the FFGL plugin bundle.
  • Use VuoRunner::newCurrentProcessRunnerFromDynamicLibrary() to launch the precompiled composition dylib.
  • Use VuoRunner::setPublishedInputPortValues(), VuoRunner::firePublishedInputPortEvent(), VuoRunner::waitForFiredPublishedInputPortEvent(), and VuoRunner::getPublishedOutputPortValue() to pass data between the FFGL plugin and the Vuo composition.
  • Render the output image into the FFGL framebuffer.
serge_gam's picture
serge_gam commented on serge_gam's Discussion, “Vuo 2 beta / run Python script

How to put a value from a node output to the python script?

Bodysoulspirit's picture

sinemod yes import will be great ;)

Related feature request : SVG & PDF import

Bodysoulspirit's picture
Bodysoulspirit commented on mike_iv's Discussion, “camera rotation around object

Use a Make Targeted Camera node that points to the desired object, then joined are 4 compositions with 4 different ways of moving the camera around.

I found the "Transform 3D Object" to be the easiest method ;)

Cheers

jstrecker's picture

Thanks for letting us know about this problem, Alastair. It's similar enough to this other bug report that I'm going to merge this one into it. The same fix will most likely fix both issues.

mike_iv's picture
mike_iv posted a new Discussion, “camera rotation around object
video piglet's picture

Thanks for the response! I managed to get hold of a kinect 360 and I can confirm it does indeed work straight out of the box (with my ten years old macbook pro). Fun stuff. Pity NiMate is discontinued, I'll post back if I find a substitute.

Pages

Welcome!

Vuo is more than nodes and cables, it's a community! Feel free to browse or add your voice.

Browse Discussions

Start a Discussion


Browse Feature Requests

Suggest a Feature


Browse the Composition Gallery

Share a Composition


How can I get notifications?

Learn more about the community

Learn more about Vuo

Vuo Announcements

Sign up for the Vuo announcements mailing list to get news and join the community. Typically a few emails per year.