Page 1 of 1

Posted: 15 May 2011, 15:28
by nay-seven
was wondering if it's possible to have a generic script for the matrix module
i imagine some listbox inlets for example named
switches
button
switch group 1
switch group2..
where you enter a list of number to specify the cells function
this way we can say cells 10,11,12,13,14 are a group of switches
cells 15 & 16 are buttons and so...

do you think it's possible..?

Posted: 15 May 2011, 15:33
by nay-seven
here an example to illustrate :
here a matrix recorder where the last row have different functions
some like rec, over,pause must be switches , clear have to be a button, and last 1,2,3,,4..are different pattern so must be a group of switches..
Image

Posted: 15 May 2011, 15:44
by 23fx23
mm seems doable i can try to have a look.

i wonder if a system to configure directly via a menu wouldn't be more easy for user.

ie we enable a 'configure' swich. then we choose button and clic all the cells that must be a button, then leave configure.
then do same for swiches and group swich. i just wonder how to deal multiples group. but i will try with only one group first..

Posted: 15 May 2011, 16:23
by nay-seven
cool, and yeah, the listbox is just an idea

Posted: 15 May 2011, 16:46
by 23fx23

Code: Select all

//////////////////////////
// MX_MULTIMODES_ 23fx15/05/2K11
// allow to configure cells to act as
// momentary/toggle swich or group swiches
/////////////////////////
// parameters declaration
var Config,MXsize:tparameter;
var Ctype:tparameter;
var arrayout,MEMtypes:tparameter;
var IDclic:tparameter;
var Msdwn:tparameter;
var L, cty,ID: integer;
var msd,cfg:boolean;
// initialisation : create parameters
procedure init;
begin 
MXsize:=createParam('Mxsize',ptdatafield);
setisoutput(Mxsize,false);
 
Config:=createParam('config',ptswitch);
setisoutput(config,false);

ctype:=createParam('ctype',ptListBox);
SetListBoxString(ctype,'button,swich,G1,G2,G3,G4,G5,G6,G7,G8');
setisoutput(ctype,false);

idclic:=createParam('idclic',ptdatafield);
setisoutput(idclic,false);

msdwn:=createParam('msdwn',ptdatafield);
setisoutput(msdwn,false);

arrayout:=createParam('arrayout',Ptarray);
setisinput(Arrayout,false);

MemTypes:=createParam('Memtypes',Ptarray);
setisinput(Memtypes,false);setdontsave(memtypes,false);

id:=0;
msd:=false;
cfg:=false;
end;

// Callback procedure
Procedure Callback(N:integer); 
begin
if (n=mxsize) then resize;

if (n=config) then begin
    cfg:=getvalue(config)=1;
    end;

if (n=idclic) then begin
   if getvalue(idclic)>-1 then begin
      ID:= trunc(getvalue(idclic));
   end;
  end;

if (n=msdwn) then begin
   MSD:=getvalue(msdwn)=1;
        if MSD then begin
        //resize;
           if CFG then begin
              setdataarrayvalue(memtypes,ID,getvalue(ctype));
           end; 
        cty:= trunc(getdataarrayvalue(memtypes,ID));
        itrace(cty);
       end;//msd
        U_CELLS(cty);
    end;//msdwn
    
end;
////////////////////////////
Procedure U_CELLS(mode : integer);
var i:integer;
begin
if mode=0 then begin  //button,mmt mode
   setdataarrayvalue(arrayout,ID,getvalue(msdwn));
   end;
 if (mode=1) and (MSD) then begin
    setdataarrayvalue(arrayout,ID,1-getdataarrayvalue(arrayout,ID));
   end;
if mode>=2 then begin
   for i:=0 to L-1 do begin
   if getdataarrayvalue(memtypes,i)=mode then begin
      setdataarrayvalue(arrayout,i,0);
    end;
    end;
   setdataarrayvalue(arrayout,id,1);
   end;



end;
/////////////////////////
Procedure RESIZE;
begin
L:=trunc(getvalue(Mxsize));
setlength(arrayout,L);
setlength(memtypes,L);
end;
//////////////////////////
or an already wired patch here:
MultiModes_MX

when you enable configure, you can choose a type in combobox (button,switch, or one of 8 group)
then clic the cells you want to behave like this. once done swich of configure.

edit: i forgot, you can delet the line itrace(cty); and make reload script.
the cells type should normally be memorized and you can use preset manager to recall to different layouts.

