HISE Logo Forum
    • Categories
    • Register
    • Login

    How do I find and remove objects in an array?

    Scheduled Pinned Locked Moved Scripting
    23 Posts 2 Posters 465 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.
    • VirtualVirginV
      VirtualVirgin @d.healey
      last edited by VirtualVirgin

      @d-healey
      I found where the problem is taking place:

                  selectedNotes.push
                  (
      	            selectedNotes.filter(function (c) 
      	            {
      	                var cx = c.col * cellWidth;
      	                var cy = height - (c.row + 1) * cellHeight;
      	
      	                return 
      	                (
      	                    cx + cellWidth > x1 &&
      	                    cx < x2 &&
      	                    cy + cellHeight > y1 &&
      	                    cy < y2
      	                );
      	            })
                  );
      

      This selectedNotes.push is pushing an object inside an array to the selectedNotes array, whereas I only need it to push an object to the array.
      So the current result is looking like [[{"row":42, "col":4}]]
      but I need it to just look like [{"row":42, "col":4}]
      I am not sure how I modify that to just use a the object and not have it wrapped in that extra array.

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

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

        @VirtualVirgin Add [0] after the parenthesis e090f3a3-5ac8-4143-bc41-ba907ae5f7c9-image.png

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

        VirtualVirginV 1 Reply Last reply Reply Quote 0
        • VirtualVirginV
          VirtualVirgin @d.healey
          last edited by

          @d-healey Almost...
          that turns it into an object, but it only returns one selection to the list instead of all of the noteCells under the selection rectangle area.
          Without the [0] it returns all of them, but inside an array.

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

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

            @VirtualVirgin In that case after it returns them, just grab the [0] element from that array.

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

            VirtualVirginV 1 Reply Last reply Reply Quote 0
            • VirtualVirginV
              VirtualVirgin @d.healey
              last edited by

              @d-healey Whoops... is there a panic button of some sort for feedback loops? I got stuck in one.

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

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

                @VirtualVirgin What do you mean?

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

                VirtualVirginV 1 Reply Last reply Reply Quote 0
                • VirtualVirginV
                  VirtualVirgin @d.healey
                  last edited by

                  @d-healey I added a for loop after that function and it seems to be stuck in the loop

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

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

                    @VirtualVirgin What does the loop do?

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

                    VirtualVirginV 1 Reply Last reply Reply Quote 0
                    • VirtualVirginV
                      VirtualVirgin @d.healey
                      last edited by

                      @d-healey

                      for (i = 0; i < noteCells; i++)
                           selectedNotes.push(noteCells[i]);
                      

                      It's not resolving because I meant to use "i < noteCells.length",
                      so I am stuck with a spinning wheel and a sluggish HISE.

                      I'll just force quit it.
                      Just didn't know if there is a button similar to "all notes off" to stop the processing.

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

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

                        @VirtualVirgin Can you just hit compile again?

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

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

                        37

                        Online

                        1.8k

                        Users

                        12.1k

                        Topics

                        105.0k

                        Posts