1 %%%% This file is part of LilyPond, the GNU music typesetter.
3 %%%% Copyright (C) 2010--2011 Carl D. Sorensen <c_sorensen@byu.edu>
5 %%%% LilyPond is free software: you can redistribute it and/or modify
6 %%%% it under the terms of the GNU General Public License as published by
7 %%%% the Free Software Foundation, either version 3 of the License, or
8 %%%% (at your option) any later version.
10 %%%% LilyPond is distributed in the hope that it will be useful,
11 %%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
12 %%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 %%%% GNU General Public License for more details.
15 %%%% You should have received a copy of the GNU General Public License
16 %%%% along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 %% A stringTuning is a list of pitches ordered by string number
22 %% Here we define a number of default string tunings.
24 %% A scheme function for converting a chord to a string tuning
25 #(define
(chord-
>tuning parser tuning-symbol chord
)
26 (let
* ((ev-chord
(car
(extract-named-music chord
'EventChord
)))
27 (pitches
(event-chord-pitches ev-chord
)))
28 (ly
:parser-define
! parser tuning-symbol
(reverse pitches
))))
30 %% A music function for converting a chord to a string tuning.
31 %% The music argument for \makeStringTuning must be a chord in
32 %% absolute mode ordered from the highest string number to the
33 %% lowest string number
36 #(define-music-function
(parser location tuning chord
)
38 (_ "Convert @{chord} to a string tuning stored in @code{tuning}.
39 @{chord} must be in absolute pitches and should have the highest
40 string number (generally the lowest pitch) first. @code{tuning}
41 should be a string that will be converted to a symbol.")
43 (chord-
>tuning parser tuning chord
)
44 (make-music
'SequentialMusic
'void
#t
)))
47 %% A music function for converting a chord to a string tuning
48 %% and setting the current context stringTunings property to
49 %% the newly-defined-string tuning.
52 #(define-music-function
(parser location tuning chord
)
54 (_ "Convert @{chord} to a string tuning stored in @code{tuning},
55 and set @code{stringTunings} of the current context to the
57 @{chord} must be in absolute pitches and should have the highest
58 string number (generally the lowest pitch) first. @code{tuning}
59 should be a string that will be converted to a symbol.")
61 (chord-
>tuning parser tuning chord
)
63 \set TabStaff
.stringTunings
= $
(ly
:parser-lookup parser tuning
)
64 \set FretBoards
.stringTunings
= $
(ly
:parser-lookup parser tuning
)
67 %% A music function for converting an alist to string-tunings
68 makeDefaultStringTunings
=
69 #(define-music-function
(parser location default-tuning-alist
)
71 (_ "Define default string tunings for each element of
72 @code{default-tuning-alist}.")
74 (for-each
(lambda
(alist-entry
)
75 (chord-
>tuning parser
(car alist-entry
) (cdr alist-entry
)))
77 (make-music
'SequentialMusic
'void
#t
)))
79 % tuning definitions require default pitchnames
80 \languageSaveAndChange #default-language
82 %% Define alist of default string tunings
83 defaultStringTunings
=
86 (guitar-tuning
. ,#{<e, a, d g b e'>#})
87 (guitar-seven-string-tuning
. ,#{<b,, e, a, d g b e'>#})
88 (guitar-drop-
d-tuning
. ,#{<d, a, d g b e'>#})
89 (guitar-open-
g-tuning
. ,#{<d, g, d g b d'>#})
90 (guitar-open-
d-tuning
. ,#{<d, a, d fis a d'>#})
91 (guitar-dadgad-tuning
. ,#{<d, a, d g a d'>#})
92 (guitar-lute-tuning
. ,#{<e, a, d fis b e'>#})
93 (guitar-asus
4-tuning
. ,#{<e, a, d e a e'>#})
96 (bass-tuning
. ,#{<e,, a,, d, g,>#})
97 (bass-four-string-tuning
. ,#{<e,, a,, d, g,>#})
98 (bass-drop-
d-tuning
. ,#{<d,, a,, d, g,>#})
99 (bass-five-string-tuning
. ,#{<b,,, e,, a,, d, g,>#})
100 (bass-six-string-tuning
. ,#{<b,,, e,, a,, d, g, c>#})
103 (mandolin-tuning
. ,#{<g d' a' e''>#})
105 ;; tunings for
5-string banjo
106 (banjo-open-
g-tuning
. ,#{<g' d g b d'>#})
107 (banjo-
c-tuning
. ,#{<g' c g b d'>#})
108 (banjo-modal-tuning
. ,#{<g' d g c' d'>#})
109 (banjo-open-
d-tuning
. ,#{<a' d fis a d'>#})
110 (banjo-open-dm-tuning
. ,#{<a' d fis a d'>#})
113 (ukulele-tuning
. ,#{<g' c' e' a'>#})
114 (ukulele-
d-tuning
. ,#{<a' d' fis' b'>#})
115 (tenor-ukulele-tuning
. ,#{<a' e' c' g>#})
116 (baritone-ukulele-tuning
. ,#{<e' b g d>#})
118 ;; orchestral strings
119 (violin-tuning
. ,#{<g d' a' e''>#})
120 (viola-tuning
. ,#{<c g d' a'>#})
121 (cello-tuning
. ,#{<c, g, d a>#})
122 (double-bass-tuning
. ,#{<e,, a,, d, g,>#})
125 %% convert 5-string banjo tuning to 4-string by removing the 5th string
126 #(define-public
(four-string-banjo tuning
)
127 (reverse
(cdr
(reverse tuning
))))
129 %% make all of the default string tunings
131 \makeDefaultStringTunings #defaultStringTunings
133 % restore the language