Welcome to %s forums

BrainModular Users Forum

Login Register

Unpack Array script

Discussions about add-ons, announcements
Post Reply
23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 14 Oct 2010, 11:13

Image

enhanced light cpu script version of previous 'last chg array' or unpack_array patchs.
when one or several elements of an array changed simultaneously,it will output one after the other only those changed values and indexs.

i find it useful to convert simultaneous arrays changes to monophonic slightly delayed flows to use ie with midi/osc modules or dispatcher/ set array elmnt ect..;.

/add-ons/data tools/

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 14 Oct 2010, 11:15

Yeahj!

Really usefull one 23fx23.

Thanks!
Seb.Dub

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 14 Oct 2010, 11:23

you're welcome ethnix, in your case, i guess you can use it to send all your matrix array changes back to launchpad via midi maybe,
in case of ie changing local stored sequences presets, to reupload all datas.

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 14 Oct 2010, 12:52

arf nope it doesn't work as expected yet, i will reupload as soon as i found what's wrong,
but if some one find what to do tell me..

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 14 Oct 2010, 13:03

ok seems fixed reuploded.

edit: mmmmm index and values seems ok but i couldn't get the "send" to work correctly,
so can still be useful bypassing and send via other thing... but if some find how to fix let me know..

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 15 Oct 2010, 02:18

ok .....sorry for my multiples messy reuploads :D

but it was messy on several points.. just found at last a working code with all 3 index, value and send working as i wanted.coool
tested with osc work like a charm with steps modules can draw very fast, should do the same for midi.
if move only one step, only one data is send, if two it toggle to send the two ect. work nice with reseting full big arrays so
i gess it's at last debugged ok ;) cool for multitouch later appz maybe..

reuploaded same /addons/data.

btw if bsork you read the script and have suggz if it's the best way to go let me know ;)

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 15 Oct 2010, 07:54

great, useful one !

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 15 Oct 2010, 17:36

Cool, I look forward to trying this. I assume this will be perfect for unpacking muttiple OSC messages received simultaniously from Monome apps etc....?

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 15 Oct 2010, 19:06

mmm not exactly, it's the other way: send one simultaneous array, to elemnt after element. it has an array on input.
I think you are after the other side : several mono received unpacked and go in an array?
multiples datas on same adress are automaticaly 'unpacked' by OSC receive modules normally,
need to use setArray elemnt to store received datas in array. (the pic i shown ya in monome thread).

if you make an array display or editor out of the setarray element of the pic, you should have your multiples datas.'repacked'.
.

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 16 Oct 2010, 05:38

Sorry. I have not had my head in Usine for awhile so I temporarily forget what is what. Last I checked I still couldn't reliably unpack received OSC but that is for the other thread...

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 16 Oct 2010, 19:45

no worries ;) . yeah we ll speak about in another thread. I got lot of scripts sorting incoming Osc datas to an array.
the set Array is cool but scripts allow more things. i ll make a very simple one that do this as exemple.

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 18 Nov 2010, 13:38

Hi 23fx23,

I've just noticed that there is an error with unpack array when it is connected to an empty matrix module, on initialisation of the patch...

Don't know if it's matrix or script related....
Seb.Dub

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 18 Nov 2010, 19:35

yes i ve seen as weel problems on init when no data is there, i got to check it up, it a pb of the script but didn't found yet.

i probably need to fill the internal array used to compare or i don't know, will let tou know..

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 19 Nov 2010, 02:34

so i reopened my wksp, this stuff is a bit complex for my tiny brain, despite it looks simple hehe.
there is maybe a simpler way to proceed but that seems to work.

this version may get rid of the error,
could you try it ethnix and see if it's forking for you? if so ill update the addon...

Code: Select all

/////////////////////////////////////////////////////////////
// Unpack array 23fx_14/10/2K10
//////////////////////////////////////////////////////////////
// Unpack simultaneous array changes bloc after bloc.
// useful to convert polyphonic messages to slightly delayed
// monophonic flows for ie midi mess or osc,dispatchers/setarrayelmt..
////////////////////////////////////////////////////////////////////////////
var ArrayIn, index, value, send: Tparameter;
var i,j,l,k,m: integer;
var ArrayLast: array of single;
var memIDs : array of integer;
//////////////////////////////////
PROCEDURE INIT;
BEGIN  

