ArrayArrayArrayArray BrainModular BrainModular Users Forum 2013-09-23T14:25:02+02:00 https://brainmodular.com/forums/app.php/feed/topic/4079 2013-09-23T14:25:02+02:00 2013-09-23T14:25:02+02:00 https://brainmodular.com/forums/viewtopic.php?t=4079&p=27856#p27856 <![CDATA[get the index of the changed value in a sequencer]]>
Indeed, it seems that it is very hard to translate patching concepts in words. Thank you for responding and trying to help! It can really mean a lot, especially as threads can go unanswered here for long stretches. That is to be expected, especially with the development pace of Holylhock, but it can still be a little demotivating.

As regards step position, yes definitely it carries the index with it (using the trunc module gets you exactly the index). This is perfectly fine for inputting new step/switch values in real-time.

However, I'm designing a drum sequencer that can also be used just with a mouse. So what I need is to get the index value of a switch that has changed. This can be 'in the future' relative to step position: step position is on the second switch, while I've just clicked to activate the 15th switch.

The script above takes care of that, I'm just starting to worry that I have so many scripts in my patch :)

Statistics: Posted by ceasless — 23 Sep 2013, 14:25


]]>
2013-09-23T13:44:12+02:00 2013-09-23T13:44:12+02:00 https://brainmodular.com/forums/viewtopic.php?t=4079&p=27853#p27853 <![CDATA[get the index of the changed value in a sequencer]]> I guess I don't have a good idea of your approach...but I looked at once and found the step position was not only where the sequencer "was" but the index of each button.

-S

Statistics: Posted by sephult — 23 Sep 2013, 13:44


]]>
2013-09-23T13:36:46+02:00 2013-09-23T13:36:46+02:00 https://brainmodular.com/forums/viewtopic.php?t=4079&p=27851#p27851 <![CDATA[get the index of the changed value in a sequencer]]>

CODE:

//////////////////////////// Index of Changed Array Value/////////////////////////// parameters declarationvar mem, arrIn, value,    index       &#58; tParameter;var s,l         &#58; integer;var m,x         &#58; single;var hasRun      &#58; integer;// initialisation &#58; create parametersprocedure init;begin      mem &#58;= createParam&#40;'memory',ptArray&#41;;    setIsInput&#40;mem,false&#41;;    setIsOutput&#40;mem,false&#41;;       arrIn &#58;= createParam&#40;'array in',ptArray&#41;;    setIsOutput&#40;arrIn,false&#41;;    index &#58;= createParam&#40;'index',ptDatafield&#41;;    setIsInput&#40;index,false&#41;;    value &#58;= createParam&#40;'value',ptDatafield&#41;;    setIsInput&#40;value,false&#41;;    hasRun &#58;= 0;end;// Callback procedureProcedure Callback&#40;N&#58;integer&#41;; begin    case N of        arrIn&#58; begin            if hasRun = 1            then begin                 l &#58;= getLength&#40;arrIn&#41;;                for s&#58;=0 to l-1                do begin                    x &#58;= getDataArrayValue&#40;arrIn,s&#41;;                    m &#58;= getDataArrayValue&#40;mem,s&#41;;                                                                        if x <> m                    then begin                        setValue&#40;index,s&#41;;                        setValue&#40;value,x&#41;;                    end;                end;            end;            l &#58;= getLength&#40;arrIn&#41;;            setLength&#40;mem,l&#41;;            for s&#58;=0 to l-1             do begin                  x &#58;= getDataArrayValue&#40;arrIn,s&#41;;                setDataArrayValue&#40;mem,s,x&#41;;            end;                                               hasRun &#58;= 1;           end;                   end;end;// Global variables//////////////////////////////// main proc//////////////////////////////Procedure Process;begin    if hasRun = 0    then begin       l &#58;= getLength&#40;arrIn&#41;;       setLength&#40;mem,l&#41;;       for s&#58;=0 to l-1        do begin             x &#58;= getDataArrayValue&#40;arrIn,s&#41;;           setDataArrayValue&#40;mem,s,x&#41;;       end;                                          hasRun &#58;= 1;    end;end;

