@cindex tablature, bass
@cindex tablature, double bass
-@funindex StringTunings
+@funindex stringTunings
LilyPond tablature automatically calculates the fret for
a note based on the string to which the note is assigned.
@code{banjo-open-g-tuning}. The predefined string tunings
are found in @file{ly/string-tuning-init.ly}.
-@funindex contextStringTunings
-@funindex \contextStringTunings
+@funindex stringTuning
+@funindex \stringTuning
@cindex tablature, custom string tunings
@cindex custom string tunings
Any desired string tuning can be created. The
-@code{\contextStringTuning} function can be
-used to define a string tuning and set it as the
-@code{stringTunings} for the current context.
-@code{\contextStringTuning} takes two arguments: the
-symbol in which the string tuning will be stored,
-and a chord construct
-that defines the pitches of each string in the tuning.
+@code{\stringTuning} function can be
+used to define a string tuning which can be used
+to set @code{stringTunings} for the current context.
+
+Its argument is a chord construct
+defining the pitches of each string in the tuning.
The chord construct must be in absolute octave mode,
see @ref{Absolute octave entry}. The string
with the highest number (generally the lowest string) must
\mynotes
}
\new TabStaff {
- \contextStringTuning #'custom-tuning <c' g' d'' a''>
+ \set stringTunings = \stringTuning <c' g' d'' a''>
\mynotes
}
>>
The @code{stringTunings} property is also used by
@code{FretBoards} to calculate automatic fret diagrams.
-@funindex makeStringTuning
-@funindex \makeStringTuning
-
String tunings are used as part of the hash key
for predefined fret diagrams
-(see @ref{Predefined fret diagrams}). The @code{\makeStringTuning}
-function is used to create a string tuning without setting the
-@code{stringTunings} property in the current context. The
-arguments to @code{\makeStringTuning} are the symbol to be
-used for the new string tuning and a chord construct used
-to define the tuning.
+(see @ref{Predefined fret diagrams}).
+
The previous example could also be written as follows:
@lilypond[quote,verbatim]
object. Pitch objects are created with the Scheme function
@code{ly:make-pitch} (see @ref{Scheme functions}).
-If desired, a string tuning can be created as a Scheme
-literal. The example below recreates the examples above,
-but the string tuning is not saved as a separate object:
-
-@lilypond[quote,verbatim]
-mynotes = {
- c'4 e' g' c'' |
- e''4 g'' b'' c'''
-}
-
-<<
- \new Staff {
- \clef treble
- \mynotes
- }
- \new TabStaff {
- \set TabStaff.stringTunings = #`(,(ly:make-pitch 1 5 0)
- ,(ly:make-pitch 1 1 0)
- ,(ly:make-pitch 0 4 0)
- ,(ly:make-pitch 0 0 0))
- \mynotes
- }
->>
-@end lilypond
+@code{\stringTuning} creates such an object from chord input.
LilyPond automatically calculates the number of lines in the
@code{TabStaff} and the number of strings in an automatically
calculated @code{FretBoard} as the number of elements
in @code{stringTunings}.
+To let all TabStaff contexts use the same custom tuning by default,
+you can use
+
+@example
+\layout @{
+ \context @{
+ \TabStaff
+ stringTunings = \stringTuning \notemode @{ <c' g' d'' a''> @}
+ @}
+@}
+@end example
+
+
@cindex moderntab clef
@cindex clef, moderntab
@cindex clef, tab
%%%% You should have received a copy of the GNU General Public License
%%%% along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
-\version "2.14.0"
+\version "2.15.16"
%% A stringTuning is a list of pitches ordered by string number
%% from 1 to N.
%% Here we define a number of default string tunings.
-%% A scheme function for converting a chord to a string tuning
-#(define (chord->tuning parser tuning-symbol chord)
- (let* ((ev-chord (car (extract-named-music chord 'EventChord)))
- (pitches (event-chord-pitches ev-chord)))
- (ly:parser-define! parser tuning-symbol (reverse pitches))))
-
%% A music function for converting a chord to a string tuning.
%% The music argument for \makeStringTuning must be a chord in
%% absolute mode ordered from the highest string number to the
%% lowest string number
-makeStringTuning =
-#(define-music-function (parser location tuning chord)
- (symbol? ly:music?)
- (_ "Convert @{chord} to a string tuning stored in @code{tuning}.
-@{chord} must be in absolute pitches and should have the highest
-string number (generally the lowest pitch) first. @code{tuning}
-should be a string that will be converted to a symbol.")
- (begin
- (chord->tuning parser tuning chord)
- (make-music 'SequentialMusic 'void #t)))
-
-
-%% A music function for converting a chord to a string tuning
-%% and setting the current context stringTunings property to
-%% the newly-defined-string tuning.
-
-contextStringTuning =
-#(define-music-function (parser location tuning chord)
- (symbol? ly:music?)
- (_ "Convert @{chord} to a string tuning stored in @code{tuning},
-and set @code{stringTunings} of the current context to the
-newly-defined tuning.
-@{chord} must be in absolute pitches and should have the highest
-string number (generally the lowest pitch) first. @code{tuning}
-should be a string that will be converted to a symbol.")
- (chord->tuning parser tuning chord)
- #{ \set stringTunings = #(ly:parser-lookup $parser $tuning)
- #})
-
-%% A music function for converting an alist to string-tunings
-makeDefaultStringTunings =
-#(define-music-function (parser location default-tuning-alist)
- (cheap-list?)
- (_ "Define default string tunings for each element of
-@code{default-tuning-alist}.")
- (begin
- (for-each (lambda (alist-entry)
- (chord->tuning parser (car alist-entry) (cdr alist-entry)))
- default-tuning-alist)
- (make-music 'SequentialMusic 'void #t)))
-
-% tuning definitions require default pitchnames
-\languageSaveAndChange #default-language
-
-%% Define alist of default string tunings
-defaultStringTunings =
-#`(
- ;; guitar tunings
- (guitar-tuning . ,#{<e, a, d g b e'>#})
- (guitar-seven-string-tuning . ,#{<b,, e, a, d g b e'>#})
- (guitar-drop-d-tuning . ,#{<d, a, d g b e'>#})
- (guitar-open-g-tuning . ,#{<d, g, d g b d'>#})
- (guitar-open-d-tuning . ,#{<d, a, d fis a d'>#})
- (guitar-dadgad-tuning . ,#{<d, a, d g a d'>#})
- (guitar-lute-tuning . ,#{<e, a, d fis b e'>#})
- (guitar-asus4-tuning . ,#{<e, a, d e a e'>#})
-
- ;; bass tunings
- (bass-tuning . ,#{<e,, a,, d, g,>#})
- (bass-four-string-tuning . ,#{<e,, a,, d, g,>#})
- (bass-drop-d-tuning . ,#{<d,, a,, d, g,>#})
- (bass-five-string-tuning . ,#{<b,,, e,, a,, d, g,>#})
- (bass-six-string-tuning . ,#{<b,,, e,, a,, d, g, c>#})
-
- ;; mandolin tunings
- (mandolin-tuning . ,#{<g d' a' e''>#})
-
- ;; tunings for 5-string banjo
- (banjo-open-g-tuning . ,#{<g' d g b d'>#})
- (banjo-c-tuning . ,#{<g' c g b d'>#})
- (banjo-modal-tuning . ,#{<g' d g c' d'>#})
- (banjo-open-d-tuning . ,#{<a' d fis a d'>#})
- (banjo-open-dm-tuning . ,#{<a' d fis a d'>#})
-
- ;; ukulele tunings
- (ukulele-tuning . ,#{<g' c' e' a'>#})
- (ukulele-d-tuning . ,#{<a' d' fis' b'>#})
- (tenor-ukulele-tuning . ,#{<a' e' c' g>#})
- (baritone-ukulele-tuning . ,#{<e' b g d>#})
-
- ;; orchestral strings
- (violin-tuning . ,#{<g d' a' e''>#})
- (viola-tuning . ,#{<c g d' a'>#})
- (cello-tuning . ,#{<c, g, d a>#})
- (double-bass-tuning . ,#{<e,, a,, d, g,>#})
- )
+stringTuning =
+#(define-scheme-function (parser location chord)
+ (ly:music?)
+ (_i "Convert @var{chord} to a string tuning.
+@var{chord} must be in absolute pitches and should have the highest
+string number (generally the lowest pitch) first.")
+ (let* ((ev-chord (car (extract-named-music chord 'EventChord))))
+ (reverse! (event-chord-pitches ev-chord))))
+
+defaultStringTunings = #'()
+
+makeDefaultStringTuning =
+#(define-void-function (parser location symbol pitches) (symbol? list?)
+ (_i "This defines a string tuning @var{symbol} via a list of @var{pitches}.
+The @var{symbol} also gets registered in @code{defaultStringTunings}
+for documentation purposes.")
+ (ly:parser-define! parser symbol pitches)
+ (set! defaultStringTunings (acons symbol pitches defaultStringTunings)))
+
+%% guitar tunings
+\makeDefaultStringTuning #'guitar-tuning \stringTuning <e, a, d g b e'>
+\makeDefaultStringTuning #'guitar-seven-string-tuning \stringTuning <b,, e, a, d g b e'>
+\makeDefaultStringTuning #'guitar-drop-d-tuning \stringTuning <d, a, d g b e'>
+\makeDefaultStringTuning #'guitar-open-g-tuning \stringTuning <d, g, d g b d'>
+\makeDefaultStringTuning #'guitar-open-d-tuning \stringTuning <d, a, d fis a d'>
+\makeDefaultStringTuning #'guitar-dadgad-tuning \stringTuning <d, a, d g a d'>
+\makeDefaultStringTuning #'guitar-lute-tuning \stringTuning <e, a, d fis b e'>
+\makeDefaultStringTuning #'guitar-asus4-tuning \stringTuning <e, a, d e a e'>
+
+%% bass tunings
+\makeDefaultStringTuning #'bass-tuning \stringTuning <e,, a,, d, g,>
+\makeDefaultStringTuning #'bass-four-string-tuning \stringTuning <e,, a,, d, g,>
+\makeDefaultStringTuning #'bass-drop-d-tuning \stringTuning <d,, a,, d, g,>
+\makeDefaultStringTuning #'bass-five-string-tuning \stringTuning <b,,, e,, a,, d, g,>
+\makeDefaultStringTuning #'bass-six-string-tuning \stringTuning <b,,, e,, a,, d, g, c>
+
+%% mandolin tunings
+\makeDefaultStringTuning #'mandolin-tuning \stringTuning <g d' a' e''>
+
+%% tunings for 5-string banjo
+\makeDefaultStringTuning #'banjo-open-g-tuning \stringTuning <g' d g b d'>
+\makeDefaultStringTuning #'banjo-c-tuning \stringTuning <g' c g b d'>
+\makeDefaultStringTuning #'banjo-modal-tuning \stringTuning <g' d g c' d'>
+\makeDefaultStringTuning #'banjo-open-d-tuning \stringTuning <a' d fis a d'>
+\makeDefaultStringTuning #'banjo-open-dm-tuning \stringTuning <a' d fis a d'>
+
+%% ukulele tunings
+\makeDefaultStringTuning #'ukulele-tuning \stringTuning <g' c' e' a'>
+\makeDefaultStringTuning #'ukulele-d-tuning \stringTuning <a' d' fis' b'>
+\makeDefaultStringTuning #'tenor-ukulele-tuning \stringTuning <a' e' c' g>
+\makeDefaultStringTuning #'baritone-ukulele-tuning \stringTuning <e' b g d>
+
+%% orchestral strings
+\makeDefaultStringTuning #'violin-tuning \stringTuning <g d' a' e''>
+\makeDefaultStringTuning #'viola-tuning \stringTuning <c g d' a'>
+\makeDefaultStringTuning #'cello-tuning \stringTuning <c, g, d a>
+\makeDefaultStringTuning #'double-bass-tuning \stringTuning <e,, a,, d, g,>
+
+defaultStringTunings = #(reverse! defaultStringTunings)
%% convert 5-string banjo tuning to 4-string by removing the 5th string
-#(define-public (four-string-banjo tuning)
- (reverse (cdr (reverse tuning))))
-
-%% make all of the default string tunings
-
-\makeDefaultStringTunings #defaultStringTunings
-
-% restore the language
-\languageRestore
-
+"four-string-banjo" = #(lambda (tuning)
+ (take tuning 4))