scripting only if changed
-
woodslanding
- Member
- Posts: 1327
Is there a way to do only if changed in a script? What would I set the output value to?
Also, I'm wondering what the math is for COEFF->DB ??
Thanks for any tips,
-e
Also, I'm wondering what the math is for COEFF->DB ??
Thanks for any tips,
-e
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
23fx23
- Member
- Posts: 2548
pass if change is done in script via setting length of the output to 0.
but then need to set back to size 1 if a float or arraysize for activating and setting values, and usually this imply that the callback trig a procedure, set sizes and values, trig a counter in process, and then in next process bloc (count+1) it will set back size to 0.
i have no clues for the db math thing sorry..
but then need to set back to size 1 if a float or arraysize for activating and setting values, and usually this imply that the callback trig a procedure, set sizes and values, trig a counter in process, and then in next process bloc (count+1) it will set back size to 0.
i have no clues for the db math thing sorry..
- senso
- Site Admin
- Posts: 4434
- Location: France
- Contact:
right 23fx,
Just a detail, to have a real NULL event set its size to -1 instead of 0, it's more general and efficient in Usine.
also the about the "Coeff to DB"
To change the volume of an audio flow, you can do a multiplication by a Coeff:
The coeff to db is to retrieve the associated dB of a coeff (the inverse of the function above)
Just a detail, to have a real NULL event set its size to -1 instead of 0, it's more general and efficient in Usine.
Code: Select all
setLength(output,-1);To change the volume of an audio flow, you can do a multiplication by a Coeff:
Code: Select all
-6 dB = mult by 0.5
-12db = mult by 0.25
...Code: Select all
coeffTodB(0.5) = -6
coeffTodB(0.25) = -12
...Olivier Sens
www.brainmodular.com
www.brainmodular.com
-
woodslanding
- Member
- Posts: 1327
Thanks, all!
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
woodslanding
- Member
- Posts: 1327
Hey, this worked great, and I have created my most sophisticated script yet.
Thanks so much!!!
Thanks so much!!!
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
woodslanding
- Member
- Posts: 1327
Olivier:senso wrote:The coeff to db is to retrieve the associated dB of a coeff (the inverse of the function above)
Code: Select all
coeffTodB(0.5) = -6 coeffTodB(0.25) = -12 ...
I'm getting:
Undeclared Identifier
when I use the function coeffToDB(single)
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
woodslanding
- Member
- Posts: 1327
Revisiting this.... this time, I want to do Only If Changed for an Array.... but I can't do setValue(-1) or setLength(-1) on an array. How do I do this??
Thanks!!
-eric
Thanks!!
-eric
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
- nay-seven
- Site Admin
- Posts: 5684
- Location: rennes France
- Contact:
find this in my library, don't know the author
not exactly what you want but maybe a source of inspiration
not exactly what you want but maybe a source of inspiration
Code: Select all
////////////////////////////////////////////////////////////////////////////////////////////
// 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 array
const 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 easily
var i,l,count: integer; // we declare the variable we will use and their type
var 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 size
setdontsave(arrayIn,false); // by doing this the arrayin can be saved to Pm or on quiting the patch
END;//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;-
woodslanding
- Member
- Posts: 1327
Thanks Nay, that looks like the right info!
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
woodslanding
- Member
- Posts: 1327
hmmm..... this is sort of not helping. I want to stop an array type out, and you are only stopping individual datafield elements of an array of TParameters. I know how to stop a datafield.
Still can't figure out how to stop a PTArray.
Still can't figure out how to stop a PTArray.
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
23fx23
- Member
- Posts: 2548
i made this script a while back , but indeed it's more complex as it was made as an individual outpts PIC from an array (and have to correct the setlength to -1 and not 0 ideally, but should still work as is).
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
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
-
woodslanding
- Member
- Posts: 1327
I actually just want to stop the array when I get a 1 from the STOP input to the script.
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:
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:
Code: Select all
/////////////////////////////////////
/////////////////////////
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 parameters
procedure 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 procedure
Procedure 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]));
END
end;
//////////////////////////////
// main proc
//////////////////////////////
Procedure Process;
begin
end;Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
23fx23
- Member
- Posts: 2548
will have a look at home this weekend, but from quick read you don't need to loop thru the whole array with a 'for i' but just set the global array length once, and i suspect pb comming from the else linked to (n=stop), as if any other inputs change, even if stop is 1 it will trig back the lenght to a positive value. try to link only to stop value, something like:
IF (stop = 1) then begin setlength(paramsOUT,-1); end else begin setlength(paramsOUT,length);end;
then your loop to set the values.
IF (stop = 1) then begin setlength(paramsOUT,-1); end else begin setlength(paramsOUT,length);end;
then your loop to set the values.
-
woodslanding
- Member
- Posts: 1327
Don't spend too much time on that--I just realized once I am sending params as an array, I can stop the whole thing with one OIC module on the array input.... so no real need to put that in the script. I just need to be able to extract certain values from the array, manipulate them, and add the new values back into the appropriate slots in the array. I think I can do all that.
Thanks so much!
-eric
Thanks so much!
-eric
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
woodslanding
- Member
- Posts: 1327
Getting back to this (as I'm doing it in a script again) so the length of a ptArray is set by setLength(x), not setArrayLength(x)?
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
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
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
-
woodslanding
- Member
- Posts: 1327
I did get this to work, not sure why it was refusing to compile before....
I did iterate, and it is working, thanks!!
I did iterate, and it is working, thanks!!
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify
