Page 1 of 1

Posted: 14 Oct 2010, 11:13
by 23fx23
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/

Posted: 14 Oct 2010, 11:15
by ethnix73
Yeahj!

Really usefull one 23fx23.

Thanks!

Posted: 14 Oct 2010, 11:23
by 23fx23
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.

Posted: 14 Oct 2010, 12:52
by 23fx23
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..

Posted: 14 Oct 2010, 13:03
by 23fx23
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..

Posted: 15 Oct 2010, 02:18
by 23fx23
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 ;)

Posted: 15 Oct 2010, 07:54
by nay-seven
great, useful one !

Posted: 15 Oct 2010, 17:36
by gurulogic
Cool, I look forward to trying this. I assume this will be perfect for unpacking muttiple OSC messages received simultaniously from Monome apps etc....?

Posted: 15 Oct 2010, 19:06
by 23fx23
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'.
.

Posted: 16 Oct 2010, 05:38
by gurulogic
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...

Posted: 16 Oct 2010, 19:45
by 23fx23
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.

Posted: 18 Nov 2010, 13:38
by ethnix73
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....

Posted: 18 Nov 2010, 19:35
by 23fx23
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..

Posted: 19 Nov 2010, 02:34
by 23fx23
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
////////////////////////////

Posted: 19 Nov 2010, 12:51
by ethnix73
Tested it quickly and it seems to be ok 23fx23!

No more error on init...

Posted: 19 Nov 2010, 17:46
by 23fx23
ok cool, i will reupdzate yje addon then

Posted: 19 Nov 2010, 18:08
by ethnix73
you've changed your keyboard, your fingers or your eyes?

:D

Posted: 19 Nov 2010, 18:11
by 23fx23
yeah i make lot of errors those days ;) need to type slower.hehe

Posted: 07 Dec 2010, 22:55
by ethnix73
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...

Posted: 08 Dec 2010, 01:51
by 23fx23
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?

Posted: 08 Dec 2010, 02:09
by ethnix73
Yes, i've got some overloads with the midi driver for the launchpad :(

And it creates audio glitches...

Posted: 08 Dec 2010, 12:45
by 23fx23
ok , i will try to find a way and let you know , for now i still fail :x

Posted: 08 Dec 2010, 13:19
by ethnix73
Thanks 23fx23!

Cool to try to help me...

Posted: 09 Dec 2010, 22:34
by 23fx23
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
////////////////////////////
/

Posted: 09 Dec 2010, 23:03
by ethnix73
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:

Posted: 10 Dec 2010, 21:30
by 23fx23
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..

Posted: 30 Jan 2012, 23:16
by r.erorr
I know it was long time ago, but I just want to say thanks... very useful...

Posted: 31 Jan 2012, 01:55
by 23fx23
well you're welcome, glad it's helpful for some :)

Posted: 14 Apr 2013, 11:52
by Fléau
hello,
23fx23, did you found the solution?

Posted: 15 Apr 2013, 23:48
by 23fx23
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 ;)

Posted: 18 Apr 2013, 12:21
by Fléau
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.

Posted: 18 Apr 2013, 21:44
by 23fx23
cool ;) well done