Statistics: Posted by ceasless — 23 Sep 2013, 13:36


]]>
2013-09-22T19:25:01+02:00 2013-09-22T19:25:01+02:00 https://brainmodular.com/forums/viewtopic.php?t=4079&p=27840#p27840 <![CDATA[get the index of the changed value in a sequencer]]>
I can write another script probably but I was hoping there would be an easier solution (maybe it doesn't take much to add this as an output in the sequencers?).

Statistics: Posted by ceasless — 22 Sep 2013, 19:25


]]>
BrainModular BrainModular Users Forum 2013-09-23T14:25:02+02:00 https://brainmodular.com/forums/app.php/feed/topic/4079 2013-09-23T14:25:02+02:00 2013-09-23T14:25:02+02:00 https://brainmodular.com/forums/viewtopic.php?t=4079&p=27856#p27856 <![CDATA[get the index of the changed value in a sequencer]]>
Indeed, it seems that it is very hard to translate patching concepts in words. Thank you for responding and trying to help! It can really mean a lot, especially as threads can go unanswered here for long stretches. That is to be expected, especially with the development pace of Holylhock, but it can still be a little demotivating.

As regards step position, yes definitely it carries the index with it (using the trunc module gets you exactly the index). This is perfectly fine for inputting new step/switch values in real-time.

However, I'm designing a drum sequencer that can also be used just with a mouse. So what I need is to get the index value of a switch that has changed. This can be 'in the future' relative to step position: step position is on the second switch, while I've just clicked to activate the 15th switch.

The script above takes care of that, I'm just starting to worry that I have so many scripts in my patch :)

Statistics: Posted by ceasless — 23 Sep 2013, 14:25


]]>
2013-09-23T13:44:12+02:00 2013-09-23T13:44:12+02:00 https://brainmodular.com/forums/viewtopic.php?t=4079&p=27853#p27853 <![CDATA[get the index of the changed value in a sequencer]]> I guess I don't have a good idea of your approach...but I looked at once and found the step position was not only where the sequencer "was" but the index of each button.

-S

Statistics: Posted by sephult — 23 Sep 2013, 13:44


]]>
2013-09-23T13:36:46+02:00 2013-09-23T13:36:46+02:00 https://brainmodular.com/forums/viewtopic.php?t=4079&p=27851#p27851 <![CDATA[get the index of the changed value in a sequencer]]>

CODE:

//////////////////////////// Index of Changed Array Value/////////////////////////// parameters declarationvar mem, arrIn, value,    index       &#58; tParameter;var s,l         &#58; integer;var m,x         &#58; single;var hasRun      &#58; integer;// initialisation &#58; create parametersprocedure init;begin      mem &#58;= createParam&#40;'memory',ptArray&#41;;    setIsInput&#40;mem,false&#41;;    setIsOutput&#40;mem,false&#41;;       arrIn &#58;= createParam&#40;'array in',ptArray&#41;;    setIsOutput&#40;arrIn,false&#41;;    index &#58;= createParam&#40;'index',ptDatafield&#41;;    setIsInput&#40;index,false&#41;;    value &#58;= createParam&#40;'value',ptDatafield&#41;;    setIsInput&#40;value,false&#41;;    hasRun &#58;= 0;end;// Callback procedureProcedure Callback&#40;N&#58;integer&#41;; begin    case N of        arrIn&#58; begin            if hasRun = 1            then begin                 l &#58;= getLength&#40;arrIn&#41;;                for s&#58;=0 to l-1                do begin                    x &#58;= getDataArrayValue&#40;arrIn,s&#41;;                    m &#58;= getDataArrayValue&#40;mem,s&#41;;                                                                        if x <> m                    then begin                        setValue&#40;index,s&#41;;                        setValue&#40;value,x&#41;;                    end;                end;            end;            l &#58;= getLength&#40;arrIn&#41;;            setLength&#40;mem,l&#41;;            for s&#58;=0 to l-1             do begin                  x &#58;= getDataArrayValue&#40;arrIn,s&#41;;                setDataArrayValue&#40;mem,s,x&#41;;            end;                                               hasRun &#58;= 1;           end;                   end;end;// Global variables//////////////////////////////// main proc//////////////////////////////Procedure Process;begin    if hasRun = 0    then begin       l &#58;= getLength&#40;arrIn&#41;;       setLength&#40;mem,l&#41;;       for s&#58;=0 to l-1        do begin             x &#58;= getDataArrayValue&#40;arrIn,s&#41;;           setDataArrayValue&#40;mem,s,x&#41;;       end;                                          hasRun &#58;= 1;    end;end;

Statistics: Posted by ceasless — 23 Sep 2013, 13:36


]]>
2013-09-22T19:25:01+02:00 2013-09-22T19:25:01+02:00 https://brainmodular.com/forums/viewtopic.php?t=4079&p=27840#p27840 <![CDATA[get the index of the changed value in a sequencer]]>
I can write another script probably but I was hoping there would be an easier solution (maybe it doesn't take much to add this as an output in the sequencers?).

Statistics: Posted by ceasless — 22 Sep 2013, 19:25


]]>