HISE Logo Forum
    • Categories
    • Register
    • Login

    Sorting a fixObjectStack / setCompareFunction

    Scheduled Pinned Locked Moved Scripting
    4 Posts 2 Posters 154 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.
    • CyberGenC
      CyberGen
      last edited by CyberGen

      :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();
      
      Christoph HartC CyberGenC 2 Replies Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart @CyberGen
        last edited by

        @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.

        1 Reply Last reply Reply Quote 0
        • CyberGenC
          CyberGen @CyberGen
          last edited by

          @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?

          CyberGenC 1 Reply Last reply Reply Quote 0
          • CyberGenC
            CyberGen @CyberGen
            last edited by

            @CyberGen @Christoph-Hart I just noticed the fixObjectArray does not show and Insert function in the API, how does one insert elements into it?

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

            42

            Online

            1.7k

            Users

            11.7k

            Topics

            101.9k

            Posts