HISE Logo Forum
    • Categories
    • Register
    • Login

    User hardcoded scripts

    Scheduled Pinned Locked Moved Feature Requests
    14 Posts 2 Posters 3.1k 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.
    • d.healeyD
      d.healey
      last edited by d.healey

      Here is an example of a script I would like to be able to share with other users, it can be dropped into a sampler or container and is used to set the playable range of an instrument, it can ignore notes that are out of the set range, change the colour of the keys on the virtual keyboard, and skip black or white keys. I can't share this with just a code snippet because it has includes from some of my other scripts.

      alt text

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

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

        It should be fixed in the latest commits:

        Link Preview Image
        - added support for multiple inclusion of script files · christophhart/HISE@7600b30

        The open source framework for sample based instruments - - added support for multiple inclusion of script files · christophhart/HISE@7600b30

        favicon

        GitHub (github.com)

        [link text](link url)

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

          The multi-inclusion seems to be working well, I like that it gives a notice in the console, but that isn't really the issue with my post in this thread :)

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

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

            That's embarrassing, I was only reading your last post and thought it was the other thread :)

            I have another proposition: How about a "CompressedScriptProcessor", that includes every external dependency but GZIPs the script into a binary file (or base64 encoded string just like the web snippet string)? You can then just distribute this file and it should contain everything to run.

            It won't be any sort of copy protection if that's what you're after though...

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

              That sounds like a good solution. Copy protection isn't an issue as I think they should be open source so developers can adapt them to their own projects. Would it include everything in the external files or just the functions that are used by the "main" script? Would it be able to resolve absolute file paths or will that end user have to sort that out?

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

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

                It would include everything (also absolute files). I don't know if its necessary to strip unneeded stuff, normally GZIP can reduce the size of text files pretty good (i could make some tinyfing operations like removing comments and whitespace before that).

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

                  I think comments and formatting should be left in, or their removal should be optional.

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

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

                    Making it optional it is :)

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

                      Alright I implemented a minimal solution:

                      1. You can export and compress a script using the context menu of the editor (Export as compressed script). It replaces all include statements with the actual file content (and skips multiple inclusions), then compresses it with GZIP and saves it to a custom file with the ending .cjs ( = compressed javascript ) in the project's script folder. This file should contain everything that the script needs.
                      2. You can import a compressed script, also using the editor's context menu (Import compressed script). Select a file and it will load it like a uncompressed script.

                      From this point on it will behave like a normal script - however everything that was included before is now written into the onInit callback, so it will bloat the preset size if you have a big include file for everything that will be duplicated for every script (in this case I'd recommend increasing the modularity of your file layout to reduce the amount of unnecessarily included code). Also the script is just as visible to the user as the uncompressed version - it just makes sharing easier.

                      This is highly expermental - I only tested it with some minimal examples, so let me know if there are issues.

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

                        Update: I added removal of unneeded namespaces before compressing. If a namespace isn't mentioned anywhere outside its definition, it will be removed. This also handles referencing within namespaces, so this code:

                        namespace firstUnusedSpace
                        {
                            reg a = 5;
                        }
                        
                        namespace secondUnusedSpace
                        {
                           reg b = firstUnusedSpace.a;
                        }
                        
                        Console.print("Empty");
                        

                        will be truncated to the last line even if the first namespace gets referenced.

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

                          This looks awesome, I shall try it out soon. Thanks :) you work very quickly!

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

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

                          21

                          Online

                          1.8k

                          Users

                          12.0k

                          Topics

                          104.7k

                          Posts