]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/notation/fretted-strings.itely
make supportNonIntegerFret a context-property
[lilypond.git] / Documentation / notation / fretted-strings.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2 @ignore
3     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
4
5     When revising a translation, copy the HEAD committish of the
6     version that you are working on.  For details, see the Contributors'
7     Guide, node Updating translation committishes..
8 @end ignore
9
10 @c \version "2.19.28"
11
12 @node Fretted string instruments
13 @section Fretted string instruments
14
15 @lilypondfile[quote]{fretted-headword.ly}
16
17 This section discusses several aspects of music notation that are unique
18 to fretted string instruments.
19
20 @cindex tablature
21 @cindex tablature, guitar
22 @cindex tablature, banjo
23 @cindex guitar tablature
24 @cindex banjo tablature
25
26 @menu
27 * Common notation for fretted strings::
28 * Guitar::
29 * Banjo::
30 @end menu
31
32 @node Common notation for fretted strings
33 @subsection Common notation for fretted strings
34
35 This section discusses common notation that is unique
36 to fretted string instruments.
37
38 @menu
39 * References for fretted strings::
40 * String number indications::
41 * Default tablatures::
42 * Custom tablatures::
43 * Fret diagram markups::
44 * Predefined fret diagrams::
45 * Automatic fret diagrams::
46 * Right-hand fingerings::
47 @end menu
48
49 @node References for fretted strings
50 @unnumberedsubsubsec References for fretted strings
51
52 Music for fretted string instruments is normally notated on
53 a single staff, either in traditional music notation or in
54 tablature.  Sometimes the two types are combined, and it is
55 especially common in popular music to use chord diagrams above
56 a staff of traditional notation.  The guitar and the banjo are
57 transposing instruments, sounding an octave lower than written.
58 Scores for these instruments should use the @code{"treble_8"} clef
59 (or @code{\transposition c} to get correct MIDI output).
60 Some other elements pertinent to fretted string instruments
61 are covered elsewhere:
62
63 @itemize
64 @item Fingerings are indicated as shown in
65 @ref{Fingering instructions}.
66
67 @item Instructions for @notation{Laissez vibrer} ties
68 as well as ties on arpeggios and tremolos can be found in
69 @ref{Ties}.
70
71 @item Instructions for handling multiple voices can be found
72 in @ref{Collision resolution}.
73
74 @item Instructions for indicating harmonics can be found in
75 @ref{Harmonics}.
76
77 @end itemize
78
79 @seealso
80 Notation Reference:
81 @ref{Fingering instructions},
82 @ref{Ties},
83 @ref{Collision resolution},
84 @ref{Instrument names},
85 @ref{Writing music in parallel},
86 @ref{Arpeggio},
87 @ref{List of articulations},
88 @ref{Clef},
89 @ref{Instrument transpositions}.
90
91
92 @node String number indications
93 @unnumberedsubsubsec String number indications
94
95 @cindex string numbers
96 @cindex string vs. fingering numbers
97 @cindex fingering vs. string numbers
98
99 The string on which a note should be played may be indicated by
100 appending @code{\@var{number}} to a note.
101
102 @lilypond[verbatim,quote,fragment]
103 \clef "treble_8"
104 c4\5 e\4 g2\3
105 <c\5 e\4 g\3>1
106 @end lilypond
107
108 When fingerings and string indications are used together, their
109 placement can be controlled by the order in which the two items appear
110 in the code @emph{only} if they appear inside of an explicit chord:
111 applied to whole chords or single notes @emph{outside} of chords,
112 fingerings are placed using a different mechanism.
113
114 @lilypond[verbatim,quote,fragment]
115 \clef "treble_8"
116 g4\3-0
117 g-0\3
118 <g\3-0>
119 <g-0\3>
120 @end lilypond
121
122 String numbers may also, as is customary with unfretted strings,
123 be printed in Roman numerals and placed below the staff rather
124 than above.
125
126 @lilypond[verbatim,quote,fragment]
127 \clef "treble_8"
128 c'2\2
129 a\3
130 \romanStringNumbers
131 c'\2
132 \set stringNumberOrientations = #'(down)
133 a\3
134 \arabicStringNumbers
135 g1\4
136 @end lilypond
137
138 @snippets
139
140 @lilypondfile[verbatim,quote,texidoc,doctitle]
141 {controlling-the-placement-of-chord-fingerings.ly}
142
143 @lilypondfile[verbatim,quote,texidoc,doctitle]
144 {allowing-fingerings-to-be-printed-inside-the-staff.ly}
145
146 @predefined
147 @code{\arabicStringNumbers},
148 @code{\romanStringNumbers}.
149 @endpredefined
150
151 @seealso
152 Notation Reference:
153 @ref{Fingering instructions}.
154
155 Snippets:
156 @rlsr{Fretted strings}.
157
158 Internals Reference:
159 @rinternals{StringNumber},
160 @rinternals{Fingering}.
161
162
163 @node Default tablatures
164 @unnumberedsubsubsec Default tablatures
165
166 @cindex tablatures, basic
167 @cindex tablatures, default
168
169 @funindex TabStaff
170 @funindex TabVoice
171
172 Music for plucked string instruments is frequently notated using a
173 finger/touch notation or tablature.  In contrast to traditional
174 notation pitches are not denoted with note heads, but by numbers (or
175 letter-like symbols in historical intavolatura).  The staff lines
176 in tablature indicate the string on which the note is to be played,
177 and a number placed on a staff line indicated the fret at which
178 the corresponding string is to be pressed.
179 Notes that are to be played simultaneously are vertically aligned.
180
181 By default, string 1 is the highest string, and corresponds to the top
182 line on the @code{TabStaff}.  The tuning of the @code{TabStaff}
183 strings defaults to the
184 standard guitar tuning (with 6 strings).  The notes are printed as
185 tablature, by using @code{TabStaff} and @code{TabVoice} contexts.  A
186 calligraphic tablature clef is added automatically.
187
188 @lilypond[quote,ragged-right,verbatim]
189 \new TabStaff \relative {
190   a,8 a' <c e> a
191   d,8 a' <d f> a
192 }
193 @end lilypond
194
195 Default tablatures do not contain any symbols for tone duration nor any
196 other musical symbols such as e.g. expressive marks.
197
198 @lilypond[quote,ragged-right,verbatim]
199 symbols = {
200   \time 3/4
201   c4-.^"Allegro" d( e)
202   f4-.\f g a^\fermata
203   \mark \default
204   c8_.\<\( c16 c~ 2\!
205   c'2.\prall\)
206 }
207
208 \score {
209   <<
210     \new Staff { \clef "G_8" \symbols }
211     \new TabStaff { \symbols }
212   >>
213 }
214 @end lilypond
215
216 @funindex \tabFullNotation
217
218 If all musical symbols used in traditional notation should also show up
219 in tablature one has to apply the command @code{\tabFullNotation} in a
220 @code{TabStaff}-context.  Please bear in mind that half notes are
221 double-stemmed in tablature in order to distinguish them from quarter
222 notes.
223
224 @lilypond[quote,ragged-right,verbatim]
225 symbols = {
226   \time 3/4
227   c4-.^"Allegro" d( e)
228   f4-.\f g a^\fermata
229   \mark \default
230   c8_.\<\( c16 c~ 2\!
231   c'2.\prall\)
232 }
233
234 \score {
235   \new TabStaff {
236     \tabFullNotation
237     \symbols
238   }
239 }
240 @end lilypond
241
242 @cindex fret
243
244 @funindex minimumFret
245 @funindex restrainOpenStrings
246
247 By default pitches are assigned to the lowest playing position on the
248 fret-board (first position).  Open strings are automatically preferred.
249 If you would like a certain pitch to be played on a specific string you
250 can add a string number indication to the pitch name.  If you don't want
251 to have string number indications appear in traditional notation, you
252 can override the respective stencil.  Usually it will be more
253 comfortable to define the playing position by using the value of
254 @code{minimumFret}.  The default value for minimumFret is 0.
255
256 Even when @code{minimumFret} is set, open strings are used whenever
257 possible.  This behaviour can be changed by setting @code{restrainOpenStrings}
258 to @code{#t}.
259
260 @lilypond[quote,ragged-right,verbatim]
261 \layout { \omit Voice.StringNumber }
262 \new StaffGroup <<
263    \new Staff \relative {
264      \clef "treble_8"
265      \time 2/4
266      c16 d e f g4
267      c,16\5 d\5 e\4 f\4 g4\4
268      c,16 d e f g4
269    }
270    \new TabStaff \relative {
271      c16 d e f g4
272      c,16\5 d\5 e\4 f\4 g4\4
273      \set TabStaff.minimumFret = #5
274      \set TabStaff.restrainOpenStrings = ##t
275      c,16 d e f g4
276    }
277 >>
278 @end lilypond
279
280 @funindex \tabChordRepeats
281 @funindex \chordRepeats
282 @cindex chord, repetition
283 @cindex repetition, using @code{q}
284 @cindex @code{q}, chord repetition
285
286 Chord constructs can be repeated by the chord repetition symbol
287 @code{q}.  In combination with tabulatures, its behavior of removing
288 string and finger numbers alongside with other events is cumbersome, so
289 you'll want to run
290 @example
291 \chordRepeats #'(string-number-event fingering-event)
292 @end example
293 explicitly on music expressions in tabulature using @ref{Chord
294 repetition}.  This particular command is so common that it is available
295 as @code{\tabChordRepeats}.
296
297 @lilypond[quote,verbatim]
298 guitar = \relative {
299   r8 <gis-2 cis-3 b-0>~ q4 q8~ 8 q4
300 }
301
302 \new StaffGroup <<
303   \new Staff {
304     \clef "treble_8"
305     \guitar
306   }
307   \new TabStaff {
308     \tabChordRepeats \guitar
309   }
310 >>
311 @end lilypond
312
313 Ties over a line break are parenthesized by default.  The same holds for
314 the second alternative of a repeat.
315
316 @lilypond[quote,ragged-right,verbatim]
317 ties = \relative {
318   \repeat volta 2 {
319     e'2. f4~
320     2 g2~
321   }
322   \alternative {
323      { g4 f2. }
324      { g4\repeatTie c,2. }
325   }
326   b1~
327   \break
328   b1
329   \bar "|."
330 }
331
332 \score {
333   <<
334     \new StaffGroup  <<
335       \new Staff {
336         \clef "treble_8"
337         \ties
338       }
339       \new TabStaff {
340         \ties
341       }
342     >>
343   >>
344   \layout {
345   indent = #0
346   ragged-right = ##t
347   }
348 }
349 @end lilypond
350
351 @funindex \hideSplitTiedTabNotes
352
353 The command @code{\hideSplitTiedTabNotes} cancels the behavior of
354 engraving fret numbers in parentheses:
355
356 @lilypond[quote,ragged-right,verbatim]
357 ties = \relative {
358   \repeat volta 2 {
359     e'2. f4~
360     2 g2~ }
361   \alternative {
362     { g4 f2. }
363     { g4\repeatTie c,2. }
364   }
365   b1~
366   \break
367   b1
368   \bar "|."
369 }
370
371 \score {
372   <<
373     \new StaffGroup  <<
374       \new Staff {
375         \clef "treble_8"
376         \ties
377       }
378       \new TabStaff {
379       \hideSplitTiedTabNotes
380         \ties
381       }
382     >>
383   >>
384   \layout {
385   indent = #0
386   ragged-right = ##t
387   }
388 }
389 @end lilypond
390
391 @cindex harmonic indications in tablature notation
392 @cindex tablature and harmonic indications
393 @funindex \harmonic
394 @funindex \harmonicByFret
395 @funindex \harmonicByRatio
396
397 Harmonic indications can be added to tablature notation as sounding
398 pitches:
399
400 @lilypond[verbatim,quote]
401 \layout { \omit Voice.StringNumber }
402 firstHarmonic = {
403   d'4\4\harmonic
404   g'4\3\harmonic
405   b'2\2\harmonic
406 }
407 \score {
408   <<
409     \new Staff {
410       \clef "treble_8"
411       \firstHarmonic
412     }
413     \new TabStaff { \firstHarmonic }
414   >>
415 }
416 @end lilypond
417
418 Note that the command @code{\harmonic} must always be attached to single
419 notes (possibly inside of a chord) instead of whole chords.
420 It only makes sense for open-string harmonics
421 in the 12th fret. All other harmonics should be calculated by LilyPond.
422 This can be achieved by indicating the fret where a finger of the
423 fretting hand should touch a string.
424
425 @lilypond[verbatim,quote]
426 fretHarmonics = {
427   \harmonicByFret #5 d16\4
428   \harmonicByFret #4 d16\4
429   \harmonicByFret #3 d8\4
430   \harmonicByFret #5 <g\3 b\2>2.
431 }
432 \score {
433   <<
434     \new Staff {
435       \clef "treble_8"
436       \fretHarmonics
437     }
438     \new TabStaff { \fretHarmonics }
439   >>
440 }
441 @end lilypond
442
443 Alternatively, harmonics can be computed by defining the ratio of
444 string lengths above and below the harmonic fingering.
445
446 @lilypond[verbatim,quote]
447 ratioHarmonics = {
448   \harmonicByRatio #1/2 <g\3 b\2 e'\1>4
449   \harmonicByRatio #1/3 <g\3 b\2 e'\1>4
450   \harmonicByRatio #1/4 { g8\3 b8\2 e'4\1 }
451 }
452 \score {
453   <<
454     \new Staff {
455       \clef "treble_8"
456       \ratioHarmonics
457     }
458     \new TabStaff { \ratioHarmonics }
459   >>
460 }
461 @end lilypond
462
463 @snippets
464 @lilypondfile[verbatim,quote,texidoc,doctitle]
465 {stem-and-beam-behavior-in-tablature.ly}
466
467 @lilypondfile[verbatim,quote,texidoc,doctitle]
468 {polyphony-in-tablature.ly}
469
470 @lilypondfile[verbatim,quote,texidoc,doctitle]
471 {open-string-harmonics-in-tablature.ly}
472
473 @lilypondfile[verbatim,quote,texidoc,doctitle]
474 {fretted-string-harmonics-in-tablature.ly}
475
476 @cindex slides in tablature notation
477 @cindex tablature and slides
478
479 @lilypondfile[verbatim,quote,texidoc,doctitle]
480 {slides-in-tablature.ly}
481
482 @cindex chord glissandi
483
484 @lilypondfile[verbatim,quote,texidoc,doctitle]
485 {chord-glissando-in-tablature.ly}
486
487 @cindex hammer on
488 @cindex pull off
489
490 @lilypondfile[verbatim,quote,texidoc,doctitle]
491 {hammer-on-and-pull-off.ly}
492
493 @lilypondfile[verbatim,quote,texidoc,doctitle]
494 {hammer-on-and-pull-off-using-voices.ly}
495
496 @lilypondfile[verbatim,quote,texidoc,doctitle]
497 {hammer-on-and-pull-off-using-chords.ly}
498
499 @seealso
500 Notation Reference:
501 @ref{Chord repetition},
502 @ref{Glissando},
503 @ref{Harmonics},
504 @ref{Stems},
505 @ref{Written-out repeats}.
506
507 Snippets:
508 @rlsr{Fretted strings}.
509
510 Internals Reference:
511 @rinternals{TabNoteHead},
512 @rinternals{TabStaff},
513 @rinternals{TabVoice},
514 @rinternals{Beam}.
515
516 @knownissues
517 Chords are not handled in a special way, and hence the automatic
518 string selector may easily select the same string for two notes in
519 a chord.
520
521 In order to handle @code{\partcombine}, a @code{TabStaff} must use
522 specially-created voices:
523
524 @lilypond[quote,ragged-right,verbatim]
525 melodia = \partcombine { e4 g g g } { e4 e e e }
526 <<
527   \new TabStaff <<
528     \new TabVoice = "one" s1
529     \new TabVoice = "two" s1
530     \new TabVoice = "shared" s1
531     \new TabVoice = "solo" s1
532     { \melodia }
533   >>
534 >>
535 @end lilypond
536
537 Guitar special effects are limited to harmonics and slides.
538
539
540 @node Custom tablatures
541 @unnumberedsubsubsec Custom tablatures
542
543 @cindex tablatures, custom
544 @cindex tablature, banjo
545 @cindex tablature, mandolin
546 @cindex tablature, guitar
547 @cindex tablature, bass guitar
548 @cindex tablature, ukulele
549 @cindex tablature, predefined string tunings
550 @cindex fretted instruments, predefined string tunings
551 @cindex predefined string tunings for fretted instruments
552 @cindex tablature, violin
553 @cindex tablature, viola
554 @cindex tablature, cello
555 @cindex tablature, bass
556 @cindex tablature, double bass
557
558 @funindex stringTunings
559
560 LilyPond tablature automatically calculates the fret for
561 a note based on the string to which the note is assigned.
562 In order to do this, the tuning of the strings must be
563 specified.  The tuning of the strings is given in the
564 @code{stringTunings} property.
565
566 LilyPond comes with predefined string tunings for banjo, mandolin,
567 guitar, bass guitar, ukulele, violin, viola, cello, and double bass.
568 LilyPond automatically sets
569 the correct transposition for predefined tunings.  The following
570 example is for bass guitar, which sounds an octave lower than
571 written.
572
573 @lilypond[quote,ragged-right,verbatim]
574 <<
575   \new Voice \with {
576     \omit StringNumber
577   } {
578     \clef "bass_8"
579     \relative {
580       c,4 d e f
581     }
582   }
583   \new TabStaff \with {
584     stringTunings = #bass-tuning
585   } {
586     \relative {
587       c,4 d e f
588     }
589   }
590 >>
591 @end lilypond
592
593 The default string tuning is @code{guitar-tuning}, which
594 is the standard EADGBE tuning.  Some other predefined tunings are
595 @code{guitar-open-g-tuning}, @code{mandolin-tuning} and
596 @code{banjo-open-g-tuning}.  The predefined string tunings
597 are found in @file{ly/string-tunings-init.ly}.
598
599 @funindex stringTuning
600 @funindex \stringTuning
601 @cindex tablature, custom string tunings
602 @cindex custom string tunings
603
604 Any desired string tuning can be created.  The
605 @code{\stringTuning} function can be
606 used to define a string tuning which can be used
607 to set @code{stringTunings} for the current context.
608
609 Its argument is a chord construct
610 defining the pitches of each string in the tuning.
611 The chord construct must be in absolute octave mode,
612 see @ref{Absolute octave entry}.  The string
613 with the highest number (generally the lowest string) must
614 come first in the chord.  For example, we can
615 define a string tuning for a four-string instrument with pitches
616 of @code{a''},  @code{d''},  @code{g'}, and @code{c'}:
617
618 @lilypond[quote,verbatim]
619
620 mynotes = {
621   c'4 e' g' c'' |
622   e''4 g'' b'' c'''
623 }
624
625 <<
626   \new Staff {
627     \clef treble
628     \mynotes
629   }
630   \new TabStaff {
631     \set Staff.stringTunings = \stringTuning <c' g' d'' a''>
632     \mynotes
633   }
634 >>
635 @end lilypond
636
637 The @code{stringTunings} property is also used by
638 @code{FretBoards} to calculate automatic fret diagrams.
639
640 String tunings are used as part of the hash key
641 for predefined fret diagrams
642 (see @ref{Predefined fret diagrams}).
643
644 The previous example could also be written as follows:
645
646 @lilypond[quote,verbatim]
647 custom-tuning = \stringTuning <c' g' d'' a''>
648
649 mynotes = {
650   c'4 e' g' c'' |
651   e''4 g'' b'' c'''
652 }
653
654 <<
655   \new Staff {
656     \clef treble
657     \mynotes
658   }
659   \new TabStaff {
660     \set TabStaff.stringTunings = #custom-tuning
661     \mynotes
662   }
663 >>
664 @end lilypond
665
666 Internally, a string tuning is a Scheme list of string pitches,
667 one for each string, ordered by string number from 1 to N,
668 where string 1 is at the top of the tablature staff and
669 string N is at the bottom.  This ordinarily results in ordering
670 from highest pitch to lowest pitch, but some instruments
671 (e.g. ukulele) do not have strings ordered by pitch.
672
673 A string pitch in a string tuning list is a LilyPond pitch
674 object.  Pitch objects are created with the Scheme function
675 @code{ly:make-pitch} (see @ref{Scheme functions}).
676
677 @code{\stringTuning} creates such an object from chord input.
678
679 LilyPond automatically calculates the number of lines in the
680 @code{TabStaff} and the number of strings in an automatically
681 calculated @code{FretBoard} as the number of elements
682 in @code{stringTunings}.
683
684 To let all TabStaff contexts use the same custom tuning by default,
685 you can use
686
687 @example
688 \layout @{
689   \context @{
690     \TabStaff
691     stringTunings = \stringTuning <c' g' d'' a''>
692   @}
693 @}
694 @end example
695
696
697 @cindex moderntab clef
698 @cindex clef, moderntab
699 @cindex clef, tab
700 @cindex tab clef
701
702 A modern tab clef can also be used.
703
704 @lilypond[quote,ragged-right,verbatim]
705 \new TabStaff {
706   \clef moderntab
707   <a, e a>1
708   \break
709   \clef tab
710   <a, e a>1
711 }
712 @end lilypond
713
714 The modern tab clef supports tablatures from 4 to 7 strings.
715
716 @cindex micro-tones, tab
717 @cindex quarter-tones, tab
718 @cindex tab micro-tones
719 @cindex tab quarter-tones
720
721 @code{TabStaff} may support micro-tones like quarter-tones, which
722 can be played using bendings.
723 @code{supportNonIntegerFret = ##t} needs to be set in
724 Score-context.  However, micro-tones are not supported in @code{FretBoards}.
725
726 @lilypond[quote,ragged-right,verbatim]
727 \layout {
728   \context {
729     \Score
730     supportNonIntegerFret = ##t
731   }
732 }
733
734 custom-tuning = \stringTuning <e, a, d ges beh eeh'>
735
736 mus = \relative {
737   eeses'4
738   eeseh
739   ees
740   eeh
741   e
742   eih
743   eis
744   eisih
745   eisis
746 }
747
748 <<
749   \new Staff << \clef "G_8" \mus >>
750   \new TabStaff \with { stringTunings = \custom-tuning } \mus
751 >>
752 @end lilypond
753
754 @seealso
755 Notation Reference:
756 @ref{Absolute octave entry},
757 @ref{Predefined fret diagrams},
758 @ref{Scheme functions}.
759
760 Installed Files:
761 @file{ly/string-tunings-init.ly},
762 @file{scm/tablature.scm}.
763
764 Snippets:
765 @rlsr{Fretted strings}.
766
767 Internals Reference:
768 @rinternals{Tab_note_heads_engraver}.
769
770 @knownissues
771 Automatic tablature calculations do not work properly in most
772 cases for instruments where string pitches do not vary
773 monotonically with string number, such as ukuleles.
774
775
776 @node Fret diagram markups
777 @unnumberedsubsubsec Fret diagram markups
778
779 @cindex fret diagrams
780 @cindex chord diagrams
781 @cindex diagrams, fret
782 @cindex diagrams, chord for fretted instruments
783 @cindex fret diagrams, custom
784 @cindex custom fret diagrams
785
786 Fret diagrams can be added to music as a markup to the desired
787 note.  The markup contains information about the desired fret
788 diagram.  There are three different fret-diagram markup
789 interfaces: standard, terse, and verbose.  The three interfaces
790 produce equivalent markups, but have varying amounts of
791 information in the markup string.  Details about the
792 syntax of the different markup strings used to define
793 fret diagrams are found at @ref{Instrument Specific Markup}.
794
795 The standard fret diagram markup string indicates the string
796 number and the fret number for each dot to be placed on the string.
797 In addition, open and unplayed (muted) strings can be indicated.
798
799 @lilypond[quote, verbatim]
800 <<
801   \new ChordNames {
802     \chordmode {
803       c1 d:m
804     }
805   }
806   \new Staff {
807     \clef "treble_8"
808     <c e g c' e'>1^\markup {
809       \fret-diagram #"6-x;5-3;4-2;3-o;2-1;1-o;"
810     }
811     <d a d' f'>1^\markup {
812       \fret-diagram #"6-x;5-x;4-o;3-2;2-3;1-1;"
813     }
814   }
815 >>
816 @end lilypond
817
818 @cindex barre indications
819
820 Barre indications can be added to the diagram from
821 the fret-diagram markup string.
822
823 @lilypond[quote, verbatim]
824 <<
825   \new ChordNames {
826      \chordmode {
827        f1 g
828      }
829   }
830   \new Staff {
831     \clef "treble_8"
832     <f, c f a c' f'>1^\markup {
833       \fret-diagram #"c:6-1-1;6-1;5-3;4-3;3-2;2-1;1-1;"
834     }
835     <g, d g b d' g'>1^\markup {
836       \fret-diagram #"c:6-1-3;6-3;5-5;4-5;3-4;2-3;1-3;"
837     }
838   }
839 >>
840 @end lilypond
841
842 @cindex fret-diagram markup
843 @cindex ukulele
844
845 @funindex fret-diagram
846 @funindex \fret-diagram
847
848 The size of the fret diagram, and the number of frets in the diagram
849 can be changed in the fret-diagram markup string.
850
851 @lilypond[quote, verbatim]
852 <<
853   \new ChordNames {
854      \chordmode {
855        f1 g
856      }
857   }
858   \new Staff {
859     \clef "treble_8"
860     <f, c f a c' f'>1^\markup {
861       \fret-diagram #"s:1.5;c:6-1-1;6-1;5-3;4-3;3-2;2-1;1-1;"
862     }
863     <g, b, d g b g'>1^\markup {
864       \fret-diagram #"h:6;6-3;5-2;4-o;3-o;2-o;1-3;"
865     }
866   }
867 >>
868 @end lilypond
869
870 The number of strings in a fret diagram can be changed to accommodate
871 different instruments such as banjos and ukuleles with the fret-diagram
872 markup string.
873
874 @lilypond[quote, verbatim]
875 <<
876   \new ChordNames {
877     \chordmode {
878       a1
879     }
880   }
881   \new Staff {
882     % An 'A' chord for ukulele
883     a'1^\markup {
884       \fret-diagram #"w:4;4-2-2;3-1-1;2-o;1-o;"
885     }
886   }
887 >>
888 @end lilypond
889
890 Fingering indications can be added, and the location of fingering labels
891 can be controlled by the fret-diagram markup string.
892
893 @lilypond[quote, verbatim]
894 <<
895   \new ChordNames {
896     \chordmode {
897       c1 d:m
898     }
899   }
900   \new Staff {
901     \clef "treble_8"
902     <c e g c' e'>1^\markup {
903       \fret-diagram #"f:1;6-x;5-3-3;4-2-2;3-o;2-1-1;1-o;"
904     }
905     <d a d' f'>1^\markup {
906       \fret-diagram #"f:2;6-x;5-x;4-o;3-2-2;2-3-3;1-1-1;"
907     }
908   }
909 >>
910 @end lilypond
911
912 Dot radius and dot position can be controlled with the fret-diagram
913 markup string.
914
915 @lilypond[quote, verbatim]
916 <<
917   \new ChordNames {
918     \chordmode {
919       c1 d:m
920     }
921   }
922   \new Staff {
923     \clef "treble_8"
924     <c e g c' e'>1^\markup {
925       \fret-diagram #"d:0.35;6-x;5-3;4-2;3-o;2-1;1-o;"
926     }
927     <d a d' f'>1^\markup {
928       \fret-diagram #"p:0.2;6-x;5-x;4-o;3-2;2-3;1-1;"
929     }
930   }
931 >>
932 @end lilypond
933
934 @cindex fret-diagram-terse markup
935
936 @funindex fret-diagram-terse
937 @funindex \fret-diagram-terse
938
939 The fret-diagram-terse markup string omits string numbers; the string
940 number is implied by the presence of semicolons.  There is one semicolon
941 for each string in the diagram.  The first semicolon corresponds to the
942 highest string number and the last semicolon corresponds to the first string.
943 Mute strings, open strings, and fret numbers can be indicated.
944
945 @lilypond[quote, verbatim]
946 <<
947   \new ChordNames {
948     \chordmode {
949       c1 d:m
950     }
951   }
952   \new Staff {
953     \clef "treble_8"
954     <c e g c' e'>1^\markup {
955       \fret-diagram-terse #"x;3;2;o;1;o;"
956     }
957     <d a d' f'>1^\markup {
958       \fret-diagram-terse #"x;x;o;2;3;1;"
959     }
960   }
961 >>
962 @end lilypond
963
964 Barre indicators can be included in the fret-diagram-terse markup string.
965
966 @lilypond[quote, verbatim]
967 <<
968   \new ChordNames {
969     \chordmode {
970       f1 g
971     }
972   }
973   \new Staff {
974     \clef "treble_8"
975     <f, c f a c' f'>1^\markup {
976       \fret-diagram-terse #"1-(;3;3;2;1;1-);"
977     }
978     <g, d g b d' g'>1^\markup {
979       \fret-diagram-terse #"3-(;5;5;4;3;3-);"
980     }
981   }
982 >>
983 @end lilypond
984
985 Fingering indications can be included in the fret-diagram-terse markup string.
986
987 @c Need to use override to enable fingerings to show this -- can we do so?
988 @lilypond[quote, verbatim]
989 <<
990   \new ChordNames {
991     \chordmode {
992       c1 d:m
993     }
994   }
995   \new Staff {
996     \override Voice.TextScript.fret-diagram-details.finger-code = #'below-string
997     \clef "treble_8"
998     <c e g c' e'>1^\markup {
999       \fret-diagram-terse #"x;3-3;2-2;o;1-1;o;"
1000     }
1001     <d a d' f'>1^\markup {
1002       \fret-diagram-terse #"x;x;o;2-2;3-3;1-1;"
1003     }
1004   }
1005 >>
1006 @end lilypond
1007
1008 Other fret diagram properties must be adjusted using
1009 @code{\override} when using the fret-diagram-terse markup.
1010
1011 @cindex fret-diagram-verbose markup
1012 @cindex capo
1013
1014 @funindex fret-diagram-verbose
1015 @funindex \fret-diagram-verbose
1016
1017 The fret-diagram-verbose markup string is in the format of a Scheme list.  Each
1018 element of the list indicates an item to be placed on the fret diagram.
1019
1020 @lilypond[quote, verbatim]
1021 <<
1022     \new ChordNames {
1023       \chordmode {
1024         c1 d:m
1025       }
1026     }
1027   \new Staff {
1028     \clef "treble_8"
1029     <c e g c' e'>1^\markup {
1030       \fret-diagram-verbose #'(
1031         (mute 6)
1032         (place-fret 5 3)
1033         (place-fret 4 2)
1034         (open 3)
1035         (place-fret 2 1)
1036         (open 1)
1037       )
1038     }
1039     <d a d' f'>1^\markup {
1040       \fret-diagram-verbose #'(
1041         (mute 6)
1042         (mute 5)
1043         (open 4)
1044         (place-fret 3 2)
1045         (place-fret 2 3)
1046         (place-fret 1 1)
1047       )
1048     }
1049   }
1050 >>
1051 @end lilypond
1052
1053 Fingering indications and barres can be included in a
1054 fret-diagram-verbose markup string.  Unique to the
1055 fret-diagram-verbose interface is a capo indication that
1056 can be placed on the fret diagram.  The capo indication is
1057 a thick bar that covers all strings.  The fret with the
1058 capo will be the lowest fret in the fret diagram.
1059
1060 Fingering indication dots can be colored as well as parenthesized;
1061 the parenthesis's color can also be altered independently.
1062
1063 Markups can be placed into the dots as well.
1064
1065 @c \override is necessary to make fingering visible
1066 @lilypond[quote, verbatim]
1067 <<
1068     \new ChordNames {
1069       \chordmode {
1070         f1 g c c b
1071       }
1072     }
1073   \new Staff {
1074     \clef "treble_8"
1075     \override Voice.TextScript.fret-diagram-details.finger-code = #'below-string
1076     <f, c f a c' f'>1^\markup {
1077       \fret-diagram-verbose #'(
1078         (place-fret 6 1)
1079         (place-fret 5 3)
1080         (place-fret 4 3)
1081         (place-fret 3 2)
1082         (place-fret 2 1)
1083         (place-fret 1 1)
1084         (barre 6 1 1)
1085       )
1086     }
1087     <g, b, d g b g'>1^\markup {
1088       \fret-diagram-verbose #'(
1089         (place-fret 6 3 2)
1090         (place-fret 5 2 1)
1091         (open 4)
1092         (open 3)
1093         (open 2)
1094         (place-fret 1 3 3)
1095       )
1096     }
1097     <c g c' e' g'>1^\markup {
1098       \fret-diagram-verbose #'(
1099         (capo 3)
1100         (mute 6)
1101         (place-fret 4 5 1)
1102         (place-fret 3 5 2)
1103         (place-fret 2 5 3)
1104       )
1105     }
1106     \override Voice.TextScript.size = 1.4
1107     <c g c' e' g'>1^\markup {
1108       \fret-diagram-verbose #'(
1109         (place-fret 6 3 1 red parenthesized default-paren-color)
1110         (place-fret 5 3 1 inverted)
1111         (place-fret 4 5 2 blue parenthesized)
1112         (place-fret 3 5 3 blue)
1113         (place-fret 2 5 4 blue)
1114         (place-fret 1 3 1 inverted)
1115       )
1116     }
1117     \override Voice.TextScript.size = 1.5
1118     <b, fis b dis' fis'>1^\markup {
1119       \override #'(fret-diagram-details . ((finger-code . in-dot)))
1120       \fret-diagram-verbose #`(
1121         (place-fret 5 2 1)
1122         (place-fret 4 4 "fis" red)
1123         (place-fret 3 4 "b" red)
1124         (place-fret
1125           2 4
1126           ,#{ \markup
1127                 \concat {
1128                   \vcenter "d"
1129                   \fontsize #-5
1130                   \musicglyph #"accidentals.sharp"} #}
1131           red)
1132         (place-fret 1 2 1)
1133       )
1134     }
1135   }
1136 >>
1137 @end lilypond
1138
1139 All other fret diagram properties must be adjusted using
1140 @code{\override} when using the fret-diagram-verbose markup.
1141
1142 @ignore
1143 The following example shows the three fret-diagram markup
1144 interfaces, along with examples of common tweaks.  For example,
1145 the size of the verbose fret diagram is reduced to 0.75, and the
1146 finger indications are specified to appear below the diagram.  The
1147 terse diagram includes tweaks to specify placement of finger code
1148 and color of dots.
1149
1150 @lilypond[verbatim,ragged-right,quote]
1151 \new Voice {
1152   \clef "treble_8"
1153   d4^\markup {
1154     \fret-diagram #"6-x;5-x;4-o;3-2;2-3;1-2;"
1155   }
1156   d4 d d
1157   fis^\markup {
1158     \override #'(size . 0.75) {
1159       \override #'(finger-code . below-string) {
1160         \fret-diagram-verbose #'((place-fret 6 2 1) (barre 6 1 2)
1161                                  (place-fret 5 4 3)
1162                                  (place-fret 4 4 4)
1163                                  (place-fret 3 3 2)
1164                                  (place-fret 2 2 1)
1165                                  (place-fret 1 2 1))
1166       }
1167     }
1168   }
1169   fis4 fis fis
1170   c^\markup {
1171     \override #'(dot-radius . 0.35) {
1172       \override #'(finger-code . in-dot) {
1173         \override #'(dot-color . white) {
1174           \fret-diagram-terse #"x;3-1-(;5-2;5-3;5-4;3-1-);"
1175         }
1176       }
1177     }
1178   }
1179   c4 c c
1180 }
1181 @end lilypond
1182 @end ignore
1183
1184 @cindex customized fret diagram
1185 @cindex fret diagram, customized
1186 @cindex diagram, fret, customized
1187
1188 @funindex fret-diagram-interface
1189
1190 The graphical layout of a fret diagram can be customized according to
1191 user preference through the properties of the
1192 @code{fret-diagram-interface}. Details are found at
1193 @rinternals{fret-diagram-interface}.  For a fret diagram
1194 markup, the interface properties belong to @code{Voice.TextScript}.
1195
1196 @snippets
1197
1198 @lilypondfile[verbatim,quote,texidoc,doctitle]
1199 {changing-fret-orientations.ly}
1200
1201 @lilypondfile[verbatim,quote,texidoc,doctitle]
1202 {customizing-markup-fret-diagrams.ly}
1203
1204 @seealso
1205 Notation Reference:
1206 @ref{Instrument Specific Markup}.
1207
1208 Snippets:
1209 @rlsr{Fretted strings}.
1210
1211 Internals Reference:
1212 @rinternals{fret-diagram-interface}.
1213
1214
1215 @node Predefined fret diagrams
1216 @unnumberedsubsubsec Predefined fret diagrams
1217
1218 @cindex fret diagrams
1219 @cindex fret diagrams, ukulele
1220 @cindex fret diagrams, mandolin
1221 @cindex chord diagrams
1222
1223 @funindex FretBoards
1224 @funindex stringTunings
1225
1226 Fret diagrams can be displayed using the @code{FretBoards} context.  By
1227 default, the @code{FretBoards} context will display fret diagrams that
1228 are stored in a lookup table:
1229
1230 @lilypond[verbatim, ragged-right, quote]
1231 \include "predefined-guitar-fretboards.ly"
1232 \new FretBoards {
1233   \chordmode {
1234     c1 d
1235   }
1236 }
1237 @end lilypond
1238
1239 The default predefined fret diagrams are contained in the file
1240 @file{predefined-guitar-fretboards.ly}.  Fret diagrams are
1241 stored based on the pitches of a chord and the value of
1242 @code{stringTunings} that is currently in use.
1243 @file{predefined-guitar-fretboards.ly} contains predefined
1244 fret diagrams only for @code{guitar-tuning}.  Predefined fret
1245 diagrams can be added for other instruments or other tunings
1246 by following the examples found in
1247 @file{predefined-guitar-fretboards.ly}.
1248
1249 Fret diagrams for the ukulele are contained in the file @*
1250 @file{predefined-ukulele-fretboards.ly}.
1251
1252 @lilypond[verbatim, ragged-right, quote]
1253 \include "predefined-ukulele-fretboards.ly"
1254
1255 myChords = \chordmode { a1 a:m a:aug }
1256
1257 \new ChordNames {
1258   \myChords
1259 }
1260
1261 \new FretBoards {
1262   \set Staff.stringTunings = #ukulele-tuning
1263   \myChords
1264 }
1265 @end lilypond
1266
1267 Fret diagrams for the mandolin are contained in the file @*
1268 @file{predefined-mandolin-fretboards.ly}.
1269
1270 @lilypond[verbatim, ragged-right, quote]
1271 \include "predefined-mandolin-fretboards.ly"
1272
1273 myChords = \chordmode { c1 c:m7.5- c:aug }
1274
1275 \new ChordNames {
1276   \myChords
1277 }
1278
1279 \new FretBoards {
1280   \set Staff.stringTunings = #mandolin-tuning
1281   \myChords
1282 }
1283 @end lilypond
1284
1285 Chord pitches can be entered
1286 either as simultaneous music or using chord mode (see
1287 @ref{Chord mode overview}).
1288
1289 @lilypond[verbatim, ragged-right,quote]
1290 \include "predefined-guitar-fretboards.ly"
1291 \new FretBoards {
1292   \chordmode { c1 }
1293   <c' e' g'>1
1294 }
1295 @end lilypond
1296
1297 @cindex chord names with fret diagrams
1298 @cindex fret diagrams with chord names
1299
1300 @funindex ChordNames
1301 @funindex chordmode
1302 @funindex \chordmode
1303
1304 It is common that both chord names and fret diagrams are displayed together.
1305 This is achieved by putting a @code{ChordNames} context in parallel with
1306 a @code{FretBoards} context and giving both contexts the same music.
1307
1308 @lilypond[verbatim, ragged-right, quote]
1309 \include "predefined-guitar-fretboards.ly"
1310 mychords = \chordmode{
1311   c1 f g
1312 }
1313
1314 <<
1315   \new ChordNames {
1316     \mychords
1317   }
1318   \new FretBoards {
1319     \mychords
1320   }
1321 >>
1322 @end lilypond
1323
1324 @cindex transposing fret diagrams
1325 @cindex fret diagrams, transposing
1326 @cindex diagrams, fret, transposing
1327
1328 Predefined fret diagrams are transposable, as long as a diagram for the
1329 transposed chord is stored in the fret diagram table.
1330
1331 @lilypond[verbatim, ragged-right, quote]
1332 \include "predefined-guitar-fretboards.ly"
1333 mychords = \chordmode{
1334   c1 f g
1335 }
1336
1337 mychordlist = {
1338   \mychords
1339   \transpose c e { \mychords }
1340 }
1341 <<
1342   \new ChordNames {
1343     \mychordlist
1344   }
1345   \new FretBoards {
1346     \mychordlist
1347   }
1348 >>
1349 @end lilypond
1350
1351
1352 The predefined fret diagram table for guitar contains eight chords (major, minor,
1353 augmented, diminished, dominant seventh, major seventh, minor seventh, dominant ninth)
1354 for each of 17 keys.
1355 The predefined fret diagram table for ukulele contains these chords
1356 plus an additional three chords (major sixth, suspended second, and
1357 suspended fourth).
1358 A complete list of the predefined fret diagrams is
1359 shown in @ref{Predefined fretboard diagrams}.  If there is no entry in
1360 the table for a chord, the FretBoards engraver will calculate a
1361 fret-diagram using the automatic fret diagram functionality described in
1362 @ref{Automatic fret diagrams}.
1363
1364 @lilypond[verbatim, ragged-right, quote]
1365 \include "predefined-guitar-fretboards.ly"
1366 mychords = \chordmode{
1367   c1 c:maj9
1368 }
1369
1370 <<
1371   \new ChordNames {
1372     \mychords
1373   }
1374   \new FretBoards {
1375     \mychords
1376   }
1377 >>
1378 @end lilypond
1379
1380 @cindex fret diagrams, adding custom
1381 @cindex custom fret diagrams, adding
1382 @cindex adding custom fret diagrams
1383
1384 Fret diagrams can be added to the fret diagram table.  To add a diagram,
1385 you must specify the hash table for the diagram, the chord for the
1386 diagram, the tuning to be used, and
1387 a definition for the diagram.  Normally, the hash table will be
1388 @var{default-fret-table}.  The diagram definition can be either a
1389 fret-diagram-terse definition string or a fret-diagram-verbose
1390 marking list.
1391
1392 @lilypond[verbatim, ragged-right, quote]
1393 \include "predefined-guitar-fretboards.ly"
1394
1395 \storePredefinedDiagram #default-fret-table
1396                         \chordmode { c:maj9 }
1397                         #guitar-tuning
1398                         #"x;3-2;o;o;o;o;"
1399
1400 mychords = \chordmode {
1401   c1 c:maj9
1402 }
1403
1404 <<
1405   \new ChordNames {
1406     \mychords
1407   }
1408   \new FretBoards {
1409     \mychords
1410   }
1411 >>
1412 @end lilypond
1413
1414 Different fret diagrams for the same chord name can be stored using different
1415 octaves of pitches.  The different octave should be at least two octaves
1416 above or below the default octave, because the octaves above and  below the
1417 default octave are used for transposing fretboards.
1418
1419 @lilypond[verbatim, ragged-right, quote]
1420 \include "predefined-guitar-fretboards.ly"
1421
1422 \storePredefinedDiagram #default-fret-table
1423                         \chordmode { c'' }
1424                         #guitar-tuning
1425                         #(offset-fret 2 (chord-shape 'bes guitar-tuning))
1426
1427 mychords = \chordmode {
1428   c1 c''
1429 }
1430
1431 <<
1432   \new ChordNames {
1433     \mychords
1434   }
1435   \new FretBoards {
1436     \mychords
1437   }
1438 >>
1439 @end lilypond
1440
1441 @cindex fretted instruments, chord shapes
1442 @cindex chord shapes for fretted instruments
1443
1444 @funindex \addChordShape
1445 @funindex addChordShape
1446 @funindex storePredefinedDiagram
1447 @funindex \storePredefinedDiagram
1448
1449 In addition to fret diagrams, LilyPond stores an internal list of chord
1450 shapes.  The chord shapes are fret diagrams that can be shifted along
1451 the neck to different positions to provide different chords.  Chord
1452 shapes can be added to the internal list and then used to define
1453 predefined fret diagrams.  Because they can be moved to various
1454 positions on the neck, chord shapes will normally not contain
1455 any open strings.  Like fret diagrams, chord shapes can be
1456 entered as either fret-diagram-terse strings or fret-diagram-verbose
1457 marking lists.
1458
1459 @lilypond[verbatim, ragged-right, quote]
1460 \include "predefined-guitar-fretboards.ly"
1461
1462 % Add a new chord shape
1463
1464 \addChordShape #'powerf #guitar-tuning #"1-1;3-3;3-4;x;x;x;"
1465
1466 % add some new chords based on the power chord shape
1467
1468 \storePredefinedDiagram #default-fret-table
1469                         \chordmode { f'' }
1470                         #guitar-tuning
1471                         #(chord-shape 'powerf guitar-tuning)
1472 \storePredefinedDiagram #default-fret-table
1473                         \chordmode { g'' }
1474                         #guitar-tuning
1475                         #(offset-fret 2 (chord-shape 'powerf guitar-tuning))
1476
1477 mychords = \chordmode{
1478   f1 f'' g g''
1479 }
1480
1481 <<
1482   \new ChordNames {
1483     \mychords
1484   }
1485   \new FretBoards {
1486     \mychords
1487   }
1488 >>
1489 @end lilypond
1490
1491 The graphical layout of a fret diagram can be customized according to
1492 user preference through the properties of the
1493 @code{fret-diagram-interface}. Details are found at
1494 @rinternals{fret-diagram-interface}.  For a predefined fret diagram,
1495 the interface properties belong to @code{FretBoards.FretBoard}.
1496
1497 @snippets
1498
1499 @lilypondfile[verbatim,quote,texidoc,doctitle]
1500 {customizing-fretboard-fret-diagrams.ly}
1501
1502 @lilypondfile[verbatim,quote,texidoc,doctitle]
1503 {defining-predefined-fretboards-for-other-instruments.ly}
1504
1505 @lilypondfile[verbatim,quote,texidoc,doctitle,ragged-right]
1506 {chordchanges-for-fretboards.ly}
1507
1508 @lilypondfile[verbatim,quote,texidoc,doctitle]
1509 {fretboards-alternate-tables.ly}
1510
1511 @seealso
1512 Notation Reference:
1513 @ref{Custom tablatures},
1514 @ref{Automatic fret diagrams},
1515 @ref{Chord mode overview},
1516 @ref{Predefined fretboard diagrams}.
1517
1518 Installed Files:
1519 @file{ly/predefined-guitar-fretboards.ly}, @*
1520 @file{ly/predefined-guitar-ninth-fretboards.ly}, @*
1521 @file{ly/predefined-ukulele-fretboards.ly}, @*
1522 @file{ly/predefined-mandolin-fretboards.ly}.
1523
1524 Snippets:
1525 @rlsr{Fretted strings}.
1526
1527 Internals Reference:
1528 @rinternals {fret-diagram-interface}.
1529
1530
1531 @node Automatic fret diagrams
1532 @unnumberedsubsubsec Automatic fret diagrams
1533
1534 @cindex fret diagrams, automatic
1535 @cindex chord diagrams, automatic
1536 @cindex automatic fret diagrams
1537 @cindex automatic chord diagrams
1538
1539 Fret diagrams can be automatically created from entered notes using the
1540 @code{FretBoards} context.  If no predefined diagram is available for
1541 the entered notes in the active @code{stringTunings}, this context
1542 calculates strings and frets that can be used to play the notes.
1543
1544 @lilypond[quote,ragged-right,verbatim]
1545 <<
1546   \new ChordNames {
1547     \chordmode {
1548       f1 g
1549     }
1550   }
1551   \new FretBoards {
1552     <f, c f a c' f'>1
1553     <g,\6 b, d g b g'>1
1554   }
1555   \new Staff {
1556     \clef "treble_8"
1557     <f, c f a c' f'>1
1558     <g, b, d g b' g'>1
1559   }
1560 >>
1561 @end lilypond
1562
1563 @funindex predefinedFretboardsOff
1564 @funindex \predefinedFretboardsOff
1565 @funindex predefinedFretboardsOn
1566 @funindex \predefinedFretboardsOn
1567
1568 As no predefined diagrams are loaded by default, automatic calculation
1569 of fret diagrams is the default behavior.  Once default diagrams are
1570 loaded, automatic calculation can be enabled and disabled with predefined
1571 commands:
1572
1573 @lilypond[quote,ragged-right,verbatim]
1574
1575 \storePredefinedDiagram #default-fret-table
1576                         <c e g c' e'>
1577                         #guitar-tuning
1578                         #"x;3-1-(;5-2;5-3;5-4;3-1-1-);"
1579 <<
1580   \new ChordNames {
1581     \chordmode {
1582       c1 c c
1583     }
1584   }
1585   \new FretBoards {
1586     <c e g c' e'>1
1587     \predefinedFretboardsOff
1588     <c e g c' e'>1
1589     \predefinedFretboardsOn
1590     <c e g c' e'>1
1591   }
1592   \new Staff {
1593     \clef "treble_8"
1594     <c e g c' e'>1
1595     <c e g c' e'>1
1596     <c e g c' e'>1
1597   }
1598 >>
1599 @end lilypond
1600
1601
1602
1603 Sometimes the fretboard calculator will be unable to find
1604 an acceptable diagram.  This can often be remedied by
1605 manually assigning a note to a string.  In many cases, only one
1606 note need be manually placed on a string; the rest of
1607 the notes will then be placed appropriately by the
1608 @code{FretBoards} context.
1609
1610 @cindex fret diagrams, adding fingerings
1611 @cindex fingerings, adding to fret diagrams
1612
1613 Fingerings can be added to FretBoard fret diagrams.
1614
1615 @lilypond[quote, verbatim]
1616 <<
1617   \new ChordNames {
1618     \chordmode {
1619       c1 d:m
1620     }
1621   }
1622   \new FretBoards {
1623     <c-3 e-2 g c'-1 e'>1
1624     <d a-2 d'-3 f'-1>1
1625   }
1626   \new Staff {
1627     \clef "treble_8"
1628     <c e g c' e'>1
1629     <d a d' f'>1
1630   }
1631 >>
1632 @end lilypond
1633
1634 @funindex minimumFret
1635
1636 The minimum fret to be used in calculating strings and frets for
1637 the FretBoard context can be set with the @code{minimumFret}
1638 property.
1639
1640 @lilypond[quote, verbatim]
1641 <<
1642   \new ChordNames {
1643     \chordmode {
1644       d1:m d:m
1645     }
1646   }
1647   \new FretBoards {
1648     <d a d' f'>1
1649     \set FretBoards.minimumFret = #5
1650     <d a d' f'>1
1651   }
1652   \new Staff {
1653     \clef "treble_8"
1654     <d a d' f'>1
1655     <d a d' f'>1
1656   }
1657 >>
1658 @end lilypond
1659
1660 The strings and frets for the @code{FretBoards} context depend
1661 on the @code{stringTunings} property, which has the same meaning
1662 as in the TabStaff context.  See @ref{Custom tablatures} for
1663 information on the @code{stringTunings} property.
1664
1665 The graphical layout of a fret diagram can be customized according to
1666 user preference through the properties of the
1667 @code{fret-diagram-interface}. Details are found at
1668 @rinternals{fret-diagram-interface}.  For a @code{FretBoards} fret
1669 diagram, the interface properties belong to
1670 @code{FretBoards.FretBoard}.
1671
1672
1673 @predefined
1674 @code{\predefinedFretboardsOff},
1675 @code{\predefinedFretboardsOn}.
1676 @endpredefined
1677
1678 @seealso
1679 Notation Reference:
1680 @ref{Custom tablatures}.
1681
1682 Snippets:
1683 @rlsr{Fretted strings}.
1684
1685 Internals Reference:
1686 @rinternals {fret-diagram-interface}.
1687
1688 @knownissues
1689 Automatic fretboard calculations do not work properly for instruments
1690 with non-monotonic tunings.
1691
1692
1693 @node Right-hand fingerings
1694 @unnumberedsubsubsec Right-hand fingerings
1695
1696 @cindex fretted instruments, right hand fingerings
1697 @cindex fingerings, right hand for fretted instruments
1698 @cindex right hand fingerings for fretted instruments
1699
1700 @funindex rightHandFinger
1701 @funindex \rightHandFinger
1702
1703 Right-hand fingerings @var{p-i-m-a} must be entered using
1704 @code{\rightHandFinger} followed by a number.
1705
1706 @warning{If the number is entered in Scheme notation, remember to append
1707 a space before following it with a closing @code{>} or similar.}
1708
1709 @lilypond[quote,verbatim,fragment]
1710 \clef "treble_8"
1711 c4\rightHandFinger #1
1712 e\rightHandFinger #2
1713 g\rightHandFinger #3
1714 c'\rightHandFinger #4
1715 <c\rightHandFinger #1 e\rightHandFinger #2
1716  g\rightHandFinger #3 c'\rightHandFinger #4 >1
1717 @end lilypond
1718
1719 For convenience, you can abbreviate @code{\rightHandFinger} to something
1720 short, for example @code{RH},
1721
1722 @example
1723 RH=#rightHandFinger
1724 @end example
1725
1726
1727 @snippets
1728
1729 @lilypondfile[verbatim,quote,texidoc,doctitle]
1730 {placement-of-right-hand-fingerings.ly}
1731
1732 @lilypondfile[verbatim,quote,texidoc,doctitle]
1733 {fingerings,-string-indications,-and-right-hand-fingerings.ly}
1734
1735 @seealso
1736 Snippets:
1737 @rlsr{Fretted strings}.
1738
1739 Internals Reference:
1740 @rinternals{StrokeFinger}.
1741
1742
1743 @node Guitar
1744 @subsection Guitar
1745
1746 Most of the notational issues associated with guitar music are
1747 covered sufficiently in the general fretted strings section, but there
1748 are a few more worth covering here.  Occasionally users want to
1749 create songbook-type documents having only lyrics with chord
1750 indications above them.  Since LilyPond is a music typesetter,
1751 it is not recommended for documents that have no music notation
1752 in them.  A better alternative is a word processor, text editor,
1753 or, for experienced users, a typesetter like GuitarTeX.
1754
1755 @menu
1756 * Indicating position and barring::
1757 * Indicating harmonics and dampened notes::
1758 * Indicating power chords::
1759 @end menu
1760
1761 @node Indicating position and barring
1762 @unnumberedsubsubsec Indicating position and barring
1763
1764 @cindex indicating position and barring for fretted instruments
1765 @cindex fretted instruments, indicating position and barring
1766
1767 This example demonstrates how to include guitar position and
1768 barring indications.
1769
1770 @lilypond[quote,ragged-right,verbatim,fragment]
1771 \relative {
1772   \clef "treble_8"
1773   b,16 d g b e
1774   \textSpannerDown
1775   \override TextSpanner.bound-details.left.text = #"XII "
1776   g16\startTextSpan
1777   b16 e g e b g\stopTextSpan
1778   e16 b g d
1779 }
1780 @end lilypond
1781
1782 @seealso
1783 Notation Reference:
1784 @ref{Text spanners}.
1785
1786 Snippets:
1787 @rlsr{Fretted strings},
1788 @rlsr{Expressive marks}.
1789
1790
1791 @node Indicating harmonics and dampened notes
1792 @unnumberedsubsubsec Indicating harmonics and dampened notes
1793
1794 @cindex fretted instruments, dampened notes
1795 @cindex fretted instruments, harmonics
1796 @cindex dampened notes on fretted instruments
1797 @cindex harmonics on fretted instruments
1798
1799 Special note heads can be used to indicate dampened notes or
1800 harmonics.  Harmonics are normally further explained with a
1801 text markup.
1802
1803 @lilypond[quote,ragged-right,verbatim]
1804 \relative {
1805   \clef "treble_8"
1806   \override Staff.NoteHead.style = #'harmonic-mixed
1807   d'^\markup { \italic { \fontsize #-2 { "harm. 12" }}} <g b>1
1808 }
1809 @end lilypond
1810
1811 Dampened notes (also called @notation{dead notes}) are supported
1812 within normal and tablature staves:
1813
1814 @lilypond[quote,ragged-right,verbatim]
1815 music = \relative {
1816   < a\3 \deadNote c\2 a'\1 >4
1817   < b\3 \deadNote d\2 b'\1 >
1818   < c\3 \deadNote e\2 c'\1 >
1819   \deadNotesOn
1820   \tuplet 3/2 { g8 b e }
1821   \deadNotesOff
1822   < a,\3 c\2 e\1 >1
1823 }
1824 \new StaffGroup <<
1825   \new Staff {
1826     \clef "treble_8"
1827     \music
1828   }
1829   \new TabStaff {
1830     \music
1831   }
1832 >>
1833 @end lilypond
1834
1835 Another playing technique (especially used on electric guitars) is
1836 called @notation{palm mute}.  The string is hereby partly muted by the
1837 palm of the striking hand (hence the name).  Lilypond supports
1838 the notation of palm mute-style notes by changing the note head to a
1839 triangle shape.
1840
1841 @lilypond[quote,ragged-right,verbatim]
1842 \new Voice { % Warning: explicit Voice instantiation is
1843              %    required to have palmMuteOff work properly
1844              %    when palmMuteOn comes at the beginning of
1845              %    the piece.
1846   \relative c, {
1847     \clef "G_8"
1848     \palmMuteOn
1849     e8^\markup { \musicglyph #"noteheads.u2do"  = palm mute }
1850     < e b' e > e
1851     \palmMuteOff
1852     e e  \palmMute e e e |
1853     e8 \palmMute { e e e } e e e e |
1854     < \palmMute e b' e >8 \palmMute { e e e } < \palmMute e b' e >2
1855   }
1856 }
1857 @end lilypond
1858
1859 @seealso
1860 Snippets:
1861 @rlsr{Fretted strings}.
1862
1863 Notation Reference:
1864 @ref{Special note heads},
1865 @ref{Note head styles}.
1866
1867
1868 @node Indicating power chords
1869 @unnumberedsubsubsec Indicating power chords
1870
1871 @funindex powerChords
1872 @funindex \powerChords
1873
1874 @cindex power chords
1875 @cindex chords, power
1876
1877 Power chords and their symbols can be engraved in chord mode or as chord
1878 constructs:
1879
1880 @lilypond[quote,ragged-right,verbatim]
1881 ChordsAndSymbols = {
1882   \chordmode {
1883     \powerChords
1884     e,,1:5
1885     a,,1:5.8
1886     \set minimumFret = #8
1887     c,1:5
1888     f,1:5.8
1889   }
1890   \set minimumFret = #5
1891   <a, e>1
1892   <g d' g'>1
1893 }
1894 \score {
1895   <<
1896     \new ChordNames {
1897     \ChordsAndSymbols
1898     }
1899     \new Staff {
1900       \clef "treble_8"
1901       \ChordsAndSymbols
1902     }
1903     \new TabStaff {
1904       \ChordsAndSymbols
1905     }
1906   >>
1907 }
1908 @end lilypond
1909
1910 Power chord symbols are automatically switched off as soon as one of the
1911 other common chord modifier is used:
1912
1913 @lilypond[quote,ragged-right,verbatim]
1914 mixedChords = \chordmode {
1915   c,1
1916   \powerChords
1917   b,,1:5
1918   fis,,1:5.8
1919   g,,1:m
1920 }
1921 \score {
1922   <<
1923     \new ChordNames {
1924       \mixedChords
1925     }
1926     \new Staff {
1927       \clef "treble_8"
1928       \mixedChords
1929     }
1930     \new TabStaff {
1931       \mixedChords
1932     }
1933   >>
1934 }
1935 @end lilypond
1936
1937 @seealso
1938 Music Glossary:
1939 @rglos{power chord}.
1940
1941 Notation Reference:
1942 @ref{Extended and altered chords},
1943 @ref{Printing chord names}.
1944
1945 Snippets:
1946 @rlsr{Fretted strings}.
1947
1948
1949 @node Banjo
1950 @subsection Banjo
1951
1952 @menu
1953 * Banjo tablatures::
1954 @end menu
1955
1956 @node Banjo tablatures
1957 @unnumberedsubsubsec Banjo tablatures
1958
1959 @cindex banjo tablatures
1960 @cindex tablature, banjo
1961
1962 LilyPond has basic support for the five-string banjo.  When making tablatures
1963 for five-string banjo, use the banjo tablature format function to get
1964 correct fret numbers for the fifth string:
1965
1966 @c due to crazy intervals of banjo music, absolute pitch is recommended
1967
1968 @lilypond[quote,ragged-right,verbatim]
1969 music = {
1970   g8 d' g'\5 a b g e d' |
1971   g4 d''8\5 b' a'\2 g'\5 e'\2 d' |
1972   g4
1973 }
1974
1975 <<
1976   \new Staff \with { \omit StringNumber }
1977   { \clef "treble_8"  \music }
1978   \new TabStaff \with {
1979     tablatureFormat = #fret-number-tablature-format-banjo
1980     stringTunings = #banjo-open-g-tuning
1981   }
1982   { \music }
1983 >>
1984 @end lilypond
1985
1986 @cindex banjo tunings
1987 @cindex tunings, banjo
1988
1989 @funindex banjo-c-tuning
1990 @funindex banjo-modal-tuning
1991 @funindex banjo-open-d-tuning
1992 @funindex banjo-open-dm-tuning
1993 @funindex four-string-banjo
1994
1995 A number of common tunings for the five-string banjo are predefined:
1996 @code{banjo-c-tuning} (gCGBD), @code{banjo-modal-tuning} (gDGCD),
1997 @code{banjo-open-d-tuning} (aDF#AD) and @code{banjo-open-dm-tuning}
1998 (aDFAD).
1999
2000 These may be converted to four-string tunings using the
2001 @code{four-string-banjo} function:
2002
2003 @example
2004 \set TabStaff.stringTunings = #(four-string-banjo banjo-c-tuning)
2005 @end example
2006
2007 @seealso
2008 Installed Files:
2009 @file{ly/string-tunings-init.ly}.
2010
2011 Snippets:
2012 @rlsr{Fretted strings}.