As I understood from the tutorial, the short code

\key d \major cis4 d e fis

would generate

enter image description here.

Is this the only way to type it, or is there a natural way to get the same output by absorbing the sharps in the key, i.e. since D major already signals that c and f really mean c-sharp and f-sharp, respectively, I'd like to know if it's possible to get the same pdf and midi by typing

\key d \major c4 d e f


P.S. Sorry if this is somewhere else in the tutorial, I'm just trying to produce my hello world in Lilypond.


The answer is "Yes you can, but doing this is a really bad idea".

It's a bad idea because you will probably soon want to write C natural or F natural with a D major key signature, and if you make "c" mean "c sharp" you won't have a good way to do that. If the key signature changes during the piece, things will quickly get very confusing.

Check out "note names for other languages" in the documentation. For example in English you can use "s" and "f" for sharp and flat, not the Dutch (or Scandinavian) "is" and "es".

If still you want to ignore the above advice and find out how to do it, check the documentation on how Lilypond handles bagpipe music (which is effectively written in the key of D but without a key signature and without accidentals) and look at "bagpipe.ly" to see how the note names are redefined.

  • That makes sense. I just wanted to be sure whether it was the optimal way. What I, as newbie, expected is: if you are already in, say D-Major, then you will likely write more cis than c and more fis than f, and that therefore anytime you are to play/obtain natural-c that there would be a way to write, cn or the like, meaning C-Becuadro, c-becarré, c-Auflösungszeichen. I guess just practice will tell me that the configuration chosen by LiilyPond developers is optimal.
    – c.p.
    Apr 18 '15 at 6:21
  • 3
    The basic idea is that defining what note is to be written is independent of how it is written. Some notation doesn't use key signatures (e.g. orchestral horn parts and guitar tablature, as well as bagpipes). You can define non-standard key signatures. You can define a sequence of notes once, not associated with any particular staff or key signature, and use it on several staves with different notation conventions. There is a \transpose command. Making all those options work sensibly when the pitch notation depended on the key signature would be a recipe for confusion.
    – user19146
    Apr 18 '15 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.