HISE Logo Forum
    • Categories
    • Register
    • Login

    Can I set info to a JSON from the onInit script?

    Scheduled Pinned Locked Moved Scripting
    7 Posts 2 Posters 145 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

      I am trying to make the preset browser resize based on the main interface size, but to do that properly I need to write to the JSON file. Can that be done through onInit?

      You can listen to orchestral 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 what json file?

        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 This one:

          Screenshot 2024-12-10 at 10.56.20 PM.png

          Or maybe I can just set all of those properties with ".set"?

          You can listen to orchestral 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 Ah I understand now. So you can get the contents of the data property using .get("Data"). You can convert it to an object using .parseAsJSON(). Once it's an object it's easy to edit. Then you can turn the edited object back to a string using .trace(), and assign it to the data property using .set()

            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 I'm trying a test just to set the properties:

              PresetBrowser.set("MoreButtonBounds", ["300", "15", "30", "15"]);
              

              and I get an error:

              ! PresetBrowser.js (8): the property doesn't exist
              

              Am I formatting the data wrong?
              Is it expecting an array with strings like that?

              You can listen to orchestral 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 There isn't a MoreButtonBounds property as such. The property is called Data and it contains a JSON string. As I explained above you need to grab the Data string, convert it to an object, make your changes, convert it back to a string, and reassign it to the preset browser.

                You could also skip out the conversions and just work on the string directly, but this is messy.

                Here's an example.

                HiseSnippet 1222.3ocsV0saaaCElxIJXQ6mtBrG.BeybFLbsiccR1P2Rbbbm2pSLhy5FPQQAsDsEWjIEHoRpQQeG1c64XuBC6AZ2sKyNTR1xxwKMw.SWj3ye77wOd34v9RgKUoDRjkyESCoHqOwdvTt1+XeBii51FY8Y18HJMUhST0ZZHQondHKqMdtQg01ahh+96uqEIfvcoYpPnWJXtzWvlvzYZ6e3OxBB5P7nWvlrf2MNrqqferHPDA3YC6pnPh6kjwzSIF2JXi9dhxGY8U1UeZSJcu5i77H0q60rYyC1+fFGTiLpZCxvZMOnwtM1a282aDxZqS7XZgbflnoJXQaI7lNvWbMOIAujoXCCnFgZnAPlSTiN1mE30eF4nPHqM6mQUajPUegcOlGat9LJ6yiMfyhXQRypvcAoZO.HYs.j1LARO1dfqjEpyrXvyGa2kCmfiHvYyhPIwWTgeuf8wBvCttxDxkzNRPXdDkZVsZYL7mc9FGmm7D7yoZrjNhJovQMVKvZeJNTRUf9gRw0JpzANFUZ7UDItSffnY7wWvBn0vOCOKOio5iESBEbPnTwbdUbVhjjgwKtGQSfLHBoR8zx3q8Yt9XlBSvJsDhpLlv8vPNuBbvfHB9GFb1oXwvek5pSAS7h7r73wfhREaCVJtSkPhTQORYhrjAA.RUh.ZkPHE5RZogJLKxNovqGvT3oPoJ10mvGSUy3h3Lkj6JNFgJ8DRZqHsVvaIh3dpWU80.TplrNWDI4KGGdHT3ig7JluIi2iRJb1wFyWMs+kJb6EoJm7aV07MaYbtsynHtqlI3XA+TgldFuzNNuyYam26fW1znQqzl4TUJBBnxUZ1bMWdWAVhGMYHUVFJYBhnycDJqyeWYq62cE2jhrEbTv6xY5yBooxcDAdl6.lee6aVnzpT3W+TWCiYtrkpqeB4xLvwpM8Jn8VxUussaSUWpEgw9lVZC28zo8JRtrs3QBhAH3Q14NkPucw9gSyD91Cul4ogte1VUKfP9T1XesQ5Osli2Df7H69wkEsRpJPCGOqk51aAKz+XVMllNIS6ebyucSds6l5b7WLCT3uJX+NGLtngUGPtJsft3WC0RQzxyrbxaCIbEb3pNRAKUzDiGiHApLWh4d4pC2Tjot0ZB0.ItmyTlZnrD1ufsZUmGzQddqNEmS4v3jUaqMMfp+OrMfRjt9sHxkMzgbkPBTmY30h15DEDzmn8mYWkiIR2PcAxxi1RHAJIm8SiljvelvpGqJQ9mMkAmCULBvvq.8Xb0J0W5q7CTOn90w43ELk9HnMybJMMCkW0+lGUBxNWbcehmGTJeeiaNmlzWzDVhgk6XlsfYwNuFb4fmQ32xpy6gGebqYlvzZgWT.QmeDt4wMoFfx4byMMyFgyM8zEe7yCXtd06bt98EhO1tOS65uZLVXEXD5h8+AFSeMzmZexnQvrqL.tocmeYce5yGH8mKhLsL6QfYiPGSa31x.nskKExNmSCTlNiELcxSjqZjMLv.J2KV3F3K0XMirUpwZyLhlPbkh23lLgx7dqOJVCfId76Q2FdXLHiqghmZsHOOAd92abcyuT2JvcW2.qutA1XcC7oqafMW2.2acCb+ObflWmeTjVLI4ZCB0q+IwC4rrNgSfJv3pUz+BAyAuhA
                

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

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

                  @d-healey
                  Thanks! I got it working from your snippet.
                  The preset browser now resizes nicely if I change the interface size.

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

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

                  12

                  Online

                  1.7k

                  Users

                  11.8k

                  Topics

                  102.8k

                  Posts