Forum
    • Categories
    • Register
    • Login

    save start and end positions in preset

    Scheduled Pinned Locked Moved General Questions
    12 Posts 4 Posters 76 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.
    • T
      treynterrio @dannytaurus
      last edited by treynterrio

      @dannytaurus

      const var BtnSavePreset = Content.getComponent("BtnSavePreset");
      
      reg currentPreset;
      
      inline function saveNextPresetAuto()
      {
          local presetRoot = FileSystem.getFolder(FileSystem.UserPresets);
          local userFolder = presetRoot.createDirectory("user");
      
          local i = 1;
          local f;
      
          while (true)
          {
              f = userFolder.getChildFile("preset-" + i + ".preset");
      
              if (!f.isFile())
                  break;
      
              i++;
          }
      
          currentPreset = f;
          Engine.saveUserPreset(f);
          updatePresetDisplay();
      }
      
      inline function onBtnSavePresetControl(component, value)
      {
          if (value)
              saveNextPresetAuto();
      }
      BtnSavePreset.setControlCallback(onBtnSavePresetControl);
      
      ulrikU Oli UllmannO 2 Replies Last reply Reply Quote 0
      • ulrikU
        ulrik @treynterrio
        last edited by

        @treynterrio if you add the module to the preset like this:

        Engine.addModuleStateToUserPreset("Audio Loop Player1");
        

        it will be saved with the preset

        savemoduleinpreset.gif

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

        dannytaurusD T 2 Replies Last reply Reply Quote 2
        • Oli UllmannO
          Oli Ullmann @treynterrio
          last edited by

          @treynterrio
          Was the code created with AI? while(true) should create an infinite loop, shouldn't it?

          As ulrik writes, Engine.addModuleStateToUserPreset should be sufficient to save the values in the user preset. :-)

          dannytaurusD 1 Reply Last reply Reply Quote 0
          • dannytaurusD
            dannytaurus @Oli Ullmann
            last edited by dannytaurus

            @Oli-Ullmann The while(true) does indeed create an infinite loop, but there's a break in there which exits the loop when the condition is satisfied.

            It's just used to find the next available preset number for saving incremental preset names.

            Start with filename "preset-1.preset"
            Does that file exist?
            If yes, then try preset-2.preset
            If no, then use that filename to the save the preset
            Repeat from file exists?
            

            Meat Beats: https://meatbeats.com
            Klippr Video: https://klippr.video

            Oli UllmannO 1 Reply Last reply Reply Quote 1
            • dannytaurusD
              dannytaurus @ulrik
              last edited by

              @ulrik Nice 👌

              Meat Beats: https://meatbeats.com
              Klippr Video: https://klippr.video

              1 Reply Last reply Reply Quote 0
              • Oli UllmannO
                Oli Ullmann @dannytaurus
                last edited by

                @dannytaurus
                Oh yes, of course! I overlooked that... Thanks! :-)

                1 Reply Last reply Reply Quote 1
                • T
                  treynterrio @ulrik
                  last edited by

                  @ulrik I just tried this but I get this error:

                  Script Processor1:! Line 84, column 34: Can't store modules with child modules {U2NyaXB0IFByb2Nlc3NvcjF8b25Jbml0KCl8Mjg3MXw4NHwzNA==}
                  exporter:! Line 84, column 34: Can't store modules with child modules {U
                  
                  1 Reply Last reply Reply Quote 0
                  • T
                    treynterrio
                    last edited by

                    I just found out it saves the start and end position in HISE but not in the exported version in my DAW. I can see this in my AudioWaveform I've displayed.

                    dannytaurusD 1 Reply Last reply Reply Quote 0
                    • dannytaurusD
                      dannytaurus @treynterrio
                      last edited by

                      @treynterrio What's in your preset XML?

                      Meat Beats: https://meatbeats.com
                      Klippr Video: https://klippr.video

                      1 Reply Last reply Reply Quote 0
                      • T
                        treynterrio
                        last edited by

                        I just managed to fix it. There was something in the script before I had to swap. so I don't needed this Engine.addModuleStateToUserPreset

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

                        29

                        Online

                        2.1k

                        Users

                        13.1k

                        Topics

                        113.9k

                        Posts