Welcome to %s forums

BrainModular Users Forum

Login Register

A simpler way of doing this...?

I need help on a Patch
Post Reply
gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 26 Apr 2010, 10:03

Basicly, what is happening in this example is the A=B module is receiving 1-16 at A repeatedly in a loop. Everytime 16 is received, the fader increments by 1 up to a maximum of 8 and then it starts over. Each increment selects a value stored into the selector by changing the X value of the img/panel module.

Essentially I am step sequencing values which are fed back into the img/panel when selected while ensuring that the current values are only recorded into the selector when the X value is manually changed from the panel.
I am going to need this to do this for 100 values, though I will be able to use the same group of A=B (0-7) modules and several other modules to control groups of 25 values. This still means I will need 800 pass event modules, 100 selectors, 200 pass if change, 100 stop and 100 has changed...!
Any ideas for a lighter / simpler way to accomplish this?

Image

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

Unread post by bsork » 26 Apr 2010, 11:41

Can't say I understood the whole thing here, but I think you'd be better off investigating the array modules - especially the Set/GetElement modules should come in handy here.
Bjørn S

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 26 Apr 2010, 11:50

I know you don't like arrays, but this is a perfect exemple where it could simplify you the task especially when dealing with high number of entries.

this could replace the go to selector/select value part and be easy extended to more values:
Image

In order: create an array, set its size (here8).
The get array is then equivalent to the selector: you ask what value is in index4, it will output the value.
The Set array is equivalent to all A=B then pass, if you say set index4, with that value and light on "set value", the corresponding value is set at desired position, if set value is 0: nothing happen,

edit: hehe bsork one more simultaneous post!

note: you're note obliged to put the array in center, could directly connect setarray to setarraysize, but if you want to save
values to some preset manager you'll need it to be present. Also you could directly setsize on array with a fader and no need the "set array size", but I think it's better to have it, cause forcing array size while there is an array on input is not recommended.

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 26 Apr 2010, 12:08

thanks! I'll try this as soon as it's not 3am any more... ;)

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 26 Apr 2010, 22:19

yes!this works!
Is it possible to do this with multiple input values without having to duplicate the modules for each individual value?
I would be interested in having both multiple single source input and output values as well as being able capture all of the values of a step module for each "page" in the index.

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 27 Apr 2010, 12:41

mm , this is not possible via classic patching with this method, cause arrays are filled with single values, but
i didn't totally catch what's is your head as well, hehe, but as you speak about "capture all values" of a step module,
im supposing you dlike a "window editable" array step that pick/edit corresponding memory "page".

for this you could directly drive the array out of step modules to a selector/dispatcher, it works with arrays as well, once you edit some steps all values are routed ie to selector 5 input, then the dispatcher can re-route ie page 6 back to the steps when changing page, all values at once, that you reedit ect.. from what i remember there are some wait one to place in this case for the values first get drived back to step from memory, then step rediting "memeory".

edit: like this:
Image

another technique is to concat all steps arrays in a bigger array, then use the "extract" sub array to reextract the portion needed.
ie concating 8x8 will return you a 64 array, then if extracting array of lengh 8 starting at 24 (8x3) will return you 8 values of Page 3.
but this is more complex then to reinject the sub array in master bigger array, i must have a patch somewher doing that, will have
a look, but know feel a script would do the job in a simpler way, will test it if some time (but im so late on liveOsc!).

feel the lower cpu ultimate method would be a script picking arrayIn, put it in some memory page, re-output on page demand corresponfing array. it would be equivalent to the selector/dispatcher, but with a probably lower cpu, maybe try the classic patching way, if it's working ok and really need lower load try to script it, could give you a hand on that,

a last ultra low cpu method would be to use the preset manager, auto saving before swiching page.

..but maybe im totally wrong on what you're after hehe

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 27 Apr 2010, 13:00

Thanks, I'll check these ideas. WHat I am doing is not really so important as to spend too much time on but I get a little OCD sometimes when I want to find a way to do something...;)

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 27 Apr 2010, 16:46

