HISE Logo Forum
    • Categories
    • Register
    • Login

    How Can I Make Custom User Presets Extension

    Scheduled Pinned Locked Moved General Questions
    24 Posts 5 Posters 1.5k 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.
    • ?
      A Former User @Tania Ghosh
      last edited by

      @Tania-Ghosh No, it is not possible only with HISE, as far I know.

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

        @Tania-Ghosh Yes it is possible if you construct your own preset browser and use "Engine.dumpAsJSON" to save the presets and "Engine.loadFromJSON()" to load the presets

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

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

          @Tania-Ghosh Here I have an excerpt from my custom preset handling, and it handles only "pan" and "gain" for a 16 channel mixer.
          Here I use the extension ".mix" instead of .preset
          And because Hise can not read directories I also save an object to store all preset names so Hise knows which presets there is in the "UserPresets" folder.
          I wish Hise could browse the directory even if it's not documents with the extension ".preset"

          I hope you can make use of the code :)

          var MixerNames = []; //All UserPreset names
          var MixerData = {MixerNames:[]};    // The object to store
          var MixerPreset = [];   //Preset to store
          var count = 0;  // Count how many times SavePreset button has been pressed
          
          //  If there is no "MixerData" in UserPresets folder, this will create it with a Default preset
          if(Engine.loadFromJSON("MixerData") == undefined)
          {
              MixerNames.push(MixerDefault[0]);
              MixerData.MixerNames = MixerNames;
              Engine.dumpAsJSON(MixerData, "MixerData");
              Engine.dumpAsJSON(MixerDefault, "Default.mix");
              MixerPresetsCmb.set("items", "");
              MixerPresetsCmb.set("items", Engine.loadFromJSON("MixerData").MixerNames.join("\n"));
              MixerPresetsCmb.setValue(1);
          }
          
          
          //  MixerPresetCmb -------------------------------------------------
          inline function onMixerPresetsCmbControl(component, value)
          {
              if(isDefined(value))
              {
                  MixerNames.clear();
                  MixerPresetsCmb.set("items", "");  //Empty Cmb menu
                  
                  local Object = Engine.loadFromJSON("MixerData");    //Get All saved user presets
                  
                  //  Set MixerNames items in Cmb menu
                  MixerPresetsCmb.set("items", Object.MixerNames.join("\n"));
                  
                  //  Check which preset is "loaded" and set the preset name to "PresetNameLbl"
                  local loaded = Engine.loadFromJSON(MixerPresetsCmb.getItemText()+".mix");
                  PresetNameLbl.set("text", MixerPresetsCmb.getItemText());
          
                  //  set all gain & pan values from the loaded preset
                  if(isDefined(loaded))
                  {
                      for(m=0; m<15; m++)
                      {
                          //MixerGains[m].setValue(loaded[m+1]);
                          //MixerGains[m].changed();
                          VolSliderPack.setSliderAtIndex(m, loaded[m+1]);
                          PanSliderPack.setSliderAtIndex(m, loaded[m+16]);
                          //PanKnbs[m].setValue(loaded[m+16]);
                          //PanKnbs[m].changed();
                      }
                      VolSliderPack.changed();
                      PanSliderPack.changed();
                  }
              }    
          };
          
          Content.getComponent("MixerPresetsCmb").setControlCallback(onMixerPresetsCmbControl);
          
          
          //  Save new preset function    ----------------------------
          inline function onSavePresetBtnControl(component, value)
          {
              if(isDefined(value) && value == 1)
              {
                  count = count + 1;
                  MixerPreset.clear();
                  // Store the presetname in "preset[0]"
                  MixerPreset[0] = PresetNameLbl.getValue();
                  
                  //  Store MixerGains values in "preset"
                  for(i=0; i<15; i++)
                  {
                      MixerPreset[i+1] = VolSliderPack.getSliderValueAt(i);
                      MixerPreset[i+16] = PanSliderPack.getSliderValueAt(i);
                  }
                  
                  //  Check if the preset name already exists
                  MixerNames = Engine.loadFromJSON("MixerData").MixerNames;
                  if(MixerNames.contains(MixerPreset[0]))
                  {
                      //  Make WarningsPanel visible and display...
                      WarningPnl.set("visible", true);
                      
                      //  ...warning text
                      WarningLbl.set("text", "Preset "+"'"+PresetNameLbl.getValue()+"'"+" already exists!"+"\n"+
                      "Do you want to owerwrite?"+"\n"+
                      "Press 'Save' or chose another name!");
                      
                      //  Check if "Save" button is clicked once more
                      if(value == 1 && count == 2)
                      {
                          local WriteOverIdx = MixerNames.indexOf(MixerPreset[0]);
                          MixerNames[WriteOverIdx] = MixerPreset[0];
                          MixerData.MixerNames = MixerNames;
                          Engine.dumpAsJSON(MixerData, "MixerData");
                          Engine.dumpAsJSON(MixerPreset, MixerPreset[0]+".mix");
                          
                          //  reset "count" to zero
                          count = 0;
                          
                          //  Hide the WarningsPanel
                          WarningPnl.set("visible", false);
                      }
                      else
                      //  If Save button is not pressed the second time, abort!
                      {
                          return;
                      }
                  }
                  
                  //  If the presetName doesn't exists already, save preset
                  else
                  {
                      MixerNames.push(MixerPreset[0]);
                      MixerData.MixerNames = MixerNames;
                      Engine.dumpAsJSON(MixerData, "MixerData");
                      Engine.dumpAsJSON(MixerPreset, MixerPreset[0]+".mix");
                      
                      //  Reset "count"
                      count = 0;
                      
                      //  Hide WarningPanel
                      WarningPnl.set("visible", false);
                  }
                  //  Get index in "MixerNames" of loaded presets name
                  var idx = MixerNames.indexOf(MixerPreset[0]);
                  MixerPresetsCmb.set("items", "");
                  MixerPresetsCmb.set("items", MixerNames.join("\n"));
                  MixerPresetsCmb.setValue(idx+1);
                  MixerPresetsCmb.changed();
              }
              
          };
          
          Content.getComponent("SavePresetBtn").setControlCallback(onSavePresetBtnControl);
          
          

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

          ulrikU Tania GhoshT d.healeyD 3 Replies Last reply Reply Quote 1
          • ulrikU
            ulrik @ulrik
            last edited by

            @ulrik I should say that in the first post I forgot some code so now it's updated, sorry about that

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

            1 Reply Last reply Reply Quote 0
            • Tania GhoshT
              Tania Ghosh @ulrik
              last edited by

              @ulrik Fantastic.. :)
              Thank you

              Tania Ghosh

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

                @ulrik You can browse directories with the File System API.

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

                ulrikU 1 Reply Last reply Reply Quote 1
                • ulrikU
                  ulrik @d.healey
                  last edited by

                  @d-healey Really? Is it newly implemented?
                  That is great news, I have to dive right in and explore, I realise I've been away much too long from Hise, thank you David! 😀🎶

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

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

                    @ulrik It's been there for a while now - https://docs.hise.audio/scripting/scripting-api/filesystem/index.html

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

                    ulrikU 1 Reply Last reply Reply Quote 1
                    • ulrikU
                      ulrik @d.healey
                      last edited by

                      @d-healey Yeah, I see now.
                      I'm trying it out at the moment and I'm not able to set absolute path to the UserPresets folder, I need that to check if there's any presets in that folder, and I mean presets with different extensions like ".mix" or other...
                      is it possible? I only find "set start folder"

                      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

                        @ulrik

                        FileSystem.findFiles(var directory, String wildcard, bool recursive)

                        so to get to the directory use:

                        FileSystem.getFolder(var locationType)

                        location types :

                        AudioFiles The audio file folder. In HISE it will be the repo folder, but in the compiled project it will be a sub folder in the appdata folder.

                        Samples The sample folder as specified in the settings (or the subfolder of the HISE project during development).

                        AppData The app data directory. This is the main directory for your project which will house the configuration files and user presets.

                        UserHome The user home folder.

                        Documents The user's Document folder.

                        Desktop The user's desktop folder.

                        Downloads The user's download folder.

                        so (guessing this would work)

                        var appD = FileSystem.getFolder(AppData);
                        var myDir = appD + "\User Presets";
                        var myList = FileSystem.findFiles(myDir, "*.mix", false);
                        

                        HISE Development for hire.
                        www.channelrobot.com

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

                          HiseSnippet 898.3ocsV01iSaDDd2bwThoAUj3GfU9jSUHx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DJCtG6sIIlRw8.tueL+xAf4WO.L2+.v7fC.yCO.L+1Af42+hXL+EhmWpkYtwDPw7Sratv3SDDnKy1Qh9OYLTpIA�
                          

                          Seems Lindon got there before me :p

                          Edit: Actually Lindon's method won't work, that's what I tried first. You can't pass strings you have to pass file objects.

                          const var appDataFolder = FileSystem.getFolder(FileSystem.AppData);
                          const var presetsFolder = appDataFolder.getChildFile("User Presets");
                          
                          const var fileList = FileSystem.findFiles(presetsFolder, "*.mix", true);
                          
                          for (f in fileList)
                          {
                              Console.print(f.toString("FullPath"));
                          }
                          

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

                          ulrikU Tania GhoshT 2 Replies Last reply Reply Quote 1
                          • ulrikU
                            ulrik @d.healey
                            last edited by

                            @d-healey @Lindon
                            Thank you both, now I get it :)

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

                            1 Reply Last reply Reply Quote 0
                            • Tania GhoshT
                              Tania Ghosh @d.healey
                              last edited by

                              @d-healey Tried your Snippet but unable to load my custom User Preset Extension (*.tania) to Preset browser. What am I doing wrong?

                              No PB.gif

                              Tania Ghosh

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

                                @Tania-Ghosh -er its not going to load a preset is it? its going to load a JSON file - which you are going to have to read thru and apply yourself in the code - so you will need to build a custom preset panel - if i understand it correctly.

                                HISE Development for hire.
                                www.channelrobot.com

                                Tania GhoshT 1 Reply Last reply Reply Quote 3
                                • Tania GhoshT
                                  Tania Ghosh @Lindon
                                  last edited by

                                  @Lindon Ok... Got it. :)

                                  Tania Ghosh

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

                                    @Tania-Ghosh After that Lindon and Healey explained the, for me, new implementation of the FileSystem I've been spending some hours on this and I wrote an example if it could help?

                                    HiseSnippet 2613.3ocuZs0ba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rJZs62GaRiA6xZ67Wt9+XyTNzcL62maOCpGAXkZ6OdnNPxMw.Rb.hD6RTTWhQzEu2HLvmN1wh+ByuIny0XuqFz4ZgcpLzvzy8GLEWcC6Kb6l7V.L4v+P+JosG6czZJ7qyAlmVi5MTFRrH+foISU7P.64Om0Wf473EXNar.y4IKvb9lEXN+9EXN+goNG1273liothHJfAcuCZyuiKU01NrPHbFox+Cf2OwUO
                                    

                                    I should say that this will only work if there is a folder named "User Presets" in the Users AppData folder.

                                    @d-healey is it possible to create a folder with this File System functions? I can't find anything about that in the docs?

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

                                    d.healeyD Tania GhoshT 2 Replies Last reply Reply Quote 2
                                    • d.healeyD
                                      d.healey @ulrik
                                      last edited by

                                      @ulrik I think it's read-only, except for JSON files.

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

                                      ulrikU 1 Reply Last reply Reply Quote 1
                                      • ulrikU
                                        ulrik @d.healey
                                        last edited by

                                        @d-healey Ok, thanks!

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

                                        1 Reply Last reply Reply Quote 0
                                        • Tania GhoshT
                                          Tania Ghosh @ulrik
                                          last edited by

                                          @ulrik Oh My God.... Amazing.. wow.. Thank you so very much. It is a New Year gift.

                                          :)

                                          Tania Ghosh

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

                                            @Tania-Ghosh I'm glad if it could be of any help, I had to learn it and document it for my self so why not share?

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

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

                                            35

                                            Online

                                            1.8k

                                            Users

                                            12.0k

                                            Topics

                                            104.4k

                                            Posts