ArrayIn :=CreateParam('ArrayIn',PtArray); SetIsOutput(ArrayIn,False);
setmin  (arrayin,-MAXINT); setMAX(arrayin,MAXINT);
//
send    :=CreateParam('send', PtLed)   ;SetIsINput(send,False);
index   :=CreateParam('index',Ptdatafield);SetIsINput(index,False);
value   :=CreateParam('value',Ptdatafield);SetIsINput(value,False);

k:=-2;      //reset unpack counter
j:=0;
setArrayLength(arrayLast,1);
setArrayLength(memIds,1);
end;
//////////////////////////////////////
PROCEDURE CALLBACK(N:integer); 
begin
   
   if (n = 0) then begin
        L:= getlength(ArrayIn);            
        setArraylength(arrayLast,L);
        j:=0;  
        k:=-1;
          for i:=0 to L-1 do begin        
             if getdataArrayValue&#40;ArrayIn,i&#41; - arrayLast&#91;i&#93; <> 0 then begin 
                setvalue&#40;send,1&#41;;                                                         
                j&#58;= j+1;                     
                setArrayLength&#40;memIDs,j&#41;;
                memIDs&#91;j-1&#93;&#58;= i;           
             end;
           end;                                                
     end;
END;//Callback
//////////////////////////////
PROCEDURE PROCESS;
BEGIN

  if k >=-1 then begin                       
     k &#58;= k+1;                          
      setValue&#40;index,memIDs&#91;k&#93;&#41;;              
      setvalue&#40;value,getDataArrayValue&#40;Arrayin,memIDs&#91;k&#93;&#41;&#41;;
      setvalue&#40;send,1&#41;;
   end
   else begin
     setvalue&#40;send,0&#41;;
   end;

  if k = 1 then begin                       
       for i&#58;= 0 to L-1 do begin
         arrayLast&#91;i&#93;&#58;= getDataArrayValue&#40;ArrayIn,i&#41;;
       end;
    end;
  
   if k > &#40;j-2&#41; then begin           
      k&#58;=-2;
    end;

END;//Process
////////////////////////////

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 19 Nov 2010, 12:51

Tested it quickly and it seems to be ok 23fx23!

No more error on init...
Seb.Dub

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 19 Nov 2010, 17:46

ok cool, i will reupdzate yje addon then

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 19 Nov 2010, 18:08

you've changed your keyboard, your fingers or your eyes?

:D
Seb.Dub

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 19 Nov 2010, 18:11

yeah i make lot of errors those days ;) need to type slower.hehe

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 07 Dec 2010, 22:55

i'm yet fighting againt scripting...

I've tried to implement a function to unpack more slowly the array, as you can find in the unpack midi script with wait cycles

But i've got big, enormous difficulties to understand your script 23fx23...

Should i put it in the procedure callback?
I've tried but with no success...
Seb.Dub

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 08 Dec 2010, 01:51

hi ethnix
even me i don't understand this script, i could get it work but i don't really know how lol.

in fact i did it from scratch, and i should have checked unpack midi first maye i think there is a simpler way.

i will try to find a way for that. just curious, why do you need slower, got some overloads?

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 08 Dec 2010, 02:09

Yes, i've got some overloads with the midi driver for the launchpad :(

And it creates audio glitches...
Seb.Dub

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 08 Dec 2010, 12:45

ok , i will try to find a way and let you know , for now i still fail :x

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 08 Dec 2010, 13:19

Thanks 23fx23!

Cool to try to help me...
Seb.Dub

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 09 Dec 2010, 22:34

hi ethnix,
here is one you could test with some bloc_nb input:

Code: Select all

////////////////////////////////////////////////////////////////////////////
var ArrayIn, index, value, send, NB_BLOCS&#58; Tparameter;
var i,j,l,k,m,BLOCS&#58; integer;
var ArrayLast, memVals&#58; array of single;
var memIDs &#58; array of integer;
//////////////////////////////////
PROCEDURE INIT;
BEGIN  

ArrayIn &#58;=CreateParam&#40;'ArrayIn',PtArray&#41;; SetIsOutput&#40;ArrayIn,False&#41;;
setmin  &#40;arrayin,-MAXINT&#41;; setMAX&#40;arrayin,MAXINT&#41;;
NB_BLOCS&#58;=CreateParam&#40;'NB_BLOCS',Ptdatafield&#41;;SetIsOUTput&#40;NB_BLOCS,False&#41;;
SetValue&#40;NB_BLOCS,1&#41;;
//
send    &#58;=CreateParam&#40;'send', PtLed&#41;   ;SetIsINput&#40;send,False&#41;;
index   &#58;=CreateParam&#40;'index',Ptdatafield&#41;;SetIsINput&#40;index,False&#41;;
value   &#58;=CreateParam&#40;'value',Ptdatafield&#41;;SetIsINput&#40;value,False&#41;;


