Welcome to %s forums

BrainModular Users Forum

Login Register

Threading(?) problem with PM256 script

I need help on a Patch
Post Reply
woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 15 Aug 2014, 07:00

I have modified the PM256 script to work with HH, but I am getting a problem (which also occurred with v5)

I have about a dozen of these scripts in my WKP, and when I first open the WKP, about 5-10% of the time one of these scripts will fail in a particular way.

Specifically, the lines:

SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');
SendInternalMsg4('SET_STRING_VALUE','LIST','comma text',SL1.getCommatext);

Cause commaText from one script to be inserted into different instance in another patch in another rack in the WKP. (There is no rack that contains 2 of these scripts.)

Any thoughts of what might be going on? Maybe it's an IML bug, but maybe I'm making a stupid (or advanced!) mistake in my script.

I can post the patch that contains it, but I can't see how the wiring would affect this. And it has been a problem with this script since V5.

Thoughts, script gurus??? Is there a way to keep this part of the script from running at startup? Hmmm. Or keep the whole script from running at startup??? I guess I could use on init, and a timer, but that seems particularly kludgey ;)

Thanks!!
-e

Code: Select all

// 256 presets Manager______________________23fx 05/06/2k10//     
/////////////////////////////////////////////////////////////
// Based on guru logic 128 pm manager                      //
// name PMs P_X.    //                                     //
// updated for HH by E. Moon                               //
/////////////////////////////////////////////////////////////    
Const PM_Prefix = 'P_';
Const PM_SIZE = 32;
////////////////////////////////////////////////////////
var num,bankIN,store,clear,Msdwn : Tparameter;
var Pm_name, Pm_num : string;
var pmnum,bankNum: integer;
var MSD: boolean;
var commain, clickIN, txtin: tparameter;
var SL1: tstringlist;
var editing : boolean;
///////////////////////////////////////////////////////////////////////
Procedure Init;
BEGIN   

    num  := CreateParam('list num',PtDataField)  ;setIsOutput(num,false);    
    commain:= createparam('commain',pttextfield); setisoutput(commain,false); 
    Msdwn:= CreateParam('list msdwn',PtDataField);setIsOutput(msdwn,false);
    store:= CreateParam('store',PtDataField);setIsOutput(store,false);
    clear:= CreateParam('clear',PtDataField);setIsOutput(clear,false);
    txtin:= createparam('txtin',pttextfield);setisoutput(txtin,false); 
    clickIN:= createparam('txtfield clk',ptdatafield); setisoutput(clickIN,false); 
    SL1.create;                             
    editing:= FALSE; 
MSD:=false;
END;
/////////////////////////////////////////
Procedure destroy;
begin SL1.free end;
//////////////////////////////////////////////////////////////////
Procedure callBack(n : integer);
BEGIN
                                                           
        if (n=clickIN)and (getvalue(clickIN)=1) then begin
            // user is editing
            editing:=TRUE;
        end;

        if (n=commain) then begin  
        
            SL1.setCommatext(getstringvalue(commain)); 
            SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');  
            SendInternalMsg4('SET_STRING_VALUE','LIST','comma text',SL1.getCommatext);
        end;

        if (n=txtin) AND (editing) then begin
            SL1.setStrings(trunc(getvalue(num)),getstringvalue(txtin)); 
            SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');  
            SendInternalMsg4('SET_STRING_VALUE','LIST','comma text',SL1.getCommatext);
            editing:= FALSE; 
        end;

        if (n=msdwn) then begin
            MSD:=getvalue(msdwn)=1;
        end;                                      
                 
        if (n=num) then begin
             SL1.setCommatext(getstringvalue(commain));
             pmnum:= trunc(getvalue(num)); 
             SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');     
             SendInternalMsg4('SET_STRING_VALUE','TXT','1',SL1.getstrings(pmnum));
             Pm_name:= PM_Prefix+ intToStr(pmnum div PM_SIZE);                       
             Pm_num := intToStr(pmnum mod PM_SIZE);
        end;

                    
        if (n=msdwn) and (getValue(Store) = 1) and (msd) then begin  
           SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');  
           SendInternalMsg4('SET_VALUE',Pm_name,'store','1');
           SendInternalMsg4('SET_VALUE',Pm_name,'store','0');
           SendInternalMsg4('SET_VALUE',Pm_name,'num',pm_num); 
           SendInternalMsg4('SET_VALUE','STORE','1','0');             
           end;

        if (n=msdwn) and (getValue(Clear) = 1) and (msd) then begin 
           SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');  
           SendInternalMsg4('SET_VALUE',Pm_name,'clear','1');
           SendInternalMsg4('SET_VALUE',Pm_name,'clear','0');
           SendInternalMsg4('SET_VALUE',Pm_name,'num',pm_num); 
           SendInternalMsg4('SET_VALUE','CLEAR','1','0');      
           end;
        
        if ((n=num))   
           and ((getValue(store)=0) and (getValue(Clear)=0)) 
           then begin 
           SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');  
           SendInternalMsg4('SET_VALUE',Pm_name,'recall '+pm_num,'1');
           SendInternalMsg4('SET_VALUE',Pm_name,'recall '+pm_num,'0');
           end;


