<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Javascript comparing values inside array]]></title><description><![CDATA[<p>Hi there,</p>
<p>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.</p>
<p>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...</p>
<p>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...</p>
<p>(For comprehension purpose, the "time" input is counter with pulse generator)</p>
<p>Thanks! :)</p>
<p>Here is my code:</p>
<pre>
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&lt;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{}
}</pre>]]></description><link>https://community.troikatronix.com/topic/5241/javascript-comparing-values-inside-array</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 04:51:33 GMT</lastBuildDate><atom:link href="https://community.troikatronix.com/topic/5241.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 14 May 2018 14:23:28 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Javascript comparing values inside array on Mon, 14 May 2018 17:56:29 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://community.troikatronix.com/uid/124">@DusX</a> That worked! thanks a lot!</p>]]></description><link>https://community.troikatronix.com/post/30601</link><guid isPermaLink="true">https://community.troikatronix.com/post/30601</guid><dc:creator><![CDATA[Maxime]]></dc:creator><pubDate>Mon, 14 May 2018 17:56:29 GMT</pubDate></item><item><title><![CDATA[Reply to Javascript comparing values inside array on Mon, 14 May 2018 16:29:23 GMT]]></title><description><![CDATA[<p>Take a look at the 'every()' method.<br /><br /><a href="https://www.w3schools.com/jsref/jsref_every.asp">https://www.w3schools.com/jsre...</a><br /><br />You can do something like:<br /></p><pre>
else if(bypass==2 &amp;&amp; rec.every(checkNotEmpty)){<br /></pre>]]></description><link>https://community.troikatronix.com/post/30600</link><guid isPermaLink="true">https://community.troikatronix.com/post/30600</guid><dc:creator><![CDATA[DusX]]></dc:creator><pubDate>Mon, 14 May 2018 16:29:23 GMT</pubDate></item></channel></rss>