muddling up an array
A job for a script guru...?
Here is a quick one off the top of my head, not tested or optimized either so let me know if it doesn't work! If you need it to be more efficient I can come up with something much better using the C++ SDK as I am still unfamiliar with the script's Pascal syntax 
Code: Select all
var ArrayIn, ButtonIn, ArrayOut : tparameter;
///////////////////////////////////////////////
procedure init;
begin
ArrayIn:= CreateParam('Array in',ptarray); SetisOutput(ArrayIn,false);
ButtonIn:= CreateParam('Shuffle',ptbutton); SetisOutput(ButtonIn,false);
Arrayout:= CreateParam('Arrayout',ptarray); Setisinput(ArrayOut,false);
end;
//////////////////////////////////////
Procedure Callback(N:integer);
Var i, j : Integer;
Var temp : real;
begin
if (N=ButtonIn) then begin
for i:= 0 to GetLength(ArrayIn)-1 do begin
SetDataArrayValue(ArrayOut, i, GetDataArrayValue(ArrayIn, i));
end;
SetLength(ArrayOut, GetLength(ArrayIn));
for i:= GetLength(ArrayOut)-1 downto 0 do begin
j := random(i);
temp := GetDataArrayValue(ArrayOut, j);
SetDataArrayValue(ArrayOut, j, GetDataArrayValue(ArrayOut, i));
SetDataArrayValue(ArrayOut, i, temp);
end;
end;
end;works fine Caco, but only for array with min=0, max=100
if not you have to set those values manually
if not you have to set those values manually
Seem to works perfect (for me)!
Leaving for the weekend, so i will test it more on monday,
now able to share a 'midi stochastic seq' in my midi harmonizing tools patch.
Thank you caco.
Leaving for the weekend, so i will test it more on monday,
now able to share a 'midi stochastic seq' in my midi harmonizing tools patch.
Thank you caco.
How strange, just to check you mean min and max value in array between 0-100? Will try and work out where I went wrong!nay-seven wrote:works fine Caco, but only for array with min=0, max=100
if not you have to set those values manually
yes, but i just realize that modules like swap or shift array don't get (and set) those values automatically , so maybe it's normal ..?
In that case I suspect array in and out ranges have default of 0-100 and just need modifying.nay-seven wrote:yes, but i just realize that modules like swap or shift array don't get (and set) those values automatically , so maybe it's normal ..?
Is this any better? Seems to work fine here now.
Code: Select all
var ArrayIn, ButtonIn, ArrayOut : tparameter;
///////////////////////////////////////////////
procedure init;
begin
ArrayIn:= CreateParam('Array in',ptarray); SetisOutput(ArrayIn,false);
ButtonIn:= CreateParam('Shuffle',ptbutton); SetisOutput(ButtonIn,false);
Arrayout:= CreateParam('Arrayout',ptarray); Setisinput(ArrayOut,false);
SetMin (ArrayIn, 1.4e-45); // set min parameter value
SetMax (ArrayIn, 3.4e38); // set max parameter value
SetMin (ArrayOut, 1.4e-45); // set min parameter value
SetMax (ArrayOut, 3.4e38); // set max parameter value
end;
//////////////////////////////////////
Procedure Callback(N:integer);
Var i, j : Integer;
Var temp : real;
begin
if (N=ButtonIn) then begin
for i:= 0 to GetLength(ArrayIn)-1 do begin
SetDataArrayValue(ArrayOut, i, GetDataArrayValue(ArrayIn, i));
end;
SetLength(ArrayOut, GetLength(ArrayIn));
for i:= GetLength(ArrayOut)-1 downto 0 do begin
j := random(i);
temp := GetDataArrayValue(ArrayOut, j);
SetDataArrayValue(ArrayOut, j, GetDataArrayValue(ArrayOut, i));
SetDataArrayValue(ArrayOut, i, temp);
end;
end;
end;it works if you create the 2 array from the script , but i mean if you have a project with an array with min =20 and max =80 , and you want add your script behind this one, this don't work..?
i suppose we need here 2 variable , min and max and get their value from the first array..?
but it's not a big deal , so don't waste time for this if you don't have..
i suppose we need here 2 variable , min and max and get their value from the first array..?
but it's not a big deal , so don't waste time for this if you don't have..
Yes, but this is the same with all array modules that you need to make sure second array is compatible with first array for min, max etc I think?
Made minor change so that Array Out is now saved in patch as was not being restored before.
Made minor change so that Array Out is now saved in patch as was not being restored before.
Code: Select all
//////////////////////////////////////////////
// Randomly reorders data in array
// Version 1.01
// 2 July 2012
// By Caco
//////////////////////////////////////////////
var ArrayIn, ButtonIn, ArrayOut : tparameter;
///////////////////////////////////////////////
procedure init;
begin
ArrayIn:= CreateParam('Array in',ptarray); SetisOutput(ArrayIn,false);
ButtonIn:= CreateParam('Shuffle',ptbutton); SetisOutput(ButtonIn,false);
Arrayout:= CreateParam('Array out',ptarray); Setisinput(ArrayOut,false);
SetMin (ArrayIn, 1.4e-45); // set min parameter value
SetMax (ArrayIn, 3.4e38); // set max parameter value
SetMin (ArrayOut, 1.4e-45); // set min parameter value
SetMax (ArrayOut, 3.4e38); // set max parameter value
SetDontSave (ArrayOut, FALSE);
end;
//////////////////////////////////////
Procedure Callback(N:integer);
Var i, j : Integer;
Var temp : real;
begin
if (N=ButtonIn) then begin
for i:= 0 to GetLength(ArrayIn)-1 do begin
SetDataArrayValue(ArrayOut, i, GetDataArrayValue(ArrayIn, i));
end;
SetLength(ArrayOut, GetLength(ArrayIn));
for i:= GetLength(ArrayOut)-1 downto 0 do begin
j := random(i);
temp := GetDataArrayValue(ArrayOut, j);
SetDataArrayValue(ArrayOut, j, GetDataArrayValue(ArrayOut, i));
SetDataArrayValue(ArrayOut, i, temp);
end;
end;
end;yes, you're certainly right, i sadly don't have time to study scripts right now, i first thing we can use something like GetDataArrayValue and a variable to get the min & max then set them back
or a GetMin equivalent to the GetLength we have yet
definitively need a parallel life...
or a GetMin equivalent to the GetLength we have yet
definitively need a parallel life...
Who is online
Users browsing this forum: Bing [Bot] and 24 guests
