HISE Logo Forum
    • Categories
    • Register
    • Login

    I dumped an LUT that I generated to a JSON: how do I access its contents after importing it back in?

    Scheduled Pinned Locked Moved Scripting
    8 Posts 2 Posters 121 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.
    • VirtualVirginV
      VirtualVirgin
      last edited by VirtualVirgin

      I made an LUT for things I want pre-computed.
      I dumped the LUT to a JSON and I can see the data is in there.
      When I import the JSON back in to work with it, it comes up as "undefined".

      const PCS_LUT = Engine.loadFromJSON("PCS_LUT.json");
      

      Screenshot 2025-01-11 at 4.55.14 PM.png

      How do I "unpack" the contents to use the LUT?

      You can listen to my orchestral mockups here:
      https://www.virtualvirgin.net/

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

        @VirtualVirgin Use the File/FileSystem APIs to load the JSON as an object.

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

        VirtualVirginV 1 Reply Last reply Reply Quote 0
        • VirtualVirginV
          VirtualVirgin @d.healey
          last edited by

          @d-healey said in I dumped an LUT that I generated to a JSON: how do I access its contents after importing it back in?:

          @VirtualVirgin Use the File/FileSystem APIs to load the JSON as an object.

          Thanks :)

          What kind of syntax do I use here?

          I'm not quite getting it:

          Screenshot 2025-01-11 at 5.06.35 PM.png

          Am I supposed to point to the file in the directory somehow?

          You can listen to my orchestral mockups here:
          https://www.virtualvirgin.net/

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

            @VirtualVirgin

            Yeah so if the file is on your desktop for example you would do this.

            const f = FileSystem.getFolder(FileSystem.Desktop).getChildFile("PCS_LUT.json");
            const pcsLut = f.loadAsObject();
            

            Now if this json data is something you want to embed in your plugin then instead of loading it as an outside file you should put the contents into a .js file and include it like a regular script.

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

            VirtualVirginV 1 Reply Last reply Reply Quote 0
            • VirtualVirginV
              VirtualVirgin @d.healey
              last edited by

              @d-healey Thanks again :)

              A couple more questions:

              1. I have a hashtag in a folder name in the directory. How do I handle that?
                Screenshot 2025-01-11 at 5.24.30 PM.png

              2. Instead of dumping my LUT to JSON, importing it and converting to a .js, is there a way to convert my generated LUT directly to a .js file?

              You can listen to my orchestral mockups here:
              https://www.virtualvirgin.net/

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

                @VirtualVirgin said in I dumped an LUT that I generated to a JSON: how do I access its contents after importing it back in?:

                I have a hashtag in a folder name in the directory. How do I handle that?

                I would change the folder name, special characters in folder names can be problematic - especially if you work with the commandline. But if you want to keep it I don't think HISE would have a problem with it, I haven't tested though.

                @VirtualVirgin said in I dumped an LUT that I generated to a JSON: how do I access its contents after importing it back in?:

                Instead of dumping my LUT to JSON, importing it and converting to a .js, is there a way to convert my generated LUT directly to a .js file?

                What format does it use? Is it just an array?

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

                VirtualVirginV 1 Reply Last reply Reply Quote 0
                • VirtualVirginV
                  VirtualVirgin @d.healey
                  last edited by VirtualVirgin

                  @d-healey It is an array with filled with objects that contain arrays. The lower-level arrays just contain integers.

                  You can listen to my orchestral mockups here:
                  https://www.virtualvirgin.net/

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

                    @VirtualVirgin

                    Just rename the file with a .js extension and assign the array to a variable.

                    For example if your file is this kind of thing

                    [
                        {someKey:[{anotherKey: data}]},
                        {someKey:[{anotherKey: data}]},
                        {someKey:[{anotherKey: data}]},
                        {someKey:[{anotherKey: data}]},
                        ...
                    ]
                    

                    Do this

                    namespace Lut
                    {
                        const pcs = [
                            {someKey:[{anotherKey: data}]},
                            {someKey:[{anotherKey: data}]},
                            {someKey:[{anotherKey: data}]},
                            {someKey:[{anotherKey: data}]},
                            ...
                        ]
                    }
                    

                    Then you can access it using Lut.pcs

                    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

                    23

                    Online

                    1.7k

                    Users

                    11.9k

                    Topics

                    103.6k

                    Posts