HISE Logo Forum
    • Categories
    • Register
    • Login

    Viewport

    Scheduled Pinned Locked Moved Scripting
    73 Posts 9 Posters 6.8k 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.
    • M
      mwplugs @d.healey
      last edited by

      @d-healey ```
      [
      "Brass",
      "Guitar",
      "Keys",
      "Piano",
      "Strings",
      "Vox"
      ]

      M 1 Reply Last reply Reply Quote 0
      • M
        mwplugs @mwplugs
        last edited by

        @mwplugs as desired it shows the categories

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

          But what does it contain at the point you are calling the join function.

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

          M 1 Reply Last reply Reply Quote 0
          • M
            mwplugs @d.healey
            last edited by

            @d-healey im simply trying to get the viewport to use the keyArray list.

            the only implementation ive seen that works to use lists is

            Viewport1.set("useList", true);
            Viewport1.set("items", list.join("\n"));

            1 Reply Last reply Reply Quote 0
            • M
              mwplugs
              last edited by

              without join it displays all on one line/selection basically as one long word

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

                The program runs from top to bottom, so if you do something with keyArray near the top of your script, before keyArray is populated, you won't get any useful results. You need to make sure things happen in the correct order.

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

                M 1 Reply Last reply Reply Quote 1
                • M
                  mwplugs @d.healey
                  last edited by

                  @d-healey there we go! ok so i got the left to populate with categories by rearranging.

                  now how do i get the samplemaps on the right to correspond to the category selected on the left?

                  1 Reply Last reply Reply Quote 0
                  • M
                    mwplugs
                    last edited by

                    im guessing i will have to have another list being made based on the selection somehow

                    1 Reply Last reply Reply Quote 0
                    • M
                      mwplugs
                      last edited by

                      Content.makeFrontInterface(1024, 768);
                      
                      const var Voice1 = Synth.getSampler("Voice1");
                      const var list = Voice1.getSampleMapList();
                      
                      inline function createTwoLevelHierarchy()
                      {
                          local allList = Voice1.getSampleMapList();
                          local obj = {};
                          
                          for(id in allList)
                          {
                              local tokens = id.split("/");
                              local key = tokens[0];
                              local value = tokens[1];
                              
                              if(obj[key])
                                  obj[key].push(value);
                              else
                                  obj[key] = [value];
                          }
                          
                          return obj;
                      }
                      
                      const var sorted = createTwoLevelHierarchy();
                      
                      const var keyArray = [];
                      
                      for(k in sorted)
                          keyArray.push(k);
                          
                      Console.print(trace(keyArray));
                      
                      
                      const var Viewport1 = Content.getComponent("Viewport1");
                      Viewport1.set("useList", true);
                      Viewport1.set("items", list.join("\n"));
                      const var Viewport2 = Content.getComponent("Viewport2");
                      Viewport2.set("useList", true);
                      Viewport2.set("items", keyArray.join("\n"));
                      inline function loadSampleFromViewport(component, value)
                      {
                          Voice1.loadSampleMap(list[value]);
                      }
                      
                      Viewport1.setControlCallback(loadSampleFromViewport);
                      
                      1 Reply Last reply Reply Quote 0
                      • d.healeyD
                        d.healey
                        last edited by

                        You'll probably want something like Lindon made - https://forum.hise.audio/topic/1404/help-with-custom-user-preset-example/9

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

                        M 1 Reply Last reply Reply Quote 0
                        • M
                          mwplugs @d.healey
                          last edited by

                          @d-healey yes ive checked that out. difference is he is manually creating the array for the categories. i just need to pull from the sorted object the same as we pulled categories and made them into keyArray, but instead make them list the samplemaps per category selected. there will ultimately be nearly 1000 samplemaps so doing them manually seems like a bad idea. if we are able to pull the categories from the sorted object then why not the samplemaps based on category? seems like what should be done opposed to manually creating arrays for each

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

                            @mwplugs Just run the object through a loop and pull out the data, same as keyArray but for the value instead of the keys.

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

                            1 Reply Last reply Reply Quote 0
                            • M
                              mwplugs
                              last edited by

                              im assuming the k here

                              for(k in sorted)
                              keyArray.push(k);

                              is reffering to key

                              so changing it to v pull the values?

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

                                i see no reference to why k is pulling keys but it is. so i made a new array and tried to change the k to v. nope. not sure how to do so ;|

                                const var keyArray = [];

                                for(k in sorted)
                                keyArray.push(k);

                                Console.print(trace(keyArray));

                                const var valueArray = [];

                                for(v in sorted)
                                valueArray.push(v);

                                Console.print(trace(valueArray));

                                there is no reference to a variable k however i do so the keys and value mentions in the code above

                                inline function createTwoLevelHierarchy()
                                {
                                    local allList = Voice1.getSampleMapList();
                                    local obj = {};
                                    
                                    for(id in allList)
                                    {
                                        local tokens = id.split("/");
                                        local key = tokens[0];
                                        local value = tokens[1];
                                        
                                        if(obj[key])
                                            obj[key].push(value);
                                        else
                                            obj[key] = [value];
                                    }
                                    
                                    return obj;
                                }
                                
                                const var sorted = createTwoLevelHierarchy();
                                
                                const var keyArray = [];
                                
                                for(k in sorted)
                                    keyArray.push(k);
                                    
                                Console.print(trace(keyArray));
                                
                                const var valueArray = [];
                                
                                for(v in sorted)
                                    valueArray.push(v);
                                    
                                Console.print(trace(valueArray));
                                
                                1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @mwplugs
                                  last edited by d.healey

                                  @mwplugs said in Viewport:

                                  im assuming the k here
                                  for(k in sorted)
                                  keyArray.push(k);
                                  is reffering to key
                                  so changing it to v pull the values?

                                  k is a made up name, you could call it what you want. Have you watched my scripting 101 video?

                                  You might find this informative too - https://www.tutorialspoint.com/javascript/javascript_forin_loop.htm

                                  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

                                  29

                                  Online

                                  1.7k

                                  Users

                                  11.7k

                                  Topics

                                  102.0k

                                  Posts