Search code examples
lilypond

how to show symbols on top of LilyPond scores?


Santa offered a toy keyboard to my 4-year-old. He enjoys the provided scores, but I'd like to add some songs that we sing together and that are not included in the basic set. Every Key has a symbol (circle, triangle, square) and a color (blue, yellow, purple, red, orange) that is displayed on top of the music score, to help him figure out which keys to press.

expected outcome

I'm not a musician, but I do have a basic understanding on how to write music scores. I've never used lilypond, but I'm a developer and I know latex.

I tried searching for a way to add extra symbols, but I'm not sure this is feasible.


Solution

  • You can draw theses symbols by using some of the various graphics commands found on this page:
    https://lilypond.org/doc/v2.24/Documentation/notation/graphic

    Store these as markup macros at the top of the LilyPond file, and then call them in the score at the appropriate places.

    \version "2.24.0"
    
    blueTriangle = \markup {
        \left-align
        \with-color "blue"
        \triangle ##t
    }
    
    orangeCircle = \markup {
        \left-align
        \with-color "orange"
        \draw-circle #1 #0 ##t
    }
    
    purpleCircle = \markup {
        \left-align
        \with-color "purple"
        \draw-circle #1 #0 ##t
    }
    
    greenSquare = \markup {
        \left-align
        \with-color "green"
        \filled-box #'(0 . 2) #'(0 . 2) #0
    }
    
    \new Staff {
        g4^\blueTriangle
        d'^\orangeCircle
        b'^\purpleCircle
        f''^\greenSquare
    }
    

    music staff with coloured shapes above notes


    This will be a bit tedious if you are placing a symbol above every note. But if you know Scheme you can probably devise a function that reads the note letters and octaves and places the correct symbol in automatically.