Fragments del LilyPond: Chords

# Chords

Chord notation

## Afegir un baix xifrat a sobre o a sota de les notes

En escriure un baix xifrat, podem ubicar les xifres a sobre a o a sota de les notes del baix, mitjançant la definició de la propietat `BassFigureAlignmentPositioning #'direction` (exclusivament dins d’un context `Staff`). es pot escollir entre `#UP` (o `#1`, a sobre), `#CENTER` (o `#0`, centraat) i `#DOWN` (o `#-1`, a sota).

Aquesta propietat es pot canviar tantes vegades com volem. Utilitzeu `\once \override` si no voleu que la sobreescriptura s’apliqui a tota la partitura.

    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
      >>
    }

## Afegir barres de compàs al context de noms d’acord (ChordNames)

Per afegir indicacions de línia divisòria dins del context dels noms d’acord `ChordNames`, incloeu el gravador `Bar_engraver`.

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

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

## Adjusting figured bass alteration glyphs

In figured bass, specially designed glyphs for `6\\`, `7\\`, and `9\\` are used by default. Similarly, specially designed glyphs for symbols `2\+`, `4\+`, and `5\+` are used by default if plus signs appear after the number.

To change that, pass an alist to `figuredBassPlusStrokedAlist` and set the glyph in question to `#f` (or omit it).

    \figures {
      \set figuredBassPlusDirection = #RIGHT
      <6\\> <7\\> <9\\> r
      <2\+> <4\+> <5\+> r

      \set figuredBassPlusStrokedAlist =
        #'((2 . "figbass.twoplus")
           ;; (4 . "figbass.fourplus")
           ;; (5 . "figbass.fiveplus")
           (6 . "figbass.sixstroked")
           ;; (7 . "figbass.sevenstroked")
           ;; (9 . "figbass.ninestroked")
          )
      <6\\> <7\\> <9\\> r
      <2\+> <4\+> <5\+> r
    }

## Modificació del separador d’acords

The separator between different parts of a chord name can be set to any markup.

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

## Canviar la nomenclatura dels acords del xifrat americà per la notació alemanya o semi-alemanya

La nomenclatura anglesa (predeterminada) per als acords del xifrat americà es pot canviar per l’alemanya (`\germanChords` que substitueix B i Bes per H i B) o per la semi-anglesa (`\semiGermanChords` que substitueix B i Bes per H i 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 }
    >>

## Canviar les posicions de les alteracions de baix xifrat

Les alteracions i els signes «més» poden aparèixer abans o després dels nombres, segon el valor de ls propietats `figuredBassAlterationDirection` i `figuredBassPlusDirection`.

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

## Excepcions per als noms d’acord

Es pot usar la propietat `chordNameExceptions` per a emmagatzemar una llista de notacions espacials per a acords específics.

    % 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
    >>

## Nom d’acord maj7

La presentació de l’acord de sèptima major es pot ajustar mitjançant majorSevenSymbol.

    \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 (G_ "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 («raïms»)

Els «clusters» o raïms són un mecanisme per indicar la interpretació d’un àmbit de notes al mateix temps.

    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
    >>

## Controlar la col·locación de les digitacions d’acords

Es pot controlar amb precisió la col·locació dels números de digitació. Perquè es tingui en compte l’orientació de les digitacions, es pot utilitzar una construcció d’acord <> tot i que siguin una sola nota.

    \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
        }
    >>

## Customizing the chord grid style

Custom divisions of chord squares can be defined through the `measure-division-lines-alist` and `measure-division-chord-placement-alist` properties of `ChordSquare`. These are both alists. Their keys are measure divisions, namely lists which give the fraction of the measure that each chord (or rest, or skip) represents. More precisely, a measure division alist is made of positive, exact numbers adding up to 1, for example: `'(1/2 1/4 1/4)`. The exactness requirement means that, e.g., `1/2` is valid but not `0.5`.

The values in `measure-division-lines-alist` are lists of lines, which are represented as `(x1 y1 x2 y2)`. The line starts at the point `(x1 . y1)` and ends at `(x2 . y2)`. Coordinates are expressed in the [-1, 1] scale relative to the extent of the square.

The values in `measure-division-chord-placement-alist` are lists of `(x . y)` pairs giving the placement of the respective chords.

This example defines a peculiar chord grid style that has a rule for measures divided in three equal parts.

    \paper {
      line-width = 10\cm
      ragged-right = ##f
    }

    \new ChordGrid \with {
      \override ChordSquare.measure-division-lines-alist =
        #'(((1) . ())
           ((1/3 1/3 1/3) . ((-1 -0.4 0 1) (0 -1 1 0.4))))
      \override ChordSquare.measure-division-chord-placement-alist =
        #'(((1) . ((0 . 0)))
           ((1/3 1/3 1/3) . ((-0.7 . 0.5) (0 . 0) (0.7 . -0.5))))
    }
    \chordmode {
      \time 3/4
      c2.
      c4 c4 c4
    }

## Customizing the no-chord symbol

By default, rests in a `ChordNames` context cause the “N.C.” symbol to be printed. This markup can be customized.

    <<
      \chords {
        R1
        \set noChordSymbol = "—"
        R1
        \set noChordSymbol = \markup \italic "Ssh!"
        R1
      }
      {
        R1*3
      }
    >>

## Impressió d’acords complexos

Aquí es presenta una forma d’imprimir un acord en la qual sona la mateixa nota dues vegades amb diferents alteracions.

    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
    }

## Dividir manualment les línies d’extensió del baix xifrat per certs números solament

