Welcome to %s forums

BrainModular Users Forum

Login Register

IML and script: send two lines PB?

I need help on a Patch
Post Reply
23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 17 May 2010, 18:32

I dlike to set some colors and captions via iml, the script looks like this:
SendUsineMsg('SET_TARGET_PATCH SENDER_PATCH');
for i:= 0 to l-1 do begin
itrace(i);
SendUsineMsg ('SET_VALUE '+'S'+IntToStr(i)+ ' ''BACK COLOR'' '+'0');
SendUsineMsg ('SET_STRING_VALUE '+'S'+IntToStr(i)+ ' CAPTION '+'-');
end;
if i make a itrace(i ), seems corect, if i set colors or caption only got it working,

but if if put bothlines, i still traced well, but iml drops starts and start to send around 14 instead of 0... any clues?
is it some iml latency limitation or something else?
or is there a way to send two lines at once?

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 17 May 2010, 18:51

mmmm well i suppose it's some iml latency ?as i can get it working like this, processing one after the other:
begin
SendUsineMsg('SET_TARGET_PATCH SENDER_PATCH');
for i:= 0 to l-1 do begin
//itrace(i);
SendUsineMsg ('SET_VALUE '+'S'+IntToStr(i)+ ' ''BACK COLOR'' '+'0');
if (i = l-1) then begin
for i:= 0 to l-1 do begin
SendUsineMsg ('SET_STRING_VALUE '+'S'+IntToStr(i)+ ' CAPTION '+'-');
end;
end;
end;
or there is a trick to send two iml process at once?

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 17 May 2010, 19:44

mmmmm now don't work anymore, if i swich off osc it works, if osc receive it messes even if no other input than my 'reset' button linked to the script, arf i suppose osc operates on iml somehow...so i dbetter deal with classic wires..

so.. back to classical arrays once more hehe (i just toggled 5x times from wires to iml, lot of script editing..),
now i start to catch when use or not.
anyway, better deal with arrays and commas for being matrix ready.. ;)

still.. any confirmation/enlightment welcome..

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 17 May 2010, 22:00

Have you tried building a single string and send the whole thing using only one SendUsineMsg?
Bjørn S

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 18 May 2010, 01:30

nope didn't tried, i should have...thanks for sugg, gonna test..

edit: just tested , seems iml don't catch two concated message on single line,

ive been totally wrong on thinking it's related to osc, and thinking it was working delayed, got it even with osc off, if 2 messages, iml start either at 14 or 28...
strange.. maybe script is too fast for more than one iml mess or idon't know, would love to catch where pb comes from,
well back to investigation...

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 18 May 2010, 23:49

I've been messing around with updating 20 parameters using a script that reads an array and creates a message text string:

[c]VAR pData, pMsg : tParameter;

PROCEDURE Init;
BEGIN
pData := CreateParam('data in', ptArray); SetIsOutput(pData, FALSE);
pMsg := CreateParam('lines msg', ptTextField); SetIsInput(pMsg, FALSE);
END; // Init

PROCEDURE Callback(n : Integer);
VAR i : Integer;
VAR s, modName : String;
BEGIN
IF ((n = pData) AND (GetLength(pData) = 20)) THEN BEGIN
s := '"SET_TARGET_PATCH SENDER_PATCH",';
FOR i := 0 TO 3 DO BEGIN
modName := 'First' + IntToStr(i + 1);
s := s + '"SET_VALUE ' + modName + ' action ' + IntToStr(trunc(GetDataArrayValue(pData, i * 5))) + '",';
s := s + '"SET_VALUE ' + modName + ' ch ' + IntToStr(trunc(GetDataArrayValue(pData, i * 5 + 1))) + '",';
s := s + '"SET_VALUE ' + modName + ' msg ' + IntToStr(trunc(GetDataArrayValue(pData, i * 5 + 2))) + '",';
s := s + '"SET_VALUE ' + modName + ' data1 ' + IntToStr(trunc(GetDataArrayValue(pData, i * 5 + 3))) + '",';
s := s + '"SET_VALUE ' + modName + ' data2 ' + IntToStr(trunc(GetDataArrayValue(pData, i * 5 + 4))) + '",';
END;
SetStringValue(pMsg, s);
END;
END; // Callback

[/c]

As you can see, I've created a comma text string and instead of using SendUsineMsg (which BTW is about to be obsolete; see the manual), I'm sending the string out through pMsg. pMsg is connected to "lines msg" on a UsineMsg module, which will send the message(s) every time "lines msg" is changed - no need to trigger "send msg".

This workaround is a bit clumsy, but I couldn't find another way that worked to keep all the messages together in one batch using SendUsineMsg. FIrst I tried formatting the string with CR/LF (ASCII 13 and 10) at the end of each line, then as comma text, but neither worked dirctly from the script. I'm sure this can be done in a simpler way, but for now it works. As Olivier obviously has something new up his sleeve with the IML for v5.17, maybe there are some changes regarding multiple messages belonging together as well(?).


PS. I've avoided spaces in in module and parameter names to simplify the text and avoid extra double quotes. DS
Bjørn S

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 19 May 2010, 01:28

