HISE Logo Forum
    • Categories
    • Register
    • Login

    Viewport

    Scheduled Pinned Locked Moved Scripting
    73 Posts 9 Posters 7.0k 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.
    • Christoph HartC
      Christoph Hart
      last edited by

      I'd rather make an API like this:

      // returns the metadata as big JSON object. keys are the IDs, and the value is a object that you can populate with anything that can be converted to a JSON string.
      const var metadata = Sampler.getSampleMapMetadataList();
      
      const var currentMetadata = metadata[Sampler.getCurrentSampleMapId()];
      
      // read operation: check the tag for the currently loaded samplemap.
      if(currentMetadata["tags"].contains("hardcore")
      {
          // Something...
      }
      
      // write operation
      currentMetadata["tags"] = ["Tag 1", "Tag 2", "Tag 3"];
      
      // "flush" the write operation. This will reload the pooled samplemap (asynchronously).
      Sampler.writeMetadata(Sampler.getCurrentSampleMapId(), currentMetadata);
      1 Reply Last reply Reply Quote 0
      • DalartD
        Dalart @Christoph Hart
        last edited by

        @Christoph-Hart said in Viewport:

        Instead of the user loading sample maps think of it as the user loading presets and each preset is tied to a sample map. I'm doing this now for a synth project. It does mean creating 1000 presets manually though it seems but this allows you to use the standard preset browser to achieve the same goal - no meta handling though.

        Not sure about this. If you have to create 1000 things of something manually there has to be a smarter way.

        I am using something like you are talking about in HEXERACT to display a sound browser and it splits the samplemaps into categories based on their folder, then shows it in two viewports - one for the category, one for the folder. In this case it is only two levels, but it shouldn't be too hard adapting the code to support multiple levels.

        However your idea of attaching some kind of metadata to the samplemap makes sense - in fact there is already a bunch of metadata present (multimic IDs, round robin amount, etc), however if I do this I must be extremely careful not to break backwards compatitbility, which would add another pile of mess to the issues with samplemap loading at the moment :)

        The functionality of the viewport you described in Hexeract sounds like a solution I would be interested in and could use for some of the projects Im tinkering with.

        Is there an example or snippet around here somewhere for the dual viewport view and category listing ? 🙏

        JayJ 1 Reply Last reply Reply Quote 1
        • JayJ
          Jay @Dalart
          last edited by

          @Dalart Following

          Joansi Villalona

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

            Yes I will include a snippet for this in the new fancy documentation I am working on right now.

            Also I realized it makes absolutely no sense storing the metadata in the samplemap file - just include a separate JSON file with the sample id as key names and do whatever you need to do using stock Javascript data processing.

            DalartD 2 Replies Last reply Reply Quote 3
            • DalartD
              Dalart @Christoph Hart
              last edited by

              @Christoph-Hart Thank You !
              I cant wait to test it out and try to learn how it works =)

              1 Reply Last reply Reply Quote 0
              • DalartD
                Dalart @Christoph Hart
                last edited by

                @Christoph-Hart said in Viewport:

                Yes I will include a snippet for this in the new fancy documentation I am working on right now.

                Is there an ETA for the new documentation and examples or are they on github already somewhere ?

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

                  Is there an API for the Viewport yet?
                  Trying to figure out how to view the contents of a folder.... ultimately, midi files so I can load them into the new midi player.

                  Dan Korneff - Producer / Mixer / Audio Nerd

                  1 Reply Last reply Reply Quote 1
                  • DalartD
                    Dalart
                    last edited by

                    Im also still interested in how to view / sort the samplemaps into folders as talked about in this thread.

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

                      @Dalart @dustbro the "Registers & Chords" is a viewport

                      Skärmavbild 2019-08-28 kl. 23.13.36.png

                      I populated it using array
                      this array

                      const var ArtList = ["Stradella", "Freebass", "Tenor (Bass)", "Master (Bass)", "Alto (Bass)",
                      "Low Shift (Bass)", "Master Shift (Bass)", "High Shift (Bass)",
                      "Bassoon (Treble)", "Bandoneon (Treble)", "Master (Treble)", "Violin (Treble)", "Clarinet (Treble)",
                      "Major (Chord)", "Minor (Chord)", "Seventh (Chord)", "Diminished (Chord)"];
                      

                      and making the array readable in the VP

                      inline function onArtVpControl(component, value)
                      {
                          ArtVp.set("items", ArtVpList.join("\n"));
                          uaccVp.setValue(uaccUserList[value]-1);
                      };
                      

                      and accessing the value from another array called uaccUserList and sending it to the "uaccVp" which is an ComboBox

                      So the "ArtVp" is the ViewPort now populated with the array "ArtVpList" and clicking on any of the items in the ArtVp will get you a value, the same value as the index of the array, if I remember right, maybe the value starts with 1 (and the first index in an array is 0)

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

                      Dan KorneffD 1 Reply Last reply Reply Quote 2
                      • Dan KorneffD
                        Dan Korneff @ulrik
                        last edited by

                        @ulrik How do you populate it with the contents of a folder?

                        Dan Korneff - Producer / Mixer / Audio Nerd

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

                          @dustbro if you mean without having the folder content already in an array? I don't know. :(

                          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

                            @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
                                            • First post
                                              Last post

                                            23

                                            Online

                                            1.7k

                                            Users

                                            11.9k

                                            Topics

                                            103.5k

                                            Posts