Welcome to %s forums

BrainModular Users Forum

Login Register

script timing mechanism

I need help on a Patch
Post Reply
sm_jamieson
Member
Posts: 555
Contact:

Unread post by sm_jamieson » 02 Feb 2015, 15:41

Sorry for all the newbie questions folks !
Is there a way to generate timer messages in the scripting language, i.e. set a timer going that sends a callback every 50 millsecs until it is cancelled ?
I wish to use this to generate a midi channel volume fade within my script.

Thanks,
Simon.

drakh
Member
Posts: 198
Location: Bratislava, SK
Contact:

Unread post by drakh » 02 Feb 2015, 17:58

in some scripts i saw solution with blocks (for example arpeggiator script)


but i'll probably use some of the time modules
http://www.sensomusic.org/wiki2/doku.ph ... es:time_ms
http://www.sensomusic.org/wiki2/doku.ph ... se_time_ms

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 02 Feb 2015, 18:46

yes in process you can count blocs something like a variable count reseted to -1 on button pulse, then a loop like
count:= count+1 , if count >=X then... or fadervalue:= count/divisor

but maybe a function is avaible for directly get current time in ms but i don't know...
if so on reset sould substact resettime to currenttime to get a ms counter.

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 02 Feb 2015, 19:19

I have used the arpeggiator callback function based on an external clock module before. Using the clock module you can sync to your project and change the timing.

Here is the list of script functions:
http://www.sensomusic.org/wiki2/doku.ph ... _reference

There is a date time that could probably be used as well, however if you want sync rather than a timer I would use a clock trigger on callback; then you can just enter your functions/procedures from there.

-S
"Every act of creation is first an act of destruction." -Picasso

sm_jamieson
Member
Posts: 555
Contact:

Unread post by sm_jamieson » 03 Feb 2015, 00:00

Well, bloc counting it is. I had not realised the Process procedure was called for a block of samples so imagined it was called more often than it is. At around 3ms that is not too much overhead. So I work out the number of blocks by dividing the ms timeout by the Usine defined BlocDuration and all is good.
I had used the countms module, but it seemed so clumsy to rig up input and output parameters and "wires" just to get the timeout functionality. The script API could really do with a proper timeout facility, but bloc counting will do !

Simon.

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 03 Feb 2015, 01:58

The process procedure is repeatedly processed...go figure. So if you have heavy load in the process loop that doesn't need to be done make sure to avoid calling it . For instance if you have array processing, make sure you are only doing it by trigger, or you will soon see your CPU climb.

I had an array once I forgot to block and quickly overloaded my CPU.

-S
"Every act of creation is first an act of destruction." -Picasso

sm_jamieson
Member
Posts: 555
Contact:

Unread post by sm_jamieson » 04 Feb 2015, 11:04

sephult wrote:The process procedure is repeatedly processed...go figure. So if you have heavy load in the process loop that doesn't need to be done make sure to avoid calling it . For instance if you have array processing, make sure you are only doing it by trigger, or you will soon see your CPU climb.

I had an array once I forgot to block and quickly overloaded my CPU.

-S
Well that is the disadvantage of bloc counting in the process procedure. You can use the processIDLE procedure if the interval is not too large (default 25ms I think) but since it various with the UI refresh setting you'd have to make sure it was OK on the slowest UI updates.
I am using bloc counting in the process procedure to produce ticks at a slower rate, and the ticks are switched off when not required, in which case the only code in the process procedure is a comparison operation to see if ticks are required.

The alternative as I found is to connect up a module such as countms with appropriate parameter inputs and outputs, which seems rather clumsy from a script. What is really required is a timer API available to the script.

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 04 Feb 2015, 13:25

As drakh said the MIDI->MIDI Tools->MIDI Arpeggiator script module has a good example of tick processing.
Just a simple clock from the library with the trigger wired allows the time to either be controlled via interval or actually sync'd to a tempo.

The advantage of using this is the immediate callback and then you can just write your own function/procedure. With this you can increment/decrement a variable to use in your script for counting/timing. If you are using multiple scripts you can just wire the single clock to your scripts to base off the same.

I agree about the ease of an api timer, but with the ability to get Date/Time and have immediate callback tick processing I don't think its necessary. I am not an expert with Pascal, but I don't think there ever was a built in timer...but just based off Date/Time??
I would think for HH though using the module for clocking is much more efficient than actually processing Date/Time continuously within the fastscript.

-S
"Every act of creation is first an act of destruction." -Picasso

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests