HISE Logo Forum
    • Categories
    • Register
    • Login

    Display preset name and folder in label

    Scheduled Pinned Locked Moved Unsolved Scripting
    10 Posts 4 Posters 553 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.
    • I
      IsoWalle
      last edited by

      Hi!
      Just sat tinkering and was trying to have the preset name show in the preset browser together with the folder the preset is in. I already got the preset name, now I just need the folder.

      Was thinking like "ROCK - MALE 1", where "rock" is the folder and "male 1" is the preset.

      Any clues to how this can be achieved?

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

        @IsoWalle - print out the CurrentPreset name and you will see it include the full path, now use string manipulation to get what you want.

        HISE Development for hire.
        www.channelrobot.com

        I 1 Reply Last reply Reply Quote 0
        • I
          IsoWalle @Lindon
          last edited by

          @Lindon Using Engine.getCurrentUserPreset only gives me the name. I've tried to go through the File API and FileSystem, though these are really not my friend. My approach was to find the file with the current presets name and then get the directory, but i can't seem to figure it out.

          ulrikU 2 Replies Last reply Reply Quote 0
          • ulrikU
            ulrik @IsoWalle
            last edited by

            @IsoWalle can't you use

            Engine.getUserPresetList()
            

            and then, as Lindon says, use string manipulation to get the dir from the path?

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

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

              @IsoWalle

              Try and paste this in to your project

              Console.print(trace(Engine.getUserPresetList()));
              

              Skärmavbild 2022-10-06 kl. 09.57.32.png

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

              I 1 Reply Last reply Reply Quote 1
              • I
                IsoWalle @ulrik
                last edited by

                @ulrik Thank you!
                Though would this work if I had multiple presets with the same name in different folders?
                Then I wouldn't be able to search for the correct one using getCurrentPresetName?

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

                  @IsoWalle No it wouldn't, but you can get the path to the preset if you use the FileSystem functions

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

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

                    @ulrik But is it impossible then?
                    Since I can't get the (complete)path using the getCurrentUserPresetName, and I cant know which preset is active with using getUserPresetList.

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

                      @IsoWalle I guess you can't use getCurrentUserPresetName if there are several presets with the same name, I think you need to build your own preset browser based on the FileSystem.

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

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

                        If you fancy playing with C++ this is the function and I don't think it would be difficult at all to modify.

                        String ScriptingApi::Engine::getCurrentUserPresetName()
                        {
                        	return getProcessor()->getMainController()->getUserPresetHandler().getCurrentlyLoadedFile().getFileNameWithoutExtension();
                        }
                        

                        What I think might be better is to add a function to the user preset handler that returns the current preset as a file object.

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

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

                        48

                        Online

                        1.7k

                        Users

                        11.7k

                        Topics

                        102.1k

                        Posts