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.
    • ulrikU
      ulrik @ulrik
      last edited by ulrik

      @ulrik I found this line in "ScriptingApi.h" from the source code

      /** Returns a list of the sounds selected in the samplemap. */
      		var createListFromGUISelection();
      

      and

      /** Returns an array with all available sample maps. */
      		var getSampleMapList() const;
      

      maybe this has something to do with it?

      Hise Develop branch
      MacOs 15.3.1, Xcode 16.2
      http://musikboden.se

      ulrikU 1 Reply Last reply Reply Quote 0
      • ulrikU
        ulrik @ulrik
        last edited by ulrik

        @dustbro This will get you an array of all sampleMaps, then you can populate the ViewPort with the array.

        const var list = Sampler.getSampleMapList();
        

        I don't know about getting midi files from the folder, sorry.

        Hise Develop branch
        MacOs 15.3.1, Xcode 16.2
        http://musikboden.se

        LindonL 1 Reply Last reply Reply Quote 0
        • LindonL
          Lindon @ulrik
          last edited by Lindon

          @Christoph-Hart yes it would seem we need a generalised way to get the contents(a list of files) from a named folder - by type(e.g. *.wav, *.mid)

          Of course it would be nicest if this was a FloatingTile with a content type of FileList

          HISE Development for hire.
          www.channelrobot.com

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

            Nah, I won't do more FloatingTiles unless absolutely necessary - the overhead of adding the text colour for the directory name is killing me.

            What I can do is adding two simple function calls:

            /** Returns the folder that contains the application data of your plugin. */
            Engine.getAppDataFolder()
            
            /** Returns a list of filenames in the given folder (non-recursively). */
            Engine.getDirectoryContent(String filename)
            

            This way you could create a file browser for yourself by grabbing the list and throw it to a viewports items property. But I won't add more Norton Commander features to HISE, from there you're on your own (but file filtering can easily be done using standard Javascript methods).

            LindonL Dan KorneffD 2 Replies Last reply Reply Quote 2
            • LindonL
              Lindon @Christoph Hart
              last edited by

              @Christoph-Hart sounds good I assume this:

              Engine.getDirectoryContent(*.mid)
              

              would work? - of course as you say I could filter with javascript but then what would be the point in having "filename"

              HISE Development for hire.
              www.channelrobot.com

              1 Reply Last reply Reply Quote 0
              • Dan KorneffD
                Dan Korneff @Christoph Hart
                last edited by

                @Christoph-Hart said in Viewport:

                /** Returns the folder that contains the application data of your plugin. */
                Engine.getAppDataFolder()

                /** Returns a list of filenames in the given folder (non-recursively). */
                Engine.getDirectoryContent(String filename)

                Have these been added yet?

                Dan Korneff - Producer / Mixer / Audio Nerd

                C 1 Reply Last reply Reply Quote 2
                • C
                  coreyu21 @Dan Korneff
                  last edited by

                  @dustbro agreed, have these function calls been integrated yet?

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

                    @Christoph-Hart is there any example of this being done simply by having the samplemaps in categorized folders. seems much more simple than to have all this regex going on just to display simple lists. also cant the samplemap list in the containing folders and the category folder names themselves simply by calling to the directory? is there any example of this?

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

                      There's no easy solution for this because every project has another hierarchy.

                      inline function createTwoLevelHierarchy()
                      {
                          local allList = Sampler.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();
                      

                      This code creates an object with a two level hierarchy and can be used to populate two lists.

                      M 2 Replies Last reply Reply Quote 0
                      • M
                        mwplugs @Christoph Hart
                        last edited by

                        @Christoph-Hart said in Viewport:

                        inline function createTwoLevelHierarchy()
                        {
                        local allList = Sampler.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();

                        ok so i need to create a viewport called what? or two? im trying to interpret this. sorry

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

                          @mwplugs What Christoph has provided is a function to generate an object obj that contains the IDs of all of your sample maps and their folders. It's up to you to create a way to display them on your GUI (using viewports if you want).

                          You can see the contents of obj by right-clicking on the variable you save it to (sorted in his example) in the watch table.

                          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 ok i see that nice

                            so how do i get these into arrays or whatever

                            using two viewports? i see this is being created

                            {
                              "Brass": [
                                "FreshHornStaccato"
                              ],
                              "Guitar": [
                                "AcousticCampfire"
                              ],
                              "Keys": [
                                "DeepFuzzVibe",
                                "HorrorPianoFuzz"
                              ],
                              "Piano": [
                                "CloudyJazzPno",
                                "GoldenPiano",
                                "RustyPiano"
                              ],
                              "Strings": [
                                "ChamberTremelo",
                                "ChamberViolinPizz",
                                "ChamberViolinSpiccati",
                                "ChamberViolinTremble",
                                "MidMedSoloString",
                                "MovieStringStacc",
                                "SoloViolinLeg",
                                "ViolinPizz1",
                                "ViolinStaccato",
                                "ViolinStaccatoB"
                              ],
                              "Vox": [
                                "WhooMaleVox"
                              ]
                            }
                            

                            now how do i get the left viewport to pull the categories and the right to list the samplemaps? thanks

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

                              haha 2 days trying to figure out this simple thing i have no idea how to make this "sorted" object an array for the viewports :/

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

                                @Christoph-Hart the object created "sorted" does contain the proper data but there is no reference as to how to split to cats and maps into arrays to be used the viewports. ive looked at every post and reply in the whole forum with the words samplemaps and also viewports. there is one involving parsing characters from BD ludwig etc and displaying by filtering names but it is not relevant. i cannot get the data in the object into a list or array for it to be used in vp

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

                                  @mwplugs You don't need arrays, you have an object ;)

                                  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

                                    This turns the object into a flat key list:

                                    const var obj = {}; // some object
                                    
                                    const var keyArray = [];
                                    
                                    for(k in obj)
                                        keyArray.push(k);
                                    

                                    Put the keyArray into the left viewport, and set the items on the right viewport by fetching the instrument list from the obj using the value of the left callback. In the right callback, assemble the samplemap name from the two viewports and load it in the sampler.

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

                                      @Christoph-Hart Line 10, column 37: Unknown function 'join'

                                      const var s = Synth.getSampler("MySampler");
                                      const var list = Sampler.getSampleMapList();
                                      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)
                                      {
                                          s.loadSampleMap(list[value]);
                                      }
                                      
                                      Viewport1.setControlCallback(loadSampleFromViewport);
                                      
                                      inline function createTwoLevelHierarchy()
                                      {
                                          local allList = Sampler.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 obj = {}; // some object
                                      
                                      const var keyArray = [];
                                      
                                      for(k in obj)
                                          keyArray.push(k);
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • d.healeyD
                                        d.healey
                                        last edited by

                                        You've called your sampler variable s, not Sampler.

                                        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 fixed that. still says the same thing

                                          Content.makeFrontInterface(1024, 768);
                                          
                                          
                                          
                                          const var Sampler = Synth.getSampler("MySampler");
                                          const var list = Sampler.getSampleMapList();
                                          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)
                                          {
                                              Sampler.loadSampleMap(list[value]);
                                          }
                                          
                                          Viewport1.setControlCallback(loadSampleFromViewport);
                                          
                                          inline function createTwoLevelHierarchy()
                                          {
                                              local allList = Sampler.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 obj = {}; // some object
                                          
                                          const var keyArray = [];
                                          
                                          for(k in obj)
                                              keyArray.push(k);
                                          

                                          and with the code as is the keyArray is only [] there is no data in it

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

                                            @mwplugs said in Viewport:

                                            keyArray.join("\n"));

                                            no matter what i do this never works. keyArray.join("\n")); whatever i try to replace list with

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

                                            47

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            101.8k

                                            Posts