You took an example which works with CC. And you need one for Notes. That is a bit tricky, when you play recorded notes they are represented as "Note", with duration. But live they are represented as "NoteOn" and "NoteOff". If you dynamically switch what notes do, check MfxOffNotes.new() documentation and "Transpose everything one octave up during C3 "switch key" engaged" as an example.
But for simple static transformation you can use (untested!!!)
function OnInput(pqIn, pqOut)
for i,e in ipairs(pqIn) do
if e.Key then
e.Key = e.Key + 7
end
pqOut.add(e)
end
end
OnEvents = function ( From, To, pqIn, pqOut)
OnInput(pqIn, pqOut)
end
The trick here is simple, "Note", "NoteOn" and "NoteOff" have the field "Key". Other MIDI events do not have it. So you modify the Key if it exists, for all cases at once...