Page `mOnActivate`/`mOnDeactivate` callbacks are invoked twice per (de)activation

The code below logs

Activating Page 1
Activating Page 1
Activating Page 1

initially and

Deactivating Page 1
Deactivating Page 1
Activating Page 2
Activating Page 2

when switching from Page 2 to Page 1 (similarly Page 1 to Page 2).

const driver = require("midiremote_api_v1").makeDeviceDriver("Demo", "Demo", "bjoluc");

const page1 = driver.mMapping.makePage("Page 1");
page1.mOnActivate = function () {
  console.log("Activating Page 1");
};
page1.mOnDeactivate = function () {
  console.log("Deactivating Page 1");
};

const page2 = driver.mMapping.makePage("Page 2");
page2.mOnActivate = function () {
  console.log("Activating Page 2");
};
page2.mOnDeactivate = function () {
  console.log("Deactivating Page 2");
};

I would expect a page’s mOnActivate/mOnDeactivate callback to be run only once per page activation/deactivation. Tested with Cubase 12.0.52 and Cubase 13.0.21 on Windows 10.

@Jochen_Trappe :eyes:

Yes, I too remember this.

1 Like

Oh, I didn’t see your topic – thanks!

Ah, no problem, I was very new at the forum, I didn’t even set an “issue” tag.

1 Like

Yeah, I experience the same thing. I don’t think it’s been acknowledged as an issue.
Hoping Jochen will chime in.

1 Like

Hi,

I was just playing with custom HostValueVariable and the same thing happens with “onProcessValueChange” callbacks.

Bests,

Thomas

Funny. My biggest issue with MIDI Remote in my scripts are multiple triggerings of .mOnValueChange that I use to send feedback to my controller for setting an LED ring. The worst part is that the number times the callback is fired is unpredictable and can be anywhere between 1 and 3 from my findings. I could disregard any additional times it fires but the value parameter of the callback function is different each time.
For example, if the .mOnValueChange callback only fires once, it will hold the correct value parameter. If it fires twice, the first time the value will be zero and the second time if fires the value parameter will have the correct value. If it fires 3 times, the first will have a zero value as the previous example and the following 2 times the value will have slightly different values (due to rounding errors I’m led to believe).
This creates a big mess in my script full of workarounds.

I was just checking and I don’t have this issue on other values. (transport start and stop for example).
I recently switched from normal midiBinding to rely on mOnProcessValueChange so I can control when the data is being sent.

But those are “command bindings” and wouldn’t have a process value, no?

I was actually using Transport Values:

page.mHostAcces.mTransport.mValue.mStart
page.mHostAcces.mTransport.mValue.mStop

1 Like