HISE Logo Forum
    • Categories
    • Register
    • Login

    Procedure for writing our own API for HiseScript?

    Scheduled Pinned Locked Moved Unsolved General Questions
    6 Posts 3 Posters 94 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.
    • HISEnbergH
      HISEnberg
      last edited by

      I am curious what the procedure is for writing/incorporating our own Scripting API that may not already exist.

      This might be a question specifically for Chirstoph, though perhaps @d-healey or some others here have experience with this.

      In my particular use case I am interested in the addition of a Markov API, specifically this one (though betters may exist):
      https://github.com/yeeking/MarkovModelCPP/tree/main

      However, thinking about this did make me wonder what the procedure was and the level of difficulty it takes. I've never really dived to deep into the scripting api section of the HISE source code.

      This is my general guess from looking into the source code:

      1. Create flag for it in hi_core/hi_core/HiseSettings.h
        DECLARE_ID(EnableMarkov);
        As well as adding some documentation.

      2. Add the MarkovModelCPP source to the tools folder

      3. Create two new files in hi_scripting/scripting/api/:

      • ScriptMarkovModel.h

      • ScriptMarkovModel.cpp

      1. Create a wrapper class that inherits from ConstScriptingObject to bridge the CPP library with JavaScript. This part has me quite confused still I have to learn more about how this works, but it seems to crop up in each class that isn't natively part of JUCE.

      2. Register the class with the JavaScript Engine (no idea on how this is done).

      I imagine there are probably some flags I need to add elsewhere to enable building with this new library as well. This is about as far as I made it though I could be delusional and completley overlooked some critical steps/details!

      Sidenote:
      My reasons for adding this library may not be the most justified. I am making a MIDI browser for finding MIDI files with certain similarities. This is probably better done offline in Python mind you and I can just generate a fat JSON file I could bring into HISE for this. A second option is just using the Math API that already exists. Still curious however.

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @HISEnberg
        last edited by

        @HISEnberg You've probably seen this already, but - https://docs.hise.dev/cpp_api/index.html#create-your-own-classes

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        HISEnbergH 1 Reply Last reply Reply Quote 0
        • HISEnbergH
          HISEnberg @d.healey
          last edited by

          @d-healey yes thank you 🙏

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

            you might get 90% there by copy & pasting any scripting object. There are a few virtual methods that you need to overwrite but hooking methods up is usually done through the internal Wrapper subclass and the API_VOID_METHOD_WRAPPER_X() preprocessor.

            Register the class with the JavaScript Engine (no idea on how this is done).

            Usually this is done by adding a method to the Engine / Synth class which creates and returns an object, just look at the myriad of existing methods like this one.

            If you want to conditionally include the class without too much intrusion into the HISE codebase, take a look at how the BeatportManager / the NKS manager are integrated.

            d.healeyD HISEnbergH 2 Replies Last reply Reply Quote 0
            • d.healeyD
              d.healey @Christoph Hart
              last edited by

              @Christoph-Hart I remember a while back you added some new class along with a bunch of comments to make it a kind of demo of how to implement a new class. But I can't remember which one it was, any idea?

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              1 Reply Last reply Reply Quote 0
              • HISEnbergH
                HISEnberg @Christoph Hart
                last edited by

                @Christoph-Hart Thank you for the nudge I was trying to find a good example to build from and this is giving me a better sense of the folder/file hierarchy relationship. I am still in the poke around the codebase and find out phase so will report back once I understand more.

                Happy to make a pull request to add it to the official version of HISE as well if I get it working, but I know this is a pretty niche case so unless there is a demand for it I won't bother!

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

                48

                Online

                1.8k

                Users

                12.0k

                Topics

                104.4k

                Posts