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.


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:


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.


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

Bumping this post as well, which is a bit more to the point of the MIDI rounding bug. This really needs fixing to be able to have the midi remote editor be useful.

Why do they even call it midi? There is nothing in the midi specification about floating point data. Not in MIDI2.0 either.

That part doesn’t have anything to do with MIDI.
It just means parameters in Cubase have a very high precision/resolution of controls, which is expected and normal in any DAW.
However, the issue is that 1 MIDI value needs to be translated to a floating point number once it ‘arrives’ in Cubase, but similarly, the floating point value it translates to must also be able to convert back to the same MIDI value that sent it.
This is where numbers aren’t rounded correctly.
Instead of rounding anything <x.5 to x, and anything >=x.5 to x+1 we get anything <x+1 translates to x. Clear bug to me as it causes problems when sending MIDI back to a controller.

1 Like