I wonder if it would be difficoult to implement this simple feature: As LyX know how to call Lilypond (just select Insert - File - External material - Lilypond) for an external .ly file, it could just send Lilypond a temporary .ly file created on-the-fly by copying the content of a in-line ERT-like box. The purpouse? For small musical excerpts or examples the user should not produce a .ly Lilypond file on its own, and just use the code in the LyX document. I think this is technically very simple, I just wonder if there should some problem with the support of UTF encoding of Lilypond files.