• Products
    • Isadora
    • Get It
    • ADD-ONS
    • IzzyCast
    • Get It
  • Forum
  • Help
  • Werkstatt
  • Newsletter
  • Impressum
  • Dsgvo
  • Press
  • Isadora
  • Get It
  • ADD-ONS
  • IzzyCast
  • Get It
  • Press
  • Dsgvo
  • Impressum

Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags

    Javascript comparing values inside array

    How To... ?
    javascript
    2
    3
    1572
    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.
    • Maxime
      Maxime last edited by Maxime

      Hi there,

      I did a value sampler with JS so I can "record" my live operations I do with my midi controller and play it back automatically afterward.

      It's working nice, but as I have different instances of it connected to different faders, I would like to test what's inside the array and if all the values are the same (which mean I didn't record this fader but another one) don't return the recorded values but the "live" input. Unfortunately this does not work yet and so when i'm playing back some recorded values, all my faders are muted, instead of just the one doing the playback...

      If someone as some clue I would be glad, cause i've turned around my code for some time and can't figure out why it's not working...

      (For comprehension purpose, the "time" input is counter with pulse generator)

      Thanks! :)

      Here is my code:

      var rec = new Array();
      function main()
      {
      var bypass = arguments[0];
      var value = arguments[1];
      var time = arguments[2];
      if(bypass==1){
      rec[time] = value;
      return [value,time];
      }
      // test for playback starts here
      else if(bypass==2){
      for(var i=1; i<rec.length; i++){
      if(rec[0]!= rec[i]){
      return [rec[time],time, rec[0],100]
      }else{
          return [value,time,]
          }
        }
      }
      //end of test for playback
      else if(bypass==0){
      return[value,0]
        }else{}
      }

      MBP 15" end 2013 / i7 2,3Ghz /NVIDIA GT 750M 2048Mo / 16Go RAM / OS 10.10.3
      Razer Blade 15" 2018 /i7/ GTX1070/ 16Go RAM

      1 Reply Last reply Reply Quote 0
      • DusX
        DusX Tech Staff last edited by

        Take a look at the 'every()' method.

        https://www.w3schools.com/jsre...

        You can do something like:

        else if(bypass==2 && rec.every(checkNotEmpty)){

        Troikatronix Technical Support

        • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
        • My Add-ons: https://troikatronix.com/add-ons/?u=dusx
        • Profession Services: https://support.troikatronix.com/support/solutions/articles/13000109444-professional-services

        Running: Win 11 64bit, i7, M.2 PCIe SSD's, 32gb DDR4, nVidia GTX 4070 | located in Ontario Canada.

        1 Reply Last reply Reply Quote 1
        • Maxime
          Maxime last edited by

          @DusX That worked! thanks a lot!

          MBP 15" end 2013 / i7 2,3Ghz /NVIDIA GT 750M 2048Mo / 16Go RAM / OS 10.10.3
          Razer Blade 15" 2018 /i7/ GTX1070/ 16Go RAM

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