HISE Logo Forum
    • Categories
    • Register
    • Login

    which data container would you recommend for this use case?

    Scheduled Pinned Locked Moved Scripting
    16 Posts 3 Posters 363 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.
    • P
      prehm
      last edited by

      hey there,
      i a using a data structure that looks as follows
      three arrays: [1, 2, 3], [4, 5, 6], [7, 8, 9]
      and one array that contains all values: [1, 2, 3, 4, 5, 6, 7, 8, 9]

      when a number is found that is contained in one of the three arrays, this array is cleared and the "main" array should reflect the new state, like this:
      number 6 was found, clear array 2: [1, 2, 3], [X], [7, 8, 9]
      main array: [1, 2, 3, 7, 8, 9]

      this structure exists 7 times and each structure has varying values, and the input value ("found number") is the same for all of them.

      everything should happen as quickly as possible (it's a midi processor).
      i have been using regular arrays (I just started learning programming a month ago with HISE) but I am looking for a more efficient way to do this, and i have trouble figuring out which special container type would serve me best.

      i just tried using an array of midi lists, but I need to restore a base state every time a new note comes in, and it seems as if midi lists are always referenced both ways, so even if I create a reg variable that gets referenced to a constant on every note on (which contains the base state), both arrays always show the same state.

      even when I store a base 64 string of the base state midi lists and recall it on a note on, it does the same thing.

      any suggestions would be very welcome!
      cheers!

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

        @prehm What is the purpose of the arrays?

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

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

          @d-healey
          they hold midi note numbers, which are used to generate additional note ons

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

            @prehm For what purpose? As with most things in programming there are many options here, so once I know what it is you want to achieve I can give more useful info.

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

            1 Reply Last reply Reply Quote 0
            • P
              prehm
              last edited by

              how do you mean?
              each main array holds an amount of possible note choices. all seven main arrays get summed up in the end, and there is another script in place which determines the note to choose for a note On event.
              i dont really know how to specify any further without breaking down the whole concept..

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

                @prehm In that case using arrays seems fine, I don't think you'll get much benefit from a MIDI list here. You should probably declare the arrays as const and use .reserve() if you know how many elements you will need.

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

                1 Reply Last reply Reply Quote 0
                • P
                  prehm
                  last edited by

                  Okay cool thank you, that’s good to know!
                  I wonder, is there any way for an array to always keep track of the concatenated state of three other arrays? Or the other way around, a smaller array that always represents a certain section of a bigger array?

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

                    @prehm might be possible with a broadcaster but I'm not sure

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

                    1 Reply Last reply Reply Quote 0
                    • VirtualVirginV
                      VirtualVirgin @prehm
                      last edited by

                      @prehm said in which data container would you recommend for this use case?:

                      Okay cool thank you, that’s good to know!
                      I wonder, is there any way for an array to always keep track of the concatenated state of three other arrays? Or the other way around, a smaller array that always represents a certain section of a bigger array?

                      I would think all you need to do is update the larger array every time you update the smaller arrays;
                      so whenever a change in value occurs for a smaller array, make sure to use array.concat() for the larger one.

                      You can listen to my orchestral mockups here:
                      https://www.virtualvirgin.net/

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

                        Another option is to dump the smaller arrays. Keep the big one with all your values, and have another one with 7 elements to keep track of the indexes within that big array.

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

                        1 Reply Last reply Reply Quote 0
                        • P
                          prehm @VirtualVirgin
                          last edited by

                          @VirtualVirgin
                          Yes that’s the way I’ve been doing it, but because that operation has to be done a lot of times in my script at a single note on event, I was wondering if instead there was a way to work with the exact same piece of memory in order to to save computation time, instead of clearing and concatenating over and over again.

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

                            @prehm said in which data container would you recommend for this use case?:

                            i dont really know how to specify any further without breaking down the whole concept..

                            Might be time to break down the concept so we know why you are doing what you are doing.

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

                            1 Reply Last reply Reply Quote 0
                            • VirtualVirginV
                              VirtualVirgin @prehm
                              last edited by VirtualVirgin

                              @prehm said in which data container would you recommend for this use case?:

                              @VirtualVirgin
                              Yes that’s the way I’ve been doing it, but because that operation has to be done a lot of times in my script at a single note on event, I was wondering if instead there was a way to work with the exact same piece of memory in order to to save computation time, instead of clearing and concatenating over and over again.

                              I would think if you use Array.reserve() like David mentions above and use only one array for the concatenation (assuming that you are only require one output at a time), then my impression is that this would simply reuse the same memory space over and over. Somebody please correct me if I am wrong about that.

                              You can listen to my orchestral mockups here:
                              https://www.virtualvirgin.net/

                              P 1 Reply Last reply Reply Quote 0
                              • P
                                prehm @VirtualVirgin
                                last edited by

                                @VirtualVirgin
                                Yes I think that’s an error on my side, but still it would save the action of clearing and concatenating if I could just „view“ part of the big array through one of the small arrays.

                                @d-healey
                                That idea is interesting, if I understand you correctly, I would set it up like this:?

                                Const SmallArray = [1, 2]
                                Const BigArray = [SmallArray[0], SmallArray[1]]
                                And so on

                                Is that what you meant? Would this keep track of value changes? Can’t test it right now but I will later, thanks!

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

                                  @prehm Not what I mean.

                                  For example (dummy values)
                                  Big array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
                                  Small array = [0, 4, 6, 9, 12, 14, 16]

                                  The small array is the index for where to start counting in your big array. So if you go with element 3 of the small array that gives you 6, so you start counting from the 6th element in the big array.

                                  Again though without knowing exactly what the end goal is we are just throwing possibilities at you.

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

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

                                    @d-healey
                                    Thanks a lot, some fresh ideas is really all I need 🙃

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

                                    15

                                    Online

                                    1.7k

                                    Users

                                    11.8k

                                    Topics

                                    103.2k

                                    Posts