Next: , Previous: Fret diagram markups, Up: Common notation for fretted strings


Predefined fret diagrams

Fret diagrams can be displayed using the FretBoards context. By default, the FretBoards context will display fret diagrams that are stored in a lookup table:

     
     \include "predefined-guitar-fretboards.ly"
     \context FretBoards {
       \chordmode {
         c1 d
       }
     }

[image of music]

The default predefined fret diagrams are contained in the file predefined-guitar-fretboards.ly. Fret diagrams are stored based on the pitches of a chord and the value of stringTunings that is currently in use. predefined-guitar-fretboards.ly contains predefined fret diagrams only for guitar-tuning. Predefined fret diagrams can be added for other instruments or other tunings by following the examples found in predefined-guitar-fretboards.ly.

Chord pitches can be entered either as simultaneous music or using chord mode (see Chord mode overview).

     
     \include "predefined-guitar-fretboards.ly"
     \context FretBoards {
       \chordmode {c1}
       <c' e' g'>1
     }

[image of music]

It is common that both chord names and fret diagrams are displayed together. This is achieved by putting a ChordNames context in parallel with a FretBoards context and giving both contexts the same music.

     
     \include "predefined-guitar-fretboards.ly"
     mychords = \chordmode{
       c1 f g
     }
     
     <<
       \context ChordNames {
         \mychords
       }
       \context FretBoards {
         \mychords
       }
     >>

[image of music]

Predefined fret diagrams are transposable, as long as a diagram for the transposed chord is stored in the fret diagram table.

     
     \include "predefined-guitar-fretboards.ly"
     mychords = \chordmode{
       c1 f g
     }
     
     mychordlist = {
       \mychords
       \transpose c e { \mychords}
     }
     <<
       \context ChordNames {
         \mychordlist
       }
       \context FretBoards {
         \mychordlist
       }
     >>

[image of music]

The predefined fret diagram table contains seven chords (major, minor, augmented, diminished, dominant seventh, major seventh, minor seventh) for each of 17 keys. A complete list of the predefined fret diagrams is shown in Predefined fretboard diagrams. If there is no entry in the table for a chord, the FretBoards engraver will calculate a fret-diagram using the automatic fret diagram functionality described in Automatic fret diagrams.

     
     \include "predefined-guitar-fretboards.ly"
     mychords = \chordmode{
       c1 c:9
     }
     
     <<
       \context ChordNames {
         \mychords
       }
       \context FretBoards {
         \mychords
       }
     >>

[image of music]

Fret diagrams can be added to the fret diagram table. To add a diagram, you must specify the chord for the diagram, the tuning to be used, and a definition for the diagram. The diagram definition can be either a fret-diagram-terse definition string or a fret-diagram-verbose marking list.

     
     \include "predefined-guitar-fretboards.ly"
     
     \storePredefinedDiagram \chordmode {c:9}
                             #guitar-tuning
                             #"x;3-2;2-1;3-3;3-4;x;"
     
     mychords = \chordmode{
       c1 c:9
     }
     
     <<
       \context ChordNames {
         \mychords
       }
       \context FretBoards {
         \mychords
       }
     >>

[image of music]

