HISE Logo Forum
    • Categories
    • Register
    • Login

    Access external functions from JIT

    Scheduled Pinned Locked Moved General Questions
    4 Posts 2 Posters 251 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ustkU
      ustk
      last edited by ustk

      @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?

      Can't help pressing F5 in the forum...

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

        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:

        javascript
        {
            // JS functions... go here
        
            scriptnode
            {
                // nodes go here
        
                snex
                {
                    // 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?

        1 Reply Last reply Reply Quote 3
        • Christoph HartC
          Christoph Hart
          last edited by

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

          d69f8ee2-4633-494f-bfc7-43176d839e16-image.png

          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)
              {
                  if(shouldCallTimer())
                      sendToTarget(getTimerValue();
              }
          
              double getTimerValue()
              {
                  return Math.randomDouble() * 0.5 + 0.2;
              }
          };
          
          ustkU 1 Reply Last reply Reply Quote 1
          • ustkU
            ustk @Christoph Hart
            last edited by

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

            Can't help pressing F5 in the forum...

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            51

            Online

            1.7k

            Users

            11.7k

            Topics

            101.8k

            Posts