if you (or some) are interested, ive made a script patch that recalls an array memory "page", that can be edited , then rerouted to master memory array, with the master array being able to be stored to some preset using preset manager.
can edit max nb of pages in the script.
this allows quick access to high nb of pages(ie 16 pages x 16 presets=256 pages) while keeping relatively descent cpu.
or allow to edit/recall some sub-sequences inside a bigger sequence for ie sequencers uses.

http://sensomusic.com/forums/uploads.ph ... e%2004.wkp

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 27 Apr 2010, 20:37

Wow!
The only thing I am missing is an inlet on the scrip to set constant NB steps...! I just hacked an inlet into the script but I suppose there's probably a little more to it than that...

The preset manager saving before switching page is also a good solution I had been playing with before but the problem is that you then lose global preset capability, at least within the sub patches containing sequenced preset managers. And then I worry about too many simultanious PM read and writes causing performance issues in Usine...?

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 27 Apr 2010, 22:28

yup think too the preset technique can be heavier and introduce some lantency, reduces uses of global preset as you point.

glad if this is what you were after,
i ll try to add an input for nb step( but each page will still need to have same nb of step, otherwise master memory will be lost, this still will need to be 'fixed' once, one more complex setup could maybe store arrays of different lenght, will investigate if easy.).

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 27 Apr 2010, 22:42

Same nb of step for all pages is fine. Thanks for this, it fit's what I am after perfectly and I'm sure there can be many usefull applications...

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 27 Apr 2010, 23:21

Ive moded the script to have a inlet for nb_steps, can copy paste and recompile the script.
//////////////////////////////////////////////////////
// Pages and memory Arrays///23fx April 2010//////////
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
const NB_page = 8; //max nb of pages to be stored
/////////////////////////////////////////////////////
var page : Tparameter;
var arrayIn : Tparameter;
var arrayOut : Tparameter;
var ArrayBig : Tparameter;
var NBsteps : Tparameter;

var i,startpos,count,l : integer;
//////////////////////////////////////////////////////
// initialisation procedure
//////////////////////////////////////////////////////
procedure init;
begin
page := CreateParam('Num Page',ptDatafader);
SetIsOutput(page,false);

ArrayIn := CreateParam('disp array In',ptArray);
SetIsOutput(ArrayIn,false);

ArrayOut := CreateParam('disp array Out',ptArray);
SetIsInput(ArrayOut,false);

ArrayBig := CreateParam('arrBig',ptArray);
//SetIsInput(ArrayBig,false);

NBsteps := CreateParam('NbSteps',ptDataField);
SetIsOutput(NBsteps,false);

end;

//////////////////////////////////////////////////////
procedure Callback(n: integer);
begin

if (n=arrayin) or (n=page) then begin
count:= 0;
end;
end;
////////////////////////
Procedure Process;

begin

if count >= 0 then begin
l:= round(GetValue(Nbsteps));
startpos:= round(GetValue(page)*l);
SetLength(ArrayOut,l);
SetLength(ArrayIn,l);
Setlength(ArrayBig,(l*NB_page));
count:= count+1;

if count = 2 then begin

for i:= 0 to GetValue(Nbsteps)-1 do
SetdataArrayValue(ArrayOut,i,GetDataArrayValue(arrayBig,i+startpos));
end

else if count = 3 then begin

for i:= 0 to GetValue(Nbsteps)-1 do
SetdataArrayValue(ArrayBig,i+startpos,GetDataArrayValue(ArrayIn,i));
end

else if count >3 then begin

count:= -1;
end;
//itrace(count);
end;

end; //process

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 27 Apr 2010, 23:37

What can I say...seems to work perfect! Thanks!

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 28 Apr 2010, 09:38

So now that you have transformed my first patch attemp X 100 to something like the below image X 5 + 5 for step Pages, just one more quick question.
Can you see any reason in this example that the fader would work perfectly with the page flip but the switch not at all?
It is driving me craaaazy!

Image

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 28 Apr 2010, 11:43

hehe i hope you gain Cpu on that one, at least you certainly avoid some wiring ;)