k&#58;=-2;      //reset unpack counter
j&#58;=0;
BLOCS&#58;=1;
setArrayLength&#40;arrayLast,1&#41;;
setArrayLength&#40;memIds,1&#41;;
setArrayLength&#40;memVals,1&#41;;
end;
//////////////////////////////////////
PROCEDURE CALLBACK&#40;N&#58;integer&#41;; 
begin

  if &#40;n=NB_BLOCS&#41; then Begin
     BLOCS&#58;= MaxI&#40;1,round&#40;getvalue&#40;NB_BLOCS&#41;&#41;&#41;;
     end; 

   if &#40;n = ArrayIn&#41; AND &#40;k=-2&#41;then begin
        L&#58;= getlength&#40;ArrayIn&#41;;            
        setArraylength&#40;arrayLast,L&#41;;
        j&#58;=0;  
        k&#58;=-1;
          for i&#58;=0 to L-1 do begin        
             if getdataArrayValue&#40;ArrayIn,i&#41; - arrayLast&#91;i&#93; <> 0 then begin 
                setvalue&#40;send,1&#41;;                                                         
                j&#58;= j+1;   
                setArrayLength&#40;memVals,j&#41;;                 
                setArrayLength&#40;memIDs,j&#41;;
                memIDs&#91;j-1&#93;&#58;= i;  
                memVals&#91;j-1&#93;&#58;= getDataArrayValue&#40;ArrayIn,i&#41;;          
             end;
           end;                                                
     end;
END;//Callback
//////////////////////////////
PROCEDURE PROCESS;
BEGIN

  if k >=-1 then begin                       
     k &#58;= k+1;
     m &#58;= k div BLOCS;                          
      setValue&#40;index,memIDs&#91;m&#93;&#41;;              
      //setvalue&#40;value,getDataArrayValue&#40;Arrayin,memIDs&#91;m&#93;&#41;&#41;;
      setvalue&#40;value,memVals&#91;m&#93;&#41;;
      setvalue&#40;send,1&#41;;
   end
   else begin
     setvalue&#40;send,0&#41;;
   end;

  if m = 1 then begin                       
       for i&#58;= 0 to L-1 do begin
         arrayLast&#91;i&#93;&#58;= getDataArrayValue&#40;ArrayIn,i&#41;;
       end;
    end;
  
   if m > &#40;j-2&#41; then begin           
      k&#58;=-2;
    end;

END;//Process
////////////////////////////
/

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 09 Dec 2010, 23:03

i've just tested it, and it seems ok 23fx23!

I Will test it more heavily but anyway you saved my actual patches!

:D & :cool:
Seb.Dub

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 10 Dec 2010, 21:30

cool :) nb: i noticed the delay works only on polyphonic, if only one data changed each bloc, it will still be sent each bloc..
i couldn't figure out yet a way to quantize first data but i will investigate, but maybe not a pb..

r.erorr
Member
Posts: 405
Location: Latvia
Contact:

Unread post by r.erorr » 30 Jan 2012, 23:16

I know it was long time ago, but I just want to say thanks... very useful...

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 31 Jan 2012, 01:55

well you're welcome, glad it's helpful for some :)

Fléau
Member
Posts: 99
Contact:

Unread post by Fléau » 14 Apr 2013, 11:52

hello,
23fx23, did you found the solution?

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 15 Apr 2013, 23:48

i fleau , sorry u mean a solution for quantisising only one data? im really sorry will all the users i promised updates i couldn't give. i had so much busy things since 6 month i could never find the time to script/ patch back any thing in usine, and i just recently spend lot of time on a scale plugin i dumbly lost wich has a bit dicourage me, but tbh im waiting hollyhock to get back on hard works cause i know few/lots of thing will change and i would prefer to work on useful long term stuff.. but it should be soon now ;)

Fléau
Member
Posts: 99
Contact:

Unread post by Fléau » 18 Apr 2013, 12:21

i think i've found the matter,
replaced:
//setvalue(value,getDataArrayValue(Arrayin,memIDs[m]));
setvalue(value,memVals[m]);
by
setvalue(value,getDataArrayValue(Arrayin,memIDs[m]));
//setvalue(value,memVals[m]);

now working on my patch.

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 18 Apr 2013, 21:44

cool ;) well done

Post Reply

Who is online

Users browsing this forum: No registered users and 40 guests