Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 495245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:34:30+00:00 2026-05-13T05:34:30+00:00

lilypond can color notes in a arbitrary way using \override NoteHead #’color = #red

  • 0

lilypond can color notes in a arbitrary way using

\override NoteHead #'color = #red c

with the default color is black. But I like to color all notes by pitch, so that my kids can more easily learn to recognize the notes as the c, d, e, f, … are associated with its own color. The above allows me to do this, but is rather verbose.

Is there a shortcut, macros of some sort, that allow me to do something along the lines of:

redc greend bluee

or even overwriting the default colors for each note by pitch so that I can even simply do:

c d e

and have each of them have a different color?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:34:30+00:00Added an answer on May 13, 2026 at 5:34 am

    There is an example for this in the snippets:

    %Association list of pitches to colors.
    #(define color-mapping
      (list
        (cons (ly:make-pitch 0 0 0) (x11-color 'red))
        (cons (ly:make-pitch 0 0 1/2) (x11-color 'green))
        (cons (ly:make-pitch 0 1 -1/2) (x11-color 'green))
        (cons (ly:make-pitch 0 2 0) (x11-color 'red))
        (cons (ly:make-pitch 0 2 1/2) (x11-color 'green))
        (cons (ly:make-pitch 0 3 -1/2) (x11-color 'red))
        (cons (ly:make-pitch 0 3 0) (x11-color 'green))
        (cons (ly:make-pitch 0 4 1/2) (x11-color 'red))
        (cons (ly:make-pitch 0 5 0) (x11-color 'green))
        (cons (ly:make-pitch 0 5 -1/2) (x11-color 'red))
        (cons (ly:make-pitch 0 6 1/2) (x11-color 'red))
        (cons (ly:make-pitch 0 1 0) (x11-color 'blue))
        (cons (ly:make-pitch 0 3 1/2) (x11-color 'blue))
        (cons (ly:make-pitch 0 4 -1/2) (x11-color 'blue))
        (cons (ly:make-pitch 0 5 1/2) (x11-color 'blue))
        (cons (ly:make-pitch 0 6 -1/2) (x11-color 'blue))
        ))
    
    %Compare pitch and alteration (not octave).
    #(define (pitch-equals? p1 p2)
      (and
        (= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
        (= (ly:pitch-notename p1) (ly:pitch-notename p2))))
    
    #(define (pitch-to-color pitch)
      (let ((color (assoc pitch color-mapping pitch-equals?)))
        (if color
          (cdr color))))
    
    #(define (color-notehead grob)
      (pitch-to-color
        (ly:event-property (ly:grob-property grob 'cause) 'pitch)))
    
    \score {
      \new Staff \relative c' {
        \override NoteHead #'color = #color-notehead
        c8 b d dis ees f g aes
      }
    }
    

    Sample image

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.