ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray
Statistics: Posted by woodslanding — 24 May 2012, 15:07 Statistics: Posted by 23fx23 — 24 May 2012, 09:52 Statistics: Posted by woodslanding — 24 May 2012, 06:48 Statistics: Posted by woodslanding — 09 Apr 2012, 04:08 Statistics: Posted by 23fx23 — 06 Apr 2012, 13:38 CODE: Statistics: Posted by woodslanding — 05 Apr 2012, 15:55 Statistics: Posted by 23fx23 — 05 Apr 2012, 13:44 Statistics: Posted by woodslanding — 05 Apr 2012, 10:03
I did iterate, and it is working, thanks!!
]]>
]]>
Because getLength on a ptArray won't compile--it says not enough parameters. But the wiki shows only one parameter.
edit:
Okay, I am much closer.... my script is almost working, but my array out length is not the same as the input array. How can I do this?
Niether of these works:
//setLength(paramsOUT, getLength(paramsIN));
//setValue(paramsOUT, getValue(paramsIN));
In both cases, my output array shows length 1 ( paramsOUT[1] ) regardless of the size of the input array.
Do I have to iterate through the in and set the out element by element? That's fine, but I can't even get a correct length for the output array, after setting it to length -1!
Thanks!!!
-eric
]]>
Thanks so much!
-eric
]]>
IF (stop = 1) then begin setlength(paramsOUT,-1); end else begin setlength(paramsOUT,length);end;
then your loop to set the values.
]]>
this script has the only syntax I could find that compiles, and it doesn't work. I just want to be able to set the values of a few specific elements of the array, and be able to stop it from a switch. Seems easy enough.... but I can't get it working. I'm seeing all zeroes at the output no matter the value of STOP://////////////////////////////////////////////////////////////Const COUNT = 9;var paramsOUT : TParameter;var paramsIN : TParameter;Var indicesIN :TParameter;Var valuesIN : Array[0..COUNT-1] of TParameter;Var stopIN :Tparameter;Var indices : TStringList;Procedure Destroy;begin indices.free;end;// initialisation : create parametersprocedure init;var i : integer;begin paramsIN := CreateParam('param arr',PtArray); SetIsOutput(paramsIN,false); SetFastCallback(paramsIN,false); SetMax(paramsIn,MAXINT); paramsOUT := CreateParam('param arr',PtArray); SetIsInput(paramsOUT,false); SetFastCallback(paramsOUT,false); SetMax(paramsOUT,MAXINT); for i := 0 to (COUNT - 1) DO BEGIN valuesIN[i] := CreateParam('value' + intToStr(i), PtTextfield); SetIsOutput(valuesIN[i],false); SetFastCallback(valuesIN[i],false); END; indicesIN := CreateParam('indices', PtTextfield); SetIsOutput(indicesIN,false); SetFastCallback(indicesIN,false); stopIN := CreateParam('stop', PtSwitch); SetIsOutput(stopIN,false); SetFastCallback(stopIN,false); end;// Callback procedureProcedure Callback(N:integer); var i,idx,stop,length : integer;value : double;name : String;begin stop := trunc(getValue(stopIN)); // how to stop an array??? length := getLength(paramsIN); IF (n = stopIN) and (stop = 1) then FOR i := 0 to (length - 1) DO setLength(paramsOUT, -1) ELSE BEGIN setLength(paramsOUT, length); for i := 0 to (length - 1) DO setDataArrayValue(paramsOUT, i, paramsIN); indices.CommaText := GetStringValue(indicesIN); // set the value of the array output at the index to the fader value coming in. FOR i := 0 to (COUNT - 1) DO setDataArrayValue(paramsOUT,strToInt(indices.Strings[i]),getValue(valuesIN[i])); ENDend;//////////////////////////////// main proc//////////////////////////////Procedure Process;beginend;
]]>
if for the whole array, just set the array to correct size when need to set values, then next bloc set it's lenght to -1. = stopped,
one solution like here is to trigg a counter when callback used to set your array changes, and when the count=+1 in process you setlength back to -1. Alternatively you can trig the back to -1 size via another input callback if wanna avoid process, but imo unless you really want to do all by script and complexify in this case, better make simple script for the functions you need and add a pic module after that, like bsork suggested me once ![]()
]]>
Still can't figure out how to stop a PTArray.
]]>
CODE:
////////////////////////////////////////////////////////////////////////////////////////////// Pass If Chg Array create an array where only values that changed in array in will pass //// As it need 2 blocs (one to check, one to store) it relies on Process procedure //// The callback will trig a counter. at bloc 0 it will compare new array with previously //// stored one. At bloc 1 it will store the array to be compared next //// The values that didn't changed are those where substracting equal 0, will set //// corresponding output length to 0, behaviour of passifChange in Usine //////////////////////////////////////////////////////////////////////////////////////////////const SIZE = 16; // nb of out wanted = size of arrayconst PREFIX = 'OUT_'; // PEFIX for outputs names, folowed by Integer;var ArrayIn: Tparameter;var OUTPUTS: Array Of Tparameter; // we will use an array of Tparameters, to allow N creations easilyvar i,l,count: integer; // we declare the variable we will use and their typevar valtmp: single;var ArrayLast: Array of single; // ArrayLast will be used to store array to check wich values changed on new in // chg./////////////////////////////////////PROCEDURE INIT;BEGIN ArrayIn :=CreateParam('ArrayIn',PtArray); SetIsOutput(ArrayIn,False); setMin(arrayIn,0);setMax(ArrayIn,127); SetArrayLength(OUTPUTS,SIZE); // we set the arraylength to create N outputs of size defined by constant on top // of script. for i:=0 to SIZE -1 do begin OUTPUTS[i]:= CreateParam(PREFIX+IntToStr(i),PtDataField); SetIsInput(OUTPUTS[i],false); end; // we create the outputs, names with the prefix followed by their corresponding nb. setArrayLength(ArrayLast,SIZE); //we set the memory array the same sizesetdontsave(arrayIn,false); // by doing this the arrayin can be saved to Pm or on quiting the patchEND;//INit//////////////////////////////PROCEDURE Callback(N:integer); BEGIN if (n=arrayIn) then begin l:= getlength(ArrayIn); count:=-1; // if detected arrayin chg, we trig the counter for process to start. end;END;//callback//////////////////////////////PROCEDURE PROCESS;BEGIN if count >= -1 then begin //start counting when callback has set count to -1 count:=count+1; // -1+1=0 so at first bloc count is 0 end; if count = 0 then begin // at first bloc we compare all values of new array with previous one. for i:=0 to l-1 do begin if ArrayLast[i]-getDataArrayValue(ArrayIn,i)<>0 then begin // if there is a difference that mean valtmp:= getDataArrayValue(ArrayIn,i); //this value has changed setLength(OUTPUTS[i],1); // we make a size 1 to activate data pass setValue(OUTPUTS[i],valtmp); // and set the value with discovered one end else begin // otherwise if no differences setLength(OUTPUTS[i],0); // we setLength of 0 = don't pass. end; end; end; if count = 1 then begin // on next bloc we store the array to internal memory for next compare. for i:=0 to L-1 do begin ArrayLast[i]:=getdataArrayValue(ArrayIn,i); setLength(OUTPUTS[i],0); // and make no values pass anymore. end; count:=-2; // and stop the counter as we reset it to -2 end; end;Statistics: Posted by nay-seven — 04 Apr 2012, 09:11
Statistics: Posted by woodslanding — 04 Apr 2012, 02:06
CODE:
coeffTodB(0.5) = -6coeffTodB(0.25) = -12...Statistics: Posted by woodslanding — 03 Nov 2011, 19:06
Statistics: Posted by woodslanding — 28 Oct 2011, 10:28
CODE:
setLength(output,-1);CODE:
-6 dB = mult by 0.5-12db = mult by 0.25...CODE:
coeffTodB(0.5) = -6coeffTodB(0.25) = -12...Statistics: Posted by senso — 22 Oct 2011, 12:07
Statistics: Posted by 23fx23 — 22 Oct 2011, 01:00
Statistics: Posted by woodslanding — 22 Oct 2011, 00:20
Statistics: Posted by woodslanding — 24 May 2012, 15:07
Statistics: Posted by 23fx23 — 24 May 2012, 09:52
Statistics: Posted by woodslanding — 24 May 2012, 06:48
Statistics: Posted by woodslanding — 09 Apr 2012, 04:08
Statistics: Posted by 23fx23 — 06 Apr 2012, 13:38
CODE:
//////////////////////////////////////////////////////////////Const COUNT = 9;var paramsOUT : TParameter;var paramsIN : TParameter;Var indicesIN :TParameter;Var valuesIN : Array[0..COUNT-1] of TParameter;Var stopIN :Tparameter;Var indices : TStringList;Procedure Destroy;begin indices.free;end;// initialisation : create parametersprocedure init;var i : integer;begin paramsIN := CreateParam('param arr',PtArray); SetIsOutput(paramsIN,false); SetFastCallback(paramsIN,false); SetMax(paramsIn,MAXINT); paramsOUT := CreateParam('param arr',PtArray); SetIsInput(paramsOUT,false); SetFastCallback(paramsOUT,false); SetMax(paramsOUT,MAXINT); for i := 0 to (COUNT - 1) DO BEGIN valuesIN[i] := CreateParam('value' + intToStr(i), PtTextfield); SetIsOutput(valuesIN[i],false); SetFastCallback(valuesIN[i],false); END; indicesIN := CreateParam('indices', PtTextfield); SetIsOutput(indicesIN,false); SetFastCallback(indicesIN,false); stopIN := CreateParam('stop', PtSwitch); SetIsOutput(stopIN,false); SetFastCallback(stopIN,false); end;// Callback procedureProcedure Callback(N:integer); var i,idx,stop,length : integer;value : double;name : String;begin stop := trunc(getValue(stopIN)); // how to stop an array??? length := getLength(paramsIN); IF (n = stopIN) and (stop = 1) then FOR i := 0 to (length - 1) DO setLength(paramsOUT, -1) ELSE BEGIN setLength(paramsOUT, length); for i := 0 to (length - 1) DO setDataArrayValue(paramsOUT, i, paramsIN); indices.CommaText := GetStringValue(indicesIN); // set the value of the array output at the index to the fader value coming in. FOR i := 0 to (COUNT - 1) DO setDataArrayValue(paramsOUT,strToInt(indices.Strings[i]),getValue(valuesIN[i])); ENDend;//////////////////////////////// main proc//////////////////////////////Procedure Process;beginend;Statistics: Posted by woodslanding — 05 Apr 2012, 15:55
Statistics: Posted by 23fx23 — 05 Apr 2012, 13:44
Statistics: Posted by woodslanding — 05 Apr 2012, 10:03
CODE:
////////////////////////////////////////////////////////////////////////////////////////////// Pass If Chg Array create an array where only values that changed in array in will pass //// As it need 2 blocs (one to check, one to store) it relies on Process procedure //// The callback will trig a counter. at bloc 0 it will compare new array with previously //// stored one. At bloc 1 it will store the array to be compared next //// The values that didn't changed are those where substracting equal 0, will set //// corresponding output length to 0, behaviour of passifChange in Usine //////////////////////////////////////////////////////////////////////////////////////////////const SIZE = 16; // nb of out wanted = size of arrayconst PREFIX = 'OUT_'; // PEFIX for outputs names, folowed by Integer;var ArrayIn: Tparameter;var OUTPUTS: Array Of Tparameter; // we will use an array of Tparameters, to allow N creations easilyvar i,l,count: integer; // we declare the variable we will use and their typevar valtmp: single;var ArrayLast: Array of single; // ArrayLast will be used to store array to check wich values changed on new in // chg./////////////////////////////////////PROCEDURE INIT;BEGIN ArrayIn :=CreateParam('ArrayIn',PtArray); SetIsOutput(ArrayIn,False); setMin(arrayIn,0);setMax(ArrayIn,127); SetArrayLength(OUTPUTS,SIZE); // we set the arraylength to create N outputs of size defined by constant on top // of script. for i:=0 to SIZE -1 do begin OUTPUTS[i]:= CreateParam(PREFIX+IntToStr(i),PtDataField); SetIsInput(OUTPUTS[i],false); end; // we create the outputs, names with the prefix followed by their corresponding nb. setArrayLength(ArrayLast,SIZE); //we set the memory array the same sizesetdontsave(arrayIn,false); // by doing this the arrayin can be saved to Pm or on quiting the patchEND;//INit//////////////////////////////PROCEDURE Callback(N:integer); BEGIN if (n=arrayIn) then begin l:= getlength(ArrayIn); count:=-1; // if detected arrayin chg, we trig the counter for process to start. end;END;//callback//////////////////////////////PROCEDURE PROCESS;BEGIN if count >= -1 then begin //start counting when callback has set count to -1 count:=count+1; // -1+1=0 so at first bloc count is 0 end; if count = 0 then begin // at first bloc we compare all values of new array with previous one. for i:=0 to l-1 do begin if ArrayLast[i]-getDataArrayValue(ArrayIn,i)<>0 then begin // if there is a difference that mean valtmp:= getDataArrayValue(ArrayIn,i); //this value has changed setLength(OUTPUTS[i],1); // we make a size 1 to activate data pass setValue(OUTPUTS[i],valtmp); // and set the value with discovered one end else begin // otherwise if no differences setLength(OUTPUTS[i],0); // we setLength of 0 = don't pass. end; end; end; if count = 1 then begin // on next bloc we store the array to internal memory for next compare. for i:=0 to L-1 do begin ArrayLast[i]:=getdataArrayValue(ArrayIn,i); setLength(OUTPUTS[i],0); // and make no values pass anymore. end; count:=-2; // and stop the counter as we reset it to -2 end; end;Statistics: Posted by nay-seven — 04 Apr 2012, 09:11
Statistics: Posted by woodslanding — 04 Apr 2012, 02:06
CODE:
coeffTodB(0.5) = -6coeffTodB(0.25) = -12...Statistics: Posted by woodslanding — 03 Nov 2011, 19:06
Statistics: Posted by woodslanding — 28 Oct 2011, 10:28
CODE:
setLength(output,-1);CODE:
-6 dB = mult by 0.5-12db = mult by 0.25...CODE:
coeffTodB(0.5) = -6coeffTodB(0.25) = -12...Statistics: Posted by senso — 22 Oct 2011, 12:07
Statistics: Posted by 23fx23 — 22 Oct 2011, 01:00
Statistics: Posted by woodslanding — 22 Oct 2011, 00:20