Ciao Robert,
sorry if I reply so late.
What you propose to do is a bit too complicated for me and I'll use it as a last resort. What I'm trying to do now is just to open the midi file with musescore and add a note in the file to correctly shift the others.
Anyway, it would be great having some programming tools to manipulate lilypond source code like what I was asking for.
Thank a lot for you help Robert!!!
Best regards, Gianmaria