ArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2010-12-09T13:57:31+02:00 https://www.brainmodular.com/forums/app.php/feed/topic/2612 2010-12-09T13:57:31+02:00 2010-12-09T13:57:31+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2612&p=17329#p17329 <![CDATA[[script]GetDataArrayValue parameter conflict]]>
I'm working on an mlr like patch. Script is really usefull and low on cpu!

Statistics: Posted by ethnix73 — 09 Dec 2010, 12:57


]]>
2010-12-08T14:33:38+02:00 2010-12-08T14:33:38+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2612&p=17314#p17314 <![CDATA[[script]GetDataArrayValue parameter conflict]]> for exemple can also, instead of using two "if 0 set to 1, if 1 set to 0" use "set to (1-value) working for booth cases,
and directly set the array picking index without having separated the two process (but more clear to separate sometimes),
also you can put the code in callback to be computed only on inputs changes:
just as exemple compacted above equivalent:

Procedure Callback (n=integer);
Begin
IF (n=Arrayin) or (n=indexin) then begin
value:= getDataArrayValue( ArrayIn, round ( getValue (indexIN) ) );
setValue(valueOut, 1 - value);
end;
END//callback


and could even compact/combine even more:
IF (n=Arrayin) or (n=indexin) then begin
setValue( valueOut, 1 - getDataArrayValue( ArrayIn, round ( getValue (indexIN) ) ) );
end;


But at some point you can get lost in parenthesis errors and can be difficult to decypher, but i did it as an exemple to
show you can combine.

Statistics: Posted by 23fx23 — 08 Dec 2010, 13:33


]]>
2010-12-08T14:27:01+02:00 2010-12-08T14:27:01+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2612&p=17313#p17313 <![CDATA[[script]GetDataArrayValue parameter conflict]]>
i tried to use trunc or round, but i see that i had not used it correctly!
I added another script line after x :=GetValue (Index); like this Trunc(x)

So in script, we can encapsulate function within others with just parenthesis?

Statistics: Posted by ethnix73 — 08 Dec 2010, 13:27


]]>
2010-12-08T14:20:01+02:00 2010-12-08T14:20:01+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2612&p=17312#p17312 <![CDATA[[script]GetDataArrayValue parameter conflict]]> TRUNC or ROUND functions.
as you would imagine:
trunc(1,56) = 1
round(1,56) = 2

Indexs in arrays are always integers, but using getValue returns floats, so in your case you should use:

X:= trunc(getValue(Index));

and X can be declared as an integer, instead of single using var X : integer; on top of script.

Statistics: Posted by 23fx23 — 08 Dec 2010, 13:20


]]>
2010-12-08T13:52:04+02:00 2010-12-08T13:52:04+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2612&p=17310#p17310 <![CDATA[[script]GetDataArrayValue parameter conflict]]>
I want to get the value of an array (inlet) at a specified index (inlet).
If that value (y)=0, set it to 1.
If that value (y)=1, set it to 0.

But i've got parameter conflict between SINGLE and INTEGER with the function GetDataArrayValue

Does i need to create another array (array of single) and feed it with the array(inlet)?

CODE:

//////////////////////////// /////////////////////////// parameters declarationvar ArrayIn &#58; Tparameter;var Index &#58; Tparameter;var ArrayOut &#58; Tparameter;var Out &#58; Tparameter;var x,y &#58; single;// initialisation &#58; create parametersprocedure init;begin  ArrayIn &#58;=CreateParam&#40;'ArrayIn',ptArray&#41;;SetisOutput&#40;ArrayIn,False&#41;;Index &#58;=CreateParam&#40;'Index',ptDataFader&#41;;SetIsOutput&#40;Index,FALSE&#41;;ArrayOut &#58;=CreateParam&#40;'ArrayOut',ptArray&#41;;SetisInput&#40;Arrayout,FALSE&#41;;Out &#58;=CreateParam&#40;'Out',Ptdatafield&#41;;SetisInput&#40;out,FALSE&#41;;setformat &#40;out,'%.0f'&#41;;end;// Callback procedureProcedure Callback&#40;N&#58;integer&#41;; beginx &#58;=GetValue &#40;Index&#41;;y &#58;=GetDataArrayValue&#40;ArrayIn,x&#41;;end;// Global variables//////////////////////////////// main proc//////////////////////////////Procedure Process;beginif y=0 then beginSetValue &#40;out,1&#41;end;If y=1 then beginSetValue &#40;out,0&#41;end;end;

