Jump to content

Creating custom key signatures: Difference between revisions

From LilyPond wiki
m New category
Tags: Mobile edit Mobile web edit
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
LilyPond supports custom key signatures. In this example, print for D minor with an extended range of printed flats.
LilyPond supports custom key signatures. In this example, print for D minor and D major with an extended range of shown flats.


<lilypond version="2.24">
<lilypond version="2.24">
Line 6: Line 6:
   \override KeySignature.flat-positions = #'((-7 . 6))
   \override KeySignature.flat-positions = #'((-7 . 6))
   \override KeyCancellation.flat-positions = #'((-7 . 6))
   \override KeyCancellation.flat-positions = #'((-7 . 6))
  % presumably sharps are also printed in both octaves
   \override KeySignature.sharp-positions = #'((-6 . 7))
   \override KeySignature.sharp-positions = #'((-6 . 7))
   \override KeyCancellation.sharp-positions = #'((-6 . 7))
   \override KeyCancellation.sharp-positions = #'((-6 . 7))


   \override Clef.stencil = #
   \override Clef.stencil =
  (lambda (grob)(grob-interpret-markup grob
    #(lambda (grob)
  #{ \markup\combine
        (grob-interpret-markup grob
    \musicglyph "clefs.C"
          #{ \markup\combine
    \translate #'(-3 . -2)
                \musicglyph "clefs.C"
    \musicglyph "clefs.F"
                \translate #'(-3 . -2)
  #}))
                  \musicglyph "clefs.F"
          #}))
     clefPosition = #3
     clefPosition = #3
     middleCPosition = #3
     middleCPosition = #3
Line 23: Line 23:


{
{
   \key d\minor
   \key d\minor f bes, f bes, |
  f bes, f bes,
  \key d\major fis b, fis b, |
}
}
</lilypond>
</lilypond>


[[Category:Tweaks and overrides]]
[[Category:Contexts and engravers]]
[[Category:Pitches]]
[[Category:Pitches]]
[[Category:Staff notation]]
[[Category:Staff notation]]
[[Category:Contexts and engravers]]
[[Category:Tweaks and overrides]]
[[Category:Included in the official documentation]]
[[Category:Included in the official documentation]]
[[Category:Snippet]]
[[Category:Snippet]]

Latest revision as of 22:02, 7 December 2025

LilyPond supports custom key signatures. In this example, print for D minor and D major with an extended range of shown flats.

\version "2.24"

\new Staff \with {
  \override StaffSymbol.line-count = #8
  \override KeySignature.flat-positions = #'((-7 . 6))
  \override KeyCancellation.flat-positions = #'((-7 . 6))
  \override KeySignature.sharp-positions = #'((-6 . 7))
  \override KeyCancellation.sharp-positions = #'((-6 . 7))

  \override Clef.stencil =
    #(lambda (grob)
        (grob-interpret-markup grob
           #{ \markup\combine
                \musicglyph "clefs.C"
                \translate #'(-3 . -2)
                  \musicglyph "clefs.F"
           #}))
    clefPosition = #3
    middleCPosition = #3
    middleCClefPosition = #3
}

{
  \key d\minor f bes, f bes, |
  \key d\major fis b, fis b, |
}