Welcome to %s forums

BrainModular Users Forum

Login Register

A 512 slot "matrix combobox"

I need help on a Patch
Post Reply
Fléau
Member
Posts: 99
Contact:

Unread post by Fléau » 22 Nov 2011, 21:49

Hi usiners,
i'm using the "256 preset manager" that i pulled to 512 on my slave computer (and it work perfectly for a vst with no program change).
To drive it via OSC on my master computer i use that wonderfull "MX combobox" ,
but i do not manage to make it works with 512 slots:
in the script, i changed NBPRESETS:= 256; by NBPRESETS:= 512; , recompiled it,
but it make black squares and i can't change their color:
Image
I noticed that the [colorsMEM] arrayout of the script is staying at 256 (sometime at 258).
I could put two of them to drive the 512 preset manager, but it's shame...
So, if anybody had an idea about that it would be great ( i'm at 240 presets and i had some 25 per day...).
Thanks,
Bérénice.

edit: noticed some problem with the scroll inertia module and touch screen.

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

Unread post by nay-seven » 23 Nov 2011, 09:13

I can't give you a complete solution cause it's a 23FX script, i suppose he can answer you soon
waiting for this, you can delete the wire colorsout to cell color and now you can change the color cells of the matrix module
you lose the possibilities to change individually the color of each cells but you can use the patch

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 23 Nov 2011, 11:13

i will have a look, it's certainly an array size that has to be extended to 512

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 23 Nov 2011, 12:11

try to replace main script by this one, by default it should have 512 slots, but note nb of slots then adapt to the comma that feed in,
so the comma (out of preset in your case) should also have 512 elmts)

Code: Select all

// MX_ComboBox______________________23fx 13/05/2k10//     
/////////////////////////////////////////////////////////////
// Matrix based combo box with inertia   //
/////////////////////////////////////////////////////////////
const COLBAZE=4473924;
////////////////////////////////////////////////////////
var num,toAll,clear,Msdwn,ScrollIn,Mxsize,nbcols,cellscap,arrayout,colorsout,colorsmem,colorin,bordersout,colorout,maxscroll,ID_CLIC,presetout : Tparameter;
var pmnum,page,raj,idclic,scrolin,mscroll: integer;
var MSD: boolean;
var commain, txtin, go: tparameter;
var SL1,SLout: tstringlist;
var WAITING_NM,OK : boolean;
var L,scroll,NB_COLS,NB_ROWS,NBPRESETS: integer;
///////////////////////////////////////////////////////////////////////
Procedure Init;
var i: integer;
var s: string;
BEGIN
NBPRESETS:= 512;
     num  := CreateParam('num',PtDataField)  ;setIsOutput(num,false);
     setdontsave(num,false);
     Msdwn:= CreateParam('msdwn',PtDataField);setIsOutput(msdwn,false);
     toAll:= CreateParam('toAll',PtDataField);setIsOutput(toAll,false);
     clear:= CreateParam('clear',PtDataField);setIsOutput(clear,false);
     commain:= createparam('commain',pttextfield); setisoutput(commain,false); setdontsave(commain,false);
     txtin:= createparam('txtin',pttextfield);setisoutput(txtin,false); 
     go:= createparam('dbclick',ptdatafield);setisoutput(go,false); 
     ScrollIn:= createparam('ScrollIn',ptdatafield);setisoutput(ScrollIn,false); 
     MXsize:= createparam('Mxsize',ptdatafield);setisoutput(Mxsize,false); 
     NBCOLS:= createparam('NBCOLS',ptdatafield);setisoutput(NBCOLS,false); 
     colorin:= createparam('COLORIN',ptdatafield);setisoutput(COLORIN,false); 
     ID_CLIC  := CreateParam('ID_CLIC',PtDataField)  ;setIsOutput(ID_CLIC,false);

     cellscap:= createparam('cellscap',pttextfield);setisinput(cellscap,false); 
     Arrayout:= createparam('arrayout',ptArray);setisinput(arrayout,false); setlength(arrayout,16);
     colorsOut:= createparam('colorsout',ptArray);setisinput(colorsout,false); setlength(colorsout,16);
     setMax(colorsOut,MAXINT);
     colorsMEM:= createparam('colorsMEM',ptArray);setisinput(colorsMEM,false); setlength(colorsMEM,nbpresets);
     setdontsave(colorsout,false);
     setMax(colorsMEM,MAXINT); setdontsave(colorsMEM,false);
     bordersOut:= createparam('bordersout',ptArray);setisinput(bordersout,false); setlength(bordersout,16);
     setMax(bordersOut,MAXINT);
colorout:= createparam('COLOROUT',ptdatafield);setisinput(COLOROUT,false); 
maxscroll:= createparam('maxscroll',ptdatafield);setisinput(maxscroll,false); 
presetout:= createparam('presetout',ptdatafield);setisinput(presetout,false); 

