HISE Logo Forum
    • Categories
    • Register
    • Login

    Engine.loadUserPreset for expansions?

    Scheduled Pinned Locked Moved General Questions
    28 Posts 2 Posters 1.2k 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.
    • bendursoB
      bendurso @d.healey
      last edited by

      @d-healey It returns this:

      User preset /Volumes/Ben/Hise Projects/Raizes Player/UserPresets/{EXP::Auralis}Category 3/Native Preset.preset doesn't exist

      If I print this:

      local wildcardReference = expHandler.getCurrentExpansion().getWildcardReference("UserPresets/Category 3/Native Preset.preset");
      
      Console.print(wildcardReference);
      

      It returns the correct path: {EXP::Auralis}Category 3/Native Preset.preset

      But.. after inserting it on Engine.loadUserPreset, it adds the "User Preset" plugin full path (non expansion) at the beginning.

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

        @bendurso I wonder if it only works in the compiled plugin

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

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

          @bendurso I just found an example of where I used it, might help..

          Link Preview Image
          RhapsodyBoilerplate/includes/Expansions.js at main

          RhapsodyBoilerplate - Boilerplate code used by Rhapsody.

          favicon

          Codeberg.org (codeberg.org)

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

          bendursoB 1 Reply Last reply Reply Quote 1
          • bendursoB
            bendurso @d.healey
            last edited by

            @d-healey Thanks, I'm going to try... today I spent all day trying to make a custom preset browser with viewports (I almost got it), but I can't load the presets hehe.

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

              @bendurso said in Engine.loadUserPreset for expansions?:

              I spent all day trying to make a custom preset browser with viewports

              Why?

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

              bendursoB 1 Reply Last reply Reply Quote 0
              • bendursoB
                bendurso @d.healey
                last edited by

                @d-healey Because the searchbar don't work on expansions, and the button bounds "Add, Rename, Delete" can't be increased. Mainly for these two things.

                1 Reply Last reply Reply Quote 0
                • bendursoB
                  bendurso
                  last edited by

                  @Christoph-Hart Does Engine.loadUserPreset works for expansion presets? How should be the proper way to reference the path? Thanks :)

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

                    @bendurso Did you try using {EXP::Auralis}Category 3/Native Preset.preset directly?

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

                    bendursoB 1 Reply Last reply Reply Quote 0
                    • bendursoB
                      bendurso @d.healey
                      last edited by

                      @d-healey Yeap, doesnt work.

                      When you use a string path it adds "Plugin/User Presets" + the string path. (that's the error log of the console)

                      like this:
                      Plugin/User Presets/{EXP::Auralis}Category 3/Native Preset.preset

                      bendursoB d.healeyD 2 Replies Last reply Reply Quote 0
                      • bendursoB
                        bendurso @bendurso
                        last edited by bendurso

                        @bendurso The only way it doesnt return an error is if I use a object full path to the preset with FileSystem.fromAboslutePath(), it starts loading a bit and Hise crashes.

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

                          @bendurso said in Engine.loadUserPreset for expansions?:

                          When you use a string path it adds "Plugin/User Presets" + the string path.

                          You mean Engine.loadUserPreset("{EXP::Auralis}Category 3/Native Preset.preset");?

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

                          bendursoB 1 Reply Last reply Reply Quote 0
                          • bendursoB
                            bendurso @d.healey
                            last edited by bendurso

                            @d-healey Yeap, if you use that, the console returns:

                            User preset /Volumes/Ben/Hise Projects/Raizes Player/UserPresets/{EXP::Auralis}Category 3/Native Preset.preset doesn't exist
                            

                            It directly searches inside the main plugin User Presets folder, so it's impossible to make it work.

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

                              @bendurso You said using a File object causes a crash. What about instead of using fromAbsolutePath you piece the path together, something like this:

                              local rootFolder = Expansion.getRootFolder(); // I can't remember the proper function name
                              local preset = rootFolder.createDirectory("UserPresets").getChildFile("myPreset.preset");
                              

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

                              bendursoB 1 Reply Last reply Reply Quote 0
                              • bendursoB
                                bendurso @d.healey
                                last edited by bendurso

                                @d-healey I had also previously tried building the entire path that way and it doesn't work either :( I mean, it doesn't throw an error but it crashes.

                                I just tried in the compiled plugin, and it also crashes :(

                                d.healeyD 2 Replies Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @bendurso
                                  last edited by

                                  @bendurso I'll do some tests

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

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

                                    @bendurso Ok it's an issue with the loadUserPreset function

                                    This is what it looks like in the source

                                    File userPresetRoot = FrontendHandler::getUserPresetDirectory();
                                    
                                    userPresetToLoad = userPresetRoot.getChildFile(file.toString());
                                    

                                    As you can see, no matter what we pass in (file) it's always going to try and load it from the userPresetRoot which is the project's user presets folder not the expansion's. I'll see if I can implement a fix.

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

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

                                      I've played around with it but it would take me quite a while to find a solution and I don't have the time at the moment to really dig into it.

                                      Either we need to modify the loadUserPreset function to use the expansion's preset folder when the filename is an expansion wildcard reference. Or we need a separate Expansion.loadUserPreset() function. My preference would be for the former.

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

                                      bendursoB 1 Reply Last reply Reply Quote 1
                                      • bendursoB
                                        bendurso @d.healey
                                        last edited by

                                        @d-healey Nice, maybe I could post a feature request and see if anyone else is interested? I find it strange that no one has found this before.

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

                                          @bendurso said in Engine.loadUserPreset for expansions?:

                                          I find it strange that no one has found this before.

                                          I don't think many people are using expansions.

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

                                          1 Reply Last reply Reply Quote 0
                                          • bendursoB
                                            bendurso @d.healey
                                            last edited by

                                            @d-healey I was checking the source code, and actually I think it should work an expansion preset with the absolute path.

                                            void ScriptingApi::Engine::loadUserPreset(var file)
                                            {
                                            	auto name = ScriptingObjects::ScriptFile::getFileNameFromFile(file);
                                            
                                            	File userPresetToLoad;
                                            
                                            	if (File::isAbsolutePath(name))
                                            	{
                                            		userPresetToLoad = File(name);
                                            	}
                                            	else
                                            	{
                                            #if USE_BACKEND
                                            		File userPresetRoot = GET_PROJECT_HANDLER(getProcessor()).getSubDirectory(ProjectHandler::SubDirectories::UserPresets);
                                            #else
                                            		File userPresetRoot = FrontendHandler::getUserPresetDirectory();
                                            #endif
                                            

                                            Because the code you mentioned (the "else" part) only runs if it's not an absolute path.

                                            And it actually loads the preset with absolute path, but I don't know why it crashes immediately. It doesn't crash with a non-expansion preset, so the problem might be somewhere else.

                                            d.healeyD 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            16

                                            Online

                                            1.8k

                                            Users

                                            12.1k

                                            Topics

                                            104.9k

                                            Posts