Different fret diagrams for the same chord name can be stored using different octaves of pitches.

     
     \include "predefined-guitar-fretboards.ly"
     
     \storePredefinedDiagram \chordmode {c'}
                             #guitar-tuning
                             #(offset-fret 2 (chord-shape 'bes guitar-tuning))
     
     mychords = \chordmode{
       c1 c'
     }
     
     <<
       \context ChordNames {
         \mychords
       }
       \context FretBoards {
         \mychords
       }
     >>

[image of music]

In addition to fret diagrams, LilyPond stores an internal list of chord shapes. The chord shapes are fret diagrams that can be shifted along the neck to different posistions to provide different chords. Chord shapes can be added to the internal list and then used to define predefined fret diagrams. Because they can be moved to various positions on the neck, chord shapes will normally not contain any open strings. Like fret diagrams, chord shapes can be entered as either fret-diagram-terse strings or fret-diagram-verbose marking lists.

     
     \include "predefined-guitar-fretboards.ly"
     
     % add a new chord shape
     
     \addChordShape #'powerf #guitar-tuning #"1-1;3-3;3-4;x;x;x;"
     
     % add some new chords based on the power chord shape
     
     \storePredefinedDiagram \chordmode {f'}
                             #guitar-tuning
                             #(chord-shape 'powerf guitar-tuning) 
     \storePredefinedDiagram \chordmode {g'}
                             #guitar-tuning
                             #(offset-fret 2 (chord-shape 'powerf guitar-tuning))
     
     mychords = \chordmode{
       f1 f' g g'
     }
     
     <<
       \context ChordNames {
         \mychords
       }
       \context FretBoards {
         \mychords
       }
     >>

[image of music]

The graphical layout of a fret diagram can be customized according to user preference through the properties of the fret-diagram-interface. Details are found at fret-diagram-interface. For a predefined fret diagram, the interface properties belong to FretBoards.FretBoard.

Selected Snippets

Customizing fretboard fret diagrams

Fret diagram properties can be set through 'fret-diagram-details. For FretBoard fret diagrams, overrides are applied to the FretBoards.FretBoard object. Like Voice, FretBoards is a bottom level context, therefore can be omitted in property overrides.

     
     \include "predefined-guitar-fretboards.ly"
     \storePredefinedDiagram \chordmode { c' }
                             #guitar-tuning
                             #"x;1-1-(;3-2;3-3;3-4;1-1-);"
     <<
       \new ChordNames {
         \chordmode { c1 c c d }
       }
       \new FretBoards {
         % Set global properties of fret diagram
         \override FretBoards.FretBoard #'size = #'1.2
         \override FretBoard
           #'(fret-diagram-details finger-code) = #'in-dot
         \override FretBoard
           #'(fret-diagram-details dot-color) = #'white
         \chordmode {
           c
           \once \override FretBoard #'size = #'1.0
           \once \override FretBoard
             #'(fret-diagram-details barre-type) = #'straight
           \once \override FretBoard
             #'(fret-diagram-details dot-color) = #'black
           \once \override FretBoard
             #'(fret-diagram-details finger-code) = #'below-string
           c'
           \once \override FretBoard
             #'(fret-diagram-details barre-type) = #'none
           \once \override FretBoard
             #'(fret-diagram-details number-type) = #'arabic
           \once \override FretBoard
             #'(fret-diagram-details orientation) = #'landscape
           \once \override FretBoard
             #'(fret-diagram-details mute-string) = #"M"
           \once \override FretBoard
             #'(fret-diagram-details label-dir) = #LEFT
           \once \override FretBoard
             #'(fret-diagram-details dot-color) = #'black
           c'
           \once \override FretBoard
             #'(fret-diagram-details finger-code) = #'below-string
           \once \override FretBoard
             #'(fret-diagram-details dot-radius) = #0.35
           \once \override FretBoard
             #'(fret-diagram-details dot-position) = #0.5
           \once \override FretBoard
             #'(fret-diagram-details fret-count) = #3
           d
         }
       }
       \new Voice {
         c'1 c' c' d'
       }
     >>

[image of music]

Defining predefined fretboards for other instruments

Predefined fret diagrams can be added for new instruments in addition to the standards used for guitar. This file shows how this is done by defining a new string-tuning and a few predefined fretboards for the Venezuelan cuatro.

This file also shows how fingerings can be included in the chords used as reference points for the chord lookup, and displayed in the fret diagram and the TabStaff, but not the music.

These fretboards are not transposable because they contain string information. This is planned to be corrected in the future.

     
     % add FretBoards for the Cuatro
     %   Note: This section could be put into a separate file
     %      predefined-cuatro-fretboards.ly
     %      and \included into each of your compositions
     
     cuatroTuning = #'(11 18 14 9)
     
     dSix = { <a\4 b\1 d\3 fis\2> }
     dMajor = { <a\4 d\1 d\3 fis \2> }
     aMajSeven = { <a\4 cis\1 e\3 g\2> }
     dMajSeven = { <a\4 c\1 d\3 fis\2> }
     gMajor = { <b\4 b\1 d\3 g\2> }
     
     \storePredefinedDiagram \dSix
                             #cuatroTuning
                             #"o;o;o;o;"
     \storePredefinedDiagram \dMajor
                             #cuatroTuning
                             #"o;o;o;3-3;"
     \storePredefinedDiagram \aMajSeven
                             #cuatroTuning
                             #"o;2-2;1-1;2-3;"
     \storePredefinedDiagram \dMajSeven
                             #cuatroTuning
                             #"o;o;o;1-1;"
     \storePredefinedDiagram \gMajor
                             #cuatroTuning
                             #"2-2;o;1-1;o;"
     
     % end of potential include file /predefined-cuatro-fretboards.ly
     
     
     #(set-global-staff-size 16)
     
     primerosNames = \chordmode {
       d:6 d a:maj7 d:maj7 
       g
     }
     primeros = {
       \dSix \dMajor \aMajSeven \dMajSeven
       \gMajor
     }
     
     \score {
       <<
         \new ChordNames {
           \set chordChanges = ##t
           \primerosNames
         }
     
         \new Staff {
           \new Voice \with {
             \remove "New_fingering_engraver"
           } 
           \relative c'' {
             \primeros
           }
         }
     
         \new FretBoards {
           \set stringTunings = #cuatroTuning
           \override FretBoard
             #'(fret-diagram-details string-count) = #'4
           \override FretBoard
             #'(fret-diagram-details finger-code) = #'in-dot
           \primeros
         }
     
         \new TabStaff \relative c'' {
           \set TabStaff.stringTunings = #cuatroTuning
           \primeros
         }
         
       >>
     
       \layout { 
         \context {
           \Score
           \override SpacingSpanner
             #'base-shortest-duration = #(ly:make-moment 1 16)
         }
       }
       \midi { }
     }

[image of music]

See also

Notation Reference: Custom tablatures, Automatic fret diagrams, Chord mode overview, Predefined fretboard diagrams.

Installed Files: ly/predefined-guitar-fretboards.ly, ly/predefined-guitar-ninth-fretboards.ly.

Snippets: Fretted strings.

Internals Reference: fret-diagram-interface.

Other languages: espaƱol, deutsch.