for the swich, mmm that's very strange indeed... will try to reproduce and see if i find some reasons, but there theorically aren't...!!

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 28 Apr 2010, 17:00

indeed, i had a look, i here i could have the swich over pages, but sometimes not toggling correctly.
there is something wrong in sript loop,
I tried few things, this one seems to fix the pb here:
//////////////////////////////////////////////////////
// Pages and memory Arrays///23fx April 2010//////////
//////////////////////////////////////////////////////
const NB_page = 8; //max nb of pages to be stored
/////////////////////////////////////////////////////
var page, arrayIn, arrayOut, arrayBig, NBsteps : Tparameter;
var i,startpos,count,l,countb : integer;
//////////////////////////////////////////////////////
procedure init;
begin
page := CreateParam('Num Page',ptDatafader);
SetIsOutput(page,false);

ArrayIn := CreateParam('disp array In',ptArray);
SetIsOutput(ArrayIn,false);

ArrayOut := CreateParam('disp array Out',ptArray);
SetIsInput(ArrayOut,false);

ArrayBig := CreateParam('arrBig',ptArray);
//SetIsInput(ArrayBig,false);

NBsteps := CreateParam('NbSteps',ptDataField);
SetIsOutput(NBsteps,false);

end;
//////////////////////////////////////////////////////
procedure Callback(n: integer);
begin
if (n=arrayin) or (n=page) then begin
count:= 0;
end;
end;
////////////////////////
Procedure Process;
begin
if count = 0 then begin
l:= round(GetValue(Nbsteps));
startpos:= round(GetValue(page)*l);
SetLength(ArrayOut,l);
SetLength(ArrayIn,l);
Setlength(ArrayBig,(l*NB_page));
for i:= 0 to GetValue(Nbsteps)-1 do
SetdataArrayValue(ArrayOut,i,GetDataArrayValue(arrayBig,i+startpos));
countb:= countb+1;

if countb = 1 then begin
for i:= 0 to GetValue(Nbsteps)-1 do
SetdataArrayValue(ArrayBig,i+startpos,GetDataArrayValue(ArrayIn,i));
end

else if countb > 1 then begin
countb:= -1;
count:= -1;
end;
//itrace(countb);
end;
end; //process

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 28 Apr 2010, 20:47

Thanks, this seems to work with switches ok now...

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 04 May 2010, 10:47

I seem to be having problems with this script when using 8 pages. If you have time, 23fx to check my example you will see that page 8 and page 1 aren't recalling properly. I don't seem to have this problem when using less pages.Also, in this exerpt from my main patch, saving and reloading seems to be not working very well at all.
What do you think?
http://www.sensomusic.com/forums/upload ... e=test.pat

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 04 May 2010, 21:22

OK, well if I set const NB_page = 10 in the script it seems to work. The problem is only when the pages roll from the last page (Page 8) to the first page.
About the saving issue in my case, I have no idea so I think I will just let preset managers make sure recall works correctly.

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 04 May 2010, 21:28

mmm will try to check that bug

for the save/quit reopen, i feel need to force script to update, and/or preset reload when patch first opens.

there is the INIT module in/interface control that send a pulse on patch opening, maybe connect to script inlet (have to check wich one is used to update, must be array in if well remember).

one Pb is i don't think last datas can be stored in script internally when quitting, so on reopening script compliles and outputs wrong datas. I think only way to keep last datas is indeed to save them to some preset and recall on init to reupdate the script.
i ll check that if find a bit of time..

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 04 May 2010, 23:38

Hmmm, in the case of my patch I cannot even be certain it is the only the contents of the array that does not always load properly. In some cases even presets aren't recalling properly, + I was having save issues with the original patch before I used your script...grrr.., I get tempted to chuck this in the trash because it is now wasting my time but it is kind of fun.
If you check out the latest version of my rainbow seq, if you switch from preset 3 to preset 2 and back again you will see it doesn't reload properly.
http://www.sensomusic.com/forums/upload ... est%29.pat

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 05 May 2010, 22:28

