Sorting a fixObjectStack / setCompareFunction
-
:waving_hand:
Need some help understanding how to sort a fixObjectStack.
I'm trying to change the default behavior of inserting notes at the end of the stack to insert the last note played at position 0 instead. Just like with array.insert(0, value);
I don't know how to write a proper compare function.
How do I place the note with the highest uptime in position 0 of the noteStack?f.setCompareFunction("uptime"); noteStack.sort();
-
@CyberGen you need to give a little bit more context here but in general that should be the right approach.
However I would not use the fixObjectStack but the FixObjectArray instead - the stack will mess up the order to fill gaps when you remove an element.
-
@Christoph-Hart For context; I'm using the monophonic glide in the snippet browser as starting point to create my own. For that example an objectStack was used. I got the glide working and added a portamento mode, which also works great. BTW, The fixObject approach is soooo much better for this. My old glide/portamento script was huge and convoluted. With the object factory it's straight forward much shorter by comparison. Thank you for that.
I want to learn how to sort the stack so that I can add a non-glide mono mode. Which is giving me a harder time than the portamento. I think it's because of the way the stack reorganizes itself. I need it to sort itself by uptime hi to low. Could you point to an example for this?
Anyhow, any performance difference between the array and the stack that I should consider for this use? or are they pretty much the same thing and I can just switch to an array?
-
@CyberGen @Christoph-Hart I just noticed the fixObjectArray does not show and Insert function in the API, how does one insert elements into it?