SL1:=Tstringlist.create;
SLOUT:=Tstringlist.create;
   (WAITING_NM):= FALSE; 
MSD:=false;
OK:=true;
page:=0;
scroll:=0;
L:=16;
raj:=0;
s:='0';
          for i:=0 to nbpresets-1 do begin
            setdataArrayvalue(colorsmem,i,COLBAZE);
            s:= S+','+intToStr(i+1);
           end;
setstringvalue(cellscap,S);
sendinternalMsg('SET_STRING_VALUE','LIST','comma text',S);
END;
/////////////////////////////////////////
Procedure destroy;
begin SL1.free; slout.free end;
//////////////////////////////////////////////////////////////////
Procedure callBack(n : integer);
var i: integer;
var nblines: single;
BEGIN

if (n=toall) and (getvalue(toall)=1) then begin
          for i:=0 to maxi(nbpresets,L)-1 do begin
            setdataArrayvalue(colorsmem,i,getvalue(colorin));
           U_CELLS(pmnum);
          end;
end;

if (n=id_clic) then begin
     if getvalue(id_clic)>-1 then begin
        IDCLIC:= trunc(getvalue(id_clic));
     end;
end;

if (n=ScrollIn) or (n=mxsize) or (n=NBCOLS) or (n=commain) then begin
   OK:=FALSE;
   SL1.commatext:= getstringvalue(commain);
   nbpresets:=SL1.count;
   NB_COLS:= trunc(getvalue(NBCOLS));
   L:= trunc(getvalue(Mxsize));
   NB_ROWS:= L div NB_COLS;
   setLength(arrayout,L);
   setLength(colorsout,L);
   setLength(bordersout,L);
   scrolin:= maxi(0,trunc(mscroll-(getvalue(scrollin))));
   scroll:= scrolin*NB_COLS;
   U_CAPS; U_CELLS(pmnum);
   nblines:=nbpresets/nb_cols;
    if  nblines<>trunc&#40;nblines&#41; then begin
    raj&#58;= 1; end else begin raj&#58;=0;end;
    Mscroll&#58;=&#40;NBpresets div NB_COLS&#41;-NB_ROWS+&#40;raj&#41;;
    setvalue&#40;maxscroll,mscroll&#41;;
   end;

if &#40;n=colorin&#41; then begin
   setdataarrayvalue&#40;colorsMEM,pmnum,getvalue&#40;colorin&#41;&#41;;U_CELLS&#40;pmnum&#41;;
   end;

if &#40;n=go&#41;and &#40;getvalue&#40;go&#41;=1&#41; then begin
    WAITING_NM&#58;=TRUE;
    end;

if &#40;n=commain&#41; then begin
   SL1.commatext&#58;= getstringvalue&#40;commain&#41;;
   nbpresets&#58;=SL1.count;
U_comma;
 U_CAPS;
 U_CELLS&#40;pmnum&#41;;
  U_SEL&#40;pmnum&#41;;
   end;

if &#40;n=txtin&#41; AND &#40;WAITING_NM&#41; then begin
    SL1.strings&#91;scroll+idclic&#93;&#58;= getstringvalue&#40;txtin&#41;;
U_comma;
   &#40;WAITING_NM&#41;&#58;= FALSE;    U_CAPS;
    end;

               if &#40;n=msdwn&#41; then begin
                  MSD&#58;=getvalue&#40;msdwn&#41;=1;
                     if &#40;MSD&#41; then begin
                         OK&#58;=TRUE;
                     end;
                     if &#40;not MSD&#41; AND &#40;OK&#41; then begin
                     U_SEL&#40;scroll+idclic&#41;;
                     U_SEL_COLOR&#40;scroll+idclic&#41;;
                     end;
                 end;
           if &#40;n=num&#41; and &#40;getvalue&#40;num&#41;>-1&#41;then begin
             SL1.commatext&#58;= getstringvalue&#40;commain&#41;;
             pmnum&#58;= trunc&#40;getvalue&#40;num&#41;&#41;;
             U_CELLS&#40;pmnum&#41;;U_SEL&#40;pmnum&#41;;U_SEL_COLOR&#40;pmnum&#41;;
             end;


END;
//////////////////////////////////////////
Procedure U_SEL&#40;ID&#58;integer&#41;;
begin
  if &#40;scroll+idclic&#41;<SL1.count then begin
SendInternalMsg&#40;'SET_TARGET_PATCH','SENDER_PATCH'&#41;;
SendInternalMsg&#40;'SET_VALUE','LIST','1',FloatToStr&#40;ID&#41;&#41;;
SendInternalMsg&#40;'SET_STRING_VALUE','TXT','NAME',SL1.strings&#91;ID&#93;&#41;;
SendInternalMsg&#40;'SET_STRING_VALUE','SELECTED','CAPTION',FloatToStr&#40;ID&#41;&#41;;
end;
end;
//////////////////////////////////////////////////////////
Procedure U_comma;
begin
SendInternalMsg&#40;'SET_TARGET_PATCH','SENDER_PATCH'&#41;;
sendinternalMsg&#40;'SET_STRING_VALUE','LIST','comma text',SL1.commatext&#41;;
end;
//////////////////////////////////////////////////////////
Procedure U_CAPS;
var i&#58;integer;
begin
SLOUT.clear;
for i&#58;= 0 to L-1 do begin
     if &#40;i+scroll&#41; < Sl1.count then begin
    SLout.add&#40;sl1.strings&#91;i+scroll&#93;&#41;;
     end else begin
     SLout.add&#40;'-'&#41;;end;
   end;