so ive atlast could check your addon, very cool!
unfortunatelly im sorry but couldn't yet identify the pb, it's a bit hard to get to someoneelse complex patch and catch the whole flows ;), and it seems you use dinamyc pages changes that is very cool but doesn't help to debug hehe.
I ll try to test the script only as im quite sure there is a simpler/better way of doing what it does and it s probably buggy/not cleanest as it could, maybe a part of pb comes from here. as i think i found better way while was searching on liveOsc, and will let you know if can readapt to your patch, but for for now
presets are a tricky part with scripts delays/updating/leting pass or not in/outs ect im not sure i can help you for now on that specific patch...
just one advice: start to look at scripts, i had lot's of repetitive, hardwired patchs as yours and i can assure benefits are enormous,
while i was anti_script/pro_patching one month ago , maybe more because of my fear, the little start fight really worth, im totally convinced now. there are lot's of case you can endup with only 5 lines of text instead of 128wires16modules ect that will all need to be rewired in case or pb/changing idea, changing nb of items can be done via 2 variables editing, and cpu gain/undo time is non negligeable.
Personally I had totally 0 knowledge of script (exect a bit of glovepie), i read and reread bejamin pdf, checked online references,
tried to hack examples, try to understood bsork really great exemples, as well as martignasse, started to make very simple scripts, just a A+B, then arrays, then store variables, then iml, and i rediscovered once more usine possibilities are endless,
well we know that already :) but on the patchs i know you do, i assure it would really worth spending a bit of time, if you plan a long term usine use ;)

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 05 May 2010, 23:28

So scripting is like riding a bike? It looks hard but once you start it is way simpler than it looks? I don't know. The way my head works I have always been ok with logic type of activities where you are given a list of clearly marked variables and have to work out the appropriate path of action, but scripting looks like learning another language which despite some valient attempts, I have never had any skill with.

It would be nice if there were some such thing as an object oriented scripting language (like Usine modules, I guess) but designed to work on a deeper level in Usine..does this make any sense?

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 06 May 2010, 00:08

mmm hum ...sorry nope i don't see, i consider script or sdk as that thing, that can make some "modules" with in/outs and make the operations in between, or you mean someting that would still use nodal with modules, but ie to make repetitive operations, mmm hard to visualize..

for me it was cetain that checkind data flows in wires, leds and pass was more clear than some strange text with strange unknown wordz. it's really really a fight at start, but once you understand one concept after the other, it becomes more and more easy, a bit like when you know all usine modules you easier catch best and fastest way to go, weren't you lost/affarid on first usine open, isn't it ultra logical for you to now to use ie a "pass if chg" in that case..

while it's true it's more hard to debug in script as need to type tracevalues to check, wich is really disturbing at start, once you managed to make it work, i was surprised how "logical" it was, i don't pick that mouse down making pass that inputvalue using 3 modules,
it ends up just type the right sentence, converting what's in your head ie:
"i want that when i press mouse the value pass" is
If mouse=1 then valueout:= valuein,
true that's simple to wire but when using 64x time this, just collect 64mousedown in an array.
"i want that when i press a button, it pass the button nb out" imagine nb of wire and pass module (now buttons outputs values,ok still would have to edit values one after the other), in script that would be done with a single line looking like:
if inputchange= arraymouse, for index = 0 to 63, if value(index) of arraymouse is 1, output:= index. /
(i just simplified a bit to make clear, but this is nearly that) ..
in fact it really worth with simple but repetitive operations, if simple the script will be very simple, but it will make the process repeat automatically for all values, without having to be a prgm killer. ie to round 64 values:
for i:=0 to 63 do arrayOut = round arrayin and your'e done.
once a script is done, can just copy paste and readapt as well.

but while im saying that i can totally understand some don't like that way, i also still prefer patch sometimes and spent hours on script to endup making my thing in two minutes via patching ;) and that's more fun, and easier to visualize for sure, that's why I loved usine at start it's was like visualizing a big script/or hardware electronics without bothering typing/or soldering... ;)

Post Reply

Who is online

Users browsing this forum: No registered users and 43 guests