MIDI Remote output rounding bug

MIDI sent out from Cubase for MIDI Remotes is seemingly sending a value*127.0 out to MIDI, which causes certain values that result certain values sending the incorrect MIDI value.
See this example here where I print out the value of the control in Cubase from the debug console:
Volume value in Cubase is 0.7637795… and this results in a value that’ll be cast to an integer when sending MIDI of 96 (96.99999999). Whereas this clearly should be sending the rounded value of 97 as in my example.

image

Simply rounding this to an integer with Math.round(127.0*newVal) will correct this.

edit: parseInt(127.0*newVal) will not work for this, as that’ll still round to the floor.

I tried this myself in a short simple script and it fixed my issues in my long thread below:

https://forums.steinberg.net/t/midi-remote-sending-delayed-and-incorrect-messages-to-my-controllers/791091/15

1 Like

While I’m at it. I noticed you have some kind of fail-safe values for panning and anything with a gain. Sending midi value 63 always forces a 64, and for gain meters it forces a 100 if you attempt to send 101. 64 being center for panning, and 100 being unity gain. Seems a bit odd though. But I guess it helps a controller find the ‘neutral’ mode easier.
edit: Ok this is just a snap for the cmd/ctrl-click default values for a given parameter. This isn’t a bug I guess?

That’s a feature :smiley:

It’s pretty clever actually. But it does mean that you get some jumps on controllers, as it then skips the value closest above the ‘default’ value.

Since you did find this thread, @Jochen_Trappe , I am just curious to know if you can confirm this rounding as a bug? To me it felt clearly like a bug since I can easily reproduce it, as well as fix it when writing my own controller script.
I believe this, as well as feedback to the same control sending cc causes a lot of the jitter that people are experiencing. After making my own script with fixes for both of those, I eliminated jitter on my end.

Value jumps by rounding is always tricky with MIDI. We have that on our list, thank you for reporting.

1 Like

In the meantime, would it be possible to get an insight in how Cubase rounds and/or truncates the values in order to replicate the same behavior in our scripts?
I’ve tried, but can’t for the life of me figure out what mathematical formula Cubase is using to round the values.

As far as I can tell from my experiments with this, Cubase values are all floating point numbers between 0.0-1.0f and the conversion is a simple value*127, and this is then cast to an integer, meaning the decimals are simply chopped off, and not rounded.
This is a good enough approximation if we were just receiving values, but since a device sending a 0-127 value can easily end up in a case where a midi value sent to Cubase is not the same as the value Cubase converts its float back to an 0-127 integer… basically we need to ensure that a float value ‘generated’ by a midi value X will also convert back to the same value X…and not X+1 or X-1… this is part of what causes some controls to be useless in the mapping assistant.

This bug still happens in 12.0.50