setstringvalue&#40;cellscap,Slout.commatext&#41;;

end;//ucaps
//////////////
Procedure U_SEL_COLOR&#40;ID&#58;integer&#41;;
begin
SendInternalMsg&#40;'SET_TARGET_PATCH','SENDER_PATCH'&#41;;
SendInternalMsg&#40;'SET_VALUE','COLOR','color',floatToStr&#40;getdataarrayvalue&#40;colorsmem,ID&#41;&#41;&#41;; 
end;
//////////////////////////////////////////////////////////
Procedure U_CELLS&#40;ID&#58;integer&#41;;
var i,j, val&#58;integer;
begin

if &#40;ID>=&#40;scroll&#41;&#41; and &#40;ID<&#40;scroll+L&#41;&#41; then begin
    val&#58;=16777215 end else begin val&#58;=colbaze;end;
for i&#58;= 0 to L-1 do begin
     if i<>&#40;&#40;id-scroll&#41; &#41; then begin
     setdataarrayvalue&#40;arrayout,i,0&#41;;
     setdataArrayvalue&#40;bordersout,i,getdataarrayvalue&#40;colorsmem,i+scroll&#41;&#41;;
     end else begin
     setdataarrayvalue&#40;arrayout,i,1&#41;;
     setdataarrayvalue&#40;bordersout,i,val&#41;;
   end;
end;
for j&#58;=0 to L-1 do begin
  if &#40;j+scroll&#41;< nbpresets then begin
  setdataArrayvalue&#40;colorsout,j,getdataarrayvalue&#40;colorsmem,j+scroll&#41;&#41;;
  end
  else begin
  setdataArrayvalue&#40;colorsout,j,colbaze&#41;;end;
end;
end;//ucaps
//////////////

Fléau
Member
Posts: 99
Contact:

Unread post by Fléau » 23 Nov 2011, 20:14

Thanks a lot, had to recompile+ init ( not just reload), and it works.

If the matrix had some more inputs than colors: like bitmaps, this patch would be wonderfull
(you could put some "stars" to give a 'rank') but color is enough.

(Merci 23fx23, tu m'enlèves une énorme épine du pied,
merci aussi pour ce très bon patch et la rapidité de ta réponse ( nay7 too).

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 23 Nov 2011, 21:00

you re welcome, de rien ;)

yes the array used to store the colors got it's max size initialized on init procedure, so must re- init the script if changed to update.
Reload works well for everything exept stuff that chged in init, ie keeping same in outs and sizes, but changing a part of processing code.

well it's actually possible to to the reverse way: feed matrix bmp out to 'draw objects' bmp in, then use the draw object module to overlay 'stars' (wich would more be circles or squares) in each cells, but then it needs a bit more complex script as it has to virtually reproduce the matrix splitted cells on draw module that will receive the mouse infos, plus the scrolling system...

I think martin is overbusy but he once said he was thinking about a way to implement gfx arrays directly on matrix.
(if so an idea is using a bmp in able to read as a frame sequence (like faders) so we can do whatever shape and animation we want,
matrix could then spread the animation for each cell, and display correct frame per cell remaping according to value array.
and if done in black and white, then the independant cell color would have their luma multiplied (classic multiply mode in gfx softs) so ie a fader with black bg and white fader on yellow cell would display a yellow fader on black bg, and with a single animation sequence we could get multiples colors, and faders,knobs, whatever kind of animation could be done easily..

i may have a look if i find time (hard actually) to do the other technique draw stuff, cause it can be also used to display faders in each cells, wich would be quite cool. i already made such patch, but only for 1D non scrollable matrix, will try to extend..

Fléau
Member
Posts: 99
Contact:

Unread post by Fléau » 16 Dec 2011, 20:38

sorry to harass you again 23fx23,
we need to do the same (512) for '256PRESETS_MX'
it would be great if you give us the entire code again,
but i prefer you give me (fleau) the lines to be replaced (i'd like to understand :cool: )

thanks.

edit: working on preset rating with something like 'concat string' and symbols,
will post it there if it works.

Fléau
Member
Posts: 99
Contact:

Unread post by Fléau » 17 Dec 2011, 11:44

Found the solution,
the script is ok, was the "PR_OUT" fader with a max value of 255.


Post Reply

Who is online

Users browsing this forum: No registered users and 76 guests