rough code, but lilypond output seems to work