Posted: 15 May 2011, 17:24
by nay-seven
whaoo! so fast crazy boy !
works perfectly , now i've some incompatibility with my visual feedback mode but maybe there's some workaround
will let you know
And i thinks this could be a cool script for many uses and to quickly build patches

Many Thanks !!!

Posted: 15 May 2011, 18:02
by 23fx23
cool, yup it will be helpful for me too ;) . btween it's not the ultimate optimized code for very big matrix, but was much easier
to code like this than tracking and incrementing size of groups, and cpu seems fairly descent like this so...ive chosen the lasy way ;)

let me know if you got pbs with your feedback mode, maybe you need some arrayin to feed the script or i don't know?
(if so you can try to deploy the script so that array out pin is visible on input, and feed your stuff maybe..

happy it's helpuf for ya nay'

Posted: 15 May 2011, 21:09
by joffo78
hey nice job i love this patch ! Well done 23fx23.

Posted: 16 May 2011, 14:02
by 23fx23
thx joffo

Posted: 17 May 2011, 07:55
by nay-seven
me again,
seems that the state of the cells are not memorized by a preset manager...?

Posted: 17 May 2011, 09:56
by 23fx23
mm oh yup, forgot that. try this one:

Code: Select all

//////////////////////////
// MX_MULTIMODES_ 23fx15/05/2K11
// allow to configure cells to act as
// momentary/toggle swich or group swiches
/////////////////////////
// parameters declaration
var Config,MXsize:tparameter;
var Ctype:tparameter;
var arrayout,MEMtypes:tparameter;
var IDclic:tparameter;
var Msdwn:tparameter;
var L, cty,ID: integer;
var msd,cfg:boolean;
// initialisation : create parameters
procedure init;
begin 
MXsize:=createParam('Mxsize',ptdatafield);
setisoutput(Mxsize,false);
 
Config:=createParam('config',ptswitch);
setisoutput(config,false);

ctype:=createParam('ctype',ptListBox);
SetListBoxString(ctype,'button,swich,G1,G2,G3,G4,G5,G6,G7,G8');
setisoutput(ctype,false);

idclic:=createParam('idclic',ptdatafield);
setisoutput(idclic,false);

msdwn:=createParam('msdwn',ptdatafield);
setisoutput(msdwn,false);

arrayout:=createParam('arrayout',Ptarray);
setisinput(Arrayout,false);setdontsave(arrayout,false);

MemTypes:=createParam('Memtypes',Ptarray);
setisinput(Memtypes,false);setdontsave(memtypes,false);

id:=0;
msd:=false;
cfg:=false;
end;

// Callback procedure
Procedure Callback(N:integer); 
begin
if (n=mxsize) then resize;

if (n=config) then begin
    cfg:=getvalue(config)=1;
    end;

if (n=idclic) then begin
   if getvalue(idclic)>-1 then begin
      ID:= trunc(getvalue(idclic));
   end;
  end;

if (n=msdwn) then begin
   MSD:=getvalue(msdwn)=1;
        if MSD then begin
        //resize;
           if CFG then begin
              setdataarrayvalue(memtypes,ID,getvalue(ctype));
           end; 
        cty:= trunc(getdataarrayvalue(memtypes,ID));
       end;//msd
        U_CELLS(cty);
    end;//msdwn
    
end;
////////////////////////////
Procedure U_CELLS(mode : integer);
var i:integer;
begin
if mode=0 then begin  //button,mmt mode
   setdataarrayvalue(arrayout,ID,getvalue(msdwn));
   end;
 if (mode=1) and (MSD) then begin
    setdataarrayvalue(arrayout,ID,1-getdataarrayvalue(arrayout,ID));
   end;
if mode>=2 then begin
   for i:=0 to L-1 do begin
   if getdataarrayvalue(memtypes,i)=mode then begin
      setdataarrayvalue(arrayout,i,0);
    end;
    end;
   setdataarrayvalue(arrayout,id,1);
   end;



end;
/////////////////////////
Procedure RESIZE;
begin
L:=trunc(getvalue(Mxsize));
setlength(arrayout,L);
setlength(memtypes,L);
end;
//////////////////////////
or if you already made assign and don't wanna loose them, add the line in init after arrayout creation:
setdontsave(arrayout,false); then make 'reload script'

Posted: 17 May 2011, 10:02
by nay-seven
great !
works fine
thanks again

Posted: 08 Mar 2013, 11:23
by Fléau
Cool one, but i have a special request:
I really need a slave one for my novation launchpad patch,
please, could you take a few minutes to add a "memtypes" array input?
That would be great, thanks in advance.

Edit: forget it,
was really easy and simple to patch.