Welcome to %s forums

BrainModular Users Forum

Login Register

[script] Wait x blocs or ms

I need help on a Patch
Post Reply
ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 14 Dec 2010, 13:44

One more time fighting with scripting, i don't understand how to wait x blocs or x ms before processing a new function or a new procedure in script...

I've been looking to midi unpack, to unpack array but i've not been able to reproduce them in my newbie scripts...

Any help from a script master?
Seb.Dub

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

Unread post by bsork » 14 Dec 2010, 14:52

The clou to this is counting (for n blocks) or checking elapsed time (for ms), and when queueing data like in the two mentioned scripts, adding and retrieving data from the queue.

The last part is IMO the most complicated and can be handled several ways, but since you mentioned waiting with processing a method, I'll stick to that.

What you have to do is initialize some variable when the waiting starts - usually by something triggering a callback, eg:
[c]
VAR countWaits : Integer;
VAR startTime : Single;
VAR doUpdate : Boolean;
....
PROCEDURE Callback(n : Integer);
...
<some_callback>
countWaits := 0;
startTime := timeMs;
doUpdate := TRUE;
...
[/c]

Then you have to check within Process whether it's about time to do something:
[c]
PROCEDURE Process;
...
IF (doUpdate) THEN BEGIN
countWaits := countWaits + 1;
IF (countWaits >= no_of_waits) THEN BEGIN
do_something;
doUpdate := FALSE;
...
IF (doUpdate) THEN BEGIN
IF ((timeMs - startTime) >= time_to_wait) THEN BEGIN
do_something;
doUpdate := FALSE;
...
[/c]

When queueing data, you wouldn't normally have any use for something like the doUpdate boolean, but instead you'd be checking whether there was anything left in the queue to handled.

Hope this helps.
Bjørn S

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 14 Dec 2010, 19:29

Thanks master Bsork!

Trying that right now...
Seb.Dub

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 16 Dec 2010, 13:11

I have not been able to do the script i need....

Anyway, i found a way to patch it:

Image

This scripting technique is yet to difficult for the moment. I need to study more the use of array in scripts.

Thanks for your help ,time, and knowledge Bsork.
Seb.Dub

Post Reply

Who is online

Users browsing this forum: No registered users and 164 guests