Could one create a package that invokes lilypond (an external command) and embeds the result?

This recent answer may interest you: