LilyPond snippets: Chords

# Chords

Chord notation

## Adding a figured bass above or below the notes

When writing a figured bass, you can place the figures above or below the bass notes, by defining the `BassFigureAlignmentPositioning.direction` property (exclusively in a `Staff` context). Choices are `#UP` (or `#1`), `#CENTER` (or `#0`) and `#DOWN` (or `#-1`).

This property can be changed as many times as you wish. Use `\once \override` if you don’t want the override to apply to the whole score.

    bass = {
      \clef bass
      g4 b, c d
      e d8 c d2
    }

    continuo = \figuremode {
      <_>4 <6>4 <5/>4
      \override Staff.BassFigureAlignmentPositioning.direction = #UP
      %\bassFigureStaffAlignmentUp
      < _+ >4 <6>
      \set Staff.useBassFigureExtenders = ##t
      \override Staff.BassFigureAlignmentPositioning.direction = #DOWN
      %\bassFigureStaffAlignmentDown
      <4>4. <4>8 <_+>4
    }

    \score {
      <<
        \new Staff = bassStaff \bass
        \context Staff = bassStaff \continuo
      >>
    }

## Tatkstriche in einen ChordNames-Kontext hinzufügen

Um Taktstriche in einem `ChordNames`-Kontext anzeigen zu lassen, muss der `Bar_engraver` hinzugefügt werden.

    \new ChordNames \with {
      \override BarLine.bar-extent = #'(-2 . 2)
      \consists "Bar_engraver"
    }

    \chordmode {
      f1:maj7 f:7 bes:7
    }

## Bar chords notation for Guitar (with Text Spanner)

Here is how to print bar chords (or barre chords) or half-bar chords (just uncomment the appropriate line for to select either one).

