You are doing calculations in the linear, frequency domain: converting MIDI note to a frequency then adding a scaled offset. That will not work because perception of pitch is logarithmic, not linear.
Instead convert...
Deleting a post is not helpful to others. Posting what solution you found, on the other hand, is.
I assume you found that Teensy has many serial outputs and thus, sending some messages on channel 1 to one DIN MIDI...
You could have a look here:
https://github.com/TeensyUser/doc/wiki/Pins
Could you add a short, complete program which works on 3.6 but not on 4.x? (see forum rule).
I'm about to resurrect a project I started on 3 or 4 years ago and abandoned (health issues, other priorities) a couple of years ago. Meanwhile, supply-chain issues mean that the original target, Teensy 3.6, seems...