there is an alternative method…
the note in a key message is floating point, so you can actually use pitchbend to modify this, and this will work with most patches.
there are two approaches
create a mother.pd, and simply alter the midi processing to taking into account pitchbend before sending the key message.
not recommend: as some patches used the key number for things other than pitches e.g. to do some different processing (e.g. switch octaves)
b) per patch
basically, do as you do above, but listen for [r key] then add the pitchbend to it. ( as fractional semitones), then send this out e.g. [s keyNote], then change in patch [r key] to [r keyNote] where appropriate (i.e. don’t change the bits that are looking for specific keys, e.g. to do things like switch octaves)
the advantage of this approach, is it doesn’t depend on there being a ‘tuning frequency parameter’, and also you save on an mtof call ( since you add semitones, not frequencies), so its slightly more efficient.
anyhow that’s I did if for my MPE patches (or a derivative of this anyway)