Sovint, el baix figurat usa línies d’extensió per indicar la continuació de l’element corresponent dins de l’acord. No obstant, en aquest cas el LilyPond està en mode “modo voraç” i usa els extensors quan és possible Per dividir els extensors individuals, podem senzillament usar el modificador \! per a un número, cosa que trenca qualsevol línia d’extensió atribuïda a aquest número just abans del número.

    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
    >>

## Print ChordNames with same root and different bass as slash and bass-note

To print subsequent `ChordNames` only differing in its bass note as slash and bass note use the here defined engraver. The behaviour may be controlled in detail by the `chordChanges` context property.

    #(define Bass_changes_equal_root_engraver
      (lambda (ctx)
      "For sequential @code{ChordNames} with same root, but different bass, the root
    markup is dropped: D D/C D/B  -> D /C /B
    The behaviour may be controlled by setting the @code{chordChanges}
    context-property."
        (let ((chord-pitches '())
              (last-chord-pitches '())
              (bass-pitch #f))
          (make-engraver
            ((initialize this-engraver)
              (let ((chord-note-namer (ly:context-property ctx 'chordNoteNamer)))
                ;; Set 'chordNoteNamer, respect user setting if already done
                (ly:context-set-property! ctx 'chordNoteNamer
                  (if (procedure? chord-note-namer)
                      chord-note-namer
                      note-name->markup))))
            (listeners
              ((note-event this-engraver event)
                (let* ((pitch (ly:event-property event 'pitch))
                       (pitch-name (ly:pitch-notename pitch))
                       (pitch-alt (ly:pitch-alteration pitch))
                       (bass (ly:event-property event 'bass #f))
                       (inversion (ly:event-property event 'inversion #f)))
                ;; Collect notes of the chord
                ;;  - to compare inversed chords we need to collect the bass note
                ;;    as usual member of the chord, whereas an added bass must be
                ;;    treated separate from the usual chord-notes
                ;;  - notes are stored as pairs containing their
                ;;    pitch-name (an integer), i.e. disregarding their octave and
                ;;    their alteration
                (cond (bass (set! bass-pitch pitch))
                      (inversion
                        (set! bass-pitch pitch)
                        (set! chord-pitches
                              (cons (cons pitch-name pitch-alt) chord-pitches)))
                      (else
                        (set! chord-pitches
                              (cons (cons pitch-name pitch-alt) chord-pitches)))))))
            (acknowledgers
              ((chord-name-interface this-engraver grob source-engraver)
                (let ((chord-changes (ly:context-property ctx 'chordChanges #f)))
                  ;; If subsequent chords are equal apart from their bass,
                  ;; reset the 'text-property.
                  ;; Equality is done by comparing the sorted lists of this chord's
                  ;; elements and the previous chord. Sorting is needed because
                  ;; inverted chords may have a different order of pitches.
                  ;; `chord-changes' needs to be true
                  (if (and bass-pitch
                           chord-changes
                           (equal?
                             (sort chord-pitches car<)
                             (sort last-chord-pitches car<)))
                      (ly:grob-set-property! grob 'text
                        (make-line-markup
                          (list
                            (ly:context-property ctx 'slashChordSeparator)
                            ((ly:context-property ctx 'chordNoteNamer)
                             bass-pitch
                             (ly:context-property ctx 'chordNameLowercaseMinor))))))
                  (set! last-chord-pitches chord-pitches)
                  (set! chord-pitches '())
                  (set! bass-pitch #f))))
            ((finalize this-engraver)
              (set! last-chord-pitches '()))))))

    myChords = \chordmode {
      %\germanChords

      \set chordChanges = ##t
      d2:m d:m/cis

      d:m/c
      \set chordChanges = ##f
      d:m/b

      e1:7
      \set chordChanges = ##t
      e
      \break
      \once \set chordChanges = ##f
      e1/f
      e2/gis e/+gis e e:m/f d:m d:m/cis d:m/c
      \set chordChanges = ##f
      d:m/b
    }

    <<
      \new ChordNames
        \with { \consists #Bass_changes_equal_root_engraver }
        \myChords
      \new Staff \myChords
    >>

## Imprimir els acords quan es produeix un canvi

Es poden imprimir els acords exclusivament al començament de les línies i quan canvia l’acord.

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

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

## Full guia d’acords o «lead sheet» senzilla

En ajuntar noms d’acord en xifrat americà, melodia i lletra, obtenim un full d’acord os «lead sheet»:

    <<
      \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 __ }
    >>

## Plantilla de pentagrama únic amb música, lletra i acords

Aquesta plantilla facilita la preparació d’una cançó amb melodia, lletra i acords.

    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 { }
    }

## Plantilla per a un pentagrama únic amb música, lletra, acords i trastos

A continuació presentem un exemple de plantilla per a un full guia d’acords amb melodia, lletra, acords i diagrama de trastos.

    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 { }
    }

## Plantilla de pentagrama únic amb música i acords

Voleu preparar un full guia d’acords (o «lead sheet») amb melodia i acords? No busqueu més!

    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 { }
    }

## Centrat vertical de les línies de baix xifrat emparellades

Al lloc on s’utilitzin línies extensores per al baix xifrat mitjançant l’establiment de `useBassFigureExtenders` al valor vertader, les parelles de línies extensores congruents se centren verticalment si el valor de `figuredBassCenterContinuations` té el valor vertader.

    <<
      \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
      }
    >>

## Corxets de primera i segona vegada a sota dels acords

Mitjançant l’addició del gravador `Volta_engraver` al pentagrama pertinent, es poden posar els corxets de primera i segona veu a sota dels acords.

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

#### LilyPond — Fragments v2.24.4 (branca estable).