Welcome to %s forums

BrainModular Users Forum

Login Register

new built in procedure for 'load' (in addition to 'init')

Tell us what you'd like Usine to do
Post Reply
ceasless
Member
Posts: 330
Contact:

Unread post by ceasless » 23 Sep 2013, 10:46

When a script is first added to the workspace, the 'init' procedure is called.

However, in this init procedure you do not have access to things that are already set in the patch. This means that you cannot get the current value of a parameter, even if that parameter has a value that has been saved in the patch/workspace.

My use case is making sure that an array outlet is actually sending the values that have been stored, rather than all '0's which is what happens now. When re-loading the workspace, Tthe array outlets on the 'Pattern Store' script are all set to 32 0s, rather than the value they held when the workspace was saved. In my Init code I removed the bits that I put it in to properly initialize them to 0 when the script is first added to the patch.

So, I propose a new built in procedure that would be called when the workspace is re-loaded.

BTW, I've worked around this by using the Process procedure and having a one-time run of the code that sets the array out using the saved value in the parameter. This is a problem though because the first note in the sequence is never played.

ceasless
Member
Posts: 330
Contact:

Unread post by ceasless » 23 Sep 2013, 11:02

I tried moving the 'one-time run' code from the Process procedure to the callback for the parameter, but no luck there. So even though the parameter will return 0 in the Init block (regardless of what is saved in the patch), when the value is loaded from the patch it does not trigger the callback.

Code: Select all

      if firstTime := 0
      then begin
        writeln('interesting');
        for i:=0 to IOs-1
        do begin
          p := ((prev-1) * IOs) + i; 
          setLength(stepOut[i],STEPs);
          for s:=0 to STEPs-1
          do begin
            temp[s] := getDataArrayValue(memory[p],s);
            setDataArrayValue(stepOut[i],s,temp[s]);
          end;
        end;
        firstTime := 1;
      end;

ynohtna
Member
Posts: 36
Location: Brighton, UK
Contact:

Unread post by ynohtna » 24 Sep 2013, 18:28

I can't help with your problem in the detailed sense, but is your example code correct?

Code: Select all

if firstTime := 0
is an assignment (":=") not a comparison ("=").

ceasless
Member
Posts: 330
Contact:

Unread post by ceasless » 29 Sep 2013, 16:34

That's definitely a bug, fixed before I posted it but I had already copied the buggy version into the buffer.

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 29 Sep 2013, 19:26

the ini procedure is not made for calculation but but initialization of the script itself.
try to change your code location, like in the callback, in the process.

also you can add an inlet "start init" which can be connected to an "on activation" module?

ceasless
Member
Posts: 330
Contact:

Unread post by ceasless » 30 Sep 2013, 10:42

But is that on activation as in the 'play' button is pressed or does it trigger before?

What I need is to get the parameter value (and set the array outs to the right values) before the play button is pressed.

ceasless
Member
Posts: 330
Contact:

Unread post by ceasless » 30 Sep 2013, 22:42

It doesn't technically need to be before the play button is pressed, I just need to write those params out before the first note triggers. I'll try your suggestion.

ceasless
Member
Posts: 330
Contact:

Unread post by ceasless » 07 Oct 2013, 11:29

Hi senso,

I attempted your solution with using an 'init' input and writing a callback. (I also had already moved it down to the 'process' procedure before posting originally, I believe I mentioned it). It still does not solve the issue.

It seems to me that having a difference between the 'init' procedure (which cannot access the data in the flux that are already attached) and something like 'post-init' (which can access and change the flux before the user starts the sound engine) would be useful in more cases than just this example. If it's not too complicated to add, would you consider it?

ceasless
Member
Posts: 330
Contact:

Unread post by ceasless » 07 Oct 2013, 22:46

Okay, I seem to have finally gotten around this issue. I think that adding some code that read the step input value array and saved it to memory somehow fixed the issue. Or maybe I just hadn't tested correctly with the 'init' based callback.

Either way it's working!

Once again Usine shows me that it already knows the answer, I just hadn't figured out the right way to ask the question :)

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

Unread post by nay-seven » 07 Oct 2013, 22:58

Once again Usine shows me that it already knows the answer, I just hadn't figured out the right way to ask the question
good philosophical response that also works for the general life ..:)

ceasless
Member
Posts: 330
Contact:

Unread post by ceasless » 08 Oct 2013, 22:27

nay-seven wrote:
Once again Usine shows me that it already knows the answer, I just hadn't figured out the right way to ask the question
good philosophical response that also works for the general life ..:)
Words to live by :)

Also I wanted to show senso that I recognize I may have been somewhat annoying with 'not a bug' reports and feature requests like this. So far its all been a function of not fully 'getting it', whatever 'it' was at the time. Thanks for the help man!

I think I have the logic finally baked to perfection.

And regarding this feature request, I only today found the synchro setting that detaches it from the sound engine 'on/off'. and it is 'on/off' that triggers the 'init', so you can easily have a longer period of "loading" with scripts and modules triggered by 'init' and only turn the synchro on when you want to.

So, feature request: already there! :D

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests