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