The syntax is : `\bbarre #"fret_number" note(s)`

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %% %%%%%%%  Cut here ----- Start 'bbarred.ly'

    %% C with slash -------------------------------
    cWithSlash = \markup {
      \combine \roman C \translate #'(0.6 . -0.4) \draw-line #'(0 . 2.0)
    }
    %% Span -----------------------------------
    %% Syntax: \bbarre #"text" { notes } - text = any number of box
    bbarre =
    #(define-music-function (barre location str music) (string? ly:music?)
       (let ((elts (extract-named-music music '(NoteEvent EventChord))))
         (if (pair? elts)
             (let ((first-element (first elts))
                   (last-element (last elts)))
               (set! (ly:music-property first-element 'articulations)
                     (cons (make-music 'TextSpanEvent 'span-direction -1)
                           (ly:music-property first-element 'articulations)))
               (set! (ly:music-property last-element 'articulations)
                     (cons (make-music 'TextSpanEvent 'span-direction 1)
                           (ly:music-property last-element 'articulations))))))
       #{
           \once \override TextSpanner.font-size = #-2
           \once \override TextSpanner.font-shape = #'upright
           \once \override TextSpanner.staff-padding = #3
           \once \override TextSpanner.style = #'line
           \once \override TextSpanner.to-barline = ##f
           \once \override TextSpanner.bound-details =
                #`((left
                    (text . ,#{ \markup { \draw-line #'( 0 . -.5) } #})
                    (Y . 0)
                    (padding . 0.25)
                    (attach-dir . -2))
                   (right
                    (text . ,#{ \markup { \cWithSlash #str } #})
                    (Y . 0)
                    (padding . 0.25)
                    (attach-dir . 2)))
    %% uncomment this line for make full barred
          % \once \override TextSpanner.bound-details.left.text = \markup{"B" #str}
          $music
       #})

    %% %%%%%%%  Cut here ----- End 'bbarred.ly'
    %% Copy and change the last line for full barred. Rename in 'fbarred.ly'
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    %% Syntaxe: \bbarre #"text" { notes } - text = any number of box
    \relative c'{ \clef "G_8" \stemUp \bbarre #"III" { <f a'>16[  c' d c d8] } }

## Akkordsymboltrenner verändern

Der Trenner zwischen unterschiedlichen Teilen eines Akkordsymbols kann beliebiger Text sein.

    \chords {
      c:7sus4
      \set chordNameSeparator
        = \markup { \typewriter | }
      c:7sus4
    }

## Changing the chord names to German or semi-German notation

The english naming of chords (default) can be changed to german (`\germanChords` replaces B and Bes with H and B) or semi-german (`\semiGermanChords` replaces B and Bes with H and Bb).

    scm = \chordmode {
      c1/c | cis/cis
      b1/b | bis/bis | bes/bes
    }

    \layout {
      ragged-right = ##t
      \context {
        \ChordNames
        \consists "Instrument_name_engraver"
      }
    }

    <<
      \new ChordNames {
        \set instrumentName = #"default"
        \scm
      }
      \new ChordNames {
        \set instrumentName = #"german"
        \germanChords \scm
      }
      \new ChordNames {
        \set instrumentName = #"semi-german"
        \semiGermanChords \scm
      }
      \new ChordNames {
        \set instrumentName = #"italian"
        \italianChords \scm
      }
      \new ChordNames {
        \set instrumentName = #"french"
        \frenchChords \scm
      }
      \context Voice { \scm }
    >>

## Positionen von Generalbass-Alterationszeichen verändern

Versetzungszeichen und Pluszeichen können vor oder nach den Ziffern erscheinen, je nach den Einstellungen der `figuredBassAlterationDirection` und `figuredBassPlusDirection`-Eigenschaften.

    \figures {
      <6\+> <5+> <6 4-> r
      \set figuredBassAlterationDirection = #RIGHT
      <6\+> <5+> <6 4-> r
      \set figuredBassPlusDirection = #RIGHT
      <6\+> <5+> <6 4-> r
      \set figuredBassAlterationDirection = #LEFT
      <6\+> <5+> <6 4-> r
    }

## Akkordsymbolausnahmen

Die Eigenschaft `chordNameExceptions` kann benutzt werden, um eine Liste an besonderen Notationen für bestimmte Akkorde zu speichern.

    % modify maj9 and 6(add9)
    % Exception music is chords with markups
    chExceptionMusic = {
      <c e g b d'>1-\markup { \super "maj9" }
      <c e g a d'>1-\markup { \super "6(add9)" }
    }

    % Convert music to list and prepend to existing exceptions.
    chExceptions = #(append
      (sequential-music-to-chord-exceptions chExceptionMusic #t)
      ignatzekExceptions)

    theMusic = \chordmode {
      g1:maj9 g1:6.9
      \set chordNameExceptions = #chExceptions
      g1:maj9 g1:6.9
    }

    \layout {
      ragged-right = ##t
    }

    <<
       \new ChordNames \theMusic
       \new Voice \theMusic
    >>

## Akkordbezeichnung maj7

Das Aussehen des großen Septakkords kann mit `majorSevenSymbol` verändert werden.

    \chords {
      c:7+
      \set majorSevenSymbol = \markup { j7 }
      c:7+
    }

## Chord names alternative

Chord names are generated from a list of pitches. The functions which construct these names can be customised.

Here are shown chords following Ignatzek (pp. 17-18, 1995), used by default since LilyPond 1.7.20, compared with an alternative Jazz chord notation and Harald Banter’s (1987) notation. A smaller font is used in the latter case, as these tend to be overly verbose.

This mirrors the mechanism originally used in early LilyPond versions (pre-1.7); not having been properly maintained, however, some features have been lost (mainly chord exception lists) and bugs have been introduced.

    %%%% Legacy chord naming functions (formerly in scm/chord-generic-names.scm)
    %%%% Copyright (C) 2003--2015 Jan Nieuwenhuizen <janneke@gnu.org>

    #(set-global-staff-size 19.7)

    #(define-public (banter-chordnames pitches bass inversion context)
      (old_chord->markup 'banter pitches bass inversion context))

    #(define-public (jazz-chordnames pitches bass inversion context)
      (old_chord->markup 'jazz pitches bass inversion context))

    #(define (define-translator-property symbol type? description)
      (if (not (and (symbol? symbol)
        (procedure? type?)
        (string? description)))
          (ly:error "error in call of define-translator-property"))
      (if (not (equal? (object-property symbol 'translation-doc) #f))
          (ly:error (_ "symbol ~S redefined") symbol))

      (set-object-property! symbol 'translation-type? type?)
      (set-object-property! symbol 'translation-doc description)
      symbol)

    #(for-each
      (lambda (x)
        (apply define-translator-property x))
      `((chordNameExceptionsFull ,list? "An alist of full chord
    exceptions.  Contains @code{(@var{chord} . @var{markup})} entries.")
        (chordNameExceptionsPartial ,list? "An alist of partial chord
    exceptions.  Contains @code{(@var{chord} . (@var{prefix-markup}
    @var{suffix-markup}))} entries.")))

    #(define-public (old_chord->markup
                    style pitches bass inversion context)
      "Entry point for @code{Chord_name_engraver}.
    @var{pitches}, @var{bass}, and @var{inversion} are lily pitches."
      (define (default-note-namer pitch)
        (note-name->markup pitch #f))

      (define (markup-or-empty-markup markup)
        "Return MARKUP if markup, else empty-markup"
        (if (markup? markup) markup empty-markup))

      (define (accidental->markup alteration)
        "Return accidental markup for ALTERATION."
        (if (= alteration 0)
            (make-line-markup (list empty-markup))
            (conditional-kern-before
             (alteration->text-accidental-markup alteration)
             (= alteration FLAT) 0.094725)))

      (define (list-minus a b)
        "Return list of elements in A that are not in B."
        (lset-difference eq? a b))

      (define (markup-join markups sep)
        "Return line-markup of MARKUPS, joining them with markup SEP"
        (if (pair? markups)
            (make-line-markup (list-insert-separator markups sep))
            empty-markup))

      (define (conditional-kern-before markup bool amount)
        "Add AMOUNT of space before MARKUP if BOOL is true."
        (if bool
            (make-line-markup
             (list (make-hspace-markup amount)
               markup))
            markup))

      (define (step-nr pitch)
        (let* ((pitch-nr (+ (* 7 (ly:pitch-octave pitch))
                            (ly:pitch-notename pitch)))
               (root-nr (+ (* 7 (ly:pitch-octave (car pitches)))
                           (ly:pitch-notename (car pitches)))))
          (+ 1 (- pitch-nr root-nr))))

      (define (next-third pitch)
        (ly:pitch-transpose pitch
                            (ly:make-pitch 0 2 (if (or (= (step-nr pitch) 3)
                                                       (= (step-nr pitch) 5))
                                                   FLAT 0))))

      (define (step-alteration pitch)
        (let* ((diff (ly:pitch-diff (ly:make-pitch 0 0 0) (car pitches)))
               (normalized-pitch (ly:pitch-transpose pitch diff))
               (alteration (ly:pitch-alteration normalized-pitch)))
          (if (= (step-nr pitch) 7) (+ alteration SEMI-TONE) alteration)))

      (define (pitch-unalter pitch)
        (let ((alteration (step-alteration pitch)))
          (if (= alteration 0)
              pitch
              (ly:make-pitch (ly:pitch-octave pitch) (ly:pitch-notename pitch)
                             (- (ly:pitch-alteration pitch) alteration)))))

      (define (step-even-or-altered? pitch)
        (let ((nr (step-nr pitch)))
          (if (!= (modulo nr 2) 0)
              (!= (step-alteration pitch) 0)
              #t)))

      (define (step->markup-plusminus pitch)
        (let ((alt (step-alteration pitch)))
          (make-line-markup
           (list
            (number->string (step-nr pitch))
            (cond
             ((= alt DOUBLE-FLAT) "--")
             ((= alt FLAT) "-")
             ((= alt NATURAL) "")
             ((= alt SHARP) "+")
             ((= alt DOUBLE-SHARP) "++"))))))

      (define (step->markup-accidental pitch)
        (make-line-markup
         (list (accidental->markup (step-alteration pitch))
               (make-simple-markup (number->string (step-nr pitch))))))

      (define (step->markup-ignatzek pitch)
        (make-line-markup
         (if (and (= (step-nr pitch) 7)
                  (= (step-alteration pitch) 1))
             (list (ly:context-property context 'majorSevenSymbol))
             (list (accidental->markup (step-alteration pitch))
                   (make-simple-markup (number->string (step-nr pitch)))))))

      ;; tja, kennok
      (define (make-sub->markup step->markup)
        (lambda (pitch)
          (make-line-markup (list (make-simple-markup "no")
                                  (step->markup pitch)))))

      (define (step-based-sub->markup step->markup pitch)
        (make-line-markup (list (make-simple-markup "no") (step->markup pitch))))

      (define (get-full-list pitch)
        (if (<= (step-nr pitch) (step-nr (last pitches)))
            (cons pitch (get-full-list (next-third pitch)))
            '()))

      (define (get-consecutive nr pitches)
        (if (pair? pitches)
            (let* ((pitch-nr (step-nr (car pitches)))
                   (next-nr (if (!= (modulo pitch-nr 2) 0) (+ pitch-nr 2) nr)))
              (if (<= pitch-nr nr)
                  (cons (car pitches) (get-consecutive next-nr (cdr pitches)))
                  '()))
            '()))

      ;;; FIXME -- exceptions no longer work. -vv

      (define (full-match exceptions)
        (if (pair? exceptions)
            (let* ((e (car exceptions))
                   (e-pitches (car e)))
              (if (equal? e-pitches pitches)
                  e
                  (full-match (cdr exceptions))))
            #f))

      (define (partial-match exceptions)
        (if (pair? exceptions)
            (let* ((e (car exceptions))
                   (e-pitches (car e)))
              (if (equal? e-pitches (take pitches (length e-pitches)))
                  e
                  (partial-match (cdr exceptions))))
            #f))

      ;; FIXME: exceptions don’t work anyway.
      (if #f (begin
               (write-me "pitches: " pitches)))
      (let* ((full-exceptions
              (ly:context-property context 'chordNameExceptionsFull))
             (full-exception (full-match full-exceptions))
             (full-markup (if full-exception (cadr full-exception) '()))
             (partial-exceptions
              (ly:context-property context 'chordNameExceptionsPartial))
             (partial-exception (partial-match partial-exceptions))
             (partial-pitches (if partial-exception (car partial-exception) '()))
             (partial-markup-prefix
              (if partial-exception (markup-or-empty-markup
                                     (cadr partial-exception)) empty-markup))
             (partial-markup-suffix
              (if (and partial-exception (pair? (cddr partial-exception)))
                  (markup-or-empty-markup (caddr partial-exception)) empty-markup))
             (root (car pitches))
             (full (get-full-list root))
             ;; kludge alert: replace partial matched lower part of all with
             ;; 'normal' pitches from full
             ;; (all pitches)
             (all (append (take full (length partial-pitches))
                          (drop pitches (length partial-pitches))))

             (highest (last all))
             (missing (list-minus full (map pitch-unalter all)))
             (consecutive (get-consecutive 1 all))
             (rest (list-minus all consecutive))
             (altered (filter step-even-or-altered? all))
             (cons-alt (filter step-even-or-altered? consecutive))
             (base (list-minus consecutive altered)))

        (if #f (begin
                 (write-me "full:" full)
                 ;; (write-me "partial-pitches:" partial-pitches)
                 (write-me "full-markup:" full-markup)
                 (write-me "partial-markup-perfix:" partial-markup-prefix)
                 (write-me "partial-markup-suffix:" partial-markup-suffix)
                 (write-me "all:" all)
                 (write-me "altered:" altered)
                 (write-me "missing:" missing)
                 (write-me "consecutive:" consecutive)
                 (write-me "rest:" rest)
                 (write-me "base:" base)))

        (case style
          ((banter)
           ;;    root
           ;;    + steps:altered + (highest all -- if not altered)
           ;;    + subs:missing

           (let* ((root->markup default-note-namer)
                  (step->markup step->markup-plusminus)
                  (sub->markup (lambda (x)
                                  (step-based-sub->markup step->markup x)))
                  (sep (make-simple-markup "/")))

             (if
              (pair? full-markup)
              (make-line-markup (list (root->markup root) full-markup))

              (make-line-markup
               (list
                (root->markup root)
                partial-markup-prefix
                (make-super-markup
                 (markup-join
                  (append
                   (map step->markup
                        (append altered
                                (if (and (> (step-nr highest) 5)
                                         (not
                                          (step-even-or-altered? highest)))
                                    (list highest) '())))
                   (list partial-markup-suffix)
                   (map sub->markup missing))
                  sep)))))))

          ((jazz)
           ;;    root
           ;;    + steps:(highest base) + cons-alt
           ;;    + 'add'
           ;;    + steps:rest
           (let* ((root->markup default-note-namer)
                  (step->markup step->markup-ignatzek)
                  (sep (make-simple-markup " "))
                  (add-prefix (make-simple-markup " add")))

             (if
              (pair? full-markup)
              (make-line-markup (list (root->markup root) full-markup))

              (make-line-markup
               (list
                (root->markup root)
                partial-markup-prefix
                (make-super-markup
                 (make-line-markup
                  (list

                   ;; kludge alert: omit <= 5
                   ;;(markup-join (map step->markup
                   ;;                        (cons (last base) cons-alt)) sep)

                   ;; This fixes:
                   ;;  c     C5       -> C
                   ;;  c:2   C5 2     -> C2
                   ;;  c:3-  Cm5      -> Cm
                   ;;  c:6.9 C5 6add9 -> C6 add 9 (add?)
                   ;;  ch = \chords { c c:2 c:3- c:6.9^7 }
                   (markup-join (map step->markup
                                     (let ((tb (last base)))
                                       (if (> (step-nr tb) 5)
                                           (cons tb cons-alt)
                                           cons-alt))) sep)

                   (if (pair? rest)
                       add-prefix
                       empty-markup)
                   (markup-join (map step->markup rest) sep)
                   partial-markup-suffix))))))))

          (else empty-markup))))

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    %%%%
    %%%% Here begins the actual snippet:

    chs = \transpose c' c' {
      <c e g>1
      <c es g>  % m = minor triad
      <c e gis>
      <c es ges> \break
      <c e g bes>
      <c es g bes>
      <c e g b>  % triangle = maj
      <c es ges beses>
      <c es ges b> \break
      <c e gis bes>
      <c es g b>
      <c e gis b>
      <c es ges bes> \break
      <c e g a>  % 6 = major triad with added sixth
      <c es g a>  % m6 = minor triad with added sixth
      <c e g bes d'>
      <c es g bes d'> \break
      <c es g bes d' f' a' >
      <c es g bes d' f' >
      <c es ges bes d' >
      <c e g bes des' > \break
      <c e g bes dis'>
      <c e g bes d' f'>
      <c e g bes d' fis'>
      <c e g bes d' f' a'> \break
      <c e g bes d' fis' as'>
      <c e gis bes dis'>
      <c e g bes dis' fis'>
      <c e g bes d' f' as'> \break
      <c e g bes des' f' as'>
      <c e g bes d' fis'>
      <c e g b d'>
      <c e g bes d' f' as'> \break
      <c e g bes des' f' as'>
      <c e g bes des' f' a'>
      <c e g b d'>
      <c e g b d' f' a'> \break
      <c e g b d' fis'>
      <c e g bes des' f ' a'>
      <c f g>
      <c f g bes> \break
      <c f g bes d'>
      <c e g d'>  % add9
      <c es g f'>
      <c e g b fis'>  % Lydian
      <c e g bes des' ees' fis' aes'>  % altered chord
    }

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % alternate Jazz notation

    efullmusicJazzAlt = {
      <c e gis>1-\markup { "+" }
      <c e g b>-\markup {
        \normal-size-super
        % \override #'(font-family . math) "N"
        \override #'(font-family . math) "M"
      }
      %%c:3.5.7 = \markup { \override #'(font-family . math) "M" }
      %%c:3.5.7 = \markup { \normal-size-super "maj7" }

      <c es ges>-\markup { \super "o" }  % should be $\circ$ ?
      <c es ges bes>-\markup { \super \combine "o" "/" }
      <c es ges beses>-\markup { \super  "o7" }
    }

    efullJazzAlt = #(sequential-music-to-chord-exceptions efullmusicJazzAlt #f)

    epartialmusicJazzAlt = {
      <c d>1-\markup { \normal-size-super "2" }
      <c es>-\markup { "m" }
      <c f>-\markup { \normal-size-super "sus4" }
      <c g>-\markup { \normal-size-super "5" }
      %% TODO, partial exceptions
      <c es f>-\markup { "m" }-\markup { \normal-size-super "sus4" }
      <c d es>-\markup { "m" }-\markup { \normal-size-super "sus2" }
    }

    epartialJazzAlt = #(sequential-music-to-chord-exceptions epartialmusicJazzAlt #f)

    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \score {
      <<
        \new ChordNames {
          %% Already set by default:
          %\set chordNameFunction = #ignatzek-chord-names
          \set instrumentName = "Ignatzek"
          \set shortInstrumentName = "Def"
          \chs
        }

        \new ChordNames {
          \set chordNameFunction = #jazz-chordnames
          \set majorSevenSymbol = \whiteTriangleMarkup
          \set chordNameSeparator = "/"
          \set chordNameExceptionsFull = \efullJazzAlt
          \set chordNameExceptionsPartial = \epartialJazzAlt
          \set instrumentName = "Alternative"
          \set shortInstrumentName = "Alt"
          \chs
        }

        %% This is the Banter (1987) style.  It gives exceedingly
        %% verbose (wide) names, making the output file take up to 4 pages.

        \new ChordNames {
          \set chordNameFunction = #banter-chordnames
          \override ChordName.font-size = #-3
          \set instrumentName = "Banter"
          \set shortInstrumentName = "Ban"
          \chs
        }

      \new Staff \transpose c c' { \chs }
      >>
      \layout {
        #(layout-set-staff-size 16)
        system-system-spacing.basic-distance = #0
        \context {
          \ChordNames
          \consists "Instrument_name_engraver"
        }
        \context {
          \Score
          \remove "Bar_number_engraver"
        }
      }
    }

## Chords with stretched fingering for FretBoards and TabVoice

Sometimes chords with a stretched fingering are required. If not otherwise specified the context-property `maximumFretStretch` is set to `4`, though. Resulting in a warning about "No string for pitch ..." and the note is omitted. You may set `maximumFretStretch` to an approppriate value or explecitely assign string-numbers to all notes of a chord.

    %% The code below will print two warnings, which may be omitted by uncommenting:
    %#(for-each (lambda (x) (ly:expect-warning "No string for pitch")) (iota 2))

    mus = {
      <c' bes'>
      <c'\2 bes'>
      \set maximumFretStretch = 5
      <c' bes'>
      <c'\2 bes'\1>
    }

    <<
      \new FretBoards \mus
      \new TabVoice \mus
    >>

## Clusters

Clusters are a device to denote that a complete range of notes is to be played.

    fragment = \relative c' {
      c4 f <e d'>4
      <g a>8 <e a> a4 c2 <d b>4
      e2 c
    }

    <<
      \new Staff \fragment
      \new Staff \makeClusters \fragment
    >>

## Position von Fingersatz in Akkorden kontrollieren

Die Position von Fingersatzzahlen kann exakt kontrolliert werden.

    \relative c' {
      \set fingeringOrientations = #'(left)
      <c-1 e-3 a-5>4
      \set fingeringOrientations = #'(down)
      <c-1 e-3 a-5>4
      \set fingeringOrientations = #'(down right up)
      <c-1 e-3 a-5>4
      \set fingeringOrientations = #'(up)
      <c-1 e-3 a-5>4
      \set fingeringOrientations = #'(left)
      <c-1>2
      \set fingeringOrientations = #'(down)
      <e-3>2
      \set stringNumberOrientations = #'(up left down)
      <f\3 a\2 c\1>1
      \set strokeFingerOrientations = #'(down right up)
      <c\rightHandFinger #1 e\rightHandFinger #2 c'\rightHandFinger #4 >
    }

## Cross-staff chords - beaming problems workaround

Sometimes it is better to use stems from the upper staff for creating cross-staff chords, because no problems with automatic beam collision avoidance then arise. If the stems from the lower staff were used in the following example, it would be necessary to change the automatic beam collision avoidance settings so that it doesn’t detect collisions between staves using `\override Staff.Beam.collision-voice-only = ##t`

    \new PianoStaff <<
      \new Staff = up
        \relative c' {
          <<
            { r4
              \override Stem.cross-staff = ##t
              \override Stem.length = #19 % this is in half-spaces,
                  % so it makes stems 9.5 staffspaces long
              \override Stem.Y-offset = #-6 % stems are normally lengthened
                  % upwards, so here we must lower the stem by the amount
                  % equal to the lengthening - in this case (19 - 7) / 2
                  % (7 is default stem length)
              e e e }
            { s4
              \change Staff = "bottom"
              \override NoteColumn.ignore-collision = ##t
              c, c c
            }
          >>
        }
      \new Staff = bottom
        \relative c' {
          \clef bass
          \voiceOne
          g8 a g a g a g a
        }
    >>

## Displaying complex chords

Here is a way to display a chord where the same note is played twice with different accidentals.

    fixA = {
      \once \override Stem.length = #11
    }

    fixB = {
      \once \override NoteHead.X-offset = #1.7
      \once \override Stem.length = #7
      \once \override Stem.rotation = #'(45 0 0)
      \once \override Stem.extra-offset = #'(-0.1 . -0.2)
      \once \override Flag.style = #'no-flag
      \once \override Accidental.extra-offset = #'(4 . -.1)
    }

    \relative c' {
      << { \fixA <b d!>8 } \\ { \voiceThree \fixB dis } >> s
    }

## Manually break figured bass extenders for only some numbers

Figured bass often uses extenders to indicate continuation of the corresponding step. However, in this case lilypond is in greedy-mode and uses extenders whenever possible. To break individual extenders, one can simply use a modifier `\!` to a number, which breaks any extender attributed to that number right before the number.

    bassfigures = \figuremode {
      \set useBassFigureExtenders = ##t
      <6 4>4 <6 4\!> <6 4\!> <6 4\!> |  <6\! 4\!>  <6 4> <6 4\!> <6 4>
    }

    <<
      \new Staff \relative c'' { c1 c1 }
      \new FiguredBass \bassfigures
    >>

## Akkordsymbole bei Wechsel anzeigen

Akkordsymbole können so eingestellt werden, dass sie nur zu Beginn der Zeile und bei Akkordwechseln angezeigt werden.

    harmonies = \chordmode {
      c1:m c:m \break c:m c:m d
    }

    <<
      \new ChordNames {
        \set chordChanges = ##t
        \harmonies
      }
      \new Staff {
        \relative c' { \harmonies }
      }
    >>

## Ein einfaches Liedblatt

Ein Liedblatt besteht aus Akkordbezeichnungen, einer Melodie und dem Liedtext:

    <<
      \chords { c2 g:sus4 f e }
      \new Staff \relative c'' {
        a4 e c8 e r4
        b2 c4( d)
      }
      \addlyrics { One day this shall be free __ }
    >>

## Vorlage für eine Notenzeile mit Noten, Text und Akkorden

Mit diesem Beispiel können Sie einen Song mit Melodie, Text und Akkorden schreiben.

    melody = \relative c' {
      \clef treble
      \key c \major
      \time 4/4

      a4 b c d
    }

    text = \lyricmode {
      Aaa Bee Cee Dee
    }

    harmonies = \chordmode {
      a2 c
    }

    \score {
      <<
        \new ChordNames {
          \set chordChanges = ##t
          \harmonies
        }
        \new Voice = "one" { \autoBeamOff \melody }
        \new Lyrics \lyricsto "one" \text
      >>
      \layout { }
      \midi { }
    }

## Single staff template with notes, lyrics, chords and frets

Here is a simple lead sheet template with melody, lyrics, chords and fret diagrams.

    verseI = \lyricmode {
      \set stanza = #"1."
      This is the first verse
    }

    verseII = \lyricmode {
      \set stanza = #"2."
      This is the second verse.
    }

    theChords = \chordmode {
      % insert chords for chordnames and fretboards here
      c2 g4 c
    }

    staffMelody = \relative c' {
       \key c \major
       \clef treble
       % Type notes for melody here
       c4 d8 e f4 g
       \bar "|."
    }

    \score {
      <<
        \context ChordNames { \theChords }
        \context FretBoards { \theChords }
        \new Staff {
          \context Voice = "voiceMelody" { \staffMelody }
        }
        \new Lyrics = "lyricsI" {
          \lyricsto "voiceMelody" \verseI
        }
        \new Lyrics = "lyricsII" {
          \lyricsto "voiceMelody" \verseII
        }
      >>
      \layout { }
      \midi { }
    }

## Vorlage für eine Notenzeile mit Akkorden

Wollen Sie ein Liedblatt mit Melodie und Akkorden schreiben? Hier ist das richtige Beispiel für Sie!

    melody = \relative c' {
      \clef treble
      \key c \major
      \time 4/4

      f4 e8[ c] d4 g
      a2 ~ a
    }

    harmonies = \chordmode {
      c4:m f:min7 g:maj c:aug
      d2:dim b4:5 e:sus
    }

    \score {
      <<
        \new ChordNames {
          \set chordChanges = ##t
          \harmonies
        }
        \new Staff \melody
      >>
      \layout{ }
      \midi { }
    }

## Vertically centering paired figured bass extenders

Where figured bass extender lines are being used by setting `useBassFigureExtenders` to true, pairs of congruent figured bass extender lines are vertically centered if `figuredBassCenterContinuations` is set to true.

    <<
      \relative c' {
        c8 c b b a a c16 c b b
        c8 c b b a a c16 c b b
        c8 c b b a a c c b b
      }
      \figures {
        \set useBassFigureExtenders = ##t
        <6+ 4 3>4 <6 4 3>8 r
        <6+ 4 3>4 <6 4 3>8 <4 3+>16 r
        \set figuredBassCenterContinuations = ##t
        <6+ 4 3>4 <6 4 3>8 r
        <6+ 4 3>4 <6 4 3>8 <4 3+>16 r
        \set figuredBassCenterContinuations = ##f
        <6+ 4 3>4 <6 4 3>8 r
        <6+ 4 3>4 <6 4 3>8 <4 3+>8
      }
    >>

## Wiederholungs-(Volta-)Klammern unterhalb der Akkordsymbole

Indem man den `Volta_engraver` zu dem entsprechenden Notensystem hinzufügt, können Wiederholungsklammern unterhalb der Akkorde gesetzt werden.

    \score {
      <<
        \chords {
          c1
          c1
        }
        \new Staff \with {
          \consists "Volta_engraver"
        }
        {
          \repeat volta 2 { c'1 }
          \alternative { c' }
        }
      >>
      \layout {
        \context {
          \Score
          \remove "Volta_engraver"
        }
      }
    }

#### LilyPond – Snippets v2.22.2 (stabiler Zweig).