Hi Enrique,
You’re right that the layout module should be the place to do this and you’re also right that you can’t find it.
Most of layout.py was written in a 36-hour sprint for a specific project at the 2013 Classical Music Hack Day in Vienna where Vladimir Viro and I created a tool Particellissima (sadly not online anymore) that let you give a musicxml file and it would render
a short-score with only the 5 most relevant staves shown at a time (a particell is another name for a short score). And it could do the same with a scanned sheet of music. Since we only needed to know precise X and Y coordinates on a per-measure basis, the
tool only works up to that level of granularity. (Getting the precise bounding box areas for musical notes is a major challenge; things like beams and articulations certainly don’t help; and there’s no MusicXML to image converter that respects exact placement
of notes from an xml file, at least none that I know of. I wish the SmartMusic .enf format were public).
But for your annotation library, if working at a measure-sized level is sufficient, then it should be possible.
In case looking at a bunch of undocumented code from 2013 (written in Python 2 for music21 v1 or 2) is helpful — there’s link to the scripts that we used to generate json data to annotate scores with. Beyond that, I can’t really help — I don’t understand
the code myself, and a lot of it was written at 4am while jetlagged.
Best,
Myke