END;
//////////////////////////////////////////////////////////
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

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

Unread post by nay-seven » 19 Aug 2014, 11:48

seems like the scripts guru's are on holidays right now..

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 19 Aug 2014, 16:27

Yeah, bad time of year, I suppose..... well, I've been dealing with this prob for 2 years, I can wait a little longer ;)

I've definitely determined it is a loading, not a saving problem. So I just need to make sure all the lists have correct data before saving a new version of the WKP. And if a WKP gets saved with wrong lists, I can copy and paste from an older version. A couple of times I've had to load my WKP three times to get all correct lists, which is a pain on a gig!

I've been doing some rearchitecting with a stripped down version of the WKP, containing only 6 of these scripts, and it hasn't mis-loaded once. But when I went from 13 of these to 14 in my WKP, it about doubled the likelyhood of mis-loading!!

P.S. I don't think anybody took a vacation last year, so I'm glad to see folks taking a break :)
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 19 Aug 2014, 19:23

I now have verified an example in my wkp of IML wire crossing during use, not just in loading.

This from my log. I separated the logic for storing and recalling from the logic for renaming, and I can get this result consistently. The IML generated by the two scripts is ALWAYS interleaved, with the result that neither script works properly:

process msg SET_TARGET_PATCH SENDER_PATCH
SET_VAR patch TARGET_PATCH_SCRIPT = D:_USINE_library-TwoSystemsKontaktPresets.pat
process msg SET_VALUE P_0 recall 4 1
process msg SET_TARGET_PATCH SENDER_PATCH
SET_VAR patch TARGET_PATCH_SCRIPT = D:_WORKSPACESInstSpecificControls.pat
process msg SET_STRING_VALUE TXT 1 Boesendorfer
Set String Value TXT 1 Boesendorfer
Module P_0 not found in Set_Value ////////////////P_0 is not referenced by this script
Can't Set Value P_0 recall 4 1
process msg SET_VALUE P_0 recall 4 0
Module P_0 not found in Set_Value
Can't Set Value P_0 recall 4 0

I've also encountered the reverse, where the other script says 'module TXT not found in Set_Value'.

Here are the scripts, first the save/recall:

Code: Select all

// 256 presets Manager______________________23fx 05/06/2k10//     
/////////////////////////////////////////////////////////////
// Based on guru logic 128 pm manager                      //
// name PMs P_X.    //                                     //
// updated for HH by E. Moon                               //
/////////////////////////////////////////////////////////////    
Const PM_Prefix = 'P_';
Const PM_SIZE = 32;
////////////////////////////////////////////////////////
var rNumIN,sNumIN,store,msDownIN : Tparameter;
var Pm_store_name, Pm_store_num, Pm_recall_name,Pm_recall_num: string;
var numToStore,bankToStore, numToRecall,bankToRecall: integer;
var MSD: boolean;
///////////////////////////////////////////////////////////////////////
Procedure Init;
BEGIN   

    rNumIN  := CreateParam('recall num',PtDataField)  ;setIsOutput(rNumIN,false);   
    sNumIN  := CreateParam('store num',PtDataField)  ;setIsOutput(sNumIN,false);
    msDownIN:= CreateParam('list msDown',PtDataField);setIsOutput(msDownIN,false);
    store:= CreateParam('store',PtDataField);setIsOutput(store,false);
                                                                                           
MSD:=false;
END;
/////////////////////////////////////////

