Page 1 of 1
Posted: 26 Jan 2012, 15:20
by caco
I am struggling to solve something I wish to do with arrays without resorting to scripting and need some advice from Usine gurus
I have array1 that is1024 long and contains a variety of results, I then have array2 which changes size and contains the indices I want from array1. So what I want to is extract those particular values from array1 into a new array but I am not sure how. So if array2 is [0,5,6,128] I want to extract the values at those positions in array1 into a new array. Does that make sense?
The tricky bit is that array2 changes size so the extraction process needs to be able to dynamically change.
Posted: 26 Jan 2012, 15:33
by 23fx23
i would really do by scripting if size dynamically change, by patch the solutions are quite tricky, you need either to use X getarrayelmnt modules, wich mean you would do a polly patch, and i don't think reapplying poly change is a cool solution to adapt dynamic size changing, or the other solution is just one module that extract indexs one after the other, with kind of counter rolling tru indexs you ask from array 2,
but this will take one bloc latency per requested value.
so script is a much more efficient and easy method here. . basically you check lenght of array2, loop thru the array to look IDs to pick from array1 and create a new array3 of same length and copy the datas. it's done in 5mn, I will post you one here.
Posted: 26 Jan 2012, 15:50
by 23fx23
here is one script that should do the job:
Code: Select all
var ArrayIn, IndexsIn, ArrayOut : tparameter;
///////////////////////////////////////////////
procedure init;
begin
ArrayIn:= CreateParam('Arrayin',ptarray); SetisOutput(arrayin,false);
IndexsIn:= CreateParam('Indexsin',ptarray); SetisOutput(Indexsin,false);
Arrayout:= CreateParam('Arrayout',ptarray); Setisinput(arrayout,false);
end;
//////////////////////////////////////
Procedure Callback(N:integer);
var i,L,ID: integer;
begin
L:=MinI(getlength(IndexsIn),getLength(Arrayin));
setLength(arrayout,L);
for i:=0 to L-1 do begin
ID:=round(getdataArrayValue(indexsIn,i));
setdataArrayvalue(Arrayout,i,getdataArrayValue(Arrayin,ID));
end;
END;//CB
////////////////////////////////////////////
Posted: 26 Jan 2012, 16:00
by caco
Thanks 23fx23
I was hoping to avoid scripting this but I think it is inevitable as I don't think the current array modules can do this.
Senso - To me, the logical way to do this without scripting was with the
Get Array Element Value module. Would it be possible for this to take an array as an index? Currently it only acts on the first value but it could be expanded so it would work on every value passed to index?
Posted: 26 Jan 2012, 17:19
by senso
thanks 23FX, you're a master.
Senso - To me, the logical way to do this without scripting was with the Get Array Element Value module. Would it be possible for this to take an array as an index? Currently it only acts on the first value but it could be expanded so it would work on every value passed to index?
It's a good suggestion, and can be extended to many other modules like, the cross-fader, etc.
Unfortunately, it's not so easy to implement and we are working hard on the V6. I'll try to remind this point to implement it in future releases.
senso+++
Posted: 27 Jan 2012, 10:10
by caco
Thanks for considering it Senso