Statistics: Posted by ethnix73 — 08 Dec 2010, 12:52


]]>
BrainModular BrainModular Users Forum 2010-12-09T13:57:31+02:00 https://www.brainmodular.com/forums/app.php/feed/topic/2612 2010-12-09T13:57:31+02:00 2010-12-09T13:57:31+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2612&p=17329#p17329 <![CDATA[[script]GetDataArrayValue parameter conflict]]>
I'm working on an mlr like patch. Script is really usefull and low on cpu!

Statistics: Posted by ethnix73 — 09 Dec 2010, 12:57


]]>
2010-12-08T14:33:38+02:00 2010-12-08T14:33:38+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2612&p=17314#p17314 <![CDATA[[script]GetDataArrayValue parameter conflict]]> for exemple can also, instead of using two "if 0 set to 1, if 1 set to 0" use "set to (1-value) working for booth cases,
and directly set the array picking index without having separated the two process (but more clear to separate sometimes),
also you can put the code in callback to be computed only on inputs changes:
just as exemple compacted above equivalent:

Procedure Callback (n=integer);
Begin
IF (n=Arrayin) or (n=indexin) then begin
value:= getDataArrayValue( ArrayIn, round ( getValue (indexIN) ) );
setValue(valueOut, 1 - value);
end;
END//callback


and could even compact/combine even more:
IF (n=Arrayin) or (n=indexin) then begin
setValue( valueOut, 1 - getDataArrayValue( ArrayIn, round ( getValue (indexIN) ) ) );
end;


But at some point you can get lost in parenthesis errors and can be difficult to decypher, but i did it as an exemple to
show you can combine.

Statistics: Posted by 23fx23 — 08 Dec 2010, 13:33


]]>
2010-12-08T14:27:01+02:00 2010-12-08T14:27:01+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2612&p=17313#p17313 <![CDATA[[script]GetDataArrayValue parameter conflict]]>
i tried to use trunc or round, but i see that i had not used it correctly!
I added another script line after x :=GetValue (Index); like this Trunc(x)

So in script, we can encapsulate function within others with just parenthesis?

Statistics: Posted by ethnix73 — 08 Dec 2010, 13:27


]]>
2010-12-08T14:20:01+02:00 2010-12-08T14:20:01+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2612&p=17312#p17312 <![CDATA[[script]GetDataArrayValue parameter conflict]]> TRUNC or ROUND functions.
as you would imagine:
trunc(1,56) = 1
round(1,56) = 2

Indexs in arrays are always integers, but using getValue returns floats, so in your case you should use:

X:= trunc(getValue(Index));

and X can be declared as an integer, instead of single using var X : integer; on top of script.

Statistics: Posted by 23fx23 — 08 Dec 2010, 13:20


]]>
2010-12-08T13:52:04+02:00 2010-12-08T13:52:04+02:00 https://www.brainmodular.com/forums/viewtopic.php?t=2612&p=17310#p17310 <![CDATA[[script]GetDataArrayValue parameter conflict]]>
I want to get the value of an array (inlet) at a specified index (inlet).
If that value (y)=0, set it to 1.
If that value (y)=1, set it to 0.

But i've got parameter conflict between SINGLE and INTEGER with the function GetDataArrayValue

Does i need to create another array (array of single) and feed it with the array(inlet)?

CODE:

//////////////////////////// /////////////////////////// parameters declarationvar ArrayIn &#58; Tparameter;var Index &#58; Tparameter;var ArrayOut &#58; Tparameter;var Out &#58; Tparameter;var x,y &#58; single;// initialisation &#58; create parametersprocedure init;begin  ArrayIn &#58;=CreateParam&#40;'ArrayIn',ptArray&#41;;SetisOutput&#40;ArrayIn,False&#41;;Index &#58;=CreateParam&#40;'Index',ptDataFader&#41;;SetIsOutput&#40;Index,FALSE&#41;;ArrayOut &#58;=CreateParam&#40;'ArrayOut',ptArray&#41;;SetisInput&#40;Arrayout,FALSE&#41;;Out &#58;=CreateParam&#40;'Out',Ptdatafield&#41;;SetisInput&#40;out,FALSE&#41;;setformat &#40;out,'%.0f'&#41;;end;// Callback procedureProcedure Callback&#40;N&#58;integer&#41;; beginx &#58;=GetValue &#40;Index&#41;;y &#58;=GetDataArrayValue&#40;ArrayIn,x&#41;;end;// Global variables//////////////////////////////// main proc//////////////////////////////Procedure Process;beginif y=0 then beginSetValue &#40;out,1&#41;end;If y=1 then beginSetValue &#40;out,0&#41;end;end;

Statistics: Posted by ethnix73 — 08 Dec 2010, 12:52


]]>