Awesome! why didn't i thinked about that! i had my head so much in script that i totally forgot than new lines input!!
.
So we use a comma text, cool. im also using the 'manual concating' technique, maybe we can make tstringlist and use it's commatext? no you mean that doesn't work? And maybe that mean "sendUsineMsg" will be replaced in script by another procedure to send commatext? anyway in my case i just need two mess for now, this are very exciting news
for me, for some future uses.
mmmm those v5.17 iml news are very interesting!!!!
SendUsineMsg (msg:string); // obsolete since Usine 5.17
SendInternalMessage(msg:string); // version 5.17 and above
SendInternalMessage(msg,arg1,arg2,arg3,arg4,arg6:string); // version 5.17 and above YEEEA!
function GetVariableString(name:string):string; YEEeA
function GetVariableInteger(name:string):integer; yeeeaa
function GetVariableFloat(name:string):double;
yeaaa!

woa so soon getString and multiples mess via iml ulta cooool! rra olivier always in the place!

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 19 May 2010, 08:24

23fx23 wrote:woa so soon getString and multiples mess via iml ulta cooool! rra olivier always in the place!
...eh... Just for the record: I don't know whether Olivier has done anything with the multiple messages part or anything else concerning the core IML functionality, I only stumbled over the new stuff by accident.

Regarding the concatenation, I briefly thought about using tStringList, but didn't really bother as it was easier to just add some double qoutes and commas.

[edit] Forgot to add that after I created the script above, I decided to incorporate the IML stuff into a larger script with array updates etc. This script is one sub-patch "above", and the IML messages are sent to two different sub-patches in one go. The little testing I did last night (should've been in bed by then...), seemed to work as it should. That is 2*20 SET_VALUEs sent out to one UsineMsg:
[c]
SET_TARGET_PATCH firstPress
SET_VALUE ... (* 20)
SET_TARGET_PATCH secondPress
SET_VALUE ... (* 20)
[/c]
Bjørn S

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 19 May 2010, 14:52

you re right, i go a bit fast, doesn't mean multiple messages,.. as previous module was sendUsinemsg, sending one line, now sendinternalMess send lines, i concluded this will probably be avaible in script as well when the function will be changed?
(in fact as you do actually but without the need of an external module)...but maybe a too fast conclusion.. ;)
well let's wait the very exciting 5.17.. anyway it's already super cool if we can do it with the module!!!!!!. :)

relating the 2x20 Mess that sounds great, very powerfull! but to be sure ive well understood, you concated them as well to one commatext right?
thanks master bsork!

edit: mmm while i got ya here hehe, i just wonder if you wouldn't have a better trick/advice for me relating commatext:

i tweaked a python script for my liveOsc that send a list of instrument names, but im total newbee in python and while im sure there must be a better way to directly send a usine type comma text, best i could get for now is is a comma text looking like:
['name0','name1','name2'.....'nameN']
so i managed to format it to : "name0","name1","nameN"

..but by using an array input on script instead of textField and changing numbers using math to get quotes become double quotes, and resizing/shifting whole array of -2 to get rid of [ ]. while this works like a charm i higly suspect its not the cleanest way.. at least to be clear readble/editable in the script..

i supposed could directly "removefirstChar" and "replacechar", (or maybe some ASCII type conversion im not aware) but don't remember exactly but faced some 'incompatibles types' Pchar/unicode32 or something like that.
while trying stringfunctions..I will try to remake the script with stringfunction and report where i block in a more clear way...

by curiosity did you play around with such cases and where you using math, or do ya often use some string functions?

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 19 May 2010, 15:22

23fx23 wrote:relating the 2x20 Mess that sounds great, very powerfull! but to be sure ive well understood, you concated them as well to one commatext right?
Yes - one, single long string.
23fx23 wrote:edit: mmm while i got ya here hehe, i just wonder if you wouldn't have a better trick/advice for me relating commatext:
I don't know anything about python... Does it use double quotes for strings? Every language I've come across has some method of incorporating the string delimiters within the string. I suppose it would be better to get the string as correct as possible at source.

[edit after a short Google] Seems python use some kind of triple quoting, and both single and double quotes can be used.[/edit]
23fx23 wrote:by curiosity did you play around with such cases and where you using math, or do ya often use some string functions?
I don't quite remember, actually. ATM I'm working on a FC300 SysEx patch (in which the IML stuff is a part), and there I do some string conversions as text is sent from Usine to the pedal, but nothing special: Just converting strings to bytes. However, if you do lot's of stuff like this it's probably wise to check out the available string functions. Not only will you save work and end up with less code, chances are that the included functions are faster and more effective as well.
Bjørn S

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 19 May 2010, 15:39

thanks a lot bsork.

you're totally right, i should more focus on getting the source clean to avoid operations, especially on large list, this will be my afternoon challenge...i know python can, i can't hehe, but hope i will.
i will also definitely try to check up all stings functions as it can really be handy in several cases, (as i imagines to make some futures instruments name checks to load custom adapted usine interface objects)
for now i m a bit lost if can use general functions directly on ptTextfield string or if need to create some Tstrings and use dedicaced functions, but best is to experiment, definitely an exciting part even if i will probably spend hours in the wind hehe..

i well supposed you were on your FC300 script, that seems really promising for happy owners!

Post Reply

Who is online

Users browsing this forum: No registered users and 52 guests