Access external functions from JIT

  • @Christoph-Hart I'm almost sure it will be possible in V3, but what about triggering a function from JIT currently?
    There are some nodes that can do it like midi or timer, but is it possible from JIT?

  • Actually I've rewritten these nodes and removed the ability to call Javascript functions 🙂

    The reason is that it's a violation of the encapsulation principle. Basically you have these layers:

        // JS functions... go here
            // nodes go here
                // JIT compiled stuff comes here

    Every layer must not access any of its parent properties and calling JS functions from a node (and worse from SNEX) would mess up this principle (same as changing node properties from SNEX). The reason is that they are supposed to be self-contained so that you can compile them (and a JIT compiled node that depends on a Javascript function doesn't make sense).

    The new timer and MIDI nodes do have a very basic API for defining SNEX functions, so this doesn't violate the principle (and if you compile these nodes, it can just take their SNEX function and call it natively). What is the content of the function that you've called in your timer callback / MIDI callback?

  • And here's a screenshot of the current WIP state of the node:


    The double getTimerValue() function is JIT compiled, so besides the performance improvement (you can run these timers now at audio rate without too much performance hit), the jit compiled version just has to create some glue code around it to get a valid C++ class with the same behavior:

    struct MyTimerNode
        void process(blablabla)
        double getTimerValue()
            return Math.randomDouble() * 0.5 + 0.2;

  • @Christoph-Hart Safety reasons I see... The goal would be to generate midi notes from JIT, or other nodes...

Log in to reply