which data container would you recommend for this use case?
-
@d-healey
they hold midi note numbers, which are used to generate additional note ons -
@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.
-
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.. -
@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. -
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? -
@prehm might be possible with a broadcaster but I'm not sure
-
@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. -
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.
-
@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. -
@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.
-
@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.
-
@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 onIs that what you meant? Would this keep track of value changes? Can’t test it right now but I will later, thanks!
-
@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.
-
@d-healey
Thanks a lot, some fresh ideas is really all I need