HISE Logo Forum
    • Categories
    • Register
    • Login

    Constant file ID

    Scheduled Pinned Locked Moved General Questions
    35 Posts 4 Posters 1.7k 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
      arminh
      last edited by

      Is there option to add some id to files to prevent change files order in for example in Combobox?

      Now im struggling with this scenario.

      I share plugin with presets and samples. There is 2 values in combobox - B and C and i they are saved in presets. User add file A an now Preset B pointing to CMB Value A and Preset C pointing to value B.

      Is there any option to fix it?

      A 1 Reply Last reply Reply Quote 0
      • A
        arminh @arminh
        last edited by arminh

        Being honest i don't know how it is sorted.

        I have 3 files 1.wav 2.wav 3.wav and in combobox they are in order 1 3 2.

        I'm confused.

        1 Reply Last reply Reply Quote 0
        • A
          arminh
          last edited by

          alt text

          1 Reply Last reply Reply Quote 0
          • A
            arminh
            last edited by

            @Christoph-Hart you have any idea?

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

              I don't understand the question

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

              Casey KolbC 1 Reply Last reply Reply Quote 0
              • Casey KolbC
                Casey Kolb @arminh
                last edited by

                @arminh The only way to workaround this is to store a hidden slider in the preset which correlates to an internal number ID. You can then use that number ID to load the associated file and set the combobox to that value based on the text associated with the ID. Honestly a viewport would be a better option in case.

                However, once the user starts adding files, I'm not really sure how you handle this. A scenario like this would only really work for internally saved data.

                1 Reply Last reply Reply Quote 0
                • Casey KolbC
                  Casey Kolb @d.healey
                  last edited by

                  @d-healey He's just referring to the fact that if you add items to a combobox, the values for any previously saved presets will be offset if you added items to the beginning of the combobox list.

                  A 1 Reply Last reply Reply Quote 2
                  • A
                    arminh @Casey Kolb
                    last edited by arminh

                    @Lunacy-Audio

                    I tried do this with external json file where all file paths would be kept but it still dosnt make sense because if user add files in different order the preset will not show proper file in combobox because cmb value will be different.

                    I think its not possible at this moment.

                    I just want create noise picker like we can see in serum.

                    Casey KolbC 1 Reply Last reply Reply Quote 0
                    • Casey KolbC
                      Casey Kolb @arminh
                      last edited by Casey Kolb

                      @arminh You just can't save the combobox in the preset, but you'd need to reset the items for the combobox on plugin load based on the external JSON. You'd need to find a way to save fixed IDs in the external JSON whenever a user loads a new file. You'd add a new number ID for each file and save that to a hidden slider in the GUI. You'd just need to be sure the slider has enough steps to accommodate a lot of files. I haven't tested this, but that could work.

                      A 1 Reply Last reply Reply Quote 0
                      • A
                        arminh @Casey Kolb
                        last edited by

                        @Lunacy-Audio IMO the best way for future updates would be creating api method to scan specified folder and return list with subfolders and files.

                        alt text

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

                          Something like this - https://docs.hise.audio/scripting/scripting-api/filesystem/index.html#findfiles ?

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

                          A 1 Reply Last reply Reply Quote 0
                          • Casey KolbC
                            Casey Kolb
                            last edited by

                            I think you might already be able to build this with the FileSystem API.

                            1 Reply Last reply Reply Quote 0
                            • Casey KolbC
                              Casey Kolb
                              last edited by

                              Ah yeah, Dave beat me to it lol

                              1 Reply Last reply Reply Quote 1
                              • A
                                arminh @d.healey
                                last edited by

                                @d-healey @Lunacy-Audio i already tried to do this, but without success because like i wrote in FileAPI topic there's problem with sorting. The second problem is that when the user adds the files in a different order the preset wasn't be able to point proper file because for example preset expect that sample will be at combobox value 10 but if we add some samples ealier on this value we will have completly different file.

                                1 Reply Last reply Reply Quote 0
                                • Casey KolbC
                                  Casey Kolb
                                  last edited by

                                  I'll have to check the sorting issue. I've been using the FileSystem API pretty seamlessly so far.

                                  @arminh said in Constant file ID:

                                  The second problem is that when the user adds the files in a different order the preset wasn't be able to point proper file because for example preset expect that sample will be at combobox value 10 but if we add some samples ealier on this value we will have completly different file.

                                  Yup, this is why I said you can't save the combobox in the preset. The combobox should just be a visual selector, unrelated to the preset restoring. You need to use another type of component to restore the values and just load the combobox with the updated information. Don't use the combobox values to restore the presets.

                                  A 1 Reply Last reply Reply Quote 0
                                  • A
                                    arminh @Casey Kolb
                                    last edited by

                                    @Lunacy-Audio but no matter where i put array data it always have random position.

                                    For example, we have audio files list (no matter if sorting works or not :D ):

                                    • 1.wav - cmb value = 1
                                    • 2.wav - cmb value = 2
                                    • 10.wav - cmb value = 3

                                    but if we add sample 3 it will looks like

                                    • 1.wav - cmb value = 1
                                    • 2.wav - cmb value = 2
                                    • 3.wav - cmb value = 3
                                    • 10.wav - cmb value = 4

                                    and that's the problem.

                                    Casey KolbC 1 Reply Last reply Reply Quote 0
                                    • Casey KolbC
                                      Casey Kolb
                                      last edited by Casey Kolb

                                      Think about it like this:

                                      1. The user uploads two files called "MyAudio1.wav" and ""MyAudio2.wav".
                                      2. You save the file names in the external JSON with an object like the one below. You'll need a different ID for each.
                                      {
                                        {
                                          "name": "MyAudio1.wav",
                                          "id": 1
                                        },
                                        {
                                          "name": "MyAudio2.wav",
                                          "id": 2
                                        },
                                      }
                                      
                                      1. In HISE, you set the value of a hidden slider (saved in preset) to 1, indicating the current file is "MyAudio1.wav"
                                      2. Update the visible combobox items to include the new audio files
                                      3. When the user changes the combobox selection, retrieve the actual text of the selection using ScriptComboBox.getItemText() and find the matching ID based in the external JSON on that text.
                                      4. Save the new ID in the slider.

                                      In this case, the combobox is purely a visual component, unrelated to the preset restoring. When the preset is restored, it will look at the hidden slider value and find the right audio file to load based on the external JSON.

                                      1 Reply Last reply Reply Quote 0
                                      • Casey KolbC
                                        Casey Kolb @arminh
                                        last edited by

                                        This post is deleted!
                                        1 Reply Last reply Reply Quote 0
                                        • A
                                          arminh
                                          last edited by

                                          @Lunacy-Audio i thought about creating json but this requires additional actions from the user. Not all of us are so technical :D

                                          1 Reply Last reply Reply Quote 0
                                          • Casey KolbC
                                            Casey Kolb
                                            last edited by

                                            The user never has to do anything. You make the JSON file in the HISEScript either using the new File API or Engine.dumpAsJSON(var object, String fileName)

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

                                            22

                                            Online

                                            1.8k

                                            Users

                                            11.9k

                                            Topics

                                            103.8k

                                            Posts