]> git.donarmstrong.com Git - lilypond.git/blob - ly/string-tunings-init.ly
Docs: run convert-ly for 2.14.0.
[lilypond.git] / ly / string-tunings-init.ly
1 %%%% This file is part of LilyPond, the GNU music typesetter.
2 %%%%
3 %%%% Copyright (C) 2010--2011 Carl D. Sorensen <c_sorensen@byu.edu>
4 %%%%
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.
9 %%%%
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.
14 %%%%
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/>.
17
18 \version "2.14.0"
19
20 %%  A stringTuning is a list of pitches ordered by string number
21 %%  from 1 to N.
22 %%  Here we define a number of default string tunings.
23
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))))
29
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
34
35 makeStringTuning =
36 #(define-music-function (parser location tuning chord)
37    (symbol? ly:music?)
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.")
42    (begin
43      (chord->tuning parser tuning chord)
44      (make-music 'SequentialMusic 'void #t)))
45
46
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.
50
51 contextStringTuning =
52 #(define-music-function (parser location tuning chord)
53    (symbol? ly:music?)
54    (_ "Convert @{chord} to a string tuning stored in @code{tuning},
55 and set @code{stringTunings} of the current context to the
56 newly-defined tuning.
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.")
60    (begin
61      (chord->tuning parser tuning chord)
62      #{
63         \set TabStaff.stringTunings = $(ly:parser-lookup parser tuning)
64         \set FretBoards.stringTunings = $(ly:parser-lookup parser tuning)
65      #}))
66
67 %% A music function for converting an alist to string-tunings
68 makeDefaultStringTunings =
69 #(define-music-function (parser location default-tuning-alist)
70    (cheap-list?)
71    (_ "Define default string tunings for each element of
72 @code{default-tuning-alist}.")
73    (begin
74      (for-each (lambda (alist-entry)
75                  (chord->tuning parser (car alist-entry) (cdr alist-entry)))
76                default-tuning-alist)
77      (make-music 'SequentialMusic 'void #t)))
78
79 % tuning definitions require default pitchnames
80 \languageSaveAndChange #default-language
81
82 %% Define alist of default string tunings
83 defaultStringTunings =
84 #`(
85    ;; guitar tunings
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-asus4-tuning . ,#{<e, a, d e a e'>#})
94
95    ;; bass tunings
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>#})
101
102    ;; mandolin tunings
103    (mandolin-tuning . ,#{<g d' a' e''>#})
104
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'>#})
111
112    ;; ukulele tunings
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>#})
117
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,>#})
123   )
124
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))))
128
129 %% make all of the default string tunings
130
131 \makeDefaultStringTunings #defaultStringTunings
132
133 % restore the language
134 \languageRestore
135