MIDI Remote - multitasking during process execution

Hi programmers,

I am currently working on the next update of my script.
For various use cases, I have programmed a function in which various operations are carried out one after the other in a recursive loop, deliberately extra slowly (with delay). This works well and what happens there in the process is not the issue here.

I am surprised that while this long recursive loop is running, I can execute other functions of the script and while this there is no blockage. I don’t see this ‘multitasking behavior’ as a bug, but I would like to understand why this is possible. I also need this information to be able to assess whether my script could possibly cause side effect problems.

Is it the case that the JavaScript interpreter checks after each line if there are any other process requests in the pipeline or are there special methods (e.g. setProcessValue) after which this happens?

I realize that my question goes beyond what MIDI Remote is actually intended for. But in the meantime, however, it has generally become apparent that more and more script creators are inclined to get what they can out of MIDI Remote.


Hi, I don’t know how exactly the API is implemented, however I would be surprised since I see the node involved, if the events were not getting triggered while in a thread that seems to block the flow. In other apis, we even face trouble with lines’ execution even in the same event.

Very logic worry. Well, if you have sequenced macros/processes and you want to keep them clear from other user interactions, the only way I can think of is to have a universal flag, and when this is set to true for example, all other activities will be ignored. This however in big scripts (I know yours is one of these) this needs a lot of effort unfortunately.


Yes, I thought of that too.
The flag would then be like a ‘semaphore’, as used for write operations in databases.
But implementing the whole script in this way would also have the disadvantage that the operation of the controller then would not be buffered. Otherwise, side effects could be avoided if the manually operation of the controller is slow enough. I can do this myself, but other users of my script may not want this.

However, it would be good to know exactly what criteria the API uses for multitasking.

When I used to program in Delphi a long time ago, a process was always processed completely, I could rely on that and had the control over possible side effects. If there was a point in the code where I could allow processes accumulated in the pipeline to be executed, I could trigger this with the Delphi-method ‘application.processmessages’.

I don’t know who is the contact person at Steinberg who can tell me exactly how the JavaScript interpreter works. Is it Jochen Trappe? Or is there another developer in the background, unknown here, who has co-developed MIDI Remote? :innocent:

Yes, @Jochen_Trappe is the proper one to provide this type of info as far as I know :slight_smile:

Today I took another look at the possible scenarios during operation with regard to the multitasking aspect.

It occurred to me that I could program the script so that a function is only executed when the previous one has been completed, but this would mean that ALL the API methods to be executed would have to be assigned to custom variables, which would no longer correspond to the general idea of MIDI Remote.

And even if I were to program it this way, the script user would still have the option of starting a function directly from Cubase while a function started by the script is running. This could still trigger a side effect. And if such a side effect leads to the flag switching (semaphore switching) not being executed correctly, the whole script would possibly hang up. That’s too risky for me.

Result: So I think the only solution is to point out to the other script users that they must take the time themselves to wait for the functions to complete and be particularly attentive if this function takes some time, as it will be the case with my new functions in my next update.

Yes, this is the best approach actually :+1:

1 Like

I’m also very interested in this subject.

I’ve tried (and suceeded) to implement a buffer for some output MIDI message so that i can manage the priority of messages during banking. And only dump the not important messages when no action is being performed.

Unfortunately my experience is that the console will not respond to incoming midi messages while dumping the buffer. So i concluded that there was no multitasking performed.

Therefore i’ll be following this thread with interest.


If you add a timer loop with a delay of a few milliseconds within your buffering, it might work to allow other process requests.

I will try that as soon as i get backto this project (hopefully this summer).

Thanks for the tip.