//////////////////////////////////////////////////////////////////
Procedure callBack(n : integer);
BEGIN

        if (n=msDownIN) then begin
            MSD:=getvalue(msDownIN)=1;
        end;
                 
        if (n=sNumIN) then begin
             numToStore:= trunc(getvalue(sNumIN)); 
             Pm_store_name:= PM_Prefix + intToStr(numToStore div PM_SIZE);                       
             Pm_store_num := intToStr(numToStore mod PM_SIZE);
        end;
        if (n=rNumIN) then begin
             numToRecall:= trunc(getvalue(rNumIN)); 
             Pm_recall_name:= PM_Prefix + intToStr(numToRecall div PM_SIZE);                       
             Pm_recall_num := intToStr(numToRecall mod PM_SIZE);
        end;
                    
        if (n=msDownIN) and (getValue(Store) = 1) and (msd) then begin  
           SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');  
           SendInternalMsg4('SET_VALUE',Pm_store_name,'store','1');
           SendInternalMsg4('SET_VALUE',Pm_store_name,'store','0');
           SendInternalMsg4('SET_VALUE',Pm_store_name,'num',Pm_store_num); 
           SendInternalMsg4('SET_VALUE','STORE','1','0');             
           end;
        
        if ((n=rNumIN))  and (getValue(store)=0) 
           then begin 
           SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');  
           SendInternalMsg4('SET_VALUE',Pm_recall_name,'recall '+Pm_recall_num,'1');
           SendInternalMsg4('SET_VALUE',Pm_recall_name,'recall '+Pm_recall_num,'0');
           end;


END;
//////////////////////////////////////////////////////////
and the set text script:

Code: Select all

// 256 presets Manager______________________23fx 05/06/2k10//     
/////////////////////////////////////////////////////////////
// Based on guru logic 128 pm manager                      //
// name PMs P_X.    //                                     //
// updated for HH by E. Moon                               //
/////////////////////////////////////////////////////////////    
Const PM_Prefix = 'P_';
Const PM_SIZE = 32;
////////////////////////////////////////////////////////
var num : Tparameter;

var pmnum,bankNum: integer;
var MSD: boolean;
var commain, clickIN, txtin: tparameter;
var SL1: tstringlist;
var editing : boolean;
///////////////////////////////////////////////////////////////////////
Procedure Init;
BEGIN                                                                                                      

    num  := CreateParam('list num',PtDataField)  ;setIsOutput(num,false);    
    commain:= createparam('commain',pttextfield); setisoutput(commain,false); 
    txtin:= createparam('txtin',pttextfield);setisoutput(txtin,false); 
    clickIN:= createparam('txtfield clk',ptdatafield); setisoutput(clickIN,false); 
    SL1.create;                             
    editing:= FALSE; 
END;
/////////////////////////////////////////                      
Procedure destroy;
begin SL1.free end;
//////////////////////////////////////////////////////////////////
Procedure callBack(n : integer);
BEGIN
                                                           
        if (n=clickIN)and (getvalue(clickIN)=1) then begin
            // user is editing
            editing:=TRUE;
        end;

        if (n=commain) then begin  
        
            SL1.setCommatext(getstringvalue(commain)); 
            SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');  
            SendInternalMsg4('SET_STRING_VALUE','LIST','comma text',SL1.getCommatext);
        end;

        if (n=txtin) AND (editing) then begin     
                strace('_____________________________________________setting text_____________________'); 
            SL1.setStrings(trunc(getvalue(num)),getstringvalue(txtin)); 
            SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');  
            SendInternalMsg4('SET_STRING_VALUE','LIST','comma text',SL1.getCommatext);
            editing:= FALSE; 
        end;
                 
        if (n=num) then begin     

             SL1.setCommatext(getstringvalue(commain));                                          
             pmnum:= trunc(getvalue(num)); 
             SendInternalMsg2('SET_TARGET_PATCH','SENDER_PATCH');     
             SendInternalMsg4('SET_STRING_VALUE','TXT','1',SL1.getstrings(pmnum));
        end;

END;
//////////////////////////////////////////////////////////
Interestingly, both scripts are updated via busses from the same source, the master preset select matrix, but are in different racks. For now, my workaround is to put a wait1 before the text script, and that keeps the IML from getting co-mingled.

It seems like maybe an 'end of IML' message of some sort is needed? My workspace is very complex, and I haven't been able to duplicate this problem in a simple WKP, but now it is happening consistenly. I will post this as a bug report, although my WKP is too large to upload.

cheers,
-e
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

seamus
Member
Posts: 484
Contact:

Unread post by seamus » 24 Aug 2014, 23:24

I remember having this problem with the 256 preset manager. Presets names were getting mixed up. I stopped using it for this reason.

Post Reply

Who is online

Users browsing this forum: No registered users and 76 guests